Rev 2726 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2726 | Rev 4687 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | PE32+ header file |
2 | PE32+ header file |
3 | */ |
3 | */ |
4 | #ifndef _PE_H |
4 | #ifndef _PE_H |
5 | #define _PE_H |
5 | #define _PE_H |
6 | 6 | ||
7 | #define IMAGE_DOS_SIGNATURE 0x5A4D // MZ |
7 | #define IMAGE_DOS_SIGNATURE 0x5A4D // MZ |
8 | #define IMAGE_OS2_SIGNATURE 0x454E // NE |
8 | #define IMAGE_OS2_SIGNATURE 0x454E // NE |
9 | #define IMAGE_OS2_SIGNATURE_LE 0x454C // LE |
9 | #define IMAGE_OS2_SIGNATURE_LE 0x454C // LE |
10 | #define IMAGE_NT_SIGNATURE 0x00004550 // PE00 |
10 | #define IMAGE_NT_SIGNATURE 0x00004550 // PE00 |
11 | #define IMAGE_EDOS_SIGNATURE 0x44454550 // PEED |
11 | #define IMAGE_EDOS_SIGNATURE 0x44454550 // PEED |
12 | 12 | ||
13 | 13 | ||
14 | typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header |
14 | typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header |
15 | UINT16 e_magic; // Magic number |
15 | UINT16 e_magic; // Magic number |
16 | UINT16 e_cblp; // Bytes on last page of file |
16 | UINT16 e_cblp; // Bytes on last page of file |
17 | UINT16 e_cp; // Pages in file |
17 | UINT16 e_cp; // Pages in file |
18 | UINT16 e_crlc; // Relocations |
18 | UINT16 e_crlc; // Relocations |
19 | UINT16 e_cparhdr; // Size of header in paragraphs |
19 | UINT16 e_cparhdr; // Size of header in paragraphs |
20 | UINT16 e_minalloc; // Minimum extra paragraphs needed |
20 | UINT16 e_minalloc; // Minimum extra paragraphs needed |
21 | UINT16 e_maxalloc; // Maximum extra paragraphs needed |
21 | UINT16 e_maxalloc; // Maximum extra paragraphs needed |
22 | UINT16 e_ss; // Initial (relative) SS value |
22 | UINT16 e_ss; // Initial (relative) SS value |
23 | UINT16 e_sp; // Initial SP value |
23 | UINT16 e_sp; // Initial SP value |
24 | UINT16 e_csum; // Checksum |
24 | UINT16 e_csum; // Checksum |
25 | UINT16 e_ip; // Initial IP value |
25 | UINT16 e_ip; // Initial IP value |
26 | UINT16 e_cs; // Initial (relative) CS value |
26 | UINT16 e_cs; // Initial (relative) CS value |
27 | UINT16 e_lfarlc; // File address of relocation table |
27 | UINT16 e_lfarlc; // File address of relocation table |
28 | UINT16 e_ovno; // Overlay number |
28 | UINT16 e_ovno; // Overlay number |
29 | UINT16 e_res[4]; // Reserved words |
29 | UINT16 e_res[4]; // Reserved words |
30 | UINT16 e_oemid; // OEM identifier (for e_oeminfo) |
30 | UINT16 e_oemid; // OEM identifier (for e_oeminfo) |
31 | UINT16 e_oeminfo; // OEM information; e_oemid specific |
31 | UINT16 e_oeminfo; // OEM information; e_oemid specific |
32 | UINT16 e_res2[10]; // Reserved words |
32 | UINT16 e_res2[10]; // Reserved words |
33 | UINT32 e_lfanew; // File address of new exe header |
33 | UINT32 e_lfanew; // File address of new exe header |
34 | } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; |
34 | } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; |
35 | 35 | ||
36 | typedef struct _IMAGE_OS2_HEADER { // OS/2 .EXE header |
36 | typedef struct _IMAGE_OS2_HEADER { // OS/2 .EXE header |
37 | UINT16 ne_magic; // Magic number |
37 | UINT16 ne_magic; // Magic number |
38 | UINT8 ne_ver; // Version number |
38 | UINT8 ne_ver; // Version number |
39 | UINT8 ne_rev; // Revision number |
39 | UINT8 ne_rev; // Revision number |
40 | UINT16 ne_enttab; // Offset of Entry Table |
40 | UINT16 ne_enttab; // Offset of Entry Table |
41 | UINT16 ne_cbenttab; // Number of bytes in Entry Table |
41 | UINT16 ne_cbenttab; // Number of bytes in Entry Table |
42 | UINT32 ne_crc; // Checksum of whole file |
42 | UINT32 ne_crc; // Checksum of whole file |
43 | UINT16 ne_flags; // Flag UINT16 |
43 | UINT16 ne_flags; // Flag UINT16 |
44 | UINT16 ne_autodata; // Automatic data segment number |
44 | UINT16 ne_autodata; // Automatic data segment number |
45 | UINT16 ne_heap; // Initial heap allocation |
45 | UINT16 ne_heap; // Initial heap allocation |
46 | UINT16 ne_stack; // Initial stack allocation |
46 | UINT16 ne_stack; // Initial stack allocation |
47 | UINT32 ne_csip; // Initial CS:IP setting |
47 | UINT32 ne_csip; // Initial CS:IP setting |
48 | UINT32 ne_sssp; // Initial SS:SP setting |
48 | UINT32 ne_sssp; // Initial SS:SP setting |
49 | UINT16 ne_cseg; // Count of file segments |
49 | UINT16 ne_cseg; // Count of file segments |
50 | UINT16 ne_cmod; // Entries in Module Reference Table |
50 | UINT16 ne_cmod; // Entries in Module Reference Table |
51 | UINT16 ne_cbnrestab; // Size of non-resident name table |
51 | UINT16 ne_cbnrestab; // Size of non-resident name table |
52 | UINT16 ne_segtab; // Offset of Segment Table |
52 | UINT16 ne_segtab; // Offset of Segment Table |
53 | UINT16 ne_rsrctab; // Offset of Resource Table |
53 | UINT16 ne_rsrctab; // Offset of Resource Table |
54 | UINT16 ne_restab; // Offset of resident name table |
54 | UINT16 ne_restab; // Offset of resident name table |
55 | UINT16 ne_modtab; // Offset of Module Reference Table |
55 | UINT16 ne_modtab; // Offset of Module Reference Table |
56 | UINT16 ne_imptab; // Offset of Imported Names Table |
56 | UINT16 ne_imptab; // Offset of Imported Names Table |
57 | UINT32 ne_nrestab; // Offset of Non-resident Names Table |
57 | UINT32 ne_nrestab; // Offset of Non-resident Names Table |
58 | UINT16 ne_cmovent; // Count of movable entries |
58 | UINT16 ne_cmovent; // Count of movable entries |
59 | UINT16 ne_align; // Segment alignment shift count |
59 | UINT16 ne_align; // Segment alignment shift count |
60 | UINT16 ne_cres; // Count of resource segments |
60 | UINT16 ne_cres; // Count of resource segments |
61 | UINT8 ne_exetyp; // Target Operating system |
61 | UINT8 ne_exetyp; // Target Operating system |
62 | UINT8 ne_flagsothers; // Other .EXE flags |
62 | UINT8 ne_flagsothers; // Other .EXE flags |
63 | UINT16 ne_pretthunks; // offset to return thunks |
63 | UINT16 ne_pretthunks; // offset to return thunks |
64 | UINT16 ne_psegrefbytes; // offset to segment ref. bytes |
64 | UINT16 ne_psegrefbytes; // offset to segment ref. bytes |
65 | UINT16 ne_swaparea; // Minimum code swap area size |
65 | UINT16 ne_swaparea; // Minimum code swap area size |
66 | UINT16 ne_expver; // Expected Windows version number |
66 | UINT16 ne_expver; // Expected Windows version number |
67 | } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER; |
67 | } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER; |
68 | 68 | ||
69 | // |
69 | // |
70 | // File header format. |
70 | // File header format. |
71 | // |
71 | // |
72 | 72 | ||
73 | typedef struct _IMAGE_FILE_HEADER { |
73 | typedef struct _IMAGE_FILE_HEADER { |
74 | UINT16 Machine; |
74 | UINT16 Machine; |
75 | UINT16 NumberOfSections; |
75 | UINT16 NumberOfSections; |
76 | UINT32 TimeDateStamp; |
76 | UINT32 TimeDateStamp; |
77 | UINT32 PointerToSymbolTable; |
77 | UINT32 PointerToSymbolTable; |
78 | UINT32 NumberOfSymbols; |
78 | UINT32 NumberOfSymbols; |
79 | UINT16 SizeOfOptionalHeader; |
79 | UINT16 SizeOfOptionalHeader; |
80 | UINT16 Characteristics; |
80 | UINT16 Characteristics; |
81 | } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; |
81 | } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; |
82 | 82 | ||
83 | #define IMAGE_SIZEOF_FILE_HEADER 20 |
83 | #define IMAGE_SIZEOF_FILE_HEADER 20 |
84 | 84 | ||
85 | #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. |
85 | #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. |
86 | #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). |
86 | #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). |
87 | #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. |
87 | #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. |
88 | #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. |
88 | #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. |
89 | #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. |
89 | #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. |
90 | #define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. |
90 | #define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. |
91 | #define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file |
91 | #define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file |
92 | #define IMAGE_FILE_SYSTEM 0x1000 // System File. |
92 | #define IMAGE_FILE_SYSTEM 0x1000 // System File. |
93 | #define IMAGE_FILE_DLL 0x2000 // File is a DLL. |
93 | #define IMAGE_FILE_DLL 0x2000 // File is a DLL. |
94 | #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. |
94 | #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. |
95 | 95 | ||
96 | #define IMAGE_FILE_MACHINE_UNKNOWN 0 |
96 | #define IMAGE_FILE_MACHINE_UNKNOWN 0 |
97 | #define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. |
97 | #define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. |
98 | #define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0540 big-endian |
98 | #define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0540 big-endian |
99 | #define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian |
99 | #define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian |
100 | #define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP |
100 | #define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP |
101 | #define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian |
101 | #define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian |
102 | #define IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine |
102 | #define IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine |
103 | // |
103 | // |
104 | // Directory format. |
104 | // Directory format. |
105 | // |
105 | // |
106 | 106 | ||
107 | typedef struct _IMAGE_DATA_DIRECTORY { |
107 | typedef struct _IMAGE_DATA_DIRECTORY { |
108 | UINT32 VirtualAddress; |
108 | UINT32 VirtualAddress; |
109 | UINT32 Size; |
109 | UINT32 Size; |
110 | } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; |
110 | } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; |
111 | 111 | ||
112 | #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 |
112 | #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 |
113 | 113 | ||
114 | // |
114 | // |
115 | // Optional header format. |
115 | // Optional header format. |
116 | // |
116 | // |
117 | 117 | ||
118 | typedef struct _IMAGE_OPTIONAL_HEADER { |
118 | typedef struct _IMAGE_OPTIONAL_HEADER { |
119 | // |
119 | // |
120 | // Standard fields. |
120 | // Standard fields. |
121 | // |
121 | // |
122 | 122 | ||
123 | UINT16 Magic; |
123 | UINT16 Magic; |
124 | UINT8 MajorLinkerVersion; |
124 | UINT8 MajorLinkerVersion; |
125 | UINT8 MinorLinkerVersion; |
125 | UINT8 MinorLinkerVersion; |
126 | UINT32 SizeOfCode; |
126 | UINT32 SizeOfCode; |
127 | UINT32 SizeOfInitializedData; |
127 | UINT32 SizeOfInitializedData; |
128 | UINT32 SizeOfUninitializedData; |
128 | UINT32 SizeOfUninitializedData; |
129 | UINT32 AddressOfEntryPoint; |
129 | UINT32 AddressOfEntryPoint; |
130 | UINT32 BaseOfCode; |
130 | UINT32 BaseOfCode; |
131 | UINT32 BaseOfData; |
131 | UINT32 BaseOfData; |
132 | 132 | ||
133 | // |
133 | // |
134 | // NT additional fields. |
134 | // NT additional fields. |
135 | // |
135 | // |
136 | 136 | ||
137 | UINT32 ImageBase; |
137 | UINT32 ImageBase; |
138 | UINT32 SectionAlignment; |
138 | UINT32 SectionAlignment; |
139 | UINT32 FileAlignment; |
139 | UINT32 FileAlignment; |
140 | UINT16 MajorOperatingSystemVersion; |
140 | UINT16 MajorOperatingSystemVersion; |
141 | UINT16 MinorOperatingSystemVersion; |
141 | UINT16 MinorOperatingSystemVersion; |
142 | UINT16 MajorImageVersion; |
142 | UINT16 MajorImageVersion; |
143 | UINT16 MinorImageVersion; |
143 | UINT16 MinorImageVersion; |
144 | UINT16 MajorSubsystemVersion; |
144 | UINT16 MajorSubsystemVersion; |
145 | UINT16 MinorSubsystemVersion; |
145 | UINT16 MinorSubsystemVersion; |
146 | UINT32 Reserved1; |
146 | UINT32 Reserved1; |
147 | UINT32 SizeOfImage; |
147 | UINT32 SizeOfImage; |
148 | UINT32 SizeOfHeaders; |
148 | UINT32 SizeOfHeaders; |
149 | UINT32 CheckSum; |
149 | UINT32 CheckSum; |
150 | UINT16 Subsystem; |
150 | UINT16 Subsystem; |
151 | UINT16 DllCharacteristics; |
151 | UINT16 DllCharacteristics; |
152 | UINT32 SizeOfStackReserve; |
152 | UINT32 SizeOfStackReserve; |
153 | UINT32 SizeOfStackCommit; |
153 | UINT32 SizeOfStackCommit; |
154 | UINT32 SizeOfHeapReserve; |
154 | UINT32 SizeOfHeapReserve; |
155 | UINT32 SizeOfHeapCommit; |
155 | UINT32 SizeOfHeapCommit; |
156 | UINT32 LoaderFlags; |
156 | UINT32 LoaderFlags; |
157 | UINT32 NumberOfRvaAndSizes; |
157 | UINT32 NumberOfRvaAndSizes; |
158 | IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; |
158 | IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; |
159 | } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; |
159 | } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; |
160 | 160 | ||
161 | typedef struct _IMAGE_ROM_OPTIONAL_HEADER { |
161 | typedef struct _IMAGE_ROM_OPTIONAL_HEADER { |
162 | UINT16 Magic; |
162 | UINT16 Magic; |
163 | UINT8 MajorLinkerVersion; |
163 | UINT8 MajorLinkerVersion; |
164 | UINT8 MinorLinkerVersion; |
164 | UINT8 MinorLinkerVersion; |
165 | UINT32 SizeOfCode; |
165 | UINT32 SizeOfCode; |
166 | UINT32 SizeOfInitializedData; |
166 | UINT32 SizeOfInitializedData; |
167 | UINT32 SizeOfUninitializedData; |
167 | UINT32 SizeOfUninitializedData; |
168 | UINT32 AddressOfEntryPoint; |
168 | UINT32 AddressOfEntryPoint; |
169 | UINT32 BaseOfCode; |
169 | UINT32 BaseOfCode; |
170 | UINT32 BaseOfData; |
170 | UINT32 BaseOfData; |
171 | UINT32 BaseOfBss; |
171 | UINT32 BaseOfBss; |
172 | UINT32 GprMask; |
172 | UINT32 GprMask; |
173 | UINT32 CprMask[4]; |
173 | UINT32 CprMask[4]; |
174 | UINT32 GpValue; |
174 | UINT32 GpValue; |
175 | } IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER; |
175 | } IMAGE_ROM_OPTIONAL_HEADER, *PIMAGE_ROM_OPTIONAL_HEADER; |
176 | 176 | ||
177 | #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56 |
177 | #define IMAGE_SIZEOF_ROM_OPTIONAL_HEADER 56 |
178 | #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28 |
178 | #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28 |
179 | #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224 |
179 | #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224 |
180 | 180 | ||
181 | #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b |
181 | #define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b |
182 | #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107 |
182 | #define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107 |
183 | 183 | ||
184 | typedef struct _IMAGE_NT_HEADERS { |
184 | typedef struct _IMAGE_NT_HEADERS { |
185 | UINT32 Signature; |
185 | UINT32 Signature; |
186 | IMAGE_FILE_HEADER FileHeader; |
186 | IMAGE_FILE_HEADER FileHeader; |
187 | IMAGE_OPTIONAL_HEADER OptionalHeader; |
187 | IMAGE_OPTIONAL_HEADER OptionalHeader; |
188 | } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; |
188 | } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; |
189 | 189 | ||
190 | typedef struct _IMAGE_ROM_HEADERS { |
190 | typedef struct _IMAGE_ROM_HEADERS { |
191 | IMAGE_FILE_HEADER FileHeader; |
191 | IMAGE_FILE_HEADER FileHeader; |
192 | IMAGE_ROM_OPTIONAL_HEADER OptionalHeader; |
192 | IMAGE_ROM_OPTIONAL_HEADER OptionalHeader; |
193 | } IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS; |
193 | } IMAGE_ROM_HEADERS, *PIMAGE_ROM_HEADERS; |
194 | 194 | ||
195 | #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \ |
195 | #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \ |
196 | ((UINT32)ntheader + \ |
196 | ((UINT32)ntheader + \ |
197 | FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) + \ |
197 | FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) + \ |
198 | ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \ |
198 | ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \ |
199 | )) |
199 | )) |
200 | 200 | ||
201 | 201 | ||
202 | // Subsystem Values |
202 | // Subsystem Values |
203 | 203 | ||
204 | #define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem. |
204 | #define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem. |
205 | #define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem. |
205 | #define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem. |
206 | #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem. |
206 | #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem. |
207 | #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem. |
207 | #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem. |
208 | #define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. |
208 | #define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. |
209 | #define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem. |
209 | #define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem. |
210 | 210 | ||
211 | 211 | ||
212 | // Directory Entries |
212 | // Directory Entries |
213 | 213 | ||
214 | #define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory |
214 | #define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory |
215 | #define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory |
215 | #define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory |
216 | #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory |
216 | #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory |
217 | #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory |
217 | #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory |
218 | #define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory |
218 | #define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory |
219 | #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table |
219 | #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table |
220 | #define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory |
220 | #define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory |
221 | #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String |
221 | #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String |
222 | #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) |
222 | #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) |
223 | #define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory |
223 | #define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory |
224 | #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory |
224 | #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory |
225 | 225 | ||
226 | // |
226 | // |
227 | // Section header format. |
227 | // Section header format. |
228 | // |
228 | // |
229 | 229 | ||
230 | #define IMAGE_SIZEOF_SHORT_NAME 8 |
230 | #define IMAGE_SIZEOF_SHORT_NAME 8 |
231 | 231 | ||
232 | typedef struct _IMAGE_SECTION_HEADER { |
232 | typedef struct _IMAGE_SECTION_HEADER { |
233 | UINT8 Name[IMAGE_SIZEOF_SHORT_NAME]; |
233 | UINT8 Name[IMAGE_SIZEOF_SHORT_NAME]; |
234 | union { |
234 | union { |
235 | UINT32 PhysicalAddress; |
235 | UINT32 PhysicalAddress; |
236 | UINT32 VirtualSize; |
236 | UINT32 VirtualSize; |
237 | } Misc; |
237 | } Misc; |
238 | UINT32 VirtualAddress; |
238 | UINT32 VirtualAddress; |
239 | UINT32 SizeOfRawData; |
239 | UINT32 SizeOfRawData; |
240 | UINT32 PointerToRawData; |
240 | UINT32 PointerToRawData; |
241 | UINT32 PointerToRelocations; |
241 | UINT32 PointerToRelocations; |
242 | UINT32 PointerToLinenumbers; |
242 | UINT32 PointerToLinenumbers; |
243 | UINT16 NumberOfRelocations; |
243 | UINT16 NumberOfRelocations; |
244 | UINT16 NumberOfLinenumbers; |
244 | UINT16 NumberOfLinenumbers; |
245 | UINT32 Characteristics; |
245 | UINT32 Characteristics; |
246 | } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; |
246 | } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; |
247 | 247 | ||
248 | #define IMAGE_SIZEOF_SECTION_HEADER 40 |
248 | #define IMAGE_SIZEOF_SECTION_HEADER 40 |
249 | 249 | ||
250 | #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved. |
250 | #define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved. |
251 | 251 | ||
252 | #define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code. |
252 | #define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code. |
253 | #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data. |
253 | #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data. |
254 | #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data. |
254 | #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data. |
255 | 255 | ||
256 | #define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved. |
256 | #define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved. |
257 | #define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information. |
257 | #define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information. |
258 | #define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image. |
258 | #define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image. |
259 | #define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat. |
259 | #define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat. |
260 | 260 | ||
261 | #define IMAGE_SCN_ALIGN_1BYTES 0x00100000 // |
261 | #define IMAGE_SCN_ALIGN_1BYTES 0x00100000 // |
262 | #define IMAGE_SCN_ALIGN_2BYTES 0x00200000 // |
262 | #define IMAGE_SCN_ALIGN_2BYTES 0x00200000 // |
263 | #define IMAGE_SCN_ALIGN_4BYTES 0x00300000 // |
263 | #define IMAGE_SCN_ALIGN_4BYTES 0x00300000 // |
264 | #define IMAGE_SCN_ALIGN_8BYTES 0x00400000 // |
264 | #define IMAGE_SCN_ALIGN_8BYTES 0x00400000 // |
265 | #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified. |
265 | #define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified. |
266 | #define IMAGE_SCN_ALIGN_32BYTES 0x00600000 // |
266 | #define IMAGE_SCN_ALIGN_32BYTES 0x00600000 // |
267 | #define IMAGE_SCN_ALIGN_64BYTES 0x00700000 // |
267 | #define IMAGE_SCN_ALIGN_64BYTES 0x00700000 // |
268 | 268 | ||
269 | #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded. |
269 | #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded. |
270 | #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable. |
270 | #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable. |
271 | #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable. |
271 | #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable. |
272 | #define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable. |
272 | #define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable. |
273 | #define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable. |
273 | #define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable. |
274 | #define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable. |
274 | #define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable. |
275 | #define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable. |
275 | #define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable. |
276 | 276 | ||
277 | // |
277 | // |
278 | // Symbol format. |
278 | // Symbol format. |
279 | // |
279 | // |
280 | 280 | ||
281 | 281 | ||
282 | #define IMAGE_SIZEOF_SYMBOL 18 |
282 | #define IMAGE_SIZEOF_SYMBOL 18 |
283 | 283 | ||
284 | // |
284 | // |
285 | // Section values. |
285 | // Section values. |
286 | // |
286 | // |
287 | // Symbols have a section number of the section in which they are |
287 | // Symbols have a section number of the section in which they are |
288 | // defined. Otherwise, section numbers have the following meanings: |
288 | // defined. Otherwise, section numbers have the following meanings: |
289 | // |
289 | // |
290 | 290 | ||
291 | #define IMAGE_SYM_UNDEFINED (UINT16)0 // Symbol is undefined or is common. |
291 | #define IMAGE_SYM_UNDEFINED (UINT16)0 // Symbol is undefined or is common. |
292 | #define IMAGE_SYM_ABSOLUTE (UINT16)-1 // Symbol is an absolute value. |
292 | #define IMAGE_SYM_ABSOLUTE (UINT16)-1 // Symbol is an absolute value. |
293 | #define IMAGE_SYM_DEBUG (UINT16)-2 // Symbol is a special debug item. |
293 | #define IMAGE_SYM_DEBUG (UINT16)-2 // Symbol is a special debug item. |
294 | 294 | ||
295 | // |
295 | // |
296 | // Type (fundamental) values. |
296 | // Type (fundamental) values. |
297 | // |
297 | // |
298 | 298 | ||
299 | #define IMAGE_SYM_TYPE_NULL 0 // no type. |
299 | #define IMAGE_SYM_TYPE_NULL 0 // no type. |
300 | #define IMAGE_SYM_TYPE_VOID 1 // |
300 | #define IMAGE_SYM_TYPE_VOID 1 // |
301 | #define IMAGE_SYM_TYPE_CHAR 2 // type character. |
301 | #define IMAGE_SYM_TYPE_CHAR 2 // type character. |
302 | #define IMAGE_SYM_TYPE_SHORT 3 // type short integer. |
302 | #define IMAGE_SYM_TYPE_SHORT 3 // type short integer. |
303 | #define IMAGE_SYM_TYPE_INT 4 // |
303 | #define IMAGE_SYM_TYPE_INT 4 // |
304 | #define IMAGE_SYM_TYPE_LONG 5 // |
304 | #define IMAGE_SYM_TYPE_LONG 5 // |
305 | #define IMAGE_SYM_TYPE_FLOAT 6 // |
305 | #define IMAGE_SYM_TYPE_FLOAT 6 // |
306 | #define IMAGE_SYM_TYPE_DOUBLE 7 // |
306 | #define IMAGE_SYM_TYPE_DOUBLE 7 // |
307 | #define IMAGE_SYM_TYPE_STRUCT 8 // |
307 | #define IMAGE_SYM_TYPE_STRUCT 8 // |
308 | #define IMAGE_SYM_TYPE_UNION 9 // |
308 | #define IMAGE_SYM_TYPE_UNION 9 // |
309 | #define IMAGE_SYM_TYPE_ENUM 10 // enumeration. |
309 | #define IMAGE_SYM_TYPE_ENUM 10 // enumeration. |
310 | #define IMAGE_SYM_TYPE_MOE 11 // member of enumeration. |
310 | #define IMAGE_SYM_TYPE_MOE 11 // member of enumeration. |
311 | #define IMAGE_SYM_TYPE_BYTE 12 // |
311 | #define IMAGE_SYM_TYPE_BYTE 12 // |
312 | #define IMAGE_SYM_TYPE_WORD 13 // |
312 | #define IMAGE_SYM_TYPE_WORD 13 // |
313 | #define IMAGE_SYM_TYPE_UINT 14 // |
313 | #define IMAGE_SYM_TYPE_UINT 14 // |
314 | #define IMAGE_SYM_TYPE_DWORD 15 // |
314 | #define IMAGE_SYM_TYPE_DWORD 15 // |
315 | 315 | ||
316 | // |
316 | // |
317 | // Type (derived) values. |
317 | // Type (derived) values. |
318 | // |
318 | // |
319 | 319 | ||
320 | #define IMAGE_SYM_DTYPE_NULL 0 // no derived type. |
320 | #define IMAGE_SYM_DTYPE_NULL 0 // no derived type. |
321 | #define IMAGE_SYM_DTYPE_POINTER 1 // pointer. |
321 | #define IMAGE_SYM_DTYPE_POINTER 1 // pointer. |
322 | #define IMAGE_SYM_DTYPE_FUNCTION 2 // function. |
322 | #define IMAGE_SYM_DTYPE_FUNCTION 2 // function. |
323 | #define IMAGE_SYM_DTYPE_ARRAY 3 // array. |
323 | #define IMAGE_SYM_DTYPE_ARRAY 3 // array. |
324 | 324 | ||
325 | // |
325 | // |
326 | // Storage classes. |
326 | // Storage classes. |
327 | // |
327 | // |
328 | 328 | ||
329 | #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1 |
329 | #define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1 |
330 | #define IMAGE_SYM_CLASS_NULL 0 |
330 | #define IMAGE_SYM_CLASS_NULL 0 |
331 | #define IMAGE_SYM_CLASS_AUTOMATIC 1 |
331 | #define IMAGE_SYM_CLASS_AUTOMATIC 1 |
332 | #define IMAGE_SYM_CLASS_EXTERNAL 2 |
332 | #define IMAGE_SYM_CLASS_EXTERNAL 2 |
333 | #define IMAGE_SYM_CLASS_STATIC 3 |
333 | #define IMAGE_SYM_CLASS_STATIC 3 |
334 | #define IMAGE_SYM_CLASS_REGISTER 4 |
334 | #define IMAGE_SYM_CLASS_REGISTER 4 |
335 | #define IMAGE_SYM_CLASS_EXTERNAL_DEF 5 |
335 | #define IMAGE_SYM_CLASS_EXTERNAL_DEF 5 |
336 | #define IMAGE_SYM_CLASS_LABEL 6 |
336 | #define IMAGE_SYM_CLASS_LABEL 6 |
337 | #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 |
337 | #define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 |
338 | #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 |
338 | #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 |
339 | #define IMAGE_SYM_CLASS_ARGUMENT 9 |
339 | #define IMAGE_SYM_CLASS_ARGUMENT 9 |
340 | #define IMAGE_SYM_CLASS_STRUCT_TAG 10 |
340 | #define IMAGE_SYM_CLASS_STRUCT_TAG 10 |
341 | #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 |
341 | #define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 |
342 | #define IMAGE_SYM_CLASS_UNION_TAG 12 |
342 | #define IMAGE_SYM_CLASS_UNION_TAG 12 |
343 | #define IMAGE_SYM_CLASS_TYPE_DEFINITION 13 |
343 | #define IMAGE_SYM_CLASS_TYPE_DEFINITION 13 |
344 | #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 |
344 | #define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 |
345 | #define IMAGE_SYM_CLASS_ENUM_TAG 15 |
345 | #define IMAGE_SYM_CLASS_ENUM_TAG 15 |
346 | #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 |
346 | #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 |
347 | #define IMAGE_SYM_CLASS_REGISTER_PARAM 17 |
347 | #define IMAGE_SYM_CLASS_REGISTER_PARAM 17 |
348 | #define IMAGE_SYM_CLASS_BIT_FIELD 18 |
348 | #define IMAGE_SYM_CLASS_BIT_FIELD 18 |
349 | #define IMAGE_SYM_CLASS_BLOCK 100 |
349 | #define IMAGE_SYM_CLASS_BLOCK 100 |
350 | #define IMAGE_SYM_CLASS_FUNCTION 101 |
350 | #define IMAGE_SYM_CLASS_FUNCTION 101 |
351 | #define IMAGE_SYM_CLASS_END_OF_STRUCT 102 |
351 | #define IMAGE_SYM_CLASS_END_OF_STRUCT 102 |
352 | #define IMAGE_SYM_CLASS_FILE 103 |
352 | #define IMAGE_SYM_CLASS_FILE 103 |
353 | // new |
353 | // new |
354 | #define IMAGE_SYM_CLASS_SECTION 104 |
354 | #define IMAGE_SYM_CLASS_SECTION 104 |
355 | #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 |
355 | #define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 |
356 | 356 | ||
357 | // type packing constants |
357 | // type packing constants |
358 | 358 | ||
359 | #define N_BTMASK 017 |
359 | #define N_BTMASK 017 |
360 | #define N_TMASK 060 |
360 | #define N_TMASK 060 |
361 | #define N_TMASK1 0300 |
361 | #define N_TMASK1 0300 |
362 | #define N_TMASK2 0360 |
362 | #define N_TMASK2 0360 |
363 | #define N_BTSHFT 4 |
363 | #define N_BTSHFT 4 |
364 | #define N_TSHIFT 2 |
364 | #define N_TSHIFT 2 |
365 | 365 | ||
366 | // MACROS |
366 | // MACROS |
367 | 367 | ||
368 | // |
368 | // |
369 | // Communal selection types. |
369 | // Communal selection types. |
370 | // |
370 | // |
371 | 371 | ||
372 | #define IMAGE_COMDAT_SELECT_NODUPLICATES 1 |
372 | #define IMAGE_COMDAT_SELECT_NODUPLICATES 1 |
373 | #define IMAGE_COMDAT_SELECT_ANY 2 |
373 | #define IMAGE_COMDAT_SELECT_ANY 2 |
374 | #define IMAGE_COMDAT_SELECT_SAME_SIZE 3 |
374 | #define IMAGE_COMDAT_SELECT_SAME_SIZE 3 |
375 | #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4 |
375 | #define IMAGE_COMDAT_SELECT_EXACT_MATCH 4 |
376 | #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 |
376 | #define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 |
377 | 377 | ||
378 | #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 |
378 | #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 |
379 | #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 |
379 | #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 |
380 | #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 |
380 | #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 |
381 | 381 | ||
382 | 382 | ||
383 | // |
383 | // |
384 | // Relocation format. |
384 | // Relocation format. |
385 | // |
385 | // |
386 | 386 | ||
387 | typedef struct _IMAGE_RELOCATION { |
387 | typedef struct _IMAGE_RELOCATION { |
388 | UINT32 VirtualAddress; |
388 | UINT32 VirtualAddress; |
389 | UINT32 SymbolTableIndex; |
389 | UINT32 SymbolTableIndex; |
390 | UINT16 Type; |
390 | UINT16 Type; |
391 | } IMAGE_RELOCATION; |
391 | } IMAGE_RELOCATION; |
392 | 392 | ||
393 | #define IMAGE_SIZEOF_RELOCATION 10 |
393 | #define IMAGE_SIZEOF_RELOCATION 10 |
394 | 394 | ||
395 | // |
395 | // |
396 | // I386 relocation types. |
396 | // I386 relocation types. |
397 | // |
397 | // |
398 | 398 | ||
399 | #define IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary |
399 | #define IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary |
400 | #define IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address |
400 | #define IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address |
401 | #define IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address |
401 | #define IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address |
402 | #define IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address |
402 | #define IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address |
403 | #define IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included |
403 | #define IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included |
404 | #define IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address |
404 | #define IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address |
405 | #define IMAGE_REL_I386_SECTION 012 |
405 | #define IMAGE_REL_I386_SECTION 012 |
406 | #define IMAGE_REL_I386_SECREL 013 |
406 | #define IMAGE_REL_I386_SECREL 013 |
407 | #define IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address |
407 | #define IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address |
408 | 408 | ||
409 | // |
409 | // |
410 | // MIPS relocation types. |
410 | // MIPS relocation types. |
411 | // |
411 | // |
412 | 412 | ||
413 | #define IMAGE_REL_MIPS_ABSOLUTE 0 // Reference is absolute, no relocation is necessary |
413 | #define IMAGE_REL_MIPS_ABSOLUTE 0 // Reference is absolute, no relocation is necessary |
414 | #define IMAGE_REL_MIPS_REFHALF 01 |
414 | #define IMAGE_REL_MIPS_REFHALF 01 |
415 | #define IMAGE_REL_MIPS_REFWORD 02 |
415 | #define IMAGE_REL_MIPS_REFWORD 02 |
416 | #define IMAGE_REL_MIPS_JMPADDR 03 |
416 | #define IMAGE_REL_MIPS_JMPADDR 03 |
417 | #define IMAGE_REL_MIPS_REFHI 04 |
417 | #define IMAGE_REL_MIPS_REFHI 04 |
418 | #define IMAGE_REL_MIPS_REFLO 05 |
418 | #define IMAGE_REL_MIPS_REFLO 05 |
419 | #define IMAGE_REL_MIPS_GPREL 06 |
419 | #define IMAGE_REL_MIPS_GPREL 06 |
420 | #define IMAGE_REL_MIPS_LITERAL 07 |
420 | #define IMAGE_REL_MIPS_LITERAL 07 |
421 | #define IMAGE_REL_MIPS_SECTION 012 |
421 | #define IMAGE_REL_MIPS_SECTION 012 |
422 | #define IMAGE_REL_MIPS_SECREL 013 |
422 | #define IMAGE_REL_MIPS_SECREL 013 |
423 | #define IMAGE_REL_MIPS_REFWORDNB 042 |
423 | #define IMAGE_REL_MIPS_REFWORDNB 042 |
424 | #define IMAGE_REL_MIPS_PAIR 045 |
424 | #define IMAGE_REL_MIPS_PAIR 045 |
425 | 425 | ||
426 | // |
426 | // |
427 | // Alpha Relocation types. |
427 | // Alpha Relocation types. |
428 | // |
428 | // |
429 | 429 | ||
430 | #define IMAGE_REL_ALPHA_ABSOLUTE 0x0 |
430 | #define IMAGE_REL_ALPHA_ABSOLUTE 0x0 |
431 | #define IMAGE_REL_ALPHA_REFLONG 0x1 |
431 | #define IMAGE_REL_ALPHA_REFLONG 0x1 |
432 | #define IMAGE_REL_ALPHA_REFQUAD 0x2 |
432 | #define IMAGE_REL_ALPHA_REFQUAD 0x2 |
433 | #define IMAGE_REL_ALPHA_GPREL32 0x3 |
433 | #define IMAGE_REL_ALPHA_GPREL32 0x3 |
434 | #define IMAGE_REL_ALPHA_LITERAL 0x4 |
434 | #define IMAGE_REL_ALPHA_LITERAL 0x4 |
435 | #define IMAGE_REL_ALPHA_LITUSE 0x5 |
435 | #define IMAGE_REL_ALPHA_LITUSE 0x5 |
436 | #define IMAGE_REL_ALPHA_GPDISP 0x6 |
436 | #define IMAGE_REL_ALPHA_GPDISP 0x6 |
437 | #define IMAGE_REL_ALPHA_BRADDR 0x7 |
437 | #define IMAGE_REL_ALPHA_BRADDR 0x7 |
438 | #define IMAGE_REL_ALPHA_HINT 0x8 |
438 | #define IMAGE_REL_ALPHA_HINT 0x8 |
439 | #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x9 |
439 | #define IMAGE_REL_ALPHA_INLINE_REFLONG 0x9 |
440 | #define IMAGE_REL_ALPHA_REFHI 0xA |
440 | #define IMAGE_REL_ALPHA_REFHI 0xA |
441 | #define IMAGE_REL_ALPHA_REFLO 0xB |
441 | #define IMAGE_REL_ALPHA_REFLO 0xB |
442 | #define IMAGE_REL_ALPHA_PAIR 0xC |
442 | #define IMAGE_REL_ALPHA_PAIR 0xC |
443 | #define IMAGE_REL_ALPHA_MATCH 0xD |
443 | #define IMAGE_REL_ALPHA_MATCH 0xD |
444 | #define IMAGE_REL_ALPHA_SECTION 0xE |
444 | #define IMAGE_REL_ALPHA_SECTION 0xE |
445 | #define IMAGE_REL_ALPHA_SECREL 0xF |
445 | #define IMAGE_REL_ALPHA_SECREL 0xF |
446 | #define IMAGE_REL_ALPHA_REFLONGNB 0x10 |
446 | #define IMAGE_REL_ALPHA_REFLONGNB 0x10 |
447 | 447 | ||
448 | // |
448 | // |
449 | // IBM PowerPC relocation types. |
449 | // IBM PowerPC relocation types. |
450 | // |
450 | // |
451 | 451 | ||
452 | #define IMAGE_REL_PPC_ABSOLUTE 0x0000 // NOP |
452 | #define IMAGE_REL_PPC_ABSOLUTE 0x0000 // NOP |
453 | #define IMAGE_REL_PPC_ADDR64 0x0001 // 64-bit address |
453 | #define IMAGE_REL_PPC_ADDR64 0x0001 // 64-bit address |
454 | #define IMAGE_REL_PPC_ADDR32 0x0002 // 32-bit address |
454 | #define IMAGE_REL_PPC_ADDR32 0x0002 // 32-bit address |
455 | #define IMAGE_REL_PPC_ADDR24 0x0003 // 26-bit address, shifted left 2 (branch absolute) |
455 | #define IMAGE_REL_PPC_ADDR24 0x0003 // 26-bit address, shifted left 2 (branch absolute) |
456 | #define IMAGE_REL_PPC_ADDR16 0x0004 // 16-bit address |
456 | #define IMAGE_REL_PPC_ADDR16 0x0004 // 16-bit address |
457 | #define IMAGE_REL_PPC_ADDR14 0x0005 // 16-bit address, shifted left 2 (load doubleword) |
457 | #define IMAGE_REL_PPC_ADDR14 0x0005 // 16-bit address, shifted left 2 (load doubleword) |
458 | #define IMAGE_REL_PPC_REL24 0x0006 // 26-bit PC-relative offset, shifted left 2 (branch relative) |
458 | #define IMAGE_REL_PPC_REL24 0x0006 // 26-bit PC-relative offset, shifted left 2 (branch relative) |
459 | #define IMAGE_REL_PPC_REL14 0x0007 // 16-bit PC-relative offset, shifted left 2 (br cond relative) |
459 | #define IMAGE_REL_PPC_REL14 0x0007 // 16-bit PC-relative offset, shifted left 2 (br cond relative) |
460 | #define IMAGE_REL_PPC_TOCREL16 0x0008 // 16-bit offset from TOC base |
460 | #define IMAGE_REL_PPC_TOCREL16 0x0008 // 16-bit offset from TOC base |
461 | #define IMAGE_REL_PPC_TOCREL14 0x0009 // 16-bit offset from TOC base, shifted left 2 (load doubleword) |
461 | #define IMAGE_REL_PPC_TOCREL14 0x0009 // 16-bit offset from TOC base, shifted left 2 (load doubleword) |
462 | 462 | ||
463 | #define IMAGE_REL_PPC_ADDR32NB 0x000A // 32-bit addr w/o image base |
463 | #define IMAGE_REL_PPC_ADDR32NB 0x000A // 32-bit addr w/o image base |
464 | #define IMAGE_REL_PPC_SECREL 0x000B // va of containing section (as in an image sectionhdr) |
464 | #define IMAGE_REL_PPC_SECREL 0x000B // va of containing section (as in an image sectionhdr) |
465 | #define IMAGE_REL_PPC_SECTION 0x000C // sectionheader number |
465 | #define IMAGE_REL_PPC_SECTION 0x000C // sectionheader number |
466 | #define IMAGE_REL_PPC_IFGLUE 0x000D // substitute TOC restore instruction iff symbol is glue code |
466 | #define IMAGE_REL_PPC_IFGLUE 0x000D // substitute TOC restore instruction iff symbol is glue code |
467 | #define IMAGE_REL_PPC_IMGLUE 0x000E // symbol is glue code; virtual address is TOC restore instruction |
467 | #define IMAGE_REL_PPC_IMGLUE 0x000E // symbol is glue code; virtual address is TOC restore instruction |
468 | 468 | ||
469 | #define IMAGE_REL_PPC_TYPEMASK 0x00FF // mask to isolate above values in IMAGE_RELOCATION.Type |
469 | #define IMAGE_REL_PPC_TYPEMASK 0x00FF // mask to isolate above values in IMAGE_RELOCATION.Type |
470 | 470 | ||
471 | // Flag bits in IMAGE_RELOCATION.TYPE |
471 | // Flag bits in IMAGE_RELOCATION.TYPE |
472 | 472 | ||
473 | #define IMAGE_REL_PPC_NEG 0x0100 // subtract reloc value rather than adding it |
473 | #define IMAGE_REL_PPC_NEG 0x0100 // subtract reloc value rather than adding it |
474 | #define IMAGE_REL_PPC_BRTAKEN 0x0200 // fix branch prediction bit to predict branch taken |
474 | #define IMAGE_REL_PPC_BRTAKEN 0x0200 // fix branch prediction bit to predict branch taken |
475 | #define IMAGE_REL_PPC_BRNTAKEN 0x0400 // fix branch prediction bit to predict branch not taken |
475 | #define IMAGE_REL_PPC_BRNTAKEN 0x0400 // fix branch prediction bit to predict branch not taken |
476 | #define IMAGE_REL_PPC_TOCDEFN 0x0800 // toc slot defined in file (or, data in toc) |
476 | #define IMAGE_REL_PPC_TOCDEFN 0x0800 // toc slot defined in file (or, data in toc) |
477 | 477 | ||
478 | // |
478 | // |
479 | // Based relocation format. |
479 | // Based relocation format. |
480 | // |
480 | // |
481 | 481 | ||
482 | typedef struct _IMAGE_BASE_RELOCATION { |
482 | typedef struct _IMAGE_BASE_RELOCATION { |
483 | UINT32 VirtualAddress; |
483 | UINT32 VirtualAddress; |
484 | UINT32 SizeOfBlock; |
484 | UINT32 SizeOfBlock; |
485 | // UINT16 TypeOffset[1]; |
485 | // UINT16 TypeOffset[1]; |
486 | } IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION; |
486 | } IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION; |
487 | 487 | ||
488 | #define IMAGE_SIZEOF_BASE_RELOCATION 8 |
488 | #define IMAGE_SIZEOF_BASE_RELOCATION 8 |
489 | 489 | ||
490 | // |
490 | // |
491 | // Based relocation types. |
491 | // Based relocation types. |
492 | // |
492 | // |
493 | 493 | ||
494 | #define IMAGE_REL_BASED_ABSOLUTE 0 |
494 | #define IMAGE_REL_BASED_ABSOLUTE 0 |
495 | #define IMAGE_REL_BASED_HIGH 1 |
495 | #define IMAGE_REL_BASED_HIGH 1 |
496 | #define IMAGE_REL_BASED_LOW 2 |
496 | #define IMAGE_REL_BASED_LOW 2 |
497 | #define IMAGE_REL_BASED_HIGHLOW 3 |
497 | #define IMAGE_REL_BASED_HIGHLOW 3 |
498 | #define IMAGE_REL_BASED_HIGHADJ 4 |
498 | #define IMAGE_REL_BASED_HIGHADJ 4 |
499 | #define IMAGE_REL_BASED_MIPS_JMPADDR 5 |
499 | #define IMAGE_REL_BASED_MIPS_JMPADDR 5 |
500 | #define IMAGE_REL_BASED_IA64_IMM64 9 |
500 | #define IMAGE_REL_BASED_IA64_IMM64 9 |
501 | #define IMAGE_REL_BASED_DIR64 10 |
501 | #define IMAGE_REL_BASED_DIR64 10 |
502 | 502 | ||
503 | // |
503 | // |
504 | // Line number format. |
504 | // Line number format. |
505 | // |
505 | // |
506 | 506 | ||
507 | typedef struct _IMAGE_LINENUMBER { |
507 | typedef struct _IMAGE_LINENUMBER { |
508 | union { |
508 | union { |
509 | UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0. |
509 | UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0. |
510 | UINT32 VirtualAddress; // Virtual address of line number. |
510 | UINT32 VirtualAddress; // Virtual address of line number. |
511 | } Type; |
511 | } Type; |
512 | UINT16 Linenumber; // Line number. |
512 | UINT16 Linenumber; // Line number. |
513 | } IMAGE_LINENUMBER; |
513 | } IMAGE_LINENUMBER; |
514 | 514 | ||
515 | #define IMAGE_SIZEOF_LINENUMBER 6 |
515 | #define IMAGE_SIZEOF_LINENUMBER 6 |
516 | 516 | ||
517 | // |
517 | // |
518 | // Archive format. |
518 | // Archive format. |
519 | // |
519 | // |
520 | 520 | ||
521 | #define IMAGE_ARCHIVE_START_SIZE 8 |
521 | #define IMAGE_ARCHIVE_START_SIZE 8 |
522 | #define IMAGE_ARCHIVE_START "!<arch>\n" |
522 | #define IMAGE_ARCHIVE_START "!<arch>\n" |
523 | #define IMAGE_ARCHIVE_END "`\n" |
523 | #define IMAGE_ARCHIVE_END "`\n" |
524 | #define IMAGE_ARCHIVE_PAD "\n" |
524 | #define IMAGE_ARCHIVE_PAD "\n" |
525 | #define IMAGE_ARCHIVE_LINKER_MEMBER "/ " |
525 | #define IMAGE_ARCHIVE_LINKER_MEMBER "/ " |
526 | #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " |
526 | #define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " |
527 | 527 | ||
528 | typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER { |
528 | typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER { |
529 | UINT8 Name[16]; // File member name - `/' terminated. |
529 | UINT8 Name[16]; // File member name - `/' terminated. |
530 | UINT8 Date[12]; // File member date - decimal. |
530 | UINT8 Date[12]; // File member date - decimal. |
531 | UINT8 UserID[6]; // File member user id - decimal. |
531 | UINT8 UserID[6]; // File member user id - decimal. |
532 | UINT8 GroupID[6]; // File member group id - decimal. |
532 | UINT8 GroupID[6]; // File member group id - decimal. |
533 | UINT8 Mode[8]; // File member mode - octal. |
533 | UINT8 Mode[8]; // File member mode - octal. |
534 | UINT8 Size[10]; // File member size - decimal. |
534 | UINT8 Size[10]; // File member size - decimal. |
535 | UINT8 EndHeader[2]; // String to end header. |
535 | UINT8 EndHeader[2]; // String to end header. |
536 | } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER; |
536 | } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER; |
537 | 537 | ||
538 | #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 |
538 | #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 |
539 | 539 | ||
540 | // |
540 | // |
541 | // DLL support. |
541 | // DLL support. |
542 | // |
542 | // |
543 | 543 | ||
544 | // |
544 | // |
545 | // Export Format |
545 | // Export Format |
546 | // |
546 | // |
547 | 547 | ||
548 | typedef struct _IMAGE_EXPORT_DIRECTORY { |
548 | typedef struct _IMAGE_EXPORT_DIRECTORY { |
549 | UINT32 Characteristics; |
549 | UINT32 Characteristics; |
550 | UINT32 TimeDateStamp; |
550 | UINT32 TimeDateStamp; |
551 | UINT16 MajorVersion; |
551 | UINT16 MajorVersion; |
552 | UINT16 MinorVersion; |
552 | UINT16 MinorVersion; |
553 | UINT32 Name; |
553 | UINT32 Name; |
554 | UINT32 Base; |
554 | UINT32 Base; |
555 | UINT32 NumberOfFunctions; |
555 | UINT32 NumberOfFunctions; |
556 | UINT32 NumberOfNames; |
556 | UINT32 NumberOfNames; |
557 | UINT32 *AddressOfFunctions; |
557 | UINT32 *AddressOfFunctions; |
558 | UINT32 *AddressOfNames; |
558 | UINT32 *AddressOfNames; |
559 | UINT32 *AddressOfNameOrdinals; |
559 | UINT32 *AddressOfNameOrdinals; |
560 | } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; |
560 | } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; |
561 | 561 | ||
562 | // |
562 | // |
563 | // Import Format |
563 | // Import Format |
564 | // |
564 | // |
565 | 565 | ||
566 | typedef struct _IMAGE_IMPORT_BY_NAME { |
566 | typedef struct _IMAGE_IMPORT_BY_NAME { |
567 | UINT16 Hint; |
567 | UINT16 Hint; |
568 | UINT8 Name[1]; |
568 | UINT8 Name[1]; |
569 | } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; |
569 | } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; |
570 | 570 | ||
571 | typedef struct _IMAGE_THUNK_DATA { |
571 | typedef struct _IMAGE_THUNK_DATA { |
572 | union { |
572 | union { |
573 | UINT32 Function; |
573 | UINT32 Function; |
574 | UINT32 Ordinal; |
574 | UINT32 Ordinal; |
575 | PIMAGE_IMPORT_BY_NAME AddressOfData; |
575 | PIMAGE_IMPORT_BY_NAME AddressOfData; |
576 | } u1; |
576 | } u1; |
577 | } IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA; |
577 | } IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA; |
578 | 578 | ||
579 | #define IMAGE_ORDINAL_FLAG 0x80000000 |
579 | #define IMAGE_ORDINAL_FLAG 0x80000000 |
580 | #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0) |
580 | #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0) |
581 | #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) |
581 | #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) |
582 | 582 | ||
583 | typedef struct _IMAGE_IMPORT_DESCRIPTOR { |
583 | typedef struct _IMAGE_IMPORT_DESCRIPTOR { |
584 | UINT32 Characteristics; |
584 | UINT32 Characteristics; |
585 | UINT32 TimeDateStamp; |
585 | UINT32 TimeDateStamp; |
586 | UINT32 ForwarderChain; |
586 | UINT32 ForwarderChain; |
587 | UINT32 Name; |
587 | UINT32 Name; |
588 | PIMAGE_THUNK_DATA FirstThunk; |
588 | PIMAGE_THUNK_DATA FirstThunk; |
589 | } IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; |
589 | } IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; |
590 | 590 | ||
591 | #endif |
591 | #endif |
592 | 592 |