PE结构各字段偏移参考

PE文件结构简述 简述: PE文件结构分为五个部分: DOS文件头 DOS加载模块 PE文件头 区段表 区段 PE文件中显示的所有地址基本都是RVA,倘若想要换算成VA一般需要加上基地址ImageBase与文件偏移地址RVA。 虚拟地址(VA=virtual address):每个32位PE文件被加载到内存的时候都会被分配4GB的虚拟内存,虚拟地址等于“程序的相对虚拟地址+基地址”。 相对虚拟地址(RVA=relatively virtual address):相对虚拟地址是相比较于文件开头的地 阅读详情
导读:
  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
  
  OFFSET SIZE NAME EXPLANATION
  00 WORD e_magic Magic DOS signature MZ (4Dh 5Ah)
  02 WORD e_cblp Bytes on last page of file
  04 WORD e_cp Pages in file
  06 WORD e_crlc Relocations
  08 WORD e_cparhdr Size of header in paragraphs
  0A WORD e_minalloc Minimum extra paragraphs needed
  0C WORD e_maxalloc Maximum extra paragraphs needed
  0E WORD e_ss Initial (relative) SS value
  10 WORD e_sp Initial SP value
  12 WORD e_csum Checksum
  14 WORD e_ip Initial IP value
  16 WORD e_cs Initial (relative) CS value
  18 WORD e_lfarlc File address of relocation table
  1A WORD e_ovno Overlay number
  1C WORD e_res[4] Reserved words
  24 WORD e_oemid OEM identifier (for e_oeminfo)
  26 WORD e_oeminfo OEM information; e_oemid specific
  28 WORD e_res2[10] Reserved words
  3C DWORD e_lfanew Offset to start of PE header
  
  The PE Header
  Offsets shown are from the beginning of this section.
  
  00 DWORD Signature PE Signature PE.. (50h 45h 00h 00h)
  04 WORD Machine 014Ch = Intel 386, 014Dh = Intel 486, 014Eh = Intel 586, 0200h = Intel 64-bit, 0162h=MIPS
  06 WORD NumberOfSections Number Of Sections
  08 DWORD TimeDateStamp Date &time image was created by the linker
  0C DWORD PointerToSymbolTable Zero or offset of COFF symbol table in older files
  10 DWORD NumberOfSymbols Number of symbols in COFF symbol table
  14 WORD SizeOfOptionalHeader Size of optional header in bytes (224 in 32bit exe)
  16 WORD Characteristics see below
  18 ********** START OF OPTIONAL HEADER **************************************
  18 WORD Magic 010Bh=32-bit executable image
  020Bh=64-bit executable image
  0107h=ROM image
  1A BYTE MajorLinkerVersion Major version number of the linker
  1B BYTE MinorLinkerVersion Minor version number of the linker
  1C DWORD SizeOfCode size of code section or sum if multiple code sections
  20 DWORD SizeOfInitializedData as above
  24 DWORD SizeOfUninitializedData as above
  28 DWORD AddressOfEntryPoint Start of code execution, optional for DLLs, zero when none present
  2C DWORD BaseOfCode RVA of first byte of code when loaded into RAM
  30 DWORD BaseOfData RVA of first byte of data when loaded into RAM
  34 DWORD ImageBase Preferred load address
  38 DWORD SectionAlignment  Alignment of sections when loaded in RAM
  3C DWORD FileAlignment  Alignment of sections in file on disk
  40 WORD MajorOperatingSystemVersion Major version no. of required operating system
  42 WORD MinorOperatingSystemVersion Minor version no. of required operating system
  44 WORD MajorImageVersion Major version number of the image
  46 WORD MinorImageVersion Minor version number of the image
  48 WORD MajorSubsystemVersion Major version number of the subsystem
  4A WORD MinorSubsystemVersion Minor version number of the subsystem
  4C DWORD Reserved1
  50 DWORD SizeOfImage Amount of memory allocated by loader for image. Must be a multiple of SectionAlignment
  54 DWORD SizeOfHeaders  Offset of first section, multiple of FileAlignment
  58 DWORD CheckSum Image checksum (only required for kernel-mode drivers and some system DLLs).
  5C WORD Subsystem 0002h=Windows GUI, 0003h=console
  5E WORD DllCharacteristics 0001h=per-process library initialization
  0002h=per-process library termination
  0003h=per-thread library initialization
  0004h=per-thread library termination
  60 DWORD SizeOfStackReserve Number of bytes reserved for the stack
  64 DWORD SizeOfStackCommit Number of bytes actually used for the stack
  68 DWORD SizeOfHeapReserve Number of bytes to reserve for the local heap
  6C DWORD SizeOfHeapCommit Number of bytes actually used for local heap
  70 DWORD LoaderFlags This member is obsolete.
  74 DWORD NumberOfRvaAndSizes Number of directory entries.
  78 ********** START OF DATADIRECTORY **************************************
  78 DWORD IMAGE_DATA_DIRECTORY0 RVA of Export Directory
  7C DWORD size of Export Directory
  80 DWORD IMAGE_DATA_DIRECTORY1 RVA of Import Directory (array of IIDs)
  84 DWORD size of Import Directory (array of IIDs)
  88 DWORD IMAGE_DATA_DIRECTORY2 RVA of Resource Directory
  8C DWORD size of Resource Directory
  90 DWORD IMAGE_DATA_DIRECTORY3 RVA of Exception Directory
  94 DWORD size of Exception Directory
  98 DWORD IMAGE_DATA_DIRECTORY4 Raw Offset of Security Directory
  9C DWORD size of Security Directory
  A0 DWORD IMAGE_DATA_DIRECTORY5 RVA of Base Relocation Directory
  A4 DWORD size of Base Relocation Directory
  A8 DWORD IMAGE_DATA_DIRECTORY6 RVA of Debug Directory
  AC DWORD size of Debug Directory
  B0 DWORD IMAGE_DATA_DIRECTORY7 RVA of Copyright Note
  B4 DWORD size of Copyright Note
  B8 DWORD IMAGE_DATA_DIRECTORY8 RVA to be used as Global Pointer (IA-64 only)
  BC DWORD Not used
  C0 DWORD IMAGE_DATA_DIRECTORY9 RVA of Thread Local Storage Directory
  C4 DWORD size of Thread Local Storage Directory
  C8 DWORD IMAGE_DATA_DIRECTORY10 RVA of Load Configuration Directory
  CC DWORD size of Load Configuration Directory
  D0 DWORD IMAGE_DATA_DIRECTORY11 RVA of Bound Import Directory
  D4 DWORD size of Bound Import Directory
  D8 DWORD IMAGE_DATA_DIRECTORY12 RVA of first Import Address Table
  DC DWORD total size of all Import Address Tables
  E0 DWORD IMAGE_DATA_DIRECTORY13 RVA of Delay Import Directory
  E4 DWORD size of Delay Import Directory
  E8 DWORD IMAGE_DATA_DIRECTORY14 RVA of COM Header (top level info &metadata...
  EC DWORD size of COM Header     ...in .NET executables)
  F0 DWORD ZERO (Reserved) Reserved
  F4 DWORD ZERO (Reserved) Reserved
  F8 ********** START OF SECTION TABLE *******Offsets shown from here********
  00 8 Bytes Name1 Name of first section header
  08 DWORD misc (VirtualSize) Actual size of data in section
  0C DWORD virtual address RVA where section begins in memory
  10 DWORD SizeOfRawData Size of data on disk (multiple of FileAlignment)
  14 DWORD pointerToRawData Raw offset of section on disk
  18 DWORD pointerToRelocations Start of relocation entries for section, zero if none
  1C DWORD PointerToLinenumbers Start of line-no. entries for section, zero if none
  20 WORD NumberOfRelocations This value is zero for executable images.
  22 WORD NumberOfLineNumbers Number of line-number entries for section.
  24 DWORD Characteristics see end of page below
  00 8 Bytes Name1 Name 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.
  
  OFFSET SIZE NAME EXPLANATION
  00 DWORD Characteristics Set to zero (currently none defined)
  04 DWORD TimeDateStamp often set to zero
  08 WORD MajorVersion user-defined version number, otherwise zero
  0A WORD MinorVersion as above
  0C DWORD Name RVA of DLL name in null-terminated ASCII
  10 DWORD Base First valid exported ordinal, normally=1
  14 DWORD NumberOfFunctions Number of entries in EAT
  18 DWORD NumberOfNames Number of entries in ENT
  1C DWORD AddressOfFunctions RVA of EAT (export address table)
  20 DWORD AddressOfNames RVA of ENT (export name table)
  24 DWORD AddressOfNameOrdinals RVA 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.
  
  OFFSET SIZE NAME EXPLANATION
  00 DWORD OriginalFirstThunk RVA to Image_Thunk_Data
  04 DWORD TimeDateStamp zero unless bound against imported DLL
  08 DWORD ForwarderChain pointer to 1st redirected function (or 0)
  0C DWORD Name1 RVA to name in null-terminated ASCII
  10 DWORD FirstThunk RVA to Image_Thunk_Data
  Image Characteristics Flags
  
  FLAG EXPLANATION
  0001 Relocation info stripped from file
  0002 File is executable (no unresolved external references)
  0004 Line numbers stripped from file
  0008 Local symbols stripped from file
  0010 Lets OS aggressively trim working set
  0020 App can handle >2Gb addresses
  0080 Low bytes of machine word are reversed
  0100 requires 32-bit WORD machine
  0200 Debugging info stripped from file into .DBG file
  0400 If image is on removable media, copy and run from swap file
  0800 If image is on a network, copy and run from swap file

本文转自
http://tech.ddvip.com/2007-01/116878372618090.html
PE文件结构学习1 PE是可移植的执行体——Portable Executable File Format 一、PE文件种类: 可执行系列有两种.exe和.scr .scr  1.是Windows专用的屏幕保护程序的扩展名; 2.在AutoCAD中是脚本文件,以记事本方式打开,如果安装了AutoCAD 2004就会被自动改为脚本; 3.SCR文件可以转换为EXE文件来运行而不影响内容; window 阅读详情

相关推荐

PE文件详解1——PE文件头部解析

参考书籍:《WindowsPE文件权威指南》 MSDN中winnt.h是PE文件定义的最终决定者。 EXE文件与DLL文件之间的区别完全是语义上的,二者PE结构完全相同。唯一区别用一个字段标示处这个文件是exe还是dll。许多DLL扩展,如OCX控件,控制面板等都是DLL,它们有一样的实体。 64位的Windows只是对PE格式做了一些简单的修饰,新格式叫PE32+。没有新的结构加进去,其余

对着世界说你好 3164

PE文件结构详解精华(从头看下去就能大概了解PE文件结构了)

前言 此博客绝大部分内容来自云课堂武大慕课《软件安全-恶意代码机理与防护》。 内容提纲 PE文件及其表现形式 PE文件格式与恶意软件的关系 PE文件格式总体结构 代码节与数据节 引入函数节:PE文件的引入函数机制 引出函数节:DLL文件的函数引出机制 资源节:文件资源索引、定位与修改 重定位节:镜像地址改变后的地址自动修正 PE文件及其表现形式 可移植的可执行文件(PE,Portable...

雨化于画 1万+

偏移量转换器,能方便的计算偏移

能快速方便的计算出PE文件的偏移量,使用步骤,1,打开PE文件;2.填上物理地址。3计算偏移

PE文件结构详解(非常详细)

1 //大小为: 0x40(64)字节3// MZ标记 0x5a4d// 最后(部分)页中的字节数// 文件中的全部和部分页数// 重定位表中的指针数// 头部尺寸以段落为单位// 所需的最小附加段// 所需的最大附加段// 初始的SS值(相对偏移量)// 初始的SP值// 补码校验值// 初始的IP值// 初始的SS值// 重定位表的字节偏移量// 覆盖号// 保留字// OEM标识符(相对m_oeminfo)// OEM信息// 保留字。

【微软MVP】zhaotianff的专栏 2686

PE文件结构

参考《加密与解密》《Windows PE权威指南》 目录 1、PE文件的结构 1、什么是可执行文件? 2、PE文件的特征 3、PE文件的整体结构 4、PE文件到内存的映射 5、DOS部分 6、PE文件头(PE Header) 7、块表 8、RVA与FOA的转换 2、输出表和输入表 1、输出表(导出表) 2、输入表(导入表) 3、重定位表 4、资源 1、PE文件的结构...

洋葱汪的博客 4081

2.2 PE结构:文件头详细解析

PE结构是`Windows`系统下最常用的可执行文件格式,理解PE文件格式不仅可以理解操作系统的加载流程,还可以更好的理解操作系统对进程和内存相关的管理知识,DOS头是PE文件开头的一个固定长度的结构体,这个结构体的大小为64字节(0x40)。DOS头包含了很多有用的信息,该信息可以让Windows操作系统使用正确的方式加载可执行文件。从DOS文件头`IMAGE_DOS_HEADER`的`e_lfanew`字段向下偏移`003CH`的位置,就是真正的PE文件头的位置,该文件头是由`IMAGE_NT_HEAD

微软技术分享 1万+

PE文件与脱壳初探

PE文件与壳一、PE文件的载入机制:(一)相对虚拟地址RVA:(二)文件偏移地址(物理地址):二、PE文件结构简述(一)MS-DOS头部(二)PE文件头DataDirectory[16](数据目录表):(三)区块 一、PE文件的载入机制: PE文件并不是作为单一映射文件被载入,它先被Windows加载器(PE装载器)遍历,决定哪个部分要被映射,(映射是高偏移地址对应高内存地址)。 然后PE文件被载入内存,数据结构布局与原始的一致之外,数据间的相对位置不一定一致。所以某一部分的载入偏移地址不一定等于原始偏移

m0_46296905的博客 3371

跟着王哥学逆向——PE文件详解篇(第一篇)

这是《跟着王哥学逆向》PE文件详解篇第一篇,该篇章主要对PE文件内部结构进行仔细剖析,同时记录下来PE文件各个字节所代表的含义,方便自己查看。此篇章对DOS头、PE文件头、区块表等按照顺序介绍,有很强的系统性,计划下一篇章对导入表、导出表、资源表、重定位表进行详解。该系列学习主要参考小甲鱼讲的PE系列视频,真的很顶。

qq_52642385的博客 8560

Windows:32位PE文件结构

文章目录什么是PE文件PE结构PE文件结构简介1. DOS头1.1 MZ头1.2 DOS残留2. PE头2.1 PE标识2.2 文件头2.3 可选头3. 节表4. 节表数据结构体关系图结构体关系详解1. DOS头2. PE头2.1 PE标识2.2 文件头2.3 可选头3. 节表 什么是PE文件 PE(Portable Executable)即可移植的执行体,使用了PE文件结构的可执行文件被称为PE文件,Win下包括EXE、DLL、SYS、OCX等 PE结构PE文件结构简介 1. DOS头 1.1 M

无名J0kзr的博客 1970

滴水逆向三期笔记和作业-PE总结1

PE头手动解析,节表,FileBuffer-ImageBuffer

weixin_44449397的博客 3273

小甲鱼PE详解之区块描述、对齐值以及RVA详解(PE详解06)

上一讲:小甲鱼PE详解之区块表(节表)和区块(节)续各种区块的描述:很多朋友喜欢听小甲鱼的PE详解,因为他们觉得课堂上老师讲解的都是略略带过,绕得大家云里雾里~刚好小甲鱼文采也没课堂上的教授讲的那么好,只能以比较通俗的话语来给大家描述~通常,区块中的数据在逻辑上是关联的。PE

3821

Windows PE文件浅析

4、数据目录:Windows下的可执行文件是PE中的一种,这种文件除了包含代码及数据段的相关数据以外还包含了许多与文件执行有关的其他数据。Windows操作系统在加载可执行文件时,会为这些具有不同属性怼的数据分别分配标记有不同属性的页面(当然,相同属性的数据可能会被放到同一个页面中),以确保程序运行时的安全。相对虚拟内存地址RVA是相对于基地址的偏移,几RVA是虚拟内存中用来定位某个特定未知的,该地址的值是这个特定位置距离某个模块基地址的偏移量。RVA是相对于模块而言的,VA是相对于进程而言的。

qq_15054345的博客 822

PE结构详解(加壳脱壳必备知识)第二篇·存储地址介绍

昨天分享了一篇PE结构详解(加壳脱壳必备知识),本篇是上一篇续篇,主要介绍关于PE结构的三种存储地址 VA、RVA、FILEOFFSET及转换方式,希望对你有所帮助。 一、关于VA、RVA、FILEOFFSET VA:虚拟地址,PE文件映射到内存后的地址。 RVA:相对虚拟地址,内存地址相对于映射基地址的偏移地址。 FileOffset:文件偏移地址,相对PE文件在磁盘上的文件开头的偏移地...

MR王峰的专栏 705
上一篇: FreeBasic,一种能开发OS的basic变种语言
下一篇: PE结构图
chief1985
博客等级 码龄21年 1545粉丝 879原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值