DOS Header

FieldsValuesExplanation
e_magic‘MZ’constant signature
e_lfanew0x40offset of the PE Header

PE Header

FieldsValuesExplanation
Signature‘PE’, 0, 0constant signature
Machine0x14c [intel 386]processor: ARM/MIPS/Intel/…
NumberOfSections3number of sections
SizeOfOptionalHeader0xe0relative offset of the section table
Characteristics0x102 [32b EXE]EXE/DLL/…

Optional Header

FieldsValuesExplanation
Magic0x10b [32b]32 bits/64 bits
AddressOfEntryPoint0x1000where execution starts
ImageBase0x400000address where the file should be mapped in memory
SectionAlignment0x1000where sections should start in memory
FileAlignment0x200where sections should start on file
MajorSubsystemVersion4 [NT 4 or later]required version of Windows
SizeOfImage0x4000total memory space required
SizeOfHeaders0x200total size of the headers
Subsystem2 [GUI]driver/graphical/command line/…
NumberOfRvaAndSizes16number of data directories

Data directory

FieldDescription
ImportsVARVA of the imports
AddressPoints to the beginning of the header in memory (relative to the start of the file).
SizeSize of the header.
NameName of the section
VirtualAddressPointer to the beginning of the section in memory (RVA addresses)
VirtualSizeSize of a section (in memory)
SizeOfRawDataSize of a section (on the hard disk)
PointerToRawDataPointer to the beginning of the section in the file on the hard disk
CharacteristicsMemory protection flags (EXECUTE, READ, and WRITE)

Section table

FieldDescription
NameName of the section
VirtualAddressPointer to the beginning of the section in memory (RVA addresses)
VirtualSizeSize of a section (in memory)
SizeOfRawDataSize of a section (on the hard disk)
PointerToRawDataPointer to the beginning of the section in the file on the hard disk
CharacteristicsMemory protection flags (EXECUTE, READ, and WRITE)

PE+ (x64 PE)

FieldDescription
ImageBase4 bytes → 8 bytes
BaseOfDataRemoved from the optional header
OthersSizeofheapcommit, sizeofheapreserve, sizeofstackreserve, and sizeofstackcommit are 4 bytes → 8 bytes
MagicValue changed from 0x10b (representing x86) to 0x20b (representing x64).

PE File & Memory