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