2 PORTABLE EXECUTABLE FORMAT
4 Author: Micheal J. O'Leary
9 This document was edited and released by Microsoft Developer
10 Support. It describes the binary portable executable format for NT.
11 The information is provided at this point because we feel it will
12 make the work of application development easier. Unfortunately, the
13 information in this document may change before the final release of
14 Windows NT. Microsoft is NOT committing to stay with these formats
15 by releasing this document. Questions or follow-ups for any of the
16 information presented here should be posted to CompuServe MSWIN32
19 Microsoft Developer Support
34 5.1 Export Directory Table
35 5.2 Export Address Table
36 5.3 Export Name Table Pointers
37 5.4 Export Ordinal Table
41 6.1 Import Directory Table
42 6.2 Import Lookup Table
44 6.4 Import Address Table
46 7. Thread Local Storage
47 7.1 Thread Local Storage Directory Table
48 7.2 Thread Local Storage CallBack Table
51 8.1 Resource Directory Table
64 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ <ÄÄ¿ <ÄÄÄÄÄ Base of Image Header
65 ³ DOS 2 Compatible ³ ³
67 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
69 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
73 ³ Offset to ³ ³ (for DOS compatibility only)
75 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
79 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ <ÄÄÙ
81 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ <ÄÄÄÄÄÄÄÄÄ Aligned on 8 byte boundary
94 Figure 1. A typical 32-bit Portable EXE File Layout
101 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
102 ³ SIGNATURE BYTES ³ CPU TYPE ³ # OBJECTS ³
103 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄ´
104 ³ TIME/DATE STAMP ³ RESERVED ³
105 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ´
106 ³ RESERVED ³ NT HDR SIZE³ FLAGS ³
107 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄ´
108 ³ RESERVED ³LMAJOR³LMINOR³ RESERVED ³
109 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
110 ³ RESERVED ³ RESERVED ³
111 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
112 ³ ENTRYPOINT RVA ³ RESERVED ³
113 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
114 ³ RESERVED ³ IMAGE BASE ³
115 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
116 ³ OBJECT ALIGN ³ FILE ALIGN ³
117 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ´
118 ³ OS MAJOR ³ OS MINOR ³USER MAJOR ³USER MINOR ³
119 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄ´
120 ³ SUBSYS MAJOR³ SUBSYS MINOR³ RESERVED ³
121 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
122 ³ IMAGE SIZE ³ HEADER SIZE ³
123 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ´
124 ³ FILE CHECKSUM ³ SUBSYSTEM ³ DLL FLAGS ³
125 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄ´
126 ³ STACK RESERVE SIZE ³ STACK COMMIT SIZE ³
127 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
128 ³ HEAP RESERVE SIZE ³ HEAP COMMIT SIZE ³
129 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
130 ³ RESERVED ³ # INTERESTING RVA/SIZES ³
131 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
132 ³ EXPORT TABLE RVA ³ TOTAL EXPORT DATA SIZE ³
133 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
134 ³ IMPORT TABLE RVA ³ TOTAL IMPORT DATA SIZE ³
135 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
136 ³ RESOURCE TABLE RVA ³ TOTAL RESOURCE DATA SIZE ³
137 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
138 ³ EXCEPTION TABLE RVA ³ TOTAL EXCEPTION DATA SIZE³
139 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
140 ³ SECURITY TABLE RVA ³ TOTAL SECURITY DATA SIZE ³
141 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
142 ³ FIXUP TABLE RVA ³ TOTAL FIXUP DATA SIZE ³
143 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
144 ³ DEBUG TABLE RVA ³ TOTAL DEBUG DIRECTORIES ³
145 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
146 ³ IMAGE DESCRIPTION RVA ³ TOTAL DESCRIPTION SIZE ³
147 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
148 ³ MACHINE SPECIFIC RVA ³ MACHINE SPECIFIC SIZE ³
149 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
150 ³ THREAD LOCAL STORAGE RVA ³ TOTAL TLS SIZE ³
151 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
157 o A VA is a virtual address that is already biased by the Image
158 Base found in the PE Header. A RVA is a virtual address that is
159 relative to the Image Base.
161 o An RVA in the PE Header which has a value of zero indicates the
164 o Image pages are aligned and zero padded to a File Align
165 boundary. The bases of all other tables and structures must be
166 aligned on DWORD (4 byte) boundary. Thus, all VA's and RVA's
167 must be on a 32 bit boundary. All table and structure fields
168 must be aligned on their "natural" boundaries, with the possible
169 exception of the Debug Info.
171 SIGNATURE BYTES = DB * 4.
172 Current value is "PE/0/0". Thats PE followed by two zeros (nulls).
174 CPU TYPE = DW CPU Type.
175 This field specifies the type of CPU compatibility required by this
176 image to run. The values are:
186 o 0162h __MIPS Mark I (R2000, R3000)
188 o 0163h __MIPS Mark II (R6000)
190 o 0166h __MIPS Mark III (R4000)
192 # OBJECTS = DW Number of object entries.
193 This field specifies the number of entries in the Object Table.
195 TIME/DATE STAMP = DD Used to store the time and date the file was
196 created or modified by the linker.
198 NT HDR SIZE = DW This is the number of remaining bytes in the NT
199 header that follow the FLAGS field.
201 FLAGS = DW Flag bits for the image.
202 The flag bits have the following definitons:
204 o 0000h __Program image.
206 o 0002h __Image is executable.
207 If this bit isn't set, then it indicates that either errors
208 where detected at link time or that the image is being
209 incrementally linked and therefore can't be loaded.
212 Indicates that if the image can't be loaded at the Image Base,
215 o 2000h __Library image.
217 LMAJOR/LMINOR = DB Linker major/minor version number.
219 ENTRYPOINT RVA = DD Entrypoint relative virtual address.
220 The address is relative to the Image Base. The address is the
221 starting address for program images and the library initialization
222 and library termination address for library images.
224 IMAGE BASE = DD The virtual base of the image.
225 This will be the virtual address of the first byte of the file (Dos
226 Header). This must be a multiple of 64K.
228 OBJECT ALIGN = DD The alignment of the objects. This must be a power
229 of 2 between 512 and 256M inclusive. The default is 64K.
231 FILE ALIGN = DD Alignment factor used to align image pages. The
232 alignment factor (in bytes) used to align the base of the image pages
233 and to determine the granularity of per-object trailing zero pad.
234 Larger alignment factors will cost more file space; smaller alignment
235 factors will impact demand load performance, perhaps significantly.
236 Of the two, wasting file space is preferable. This value should be a
237 power of 2 between 512 and 64K inclusive.
239 OS MAJOR/MINOR = DW OS version number required to run this image.
241 USER MAJOR/MINOR # = DW User major/minor version number.
242 This is useful for differentiating between revisions of
243 images/dynamic linked libraries. The values are specified at link
246 SUBSYS MAJOR/MINOR # = DW Subsystem major/minor version number.
248 IMAGE SIZE = DD The virtual size (in bytes) of the image.
249 This includes all headers. The total image size must be a multiple
252 HEADER SIZE = DD Total header size.
253 The combined size of the Dos Header, PE Header and Object Table.
255 FILE CHECKSUM = DD Checksum for entire file. Set to 0 by the linker.
257 SUBSYSTEM = DW NT Subsystem required to run this image.
264 o 0002h __Windows GUI
266 o 0003h __Windows Character
268 o 0005h __OS/2 Character
270 o 0007h __Posix Character
272 DLL FLAGS = DW Indicates special loader requirements.
273 This flag has the following bit values:
275 o 0001h __Per-Process Library Initialization.
277 o 0002h __Per-Process Library Termination.
279 o 0004h __Per-Thread Library Initialization.
281 o 0008h __Per-Thread Library Termination.
283 All other bits are reserved for future use and should be set to zero.
285 STACK RESERVE SIZE = DD Stack size needed for image.
286 The memory is reserved, but only the STACK COMMIT SIZE is committed.
287 The next page of the stack is a 'guarded page'. When the application
288 hits the guarded page, the guarded page becomes valid, and the next
289 page becomes the guarded page. This continues until the RESERVE SIZE
292 STACK COMMIT SIZE = DD Stack commit size.
294 HEAP RESERVE SIZE = DD Size of local heap to reserve.
296 HEAP COMMIT SIZE = DD Amount to commit in local heap.
298 # INTERESTING VA/SIZES = DD Indicates the size of the VA/SIZE array
301 EXPORT TABLE RVA = DD Relative Virtual Address of the Export Table.
302 This address is relative to the Image Base.
304 IMPORT TABLE RVA = DD Relative Virtual Address of the Import Table.
305 This address is relative to the Image Base.
307 RESOURCE TABLE RVA = DD Relative Virtual Address of the Resource
308 Table. This address is relative to the Image Base.
310 EXCEPTION TABLE RVA = DD Relative Virtual Address of the Exception
311 Table. This address is relative to the Image Base.
313 SECURITY TABLE RVA = DD Relative Virtual Address of the Security
314 Table. This address is relative to the Image Base.
316 FIXUP TABLE RVA = DD Relative Virtual Address of the Fixup Table.
317 This address is relative to the Image Base.
319 DEBUG TABLE RVA = DD Relative Virtual Address of the Debug Table.
320 This address is relative to the Image Base.
322 IMAGE DESCRIPTION RVA = DD Relative Virtual Address of the
323 description string specified in the module definiton file.
325 MACHINE SPECIFIC RVA = DD Relative Virtual Address of a machine
326 specific value. This address is relative to the Image Base.
328 TOTAL EXPORT DATA SIZE = DD Total size of the export data.
330 TOTAL IMPORT DATA SIZE = DD Total size of the import data.
332 TOTAL RESOURCE DATA SIZE = DD Total size of the resource data.
334 TOTAL EXCEPTION DATA SIZE = DD Total size of the exception data.
336 TOTAL SECURITY DATA SIZE = DD Total size of the security data.
338 TOTAL FIXUP DATA SIZE = DD Total size of the fixup data.
340 TOTAL DEBUG DIRECTORIES = DD Total number of debug directories.
342 TOTAL DESCRIPTION SIZE = DD Total size of the description data.
344 MACHINE SPECIFIC SIZE = DD A machine specific value.
350 The number of entries in the Object Table is given by the # Objects
351 field in the PE Header. Entries in the Object Table are numbered
352 starting from one. The object table immediately follows the PE
353 Header. The code and data memory object entries are in the order
354 chosen by the linker. The virtual addresses for objects must be
355 assigned by the linker such that they are in ascending order and
356 adjacent, and must be a multiple of Object Align in the PE header.
358 Each Object Table entry has the following format:
360 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
362 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
363 ³ VIRTUAL SIZE ³ RVA ³
364 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
365 ³ PHYSICAL SIZE ³ PHYSICAL OFFSET ³
366 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
367 ³ RESERVED ³ RESERVED ³
368 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
369 ³ RESERVED ³ OBJECT FLAGS ³
370 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
372 Figure 3. Object Table
374 OBJECT NAME = DB * 8 Object name. This is an eight-byte null-padded
375 ASCII string representing the object name.
377 VIRTUAL SIZE = DD Virtual memory size. The size of the object that
378 will be allocated when the object is loaded. Any difference between
379 PHYSICAL SIZE and VIRTUAL SIZE is zero filled.
381 RVA = DD Relative Virtual Address. The virtual address the object is
382 currently relocated to, relative to the Image Base. Each Object's
383 virtual address space consumes a multiple of Object Align (power of 2
384 between 512 and 256M inclusive. Default is 64K), and immediately
385 follows the previous Object in the virtual address space (the virtual
386 address space for a image must be dense).
388 PHYSICAL SIZE = DD Physical file size of initialized data. The size
389 of the initialized data in the file for the object. The physical
390 size must be a multiple of the File Align field in the PE Header, and
391 must be less than or equal to the Virtual Size.
393 PHYSICAL OFFSET = DD Physical offset for object's first page. This
394 offset is relative to beginning of the EXE file, and is aligned on a
395 multiple of the File Align field in the PE Header. The offset is
396 used as a seek value.
398 OBJECT FLAGS = DD Flag bits for the object. The object flag bits
399 have the following definitions:
401 o 000000020h __Code object.
403 o 000000040h __Initialized data object.
405 o 000000080h __Uninitialized data object.
407 o 040000000h __Object must not be cached.
409 o 080000000h __Object is not pageable.
411 o 100000000h __Object is shared.
413 o 200000000h __Executable object.
415 o 400000000h __Readable object.
417 o 800000000h __Writeable object.
419 All other bits are reserved for future use and should be set to zero.
423 The Image Pages section contains all initialized data for all
424 objects. The seek offset for the first page in each object is
425 specified in the object table and is aligned on a File Align
426 boundary. The objects are ordered by the RVA. Every object begins
427 on a multiple of Object Align.
433 A typical file layout for the export information follows:
435 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
437 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
445 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
450 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
455 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
459 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
461 Figure 4. Export File Layout
463 5.1 Export Directory Table
465 The export information begins with the Export Directory Table which
466 describes the remainder of the export information. The Export
467 Directory Table contains address information that is used to resolve
468 fixup references to the entry points within this image.
470 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
472 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
474 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
475 ³ MAJOR VERSION ³ MINOR VERSION ³
476 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
478 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
480 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
482 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
484 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
485 ³ ADDRESS TABLE RVA ³
486 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
487 ³ NAME PTR TABLE RVA ³
488 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
489 ³ ORDINAL TABLE RVA ³
490 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
492 Figure 5. Export Directory Table Entry
494 EXPORT FLAGS = DD Currently set to zero.
496 TIME/DATE STAMP = DD Time/Date the export data was created.
498 MAJOR/MINOR VERSION = DW A user settable major/minor version number.
500 NAME RVA = DD Relative Virtual Address of the Dll asciiz Name.
501 This is the address relative to the Image Base.
503 ORDINAL BASE = DD First valid exported ordinal.
504 This field specifies the starting ordinal number for the export
505 address table for this image. Normally set to 1.
507 # EAT ENTRIES = DD Indicates number of entries in the Export Address
510 # NAME PTRS = DD This indicates the number of entries in the Name Ptr
511 Table (and parallel Ordinal Table).
513 ADDRESS TABLE RVA = DD Relative Virtual Address of the Export Address
515 This address is relative to the Image Base.
517 NAME TABLE RVA = DD Relative Virtual Address of the Export Name Table
519 This address is relative to the beginning of the Image Base. This
520 table is an array of RVA's with # NAMES entries.
522 ORDINAL TABLE RVA = DD Relative Virtual Address of Export Ordinals
524 This address is relative to the beginning of the Image Base.
526 5.2 Export Address Table
528 The Export Address Table contains the address of exported entrypoints
529 and exported data and absolutes. An ordinal number is used to index
530 the Export Address Table. The ORDINAL BASE must be subracted from the
531 ordinal number before indexing into this table.
533 Export Address Table entry formats are described below:
535 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
537 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
539 Figure 6. Export Address Table Entry
541 EXPORTED RVA = DD Export address.
542 This field contains the relative virtual address of the exported
543 entry (relative to the Image Base).
545 5.3 Export Name Table Pointers
547 The export name table pointers array contains address into the Export
548 Name Table. The pointers are 32-bits each, and are relative to the
549 Image Base. The pointers are ordered lexically to allow binary
552 5.4 Export Ordinal Table
554 The Export Name Table Pointers and the Export Ordinal Table form two
555 parallel arrays, separated to allow natural field alignment. The
556 export ordinal table array contains the Export Address Table ordinal
557 numbers associated with the named export referenced by corresponding
558 Export Name Table Pointers.
560 The ordinals are 16-bits each, and already include the Ordinal Base
561 stored in the Export Directory Table.
563 5.5 Export Name Table
565 The export name table contains optional ASCII names for exported
566 entries in the image. These tables are used with the array of Export
567 Name Table Pointers and the array of Export Ordinals to translate a
568 procedure name string into an ordinal number by searching for a
569 matching name string. The ordinal number is used to locate the entry
570 point information in the export address table.
572 Import references by name require the Export Name Table Pointers
573 table to be binary searched to find the matching name, then the
574 corresponding Export Ordinal Table is known to contain the entry
575 point ordinal number. Import references by ordinal number provide
576 the fastest lookup since searching the name table is not required.
578 Each name table entry has the following format:
580 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
581 ³ ASCII STRING ::: :::::::: '\0' ³
582 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
584 Figure 7. Export Name Table Entry
586 ASCII STRING = DB ASCII String.
587 The string is case sensitive and is terminated by a null byte.
593 A typical file layout for the import information follows:
595 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
600 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
602 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
604 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
605 ³ DLL1 LOOKUP TABLE ³
607 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
609 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
611 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
612 ³ DLL2 LOOKUP TABLE ³
614 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
616 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
618 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
619 ³ Dll3 LOOKUP TABLE ³
621 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
623 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
625 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
628 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
630 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
631 ³ DLL1 ADDRESS TABLE ³
633 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
635 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
637 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
638 ³ DLL2 ADDRESS TABLE ³
640 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
642 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
644 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
645 ³ DLL3 ADDRESS TABLE ³
647 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
649 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
651 Figure 8. Import File Layout
653 6.1 Import Directory Table
655 The import information begins with the Import Directory Table which
656 describes the remainder of the import information. The Import
657 Directory Table contains address information that is used to resolve
658 fixup references to the entry points within a DLL image. The import
659 directory table consists of an array of Import Directory Entries, one
660 entry for each DLL this image references. The last directory entry is
661 empty (NULL) which indicates the end of the directory table.
663 An Import Directory Entry has the following format:
665 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
667 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
669 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
670 ³ MAJOR VERSION ³ MINOR VERSION ³
671 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
673 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
674 ³ IMPORT LOOKUP TABLE RVA ³
675 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
676 ³ IMPORT ADDRESS TABLE RVA ³
677 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
679 Figure 9. Import Directory Entry
681 IMPORT FLAGS = DD Currently set to zero.
683 TIME/DATE STAMP = DD Time/Date the import data was pre-snapped or
684 zero if not pre-snapped.
686 MAJOR/MINOR VERSION = DW The major/minor version number of the dll
689 NAME RVA = DD Relative Virtual Address of the Dll asciiz Name.
690 This is the address relative to the Image Base.
692 IMPORT LOOKUP TABLE RVA = DD This field contains the address of the
693 start of the import lookup table for this image. The address is
694 relative to the beginning of the Image Base.
696 IMPORT ADDRESS TABLE RVA = DD This field contains the address of the
697 start of the import addresses for this image. The address is
698 relative to the beginning of the Image Base.
700 6.2 Import Lookup Table
702 The Import Lookup Table is an array of ordinal or hint/name RVA's for
703 each DLL. The last entry is empty (NULL) which indicates the end of
706 The last element is empty.
710 ÚÄÒÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
711 ³0º ORDINAL#/HINT-NAME TABLE RVA ³
712 ÀÄÐÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
714 Figure 10. Import Address Table Format
716 ORDINAL/HINT-NAME TABLE RVA = 31-bits (mask = 7fffffffh) Ordinal
717 Number or Name Table RVA.
718 If the import is by ordinal, this field contains a 31 bit ordinal
719 number. If the import is by name, this field contains a 31 bit
720 address relative to the Image Base to the Hint-Name Table.
722 O = 1-bit (mask = 80000000h) Import by ordinal flag.
724 o 00000000h __Import by name.
726 o 80000000h __Import by ordinal.
730 The Hint-Name Table format follows:
732 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
733 ³ HINT ³ ASCII STRING |||³
734 ÃÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄ´
735 ³|||||||||||||||||³ '\0' PAD ³
736 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
739 The PAD field is optional.
741 Figure 11. Import Hint-Name Table
743 HINT = DW Hint into Export Name Table Pointers.
744 The hint value is used to index the Export Name Table Pointers array,
745 allowing faster by-name imports. If the hint is incorrect, then a
746 binary search is performed on the Export Name Ptr Table.
748 ASCII STRING = DB ASCII String.
749 The string is case sensitive and is terminated by a null byte.
751 PAD = DB Zero pad byte.
752 A trailing zero pad byte appears after the trailing null byte if
753 necessary to align the next entry on an even boundary.
755 The loader overwrites the import address table when loading the image
756 with the 32-bit address of the import.
760 6.4 Import Address Table
762 The Import Address Table is an array of addresses of the imported
763 routines for each DLL. The last entry is empty (NULL) which indicates
764 the end of the table.
766 7. Thread Local Storage
768 Thread local storage is a special contiguous block of data. Each
769 thread will gets its own block upon creation of the thread.
771 The file layout for thread local storage follows:
772 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
774 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
775 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
777 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
778 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
780 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
781 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
782 ³ CALLBACK ADDRESSES ³
783 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
785 Figure 12. Thread Local Storage Layout
787 7.1 Thread Local Storage Directory Table
789 The Thread Local Storage Directory Table contains address information
790 that is used to describe the rest of TLS.
792 The Thread Local Storage Directory Table has the following format:
794 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
795 ³ START DATA BLOCK VA ³
796 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
797 ³ END DATA BLOCK VA ³
798 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
800 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
801 ³ CALLBACK TABLE VA ³
802 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
804 Figure 13. Thread Local Storage Directory Table
806 START DATA BLOCK VA = DD Virtual Address of the start of the thread
807 local storage data block.
809 END DATA BLOCK VA = DD Virtual Address of the end of the thread local
812 INDEX VA = DD Virtual Address of the index variable used to access
813 the thread local storage data block.
815 CALLBACK TABLE VA = DD Virtual Address of the callback table.
817 7.2 Thread Local Storage CallBack Table
819 The Thread Local Storage Callbacks is an array of Virtual Address of
820 functions to be called by the loader after thread creation and thread
821 termination. The last entry is empty (NULL) which indicates the end
824 The Thread Local Storage CallBack Table has the following format:
826 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
828 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
830 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
832 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
834 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
836 Figure 14. Thread Local Storage CallBack Table
840 Resources are indexed by a multiple level binary-sorted tree
841 structure. The overall design can incorporate 2**31 levels, however,
842 NT uses only three: the highest is TYPE, then NAME, then LANGUAGE.
844 A typical file layout for the resource information follows:
845 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
846 ³ RESOURCE DIRECTORY ³
850 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
858 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
860 Figure 15. Resource File Layout
863 The Resource directory is made up of the following tables:
867 8.1 Resource Directory Table
868 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
870 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
872 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
873 ³ MAJOR VERSION ³ MINOR VERSION ³
874 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
875 ³ # NAME ENTRY ³ # ID ENTRY ³
876 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
877 ³ RESOURCE DIR ENTRIES ³
878 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
880 Figure 16. Resource Table Entry
883 RESOURCE FLAGS = DD Currently set to zero.
885 TIME/DATE STAMP = DD Time/Date the resource data was created by the
888 MAJOR/MINOR VERSION = DW A user settable major/minor version number.
890 # NAME ENTRY = DW The number of name entries.
891 This field contains the number of entries at the beginning of the
892 array of directory entries which have actual string names associated
895 # ID ENTRY = DW The number of ID integer entries.
896 This field contains the number of 32-bit integer IDs as their names
897 in the array of directory entries.
899 The resource directory is followed by a variable length array of
900 directory entries. # NAME ENTRY is the number of entries at the
901 beginning of the array that have actual names associated with each
902 entry. The entires are in ascending order, case insensitive strings.
903 # ID ENTRY identifies the number of entries that have 32-bit integer
904 IDs as their name. These entries are also sorted in ascending order.
906 This structure allows fast lookup by either name or number, but for
907 any given resource entry only one form of lookup is supported, not
908 both. This is consistent with the syntax of the .RC file and the .RES
913 The array of directory entries have the following format:
916 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
917 ³ NAME RVA/INTEGER ID ³
918 ÃÄÒÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
919 ³Eº DATA ENTRY RVA/SUBDIR RVA ³
920 ÀÄÐÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
922 Figure 17. Resource Directory Entry
926 This field contains a integer ID field to identify a resource.
928 NAME RVA = DD Name RVA address.
929 This field contains a 31-bit address relative to the beginning of the
930 Image Base to a Resource Directory String Entry.
932 E = 1-bit (mask 80000000h) Unescape bit.
933 This bit is zero for unescaped Resource Data Entries.
935 DATA RVA = 31-bits (mask 7fffffffh) Data entry address.
936 This field contains a 31-bit address relative to the beginning of the
937 Image Base to a Resource Data Entry.
939 E = 1-bit (mask 80000000h) Escape bit.
940 This bit is 1 for escaped Subdirectory Entry.
942 DATA RVA = 31-bits (mask 7fffffffh) Directory entries.
943 This field contains a 31-bit address relative to the beginning of the
944 Image Base to Subdirectory Entry.
948 Each resource directory string entry has the following format:
949 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
950 ³ LENGTH ³ UNICODE STRING ³
951 ÃÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄ´
953 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
955 Figure 18. Resource Directory String Entry
958 LENGTH = DW Length of string.
960 UNICODE STRING = DW UNICODE String.
962 All of these string objects are stored together after the last
963 resource directory entry and before the first resource data object.
964 This minimizes the impact of these variable length objects on the
965 alignment of the fixed size directory entry objects. The length needs
970 Each Resource Data Entry has the following format:
972 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
974 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
976 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
978 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
980 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
982 Figure 19. Resource Data Entry
986 DATA RVA = DD Address of Resource Data.
987 This field contains 32-bit virtaul address of the resource data
988 (relative to the Image Base).
990 SIZE = DD Size of Resource Data.
991 This field contains the size of the resource data for this resource.
993 CODEPAGE = DD Codepage.
995 RESERVED = DD Reserved - must be zero.
997 Each resource data entry describes a leaf node in the resource
998 directory tree. It contains an address which is relative to the
999 beginning of Image Base, a size field that gives the number of bytes
1000 of data at that address, a CodePage that should be used when decoding
1001 code point values within the resource data. Typically for new
1002 applications the code page would be the unicode code page.
1006 8.2 Resource Example
1008 The following is an example for an app. which wants to use the following data
1011 TypeId# NameId# Language ID Resource Data
1012 00000001 00000001 0 00010001
1013 00000001 00000001 1 10010001
1014 00000001 00000002 0 00010002
1015 00000001 00000003 0 00010003
1016 00000002 00000001 0 00020001
1017 00000002 00000002 0 00020002
1018 00000002 00000003 0 00020003
1019 00000002 00000004 0 00020004
1020 00000009 00000001 0 00090001
1021 00000009 00000009 0 00090009
1022 00000009 00000009 1 10090009
1023 00000009 00000009 2 20090009
1025 Then the Resource Directory in the Portable format looks like:
1027 0000: 00000000 00000000 00000000 00030000 (3 entries in this directory)
1028 0010: 00000001 80000028 (TypeId #1, Subdirectory at offset 0x28)
1029 0018: 00000002 80000050 (TypeId #2, Subdirectory at offset 0x50)
1030 0020: 00000009 80000080 (TypeId #9, Subdirectory at offset 0x80)
1031 0028: 00000000 00000000 00000000 00030000 (3 entries in this directory)
1032 0038: 00000001 800000A0 (NameId #1, Subdirectory at offset 0xA0)
1033 0040: 00000002 00000108 (NameId #2, data desc at offset 0x108)
1034 0048: 00000003 00000118 (NameId #3, data desc at offset 0x118)
1035 0050: 00000000 00000000 00000000 00040000 (4 entries in this directory)
1036 0060: 00000001 00000128 (NameId #1, data desc at offset 0x128)
1037 0068: 00000002 00000138 (NameId #2, data desc at offset 0x138)
1038 0070: 00000003 00000148 (NameId #3, data desc at offset 0x148)
1039 0078: 00000004 00000158 (NameId #4, data desc at offset 0x158)
1040 0080: 00000000 00000000 00000000 00020000 (2 entries in this directory)
1041 0090: 00000001 00000168 (NameId #1, data desc at offset 0x168)
1042 0098: 00000009 800000C0 (NameId #9, Subdirectory at offset 0xC0)
1043 00A0: 00000000 00000000 00000000 00020000 (2 entries in this directory)
1044 00B0: 00000000 000000E8 (Language ID 0, data desc at offset 0xE8
1045 00B8: 00000001 000000F8 (Language ID 1, data desc at offset 0xF8
1046 00C0: 00000000 00000000 00000000 00030000 (3 entries in this directory)
1047 00D0: 00000001 00000178 (Language ID 0, data desc at offset 0x178
1048 00D8: 00000001 00000188 (Language ID 1, data desc at offset 0x188
1049 00E0: 00000001 00000198 (Language ID 2, data desc at offset 0x198
1051 00E8: 000001A8 (At offset 0x1A8, for TypeId #1, NameId #1, Language id #0
1052 00000004 (4 bytes of data)
1055 00F8: 000001AC (At offset 0x1AC, for TypeId #1, NameId #1, Language id #1
1056 00000004 (4 bytes of data)
1059 0108: 000001B0 (At offset 0x1B0, for TypeId #1, NameId #2,
1060 00000004 (4 bytes of data)
1063 0118: 000001B4 (At offset 0x1B4, for TypeId #1, NameId #3,
1064 00000004 (4 bytes of data)
1067 0128: 000001B8 (At offset 0x1B8, for TypeId #2, NameId #1,
1068 00000004 (4 bytes of data)
1071 0138: 000001BC (At offset 0x1BC, for TypeId #2, NameId #2,
1072 00000004 (4 bytes of data)
1075 0148: 000001C0 (At offset 0x1C0, for TypeId #2, NameId #3,
1076 00000004 (4 bytes of data)
1079 0158: 000001C4 (At offset 0x1C4, for TypeId #2, NameId #4,
1080 00000004 (4 bytes of data)
1083 0168: 000001C8 (At offset 0x1C8, for TypeId #9, NameId #1,
1084 00000004 (4 bytes of data)
1087 0178: 000001CC (At offset 0x1CC, for TypeId #9, NameId #9, Language id #0
1088 00000004 (4 bytes of data)
1091 0188: 000001D0 (At offset 0x1D0, for TypeId #9, NameId #9, Language id #1
1092 00000004 (4 bytes of data)
1095 0198: 000001D4 (At offset 0x1D4, for TypeId #9, NameId #9, Language id #2
1096 00000004 (4 bytes of data)
1100 And the data for the resources will look like:
1117 The Fixup Table contains entries for all fixups in the image. The
1118 Total Fixup Data Size in the PE Header is the number of bytes in the
1119 fixup table. The fixup table is broken into blocks of fixups. Each
1120 block represents the fixups for a 4K page.
1122 Fixups that are resolved by the linker do not need to be processed by
1123 the loader, unless the load image can't be loaded at the Image Base
1124 specified in the PE Header.
1128 Fixup blocks have the following format:
1130 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
1132 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1134 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1135 ³ TYPE/OFFSET ³ TYPE/OFFSET ³
1136 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1137 ³ TYPE/OFFSET ³ ... ³
1138 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
1140 Figure 20. Fixup Block Format
1142 To apply a fixup, a delta needs to be calculated. The 32-bit delta
1143 is the difference between the preferred base, and the base where the
1144 image is actually loaded. If the image is loaded at its preferred
1145 base, the delta would be zero, and thus the fixups would not have to
1146 be applied. Each block must start on a DWORD boundary. The ABSOLUTE
1147 fixup type can be used to pad a block.
1149 PAGE RVA = DD Page RVA. The image base plus the page rva is added to
1150 each offset to create the virtual address of where the fixup needs to
1153 BLOCK SIZE = DD Number of bytes in the fixup block. This includes the
1154 PAGE RVA and SIZE fields.
1156 TYPE/OFFSET is defined as:
1163 Figure 21. Fixup Record Format
1165 TYPE = 4-bit fixup type. This value has the following definitions:
1167 o 0h __ABSOLUTE. This is a NOP. The fixup is skipped.
1169 o 1h __HIGH. Add the high 16-bits of the delta to the 16-bit field
1170 at Offset. The 16-bit field represents the high value of a 32-
1173 o 2h __LOW. Add the low 16-bits of the delta to the 16-bit field
1174 at Offset. The 16-bit field represents the low half value of a
1175 32-bit word. This fixup will only be emitted for a RISC machine
1176 when the image Object Align isn't the default of 64K.
1178 o 3h __HIGHLOW. Apply the 32-bit delta to the 32-bit field at
1181 o 4h __HIGHADJUST. This fixup requires a full 32-bit value. The
1182 high 16-bits is located at Offset, and the low 16-bits is
1183 located in the next Offset array element (this array element is
1184 included in the SIZE field). The two need to be combined into a
1185 signed variable. Add the 32-bit delta. Then add 0x8000 and
1186 store the high 16-bits of the signed variable to the 16-bit
1191 All other values are reserved.
1195 10. Debug Information
1197 The debug information is defined by the debugger and is not
1198 controlled by the portable EXE format or linker. The only data
1199 defined by the portable EXE format is the Debug Directory Table.
1201 10.1 Debug Directory
1203 The debug directory table consists of one or more entries that have
1204 the following format:
1206 ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿
1208 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1210 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1211 ³ MAJOR VERSION ³ MINOR VERSION ³
1212 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1214 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1216 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1218 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
1220 ÀÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ
1222 Figure 22. Debug Directory Entry
1224 DEBUG FLAGS = DD Set to zero for now.
1226 TIME/DATE STAMP = DD Time/Date the debug data was created.
1228 MAJOR/MINOR VERSION = DW Version stamp.
1229 This stamp can be used to determine the version of the debug data.
1231 DEBUG TYPE = DD Format type.
1232 To support multiple debuggers, this field determines the format of
1233 the debug information. This value has the following definitions:
1235 o 0001h __Image contains COFF symbolics.
1237 o 0001h __Image contains CodeView symbolics.
1239 o 0001h __Image contains FPO symbolics.
1241 DATA SIZE = DD The number of bytes in the debug data. This is the
1242 size of the actual debug data and does not include the debug
1245 DATA RVA = DD The relative virtual address of the debug data. This
1246 address is relative to the beginning of the Image Base.
1248 DATA SEEK = DD The seek value from the beginning of the file to the
1251 If the image contains more than one type of debug information, then
1252 the next debug directory will immediately follow the first debug