PE格式详细讲解2 - 系统篇02|解密系列
PE格式详细讲解2 - 系统篇02
让编程改变世界
Change the world by program
PE Header 是PE相关结构NT映像头(IMAGE_NT_HEADER)的简称,里边包含着许多PE装载器用到的重要字段。下边小甲鱼将为大家详细讲解哈~ 首先是IMAGE_NT_HEADERS 结构的定义:(啥?结构不会,先看看小甲鱼童鞋的《零基础入门学习C语言》关于结构方面的章节吧~) [codesyntax lang="asm"]
IMAGE_NT_HEADERS STRUCT { +0h DWORDSignature +4h IMAGE_FILE_HEADER FileHeader +18h IMAGE_OPTIONAL_HEADER32OptionalHeader } IMAGE_NT_HEADERS ENDS[/codesyntax]
Signature字段:
在一个有效的 PE 文件里,Signature 字段被设置为00004550h, ASCII 码字符是“PE00”。标志这 PE 文件头的开始。 “PE00” 字符串是 PE 文件头的开始,DOS 头部的 e_lfanew 字段正是指向这里。 如下图所示: [caption id="attachment_1552" align="alignnone" width="620"] PE结构讲解,Signature字段[/caption]IMAGE_FILE_HEADER 结构
[codesyntax lang="c"]IMAGE_FILE_HEADER 结构 typedef struct _IMAGE_FILE_HEADER { +04h WORD Machine; // 运行平台 +06h WORD NumberOfSections; // 文件的区块数目 +08h DWORD TimeDateStamp; // 文件创建日期和时间 +0Ch DWORD PointerToSymbolTable; // 指向符号表(主要用于调试) +10h DWORD NumberOfSymbols; // 符号表中符号个数(同上) +14h WORD SizeOfOptionalHeader; // IMAGE_OPTIONAL_HEADER32 结构大小 +16h WORD Characteristics; // 文件属性 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;[/codesyntax]
该结构如下图所示:
[caption id="attachment_1553" align="alignnone" width="626"] IMAGE_FILE_HEADER结构[/caption] 下边,小甲鱼童鞋为大家详细解释各个成员的含义和用法: (1)Machine:可执行文件的目标CPU类型。Value | Meaning |
---|---|
|
x86 |
|
Intel Itanium |
|
x64 |
Value | Meaning |
---|---|
|
Relocation information was stripped from the file. The file must be loaded at its preferredbase address. If the base address is notavailable, the loader reports an error. |
|
The file is executable (there are no unresolved external references). |
|
COFF line numbers were stripped from the file. |
|
COFF symbol table entries were stripped from file. |
|
Aggressively trim the working set. This value is obsolete as of Windows 2000. |
|
The application can handle addresses larger than 2 GB. |
|
The bytes of the word are reversed. This flag is obsolete. |
|
The computer supports 32-bit words. |
|
Debugging information was removed and stored separately in another file. |
|
If the image is on removable media, copy it toand run it from the swap file. |
|
If the image is on the network, copy it to and run it from the swap file. |
|
The image is a system file. |
|
The image is a DLL file. While it is an executable file, it cannot be run directly. |
|
The file should be run only on a uniprocessor computer. |
|
The bytes of the word are reversed. This flag is obsolete. |