PE檔案格式

2021-10-02 16:50:45 字數 3723 閱讀 3865

pe頭節區頭

rva to raw

iateat

高階pe

pe檔案:windows作業系統下使用的可執行檔案,pe檔案是指32位的可執行檔案,也稱pe32,64位可執行檔案稱為pe+或pe32+。

pe檔案種類:

種類主要副檔名

可執行系列

exe、scr

庫系列dll、ocx、cpl、drv

驅動程式系列

sys、vxd

物件檔案系列

obj以記事本程式(notepad.exe)為例:

pe檔案載入到記憶體的情形:

rva:指從某個基準位置開始的相對位址

其結構體大小為f8。

typedef

struct _image_file_header image_file_header,

*pimage_file_header;

typedef

struct _image_data_directory image_data_directory,

*pimage_data_directory;

typedef

struct _image_optional_header image_optional_header32,

*pimage_optional_header32;

sectionalignment:指定節區在磁碟檔案中的最小單位

filealignment:指定節區在記憶體中的最小單位

sizeofimage:指定pe image在虛擬記憶體中所佔空間的大小

sizeofheader:指定整個pe頭的大小

subsystem:用來區分系統驅動檔案(.sys)與普通的可執行檔案(.exe、.dll)

【1——driver檔案,系統驅動】

【2——gui檔案,視窗應用程式】

【3——cui檔案,控制台應用程式】

numberofrvaandsize:指定datadirectory陣列的個數

datadirectory

節區頭:定義各節區屬性。

類別訪問許可權

code

執行、讀取

data

非執行,讀寫

resource

非執行,讀寫

image_section_header結構體:

typedef

struct _image_section_header

dword virtualaddress;

dword sizeofrawdata;

dword pointertorawdata;

dword pointertorelocations;

dword pointertolinenumbers;

dword numberofrelocations;

dword numberoflinenumbers;

dword characteristics;

} image_section_header,

*pimage_section_header;

專案

含義virtualsize

記憶體中節區所佔大小

virtualaddress

記憶體中節區起始位址(rva)

sizeofrawdata

磁碟檔案中節區所佔大小

pointertorawdata

磁碟檔案中節區起始位置

characteristics

節區屬性

r aw

=rva

−vir

tual

addr

ess+

poin

tert

oraw

data

raw=rva-virtualaddress+pointertorawdata

raw=rv

a−vi

rtua

ladd

ress

+poi

nter

tora

wdat

a載入dll的方法:

image_import_descriptor中記錄著pe檔案要匯入哪些庫檔案。

typedef

struct _image_import_descriptor

; dword timedatestamp;

dword forwarderchain;

dword name;

dword firstthunk;

//iat位址

} image_import_descripror;

typedef

struct _image_import_by_name image_import_by_name,

*pimage_import_by_name;

專案

含義originalfirstthunk

int的位址

name

庫名稱字串的位址

firstthunk

iat的位址

iat的輸入順序:

eat:使不同的應用程式可以呼叫庫檔案中提供的函式。

typedef

struct _image_export_directory image_export_directory,

*pimage_export_directory;

專案

含義numberoffunctions

實際export函式的個數

numberofnames

export函式中具名的函式個數

addressoffunctions

export函式位址陣列

addressofnames

函式名稱位址陣列

addressofnameordinals

ordinal位址陣列

pe規範只是乙個建議性質的書面標準,其實許多成員均未被使用,事實上,只要檔案符合pe規範就是pe檔案,patched pe就是指此類pe檔案。

參考文獻

《逆向工程核心原理》

PE檔案格式

pe 的意思是 portable executable 可移植的執行體 它是 win32環境自身所帶的執行檔案格式。它的一些特性繼承自unix的coff common object file format 檔案格式。portable executable 可移植的執行體 意味著此檔案格式是跨win3...

PE檔案格式

pe檔案格式分析及修改 圖 1 2009 01 09 14 08 pe 的意思是 portable executable 可移植的執行體 它是 win32環境自身所帶的執行檔案格式。它的一些特性繼承自unix的coff common object file format 檔案格式。portable ...

PE檔案格式

pe檔案格式應用於所有32位windows系統 windows 9x,windows nt,windows 2000及windows xp vista已經對pe格式進行了公升級,也出現了pe64 而在msdn 98中有pe的大量詳細資料 按目錄 msdn library visual studio ...