转自:http://www.sgoldcn.com/simple/?t1876.html
PE 文件所有使用的 resource table 非常复杂,一个典型的 windows GUI 应用程序普遍都使用到了 7 个左右的资源。
/* * Predefined Resource Types */ #define RT_CURSOR MAKEINTRESOURCE(1) #define RT_BITMAP MAKEINTRESOURCE(2) #define RT_ICON MAKEINTRESOURCE(3) #define RT_MENU MAKEINTRESOURCE(4) #define RT_DIALOG MAKEINTRESOURCE(5) #define RT_STRING MAKEINTRESOURCE(6) #define RT_FONTDIR MAKEINTRESOURCE(7) #define RT_FONT MAKEINTRESOURCE(8) #define RT_ACCELERATOR MAKEINTRESOURCE(9) #define RT_RCDATA MAKEINTRESOURCE(10) #define RT_MESSAGETABLE MAKEINTRESOURCE(11) #define DIFFERENCE 11 #define RT_GROUP_CURSOR MAKEINTRESOURCE((ULONG_PTR)(RT_CURSOR) + DIFFERENCE) #define RT_GROUP_ICON MAKEINTRESOURCE((ULONG_PTR)(RT_ICON) + DIFFERENCE) #define RT_VERSION MAKEINTRESOURCE(16) #define RT_DLGINCLUDE MAKEINTRESOURCE(17) #if(WINVER >= 0x0400) #define RT_PLUGPLAY MAKEINTRESOURCE(19) #define RT_VXD MAKEINTRESOURCE(20) #define RT_ANICURSOR MAKEINTRESOURCE(21) #define RT_ANIICON MAKEINTRESOURCE(22) #endif /* WINVER >= 0x0400 */ #define RT_HTML MAKEINTRESOURCE(23) #ifdef RC_INVOKED #define RT_MANIFEST 24 #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2 #define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3 #define MINIMUM_RESERVED_MANIFEST_RESOURCE_ID 1 /* inclusive */ #define MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID 16 /* inclusive */ #else /* RC_INVOKED */ #define RT_MANIFEST MAKEINTRESOURCE(24) #define CREATEPROCESS_MANIFEST_RESOURCE_ID MAKEINTRESOURCE( 1) #define ISOLATIONAWARE_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(2) #define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(3) #define MINIMUM_RESERVED_MANIFEST_RESOURCE_ID MAKEINTRESOURCE( 1 /*inclusive*/) #define MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID MAKEINTRESOURCE(16 /*inclusive*/) |
域
|
.rsrc 节
|
VirtualSize |
0x0000E71C
|
VirtualAddress |
0x00019000
|
SizeOfRawData |
0x0000E800
|
PointerToRawData |
0x00006C00
|
PointerToRelocations |
0
|
PointerToLinenumbers |
0
|
NumberOfRelocations |
0
|
NumberOfLinenumbers |
0
|
Characteristics |
0x40000040
|
域
|
resource table
|
VirtualAddress
|
0x00019000
|
size
|
0xE71C
|
|
typedef struct _IMAGE_RESOURCE_DIRECTORY { DWORD Characteristics; DWORD TimeDateStamp; WORD MajorVersion; WORD MinorVersion; WORD NumberOfNamedEntries; WORD NumberOfIdEntries; // IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; } IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY; |
|
typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY { union { struct { DWORD NameOffset:31; DWORD NameIsString:1; } DUMMYSTRUCTNAME; DWORD Name; WORD Id; } DUMMYUNIONNAME; union { DWORD OffsetToData; struct { DWORD OffsetToDirectory:31; DWORD DataIsDirectory:1; } DUMMYSTRUCTNAME2; } DUMMYUNIONNAME2; } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; |
typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY { DWORD Name; DWORD OffsetToData; } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; |
// entry[0] 00419010 03 00 00 00 // Name = 0x03 ====> ID = 3 (ICON) 00419014 48 00 00 80 // OffsetToData = 0x80000048 |
// Entry[0] 00419180 09 04 00 00 // ID = 0x409 00419184 98 03 00 00 // ****** IMAGE_RESOURCE_DATA_ENTRY: 0x00000398 |
// Driectory: (root) 00419000 00 00 00 00 00419004 00 00 00 00 00419008 00 00 0041900A 00 00 0041900C 00 00 // NumberOfNameEntries 0041900E 07 00 // NumberOfIdEntries // entry[0] 00419010 03 00 00 00 // ID = 3 (ICON) 00419014 48 00 00 80 // OffsetToData = 0x80000048 // entry[1] 00419018 04 00 00 00 // ID = 4 (MENU) 0041901C D8 00 00 80 // OffsetToData = 0x800000D8 // entry[2] 00419020 05 00 00 00 // ID = 5 (DIALOG) 00419024 F0 00 00 80 // OffsetToData = 0x800000F0 // entry[3] 00419028 06 00 00 00 // ID = 6 (STRING) 0041902C 08 01 00 80 // OffsetToData = 0x80000180 // entry[4] 00419030 09 00 00 00 // ID = 9 (ACCELERATOR) 00419034 20 01 00 80 // OffsetToData = 0x80000120 // entry[5] 00419038 0E 00 00 00 // ID = 0E (GROUP_ICON) 0041903C 38 01 00 80 // OffsetToData = 0x80000138 // entry[6] 00419040 18 00 00 00 // ID = 0x18 (MAINFEST) 00419044 58 01 00 80 // OffsetToData = 0x80000158 |
typedef struct _IMAGE_RESOURCE_DATA_ENTRY { DWORD OffsetToData; DWORD Size; DWORD CodePage; DWORD Reserved; } IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY; |
typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING { WORD Length; CHAR NameString[ 1 ]; } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING; typedef struct _IMAGE_RESOURCE_DIR_STRING_U { WORD Length; WCHAR NameString[ 1 ]; } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U; |
|
// Driectory: (root) 00419000 00 00 00 00 00419004 00 00 00 00 00419008 00 00 0041900A 00 00 0041900C 00 00 // NumberOfNameEntries 0041900E 07 00 // NumberOfIdEntries // entry[0] 00419010 03 00 00 00 // ID = 3 (ICON) 00419014 48 00 00 80 // OffsetToData = 0x80000048 // entry[1] 00419018 04 00 00 00 // ID = 4 (MENU) 0041901C D8 00 00 80 // OffsetToData = 0x800000D8 // entry[2] 00419020 05 00 00 00 // ID = 5 (DIALOG) 00419024 F0 00 00 80 // OffsetToData = 0x800000F0 // entry[3] 00419028 06 00 00 00 // ID = 6 (STRING) 0041902C 08 01 00 80 // OffsetToData = 0x80000180 // entry[4] 00419030 09 00 00 00 // ID = 9 (ACCELERATOR) 00419034 20 01 00 80 // OffsetToData = 0x80000120 // entry[5] 00419038 0E 00 00 00 // ID = 0E (GROUP_ICON) 0041903C 38 01 00 80 // OffsetToData = 0x80000138 // entry[6] 00419040 18 00 00 00 // ID = 0x18 (MAINFEST) 00419044 58 01 00 80 // OffsetToData = 0x80000158 |
// Driectory: (root) 00419000 00 00 00 00 00419004 00 00 00 00 00419008 00 00 0041900A 00 00 0041900C 00 00 // NumberOfNameEntries 0041900E 07 00 // NumberOfIdEntries // entry[0] 00419010 03 00 00 00 // ID = 3 (ICON) 00419014 48 00 00 80 // OffsetToData = 0x80000048 |
// Directory 00419048 00 00 00 00 0041904C 00 00 00 00 00419050 00 00 00419052 00 00 00419054 00 00 // NumberOfNameEntries 00419056 10 00 // NumberOfIdEntries // Entry[0] 00419058 01 00 00 00 // ID = 01 0041905C 70 01 00 80 // OffsetToData = 0x80000170 00419060 02 00 00 00 // ID = 02 00419064 88 01 00 80 // OffsetToData = 0x80000188 00419068 03 00 00 00 // ID = 03 0041906C A0 01 00 80 // OffsetToData = 0x800001A0 00419070 04 00 00 00 00419074 B8 01 00 80 00419078 05 00 00 00 0041907C D0 01 00 80 00419080 06 00 00 00 00419084 E8 01 00 80 00419088 07 00 00 00 0041908C 00 02 00 80 00419090 08 00 00 00 00419094 18 02 00 80 00419098 09 00 00 00 0041909C 30 02 00 80 004190A0 0A 00 00 00 004190A4 48 02 00 80 004190A8 0B 00 00 00 004190AC 60 02 00 80 004190B0 0C 00 00 00 004190B4 78 02 00 80 004190B8 0D 00 00 00 004190BC 90 02 00 80 004190C0 0E 00 00 00 004190C4 A8 02 00 80 004190C8 0F 00 00 00 004190CC C0 02 00 80 // Entry[15] 004190D0 10 00 00 00 004190D4 D8 02 00 80 |
// Directory 00419170 00 00 00 00 00419174 00 00 00 00 00419178 00 00 0041917A 00 00 0041917C 00 00 0041917E 01 00 // Entry[0] 00419180 09 04 00 00 // ID = 0x409 00419184 98 03 00 00 // ****** IMAGE_RESOURCE_DATA_ENTRY: 0x00000398 |
// IMAGE_RESOURCE_DATA_ENTRY 00419398 A8 98 01 00 // OffsetToData = 0x000198A8 0041939C E8 02 00 00 // Size = 0x02E8 004193A0 00 00 00 00 // Codepage 004193AC 00 00 00 00 // Reserved |
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 004198A0 28 00 00 00 20 00 00 00 .(... ... 004198B0 40 00 00 00 01 00 04 00 00 00 00 00 00 00 00 00 @............... 004198C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 004198D0 00 00 00 00 00 00 80 00 00 80 00 00 00 80 80 00 ......€..€...€€. 004198E0 80 00 00 00 80 00 80 00 80 80 00 00 80 80 80 00 €...€.€.€€..€€€. 004198F0 C0 C0 C0 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 ààà...?..?...??. 00419900 FF 00 00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 ?...?.?.??..???. 00419910 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA aaaaaaaaaaaaaaaa 00419920 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00419930 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 70 wwwwwwwwwwwwwwwp 00419940 78 88 88 88 88 88 88 88 88 88 88 88 88 88 88 70 x??????????????p 00419950 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419960 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419970 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419980 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419990 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 004199A0 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 004199B0 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 004199C0 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 004199D0 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 004199E0 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 004199F0 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A00 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A10 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A20 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A30 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A40 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A50 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A60 78 7F FF FF FF FF FF FF FF FF FF FF FF FF F8 70 x.?????????????p 00419A70 78 77 77 77 77 77 77 77 77 77 77 77 77 77 78 70 xwwwwwwwwwwwwwxp 00419A80 78 88 88 88 88 88 88 88 88 88 88 88 88 88 88 70 x??????????????p 00419A90 78 44 44 44 44 44 44 44 44 44 40 00 00 00 00 70 [email protected] 00419AA0 78 44 44 44 44 44 44 44 44 44 48 80 88 08 80 70 xDDDDDDDDDH€?.€p 00419AB0 78 44 44 44 44 44 44 44 44 44 48 80 88 08 80 70 xDDDDDDDDDH€?.€p 00419AC0 78 44 44 44 44 44 44 44 44 44 44 44 44 44 44 70 xDDDDDDDDDDDDDDp 00419AD0 78 88 88 88 88 88 88 88 88 88 88 88 88 88 88 70 x??????????????p 00419AE0 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 70 wwwwwwwwwwwwwwwp 00419AF0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA aaaaaaaaaaaaaaaa |