PE总体层次结构:

DOS MZ header
DOS stub
PE header
section table
section 1
section 2
...
section n

DOS stub通常是This program cannot run in DOS mode,section table中包含了n个section的信息,section中是各种数据或代码等。

验证PE文件的有效性:

  1. 校验DOS MZ header的e_magic是否为MZ
  2. 用e_lfanew定位PE header。
  3. 校验PE header的signature是否为PE\0\0

PE header中的重要信息:

signature
file header
optional header

file header包含PE文件的逻辑描述,如可运行在何平台,文件的创建时间等。

optional header是很重要的,并不像他的名字描述的那样