iPXE
PeImage.h
Go to the documentation of this file.
1 /** @file
2  EFI image format for PE32, PE32+ and TE. Please note some data structures are
3  different for PE32 and PE32+. EFI_IMAGE_NT_HEADERS32 is for PE32 and
4  EFI_IMAGE_NT_HEADERS64 is for PE32+.
5 
6  This file is coded to the Visual Studio, Microsoft Portable Executable and
7  Common Object File Format Specification, Revision 8.3 - February 6, 2013.
8  This file also includes some definitions in PI Specification, Revision 1.0.
9 
10 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
11 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
12 This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php.
16 
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 
20 **/
21 
22 #ifndef __PE_IMAGE_H__
23 #define __PE_IMAGE_H__
24 
25 FILE_LICENCE ( BSD3 );
26 
27 //
28 // PE32+ Subsystem type for EFI images
29 //
30 #define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10
31 #define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
32 #define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
33 #define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 ///< defined PI Specification, 1.0
34 
35 
36 //
37 // PE32+ Machine type for EFI images
38 //
39 #define IMAGE_FILE_MACHINE_I386 0x014c
40 #define IMAGE_FILE_MACHINE_IA64 0x0200
41 #define IMAGE_FILE_MACHINE_EBC 0x0EBC
42 #define IMAGE_FILE_MACHINE_X64 0x8664
43 #define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2
44 #define IMAGE_FILE_MACHINE_ARM64 0xAA64
45 
46 //
47 // EXE file formats
48 //
49 #define EFI_IMAGE_DOS_SIGNATURE SIGNATURE_16('M', 'Z')
50 #define EFI_IMAGE_OS2_SIGNATURE SIGNATURE_16('N', 'E')
51 #define EFI_IMAGE_OS2_SIGNATURE_LE SIGNATURE_16('L', 'E')
52 #define EFI_IMAGE_NT_SIGNATURE SIGNATURE_32('P', 'E', '\0', '\0')
53 
54 ///
55 /// PE images can start with an optional DOS header, so if an image is run
56 /// under DOS it can print an error message.
57 ///
58 typedef struct {
59  UINT16 e_magic; ///< Magic number.
60  UINT16 e_cblp; ///< Bytes on last page of file.
61  UINT16 e_cp; ///< Pages in file.
62  UINT16 e_crlc; ///< Relocations.
63  UINT16 e_cparhdr; ///< Size of header in paragraphs.
64  UINT16 e_minalloc; ///< Minimum extra paragraphs needed.
65  UINT16 e_maxalloc; ///< Maximum extra paragraphs needed.
66  UINT16 e_ss; ///< Initial (relative) SS value.
67  UINT16 e_sp; ///< Initial SP value.
68  UINT16 e_csum; ///< Checksum.
69  UINT16 e_ip; ///< Initial IP value.
70  UINT16 e_cs; ///< Initial (relative) CS value.
71  UINT16 e_lfarlc; ///< File address of relocation table.
72  UINT16 e_ovno; ///< Overlay number.
73  UINT16 e_res[4]; ///< Reserved words.
74  UINT16 e_oemid; ///< OEM identifier (for e_oeminfo).
75  UINT16 e_oeminfo; ///< OEM information; e_oemid specific.
76  UINT16 e_res2[10]; ///< Reserved words.
77  UINT32 e_lfanew; ///< File address of new exe header.
79 
80 ///
81 /// COFF File Header (Object and Image).
82 ///
83 typedef struct {
92 
93 ///
94 /// Size of EFI_IMAGE_FILE_HEADER.
95 ///
96 #define EFI_IMAGE_SIZEOF_FILE_HEADER 20
97 
98 //
99 // Characteristics
100 //
101 #define EFI_IMAGE_FILE_RELOCS_STRIPPED BIT0 ///< 0x0001 Relocation info stripped from file.
102 #define EFI_IMAGE_FILE_EXECUTABLE_IMAGE BIT1 ///< 0x0002 File is executable (i.e. no unresolved externel references).
103 #define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED BIT2 ///< 0x0004 Line nunbers stripped from file.
104 #define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED BIT3 ///< 0x0008 Local symbols stripped from file.
105 #define EFI_IMAGE_FILE_BYTES_REVERSED_LO BIT7 ///< 0x0080 Bytes of machine word are reversed.
106 #define EFI_IMAGE_FILE_32BIT_MACHINE BIT8 ///< 0x0100 32 bit word machine.
107 #define EFI_IMAGE_FILE_DEBUG_STRIPPED BIT9 ///< 0x0200 Debugging info stripped from file in .DBG file.
108 #define EFI_IMAGE_FILE_SYSTEM BIT12 ///< 0x1000 System File.
109 #define EFI_IMAGE_FILE_DLL BIT13 ///< 0x2000 File is a DLL.
110 #define EFI_IMAGE_FILE_BYTES_REVERSED_HI BIT15 ///< 0x8000 Bytes of machine word are reversed.
111 
112 ///
113 /// Header Data Directories.
114 ///
115 typedef struct {
119 
120 //
121 // Directory Entries
122 //
123 #define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0
124 #define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1
125 #define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2
126 #define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
127 #define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4
128 #define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5
129 #define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6
130 #define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
131 #define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
132 #define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9
133 #define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
134 
135 #define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16
136 
137 ///
138 /// @attention
139 /// EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC means PE32 and
140 /// EFI_IMAGE_OPTIONAL_HEADER32 must be used. The data structures only vary
141 /// after NT additional fields.
142 ///
143 #define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
144 
145 ///
146 /// Optional Header Standard Fields for PE32.
147 ///
148 typedef struct {
149  ///
150  /// Standard fields.
151  ///
160  UINT32 BaseOfData; ///< PE32 contains this additional field, which is absent in PE32+.
161  ///
162  /// Optional Header Windows-Specific Fields.
163  ///
187 
188 ///
189 /// @attention
190 /// EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC means PE32+ and
191 /// EFI_IMAGE_OPTIONAL_HEADER64 must be used. The data structures only vary
192 /// after NT additional fields.
193 ///
194 #define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
195 
196 ///
197 /// Optional Header Standard Fields for PE32+.
198 ///
199 typedef struct {
200  ///
201  /// Standard fields.
202  ///
211  ///
212  /// Optional Header Windows-Specific Fields.
213  ///
237 
238 
239 ///
240 /// @attention
241 /// EFI_IMAGE_NT_HEADERS32 is for use ONLY by tools.
242 ///
243 typedef struct {
248 
249 #define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)
250 
251 ///
252 /// @attention
253 /// EFI_IMAGE_HEADERS64 is for use ONLY by tools.
254 ///
255 typedef struct {
260 
261 #define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)
262 
263 //
264 // Other Windows Subsystem Values
265 //
266 #define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0
267 #define EFI_IMAGE_SUBSYSTEM_NATIVE 1
268 #define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2
269 #define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3
270 #define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5
271 #define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7
272 
273 ///
274 /// Length of ShortName.
275 ///
276 #define EFI_IMAGE_SIZEOF_SHORT_NAME 8
277 
278 ///
279 /// Section Table. This table immediately follows the optional header.
280 ///
281 typedef struct {
283  union {
286  } Misc;
296 
297 ///
298 /// Size of EFI_IMAGE_SECTION_HEADER.
299 ///
300 #define EFI_IMAGE_SIZEOF_SECTION_HEADER 40
301 
302 //
303 // Section Flags Values
304 //
305 #define EFI_IMAGE_SCN_TYPE_NO_PAD BIT3 ///< 0x00000008 ///< Reserved.
306 #define EFI_IMAGE_SCN_CNT_CODE BIT5 ///< 0x00000020
307 #define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA BIT6 ///< 0x00000040
308 #define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA BIT7 ///< 0x00000080
309 
310 #define EFI_IMAGE_SCN_LNK_OTHER BIT8 ///< 0x00000100 ///< Reserved.
311 #define EFI_IMAGE_SCN_LNK_INFO BIT9 ///< 0x00000200 ///< Section contains comments or some other type of information.
312 #define EFI_IMAGE_SCN_LNK_REMOVE BIT11 ///< 0x00000800 ///< Section contents will not become part of image.
313 #define EFI_IMAGE_SCN_LNK_COMDAT BIT12 ///< 0x00001000
314 
315 #define EFI_IMAGE_SCN_ALIGN_1BYTES BIT20 ///< 0x00100000
316 #define EFI_IMAGE_SCN_ALIGN_2BYTES BIT21 ///< 0x00200000
317 #define EFI_IMAGE_SCN_ALIGN_4BYTES (BIT20|BIT21) ///< 0x00300000
318 #define EFI_IMAGE_SCN_ALIGN_8BYTES BIT22 ///< 0x00400000
319 #define EFI_IMAGE_SCN_ALIGN_16BYTES (BIT20|BIT22) ///< 0x00500000
320 #define EFI_IMAGE_SCN_ALIGN_32BYTES (BIT21|BIT22) ///< 0x00600000
321 #define EFI_IMAGE_SCN_ALIGN_64BYTES (BIT20|BIT21|BIT22) ///< 0x00700000
322 
323 #define EFI_IMAGE_SCN_MEM_DISCARDABLE BIT25 ///< 0x02000000
324 #define EFI_IMAGE_SCN_MEM_NOT_CACHED BIT26 ///< 0x04000000
325 #define EFI_IMAGE_SCN_MEM_NOT_PAGED BIT27 ///< 0x08000000
326 #define EFI_IMAGE_SCN_MEM_SHARED BIT28 ///< 0x10000000
327 #define EFI_IMAGE_SCN_MEM_EXECUTE BIT29 ///< 0x20000000
328 #define EFI_IMAGE_SCN_MEM_READ BIT30 ///< 0x40000000
329 #define EFI_IMAGE_SCN_MEM_WRITE BIT31 ///< 0x80000000
330 
331 ///
332 /// Size of a Symbol Table Record.
333 ///
334 #define EFI_IMAGE_SIZEOF_SYMBOL 18
335 
336 //
337 // Symbols have a section number of the section in which they are
338 // defined. Otherwise, section numbers have the following meanings:
339 //
340 #define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 ///< Symbol is undefined or is common.
341 #define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 ///< Symbol is an absolute value.
342 #define EFI_IMAGE_SYM_DEBUG (UINT16) -2 ///< Symbol is a special debug item.
343 
344 //
345 // Symbol Type (fundamental) values.
346 //
347 #define EFI_IMAGE_SYM_TYPE_NULL 0 ///< no type.
348 #define EFI_IMAGE_SYM_TYPE_VOID 1 ///< no valid type.
349 #define EFI_IMAGE_SYM_TYPE_CHAR 2 ///< type character.
350 #define EFI_IMAGE_SYM_TYPE_SHORT 3 ///< type short integer.
351 #define EFI_IMAGE_SYM_TYPE_INT 4
352 #define EFI_IMAGE_SYM_TYPE_LONG 5
353 #define EFI_IMAGE_SYM_TYPE_FLOAT 6
354 #define EFI_IMAGE_SYM_TYPE_DOUBLE 7
355 #define EFI_IMAGE_SYM_TYPE_STRUCT 8
356 #define EFI_IMAGE_SYM_TYPE_UNION 9
357 #define EFI_IMAGE_SYM_TYPE_ENUM 10 ///< enumeration.
358 #define EFI_IMAGE_SYM_TYPE_MOE 11 ///< member of enumeration.
359 #define EFI_IMAGE_SYM_TYPE_BYTE 12
360 #define EFI_IMAGE_SYM_TYPE_WORD 13
361 #define EFI_IMAGE_SYM_TYPE_UINT 14
362 #define EFI_IMAGE_SYM_TYPE_DWORD 15
363 
364 //
365 // Symbol Type (derived) values.
366 //
367 #define EFI_IMAGE_SYM_DTYPE_NULL 0 ///< no derived type.
368 #define EFI_IMAGE_SYM_DTYPE_POINTER 1
369 #define EFI_IMAGE_SYM_DTYPE_FUNCTION 2
370 #define EFI_IMAGE_SYM_DTYPE_ARRAY 3
371 
372 //
373 // Storage classes.
374 //
375 #define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION ((UINT8) -1)
376 #define EFI_IMAGE_SYM_CLASS_NULL 0
377 #define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1
378 #define EFI_IMAGE_SYM_CLASS_EXTERNAL 2
379 #define EFI_IMAGE_SYM_CLASS_STATIC 3
380 #define EFI_IMAGE_SYM_CLASS_REGISTER 4
381 #define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5
382 #define EFI_IMAGE_SYM_CLASS_LABEL 6
383 #define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
384 #define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
385 #define EFI_IMAGE_SYM_CLASS_ARGUMENT 9
386 #define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10
387 #define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
388 #define EFI_IMAGE_SYM_CLASS_UNION_TAG 12
389 #define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13
390 #define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
391 #define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15
392 #define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
393 #define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17
394 #define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18
395 #define EFI_IMAGE_SYM_CLASS_BLOCK 100
396 #define EFI_IMAGE_SYM_CLASS_FUNCTION 101
397 #define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102
398 #define EFI_IMAGE_SYM_CLASS_FILE 103
399 #define EFI_IMAGE_SYM_CLASS_SECTION 104
400 #define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
401 
402 //
403 // type packing constants
404 //
405 #define EFI_IMAGE_N_BTMASK 017
406 #define EFI_IMAGE_N_TMASK 060
407 #define EFI_IMAGE_N_TMASK1 0300
408 #define EFI_IMAGE_N_TMASK2 0360
409 #define EFI_IMAGE_N_BTSHFT 4
410 #define EFI_IMAGE_N_TSHIFT 2
411 
412 //
413 // Communal selection types.
414 //
415 #define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1
416 #define EFI_IMAGE_COMDAT_SELECT_ANY 2
417 #define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3
418 #define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4
419 #define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
420 
421 //
422 // the following values only be referred in PeCoff, not defined in PECOFF.
423 //
424 #define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
425 #define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
426 #define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
427 
428 ///
429 /// Relocation format.
430 ///
431 typedef struct {
436 
437 ///
438 /// Size of EFI_IMAGE_RELOCATION
439 ///
440 #define EFI_IMAGE_SIZEOF_RELOCATION 10
441 
442 //
443 // I386 relocation types.
444 //
445 #define EFI_IMAGE_REL_I386_ABSOLUTE 0x0000 ///< Reference is absolute, no relocation is necessary.
446 #define EFI_IMAGE_REL_I386_DIR16 0x0001 ///< Direct 16-bit reference to the symbols virtual address.
447 #define EFI_IMAGE_REL_I386_REL16 0x0002 ///< PC-relative 16-bit reference to the symbols virtual address.
448 #define EFI_IMAGE_REL_I386_DIR32 0x0006 ///< Direct 32-bit reference to the symbols virtual address.
449 #define EFI_IMAGE_REL_I386_DIR32NB 0x0007 ///< Direct 32-bit reference to the symbols virtual address, base not included.
450 #define EFI_IMAGE_REL_I386_SEG12 0x0009 ///< Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address.
451 #define EFI_IMAGE_REL_I386_SECTION 0x000A
452 #define EFI_IMAGE_REL_I386_SECREL 0x000B
453 #define EFI_IMAGE_REL_I386_REL32 0x0014 ///< PC-relative 32-bit reference to the symbols virtual address.
454 
455 //
456 // x64 processor relocation types.
457 //
458 #define IMAGE_REL_AMD64_ABSOLUTE 0x0000
459 #define IMAGE_REL_AMD64_ADDR64 0x0001
460 #define IMAGE_REL_AMD64_ADDR32 0x0002
461 #define IMAGE_REL_AMD64_ADDR32NB 0x0003
462 #define IMAGE_REL_AMD64_REL32 0x0004
463 #define IMAGE_REL_AMD64_REL32_1 0x0005
464 #define IMAGE_REL_AMD64_REL32_2 0x0006
465 #define IMAGE_REL_AMD64_REL32_3 0x0007
466 #define IMAGE_REL_AMD64_REL32_4 0x0008
467 #define IMAGE_REL_AMD64_REL32_5 0x0009
468 #define IMAGE_REL_AMD64_SECTION 0x000A
469 #define IMAGE_REL_AMD64_SECREL 0x000B
470 #define IMAGE_REL_AMD64_SECREL7 0x000C
471 #define IMAGE_REL_AMD64_TOKEN 0x000D
472 #define IMAGE_REL_AMD64_SREL32 0x000E
473 #define IMAGE_REL_AMD64_PAIR 0x000F
474 #define IMAGE_REL_AMD64_SSPAN32 0x0010
475 
476 ///
477 /// Based relocation format.
478 ///
479 typedef struct {
483 
484 ///
485 /// Size of EFI_IMAGE_BASE_RELOCATION.
486 ///
487 #define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8
488 
489 //
490 // Based relocation types.
491 //
492 #define EFI_IMAGE_REL_BASED_ABSOLUTE 0
493 #define EFI_IMAGE_REL_BASED_HIGH 1
494 #define EFI_IMAGE_REL_BASED_LOW 2
495 #define EFI_IMAGE_REL_BASED_HIGHLOW 3
496 #define EFI_IMAGE_REL_BASED_HIGHADJ 4
497 #define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5
498 #define EFI_IMAGE_REL_BASED_ARM_MOV32A 5
499 #define EFI_IMAGE_REL_BASED_ARM_MOV32T 7
500 #define EFI_IMAGE_REL_BASED_IA64_IMM64 9
501 #define EFI_IMAGE_REL_BASED_MIPS_JMPADDR16 9
502 #define EFI_IMAGE_REL_BASED_DIR64 10
503 
504 ///
505 /// Line number format.
506 ///
507 typedef struct {
508  union {
509  UINT32 SymbolTableIndex; ///< Symbol table index of function name if Linenumber is 0.
510  UINT32 VirtualAddress; ///< Virtual address of line number.
511  } Type;
512  UINT16 Linenumber; ///< Line number.
514 
515 ///
516 /// Size of EFI_IMAGE_LINENUMBER.
517 ///
518 #define EFI_IMAGE_SIZEOF_LINENUMBER 6
519 
520 //
521 // Archive format.
522 //
523 #define EFI_IMAGE_ARCHIVE_START_SIZE 8
524 #define EFI_IMAGE_ARCHIVE_START "!<arch>\n"
525 #define EFI_IMAGE_ARCHIVE_END "`\n"
526 #define EFI_IMAGE_ARCHIVE_PAD "\n"
527 #define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ "
528 #define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
529 
530 ///
531 /// Archive Member Headers
532 ///
533 typedef struct {
534  UINT8 Name[16]; ///< File member name - `/' terminated.
535  UINT8 Date[12]; ///< File member date - decimal.
536  UINT8 UserID[6]; ///< File member user id - decimal.
537  UINT8 GroupID[6]; ///< File member group id - decimal.
538  UINT8 Mode[8]; ///< File member mode - octal.
539  UINT8 Size[10]; ///< File member size - decimal.
540  UINT8 EndHeader[2]; ///< String to end header. (0x60 0x0A).
542 
543 ///
544 /// Size of EFI_IMAGE_ARCHIVE_MEMBER_HEADER.
545 ///
546 #define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
547 
548 
549 //
550 // DLL Support
551 //
552 
553 ///
554 /// Export Directory Table.
555 ///
556 typedef struct {
569 
570 ///
571 /// Hint/Name Table.
572 ///
573 typedef struct {
577 
578 ///
579 /// Import Address Table RVA (Thunk Table).
580 ///
581 typedef struct {
582  union {
586  } u1;
588 
589 #define EFI_IMAGE_ORDINAL_FLAG BIT31 ///< Flag for PE32.
590 #define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)
591 #define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
592 
593 ///
594 /// Import Directory Table
595 ///
596 typedef struct {
603 
604 
605 ///
606 /// Debug Directory Format.
607 ///
608 typedef struct {
615  UINT32 RVA; ///< The address of the debug data when loaded, relative to the image base.
616  UINT32 FileOffset; ///< The file pointer to the debug data.
618 
619 #define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information.
620 
621 ///
622 /// Debug Data Structure defined in Microsoft C++.
623 ///
624 #define CODEVIEW_SIGNATURE_NB10 SIGNATURE_32('N', 'B', '1', '0')
625 typedef struct {
626  UINT32 Signature; ///< "NB10"
630  //
631  // Filename of .PDB goes here
632  //
634 
635 ///
636 /// Debug Data Structure defined in Microsoft C++.
637 ///
638 #define CODEVIEW_SIGNATURE_RSDS SIGNATURE_32('R', 'S', 'D', 'S')
639 typedef struct {
640  UINT32 Signature; ///< "RSDS".
646  //
647  // Filename of .PDB goes here
648  //
650 
651 
652 ///
653 /// Debug Data Structure defined by Apple Mach-O to Coff utility.
654 ///
655 #define CODEVIEW_SIGNATURE_MTOC SIGNATURE_32('M', 'T', 'O', 'C')
656 typedef struct {
657  UINT32 Signature; ///< "MTOC".
659  //
660  // Filename of .DLL (Mach-O with debug info) goes here
661  //
663 
664 ///
665 /// Resource format.
666 ///
667 typedef struct {
674  //
675  // Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here.
676  //
678 
679 ///
680 /// Resource directory entry format.
681 ///
682 typedef struct {
683  union {
684  struct {
687  } s;
689  } u1;
690  union {
692  struct {
695  } s;
696  } u2;
698 
699 ///
700 /// Resource directory entry for string.
701 ///
702 typedef struct {
704  CHAR16 String[1];
706 
707 ///
708 /// Resource directory entry for data array.
709 ///
710 typedef struct {
716 
717 ///
718 /// Header format for TE images, defined in the PI Specification, 1.0.
719 ///
720 typedef struct {
721  UINT16 Signature; ///< The signature for TE format = "VZ".
722  UINT16 Machine; ///< From the original file header.
723  UINT8 NumberOfSections; ///< From the original file header.
724  UINT8 Subsystem; ///< From original optional header.
725  UINT16 StrippedSize; ///< Number of bytes we removed from the header.
726  UINT32 AddressOfEntryPoint; ///< Offset to entry point -- from original optional header.
727  UINT32 BaseOfCode; ///< From original image -- required for ITP debug.
728  UINT64 ImageBase; ///< From original file header.
729  EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; ///< Only base relocation and debug directory.
731 
732 
733 #define EFI_TE_IMAGE_HEADER_SIGNATURE SIGNATURE_16('V', 'Z')
734 
735 //
736 // Data directory indexes in our TE image header
737 //
738 #define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
739 #define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
740 
741 
742 ///
743 /// Union of PE32, PE32+, and TE headers.
744 ///
745 typedef union {
750 
751 typedef union {
757 
758 #endif
EFI_IMAGE_IMPORT_BY_NAME * AddressOfData
Definition: PeImage.h:585
UINT16 e_ip
Initial IP value.
Definition: PeImage.h:69
Archive Member Headers.
Definition: PeImage.h:533
UINT16 MinorVersion
Definition: PeImage.h:612
UINT16 SizeOfOptionalHeader
Definition: PeImage.h:89
UINT32 Unknown3
Definition: PeImage.h:629
UINT8 Type
Definition: Acpi10.h:141
EFI_IMAGE_FILE_HEADER FileHeader
Definition: PeImage.h:245
UINT16 MajorOperatingSystemVersion
Definition: PeImage.h:167
UINT8 NumberOfSections
From the original file header.
Definition: PeImage.h:723
UINT32 Characteristics
Definition: PeImage.h:609
EFI_IMAGE_OPTIONAL_HEADER_UNION * Union
Definition: PeImage.h:755
UINT32 Unknown5
Definition: PeImage.h:645
128 bit buffer containing a unique identifier value.
Definition: Base.h:263
UINT16 e_maxalloc
Maximum extra paragraphs needed.
Definition: PeImage.h:65
EFI_IMAGE_NT_HEADERS32 * Pe32
Definition: PeImage.h:752
UINT32 NameIsString
Definition: PeImage.h:686
UINT16 e_cp
Pages in file.
Definition: PeImage.h:61
UINT32 BaseOfCode
From original image – required for ITP debug.
Definition: PeImage.h:727
UINT32 OffsetToData
Definition: PeImage.h:691
Union of PE32, PE32+, and TE headers.
Definition: PeImage.h:745
UINT32 VirtualAddress
Definition: PeImage.h:432
UINT32 TimeDateStamp
Definition: PeImage.h:86
FILE_LICENCE(BSD3)
unsigned int UINT32
Definition: ProcessorBind.h:56
Definition: PeImage.h:625
unsigned short CHAR16
Definition: ProcessorBind.h:59
GUID MachOUuid
Definition: PeImage.h:658
UINT16 e_oemid
OEM identifier (for e_oeminfo).
Definition: PeImage.h:74
Optional Header Standard Fields for PE32+.
Definition: PeImage.h:199
UINT16 Linenumber
Line number.
Definition: PeImage.h:512
Optional Header Standard Fields for PE32.
Definition: PeImage.h:148
UINT16 e_csum
Checksum.
Definition: PeImage.h:68
UINT32 PointerToSymbolTable
Definition: PeImage.h:87
Import Address Table RVA (Thunk Table).
Definition: PeImage.h:581
EFI_IMAGE_NT_HEADERS32 Pe32
Definition: PeImage.h:746
unsigned char UINT8
Definition: ProcessorBind.h:62
COFF File Header (Object and Image).
Definition: PeImage.h:83
Resource directory entry format.
Definition: PeImage.h:682
UINT16_t Size
Size of structure.
Definition: pxe_api.h:58
UINT16 e_lfarlc
File address of relocation table.
Definition: PeImage.h:71
UINT16 Machine
From the original file header.
Definition: PeImage.h:722
Definition: PeImage.h:656
UINT32 Type
Definition: PeImage.h:613
UINT16 MajorOperatingSystemVersion
Definition: PeImage.h:217
Section Table.
Definition: PeImage.h:281
UINT32 SymbolTableIndex
Definition: PeImage.h:433
UINT8 Name
Definition: Acpi10.h:140
UINT32 ImageBase
Optional Header Windows-Specific Fields.
Definition: PeImage.h:164
EFI_TE_IMAGE_HEADER Te
Definition: PeImage.h:748
UINT16 MajorVersion
Definition: PeImage.h:611
Resource directory entry for string.
Definition: PeImage.h:702
EFI_IMAGE_FILE_HEADER FileHeader
Definition: PeImage.h:257
UINT32 BaseOfData
PE32 contains this additional field, which is absent in PE32+.
Definition: PeImage.h:160
UINT16 MinorOperatingSystemVersion
Definition: PeImage.h:168
UINT16 MinorOperatingSystemVersion
Definition: PeImage.h:218
#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES
Definition: PeImage.h:135
UINT32 FileOffset
The file pointer to the debug data.
Definition: PeImage.h:616
Relocation format.
Definition: PeImage.h:431
UINT16 e_minalloc
Minimum extra paragraphs needed.
Definition: PeImage.h:64
UINT32 Size
Definition: PeImage.h:712
UINT16 e_cparhdr
Size of header in paragraphs.
Definition: PeImage.h:63
UINT64 ImageBase
Optional Header Windows-Specific Fields.
Definition: PeImage.h:214
UINT32 Unknown3
Definition: PeImage.h:643
unsigned short UINT16
Definition: ProcessorBind.h:58
Export Directory Table.
Definition: PeImage.h:556
UINT16 Magic
Standard fields.
Definition: PeImage.h:152
Line number format.
Definition: PeImage.h:507
UINT16 NumberOfSections
Definition: PeImage.h:85
UINT32 Unknown2
Definition: PeImage.h:642
UINT32 Id
Definition: PeImage.h:688
UINT16 e_crlc
Relocations.
Definition: PeImage.h:62
EFI_IMAGE_THUNK_DATA * FirstThunk
Definition: PeImage.h:601
UINT32 Signature
"NB10"
Definition: PeImage.h:626
UINT16 Signature
The signature for TE format = "VZ".
Definition: PeImage.h:721
Header Data Directories.
Definition: PeImage.h:115
UINT32 Unknown
Definition: PeImage.h:627
UINT16 Characteristics
Definition: PeImage.h:90
EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: PeImage.h:258
UINT16 e_oeminfo
OEM information; e_oemid specific.
Definition: PeImage.h:75
Definition: PeImage.h:639
UINT16 e_ovno
Overlay number.
Definition: PeImage.h:72
unsigned long long UINT64
Definition: ProcessorBind.h:54
Hint/Name Table.
Definition: PeImage.h:573
Debug Directory Format.
Definition: PeImage.h:608
UINT16 StrippedSize
Number of bytes we removed from the header.
Definition: PeImage.h:725
UINT32 AddressOfEntryPoint
Offset to entry point – from original optional header.
Definition: PeImage.h:726
#define EFI_IMAGE_SIZEOF_SHORT_NAME
Length of ShortName.
Definition: PeImage.h:276
Header format for TE images, defined in the PI Specification, 1.0.
Definition: PeImage.h:720
Resource directory entry for data array.
Definition: PeImage.h:710
UINT32 e_lfanew
File address of new exe header.
Definition: PeImage.h:77
UINT16 e_magic
Magic number.
Definition: PeImage.h:59
UINT32 DataIsDirectory
Definition: PeImage.h:694
EFI_TE_IMAGE_HEADER * Te
Definition: PeImage.h:754
UINT32 CodePage
Definition: PeImage.h:713
UINT32 NumberOfSymbols
Definition: PeImage.h:88
UINT32 Unknown4
Definition: PeImage.h:644
UINT32 NameOffset
Definition: PeImage.h:685
PE images can start with an optional DOS header, so if an image is run under DOS it can print an erro...
Definition: PeImage.h:58
UINT32 TimeDateStamp
Definition: PeImage.h:610
UINT32 OffsetToData
Definition: PeImage.h:711
UINT64 ImageBase
From original file header.
Definition: PeImage.h:728
UINT32 SymbolTableIndex
Symbol table index of function name if Linenumber is 0.
Definition: PeImage.h:509
Resource format.
Definition: PeImage.h:667
UINT32 Unknown
Definition: PeImage.h:641
UINT8 Subsystem
From original optional header.
Definition: PeImage.h:724
UINT32 Signature
"RSDS".
Definition: PeImage.h:640
EFI_IMAGE_NT_HEADERS64 Pe32Plus
Definition: PeImage.h:747
EFI_IMAGE_NT_HEADERS64 * Pe32Plus
Definition: PeImage.h:753
UINT32 RVA
The address of the debug data when loaded, relative to the image base.
Definition: PeImage.h:615
UINT32 SizeOfData
Definition: PeImage.h:614
UINT16 e_ss
Initial (relative) SS value.
Definition: PeImage.h:66
UINT16 Magic
Standard fields.
Definition: PeImage.h:203
Based relocation format.
Definition: PeImage.h:479
UINT16 e_cblp
Bytes on last page of file.
Definition: PeImage.h:60
Import Directory Table.
Definition: PeImage.h:596
UINT32 OffsetToDirectory
Definition: PeImage.h:693
UINT32 VirtualAddress
Virtual address of line number.
Definition: PeImage.h:510
UINT16 e_cs
Initial (relative) CS value.
Definition: PeImage.h:70
UINT32 Reserved
Definition: PeImage.h:714
EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: PeImage.h:246
UINT32 Unknown2
Definition: PeImage.h:628
UINT16 e_sp
Initial SP value.
Definition: PeImage.h:67
UINT32 Signature
"MTOC".
Definition: PeImage.h:657