WEB开发网
开发学院网络安全黑客技术 PE结构各字段偏移参考 阅读

PE结构各字段偏移参考

 2007-01-14 20:14:57 来源:WEB开发网   
核心提示:While there is a lot of data and various parts of the structure are at varying positions there are still a lot of useful fixed and relative offsets that will he

While there is a lot of data and various parts of the structure are at varying positions there are still a lot of useful fixed and relative offsets that will help when disassembling/examining PE files. Resource information and the such like are omitted - there are good tools available to manipulate these e.g. ResHacker.

The DOS Header

OFFSETSIZENAMEEXPLANATION
00WORDe_magicMagic DOS signature MZ (4Dh 5Ah)
02WORDe_cblpBytes on last page of file
04WORDe_cpPages in file
06WORDe_crlcRelocations
08WORDe_cparhdrSize of header in paragraphs
0AWORDe_minallocMinimum extra paragraphs needed
0CWORDe_maxallocMaximum extra paragraphs needed
0EWORDe_ssInitial (relative) SS value
10WORDe_spInitial SP value
12WORDe_csumChecksum
14WORDe_ipInitial IP value
16WORDe_csInitial (relative) CS value
18WORDe_lfarlcFile address of relocation table
1AWORDe_ovnoOverlay number
1CWORDe_res[4]Reserved words
24WORDe_oemidOEM identifier (for e_oeminfo)
26WORDe_oeminfoOEM information; e_oemid specific
28WORDe_res2[10]Reserved words
3CDWORDe_lfanewOffset to start of PE header
 

The PE Header

Offsets shown are from the beginning of this section.

00DWORDSignaturePE Signature PE.. (50h 45h 00h 00h)
04WORDMachine014Ch = Intel 386, 014Dh = Intel 486, 014Eh = Intel 586, 0200h = Intel 64-bit, 0162h=MIPS
06WORDNumberOfSectionsNumber Of Sections
08DWORDTimeDateStampDate & time image was created by the linker
0CDWORDPointerToSymbolTableZero or offset of COFF symbol table in older files
10DWORDNumberOfSymbolsNumber of symbols in COFF symbol table
14WORDSizeOfOptionalHeaderSize of optional header in bytes (224 in 32bit exe)
16WORDCharacteristicssee below
18**********START OF OPTIONAL HEADER**************************************
18WORDMagic010Bh=32-bit executable image

020Bh=64-bit executable image

0107h=ROM image

1ABYTEMajorLinkerVersionMajor version number of the linker
1BBYTEMinorLinkerVersionMinor version number of the linker
1CDWORDSizeOfCodesize of code section or sum if multiple code sections
20DWORDSizeOfInitializedDataas above
24DWORDSizeOfUninitializedDataas above
28DWORDAddressOfEntryPointStart of code execution, optional for DLLs, zero when none present
2CDWORDBaseOfCodeRVA of first byte of code when loaded into RAM
30DWORDBaseOfDataRVA of first byte of data when loaded into RAM
34DWORDImageBasePreferred load address
38DWORDSectionAlignment Alignment of sections when loaded in RAM
3CDWORDFileAlignment Alignment of sections in file on disk
40WORDMajorOperatingSystemVersionMajor version no. of required operating system
42WORDMinorOperatingSystemVersionMinor version no. of required operating system
44WORDMajorImageVersionMajor version number of the image
46WORDMinorImageVersionMinor version number of the image
48WORDMajorSubsystemVersionMajor version number of the subsystem
4AWORDMinorSubsystemVersionMinor version number of the subsystem
4CDWORDReserved1
50DWORDSizeOfImageAmount of memory allocated by loader for image. Must be a multiple of SectionAlignment
54DWORDSizeOfHeaders Offset of first section, multiple of FileAlignment
58DWORDCheckSumImage checksum (only required for kernel-mode drivers and some system DLLs).
5CWORDSubsystem0002h=Windows GUI, 0003h=console
5EWORDDllCharacteristics0001h=per-process library initialization

0002h=per-process library termination

0003h=per-thread library initialization

0004h=per-thread library termination

60DWORDSizeOfStackReserveNumber of bytes reserved for the stack
64DWORDSizeOfStackCommitNumber of bytes actually used for the stack
68DWORDSizeOfHeapReserveNumber of bytes to reserve for the local heap
6CDWORDSizeOfHeapCommitNumber of bytes actually used for local heap
70DWORDLoaderFlagsThis member is obsolete.
74DWORDNumberOfRvaAndSizesNumber of directory entries.
78**********START OF DATADIRECTORY**************************************
78DWORDIMAGE_DATA_DIRECTORY0 RVA of Export Directory
7CDWORDsize of Export Directory
80DWORDIMAGE_DATA_DIRECTORY1RVA of Import Directory (array of IIDs)
84DWORDsize of Import Directory (array of IIDs)
88DWORDIMAGE_DATA_DIRECTORY2RVA of Resource Directory
8CDWORDsize of Resource Directory
90DWORDIMAGE_DATA_DIRECTORY3RVA of Exception Directory
94DWORDsize of Exception Directory
98DWORDIMAGE_DATA_DIRECTORY4Raw Offset of Security Directory
9CDWORDsize of Security Directory
A0DWORDIMAGE_DATA_DIRECTORY5RVA of Base Relocation Directory
A4DWORDsize of Base Relocation Directory
A8DWORDIMAGE_DATA_DIRECTORY6RVA of Debug Directory
ACDWORDsize of Debug Directory
B0DWORDIMAGE_DATA_DIRECTORY7RVA of Copyright Note
B4DWORDsize of Copyright Note
B8DWORDIMAGE_DATA_DIRECTORY8RVA to be used as Global Pointer (IA-64 only)
BCDWORDNot used
C0DWORDIMAGE_DATA_DIRECTORY9RVA of Thread Local Storage Directory
C4DWORDsize of Thread Local Storage Directory
C8DWORDIMAGE_DATA_DIRECTORY10RVA of Load Configuration Directory
CCDWORDsize of Load Configuration Directory
D0DWORDIMAGE_DATA_DIRECTORY11RVA of Bound Import Directory
D4DWORDsize of Bound Import Directory
D8DWORDIMAGE_DATA_DIRECTORY12RVA of first Import Address Table
DCDWORDtotal size of all Import Address Tables
E0DWORDIMAGE_DATA_DIRECTORY13RVA of Delay Import Directory
E4DWORDsize of Delay Import Directory
E8DWORDIMAGE_DATA_DIRECTORY14RVA of COM Header (top level info & metadata...
ECDWORDsize of COM Header     ...in .NET executables)
F0DWORDZERO (Reserved)Reserved
F4DWORDZERO (Reserved)Reserved
F8**********START OF SECTION TABLE*******Offsets shown from here********
008 BytesName1Name of first section header
08DWORDmisc (VirtualSize)Actual size of data in section
0CDWORDvirtual address RVA where section begins in memory
10DWORDSizeOfRawData Size of data on disk (multiple of FileAlignment)
14DWORDpointerToRawData Raw offset of section on disk
18DWORDpointerToRelocationsStart of relocation entries for section, zero if none
1CDWORDPointerToLinenumbersStart of line-no. entries for section, zero if none
20WORDNumberOfRelocationsThis value is zero for executable images.
22WORDNumberOfLineNumbersNumber of line-number entries for section.
24DWORDCharacteristicssee end of page below
008 BytesName1Name of second section header
**********Repeats for rest of sections**************************************

The Export Table

Offsets shown from beginning of table (given at offset 78 from start of PE header). The following 40 Bytes repeat for each export library (DLL whose functions are imported by the executable) and ends with one full of zeroes.

OFFSETSIZENAMEEXPLANATION
00DWORDCharacteristicsSet to zero (currently none defined)
04DWORDTimeDateStampoften set to zero
08WORDMajorVersionuser-defined version number, otherwise zero
0AWORDMinorVersionas above
0CDWORDNameRVA of DLL name in null-terminated ASCII
10DWORDBaseFirst valid exported ordinal, normally=1
14DWORDNumberOfFunctionsNumber of entries in EAT
18DWORDNumberOfNamesNumber of entries in ENT
1CDWORDAddressOfFunctionsRVA of EAT (export address table)
20DWORDAddressOfNamesRVA of ENT (export name table)
24DWORDAddressOfNameOrdinalsRVA of EOT (export ordinal table)

The Import Table

Offsets shown from beginning of table (given at offset 80 from start of PE header). The following 5 DWORDS repeat for each import library (DLL whose functions are imported by the executable) and ends with one full of zeroes.

OFFSETSIZENAMEEXPLANATION
00DWORDOriginalFirstThunkRVA to Image_Thunk_Data
04DWORDTimeDateStampzero unless bound against imported DLL
08DWORDForwarderChainpointer to 1st redirected function (or 0)
0CDWORDName1RVA to name in null-terminated ASCII
10DWORDFirstThunkRVA to Image_Thunk_Data

Image Characteristics Flags

FLAGEXPLANATION
0001Relocation info stripped from file
0002File is executable (no unresolved external references)
0004Line numbers stripped from file
0008Local symbols stripped from file
0010Lets OS aggressively trim working set
0020App can handle >2Gb addresses
0080Low bytes of machine word are reversed
0100requires 32-bit WORD machine
0200Debugging info stripped from file into .DBG file
0400If image is on removable media, copy and run from swap file
0800If image is on a network, copy and run from swap file
1000System file
2000File is a DLL
4000File should only be run on a single-processor machine
8000High bytes of machine word are reversed

Section Characteristics Flags

FLAGEXPLANATION
00000008Section should not be padded to next boundary
00000020Section contains code
00000040Section contains initialised data (which will become initialised with real values before the file is launched)
00000080Section contains uninitialised data (which will be initialised as 00 byte values before launch)
00000200Section contains comments for the linker
00000800Section contents will not become part of image
00001000Section contents comdat (Common Block Data)
00008000Section contents cannot be accessed relative to GP
00100000 to 00800000Boundary alignment settings
01000000Section contains extended relocations
02000000Section can be discarded (e.g. .reloc)
04000000Section is not cacheable
08000000Section is pageable
10000000Section is shareable
20000000Section is executable
40000000Section is readable
80000000Section is writable

Tags:PE 结构 字段

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接