您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 招标投标 > 小甲鱼PE结构详解课件
小甲鱼PEPEPEPE详解之IMAGE_DOS_HEADERIMAGE_DOS_HEADERIMAGE_DOS_HEADERIMAGE_DOS_HEADER结构定义即各个属性的作用小甲鱼在这里为大家做好了详细的注释,免得大家一头雾水,另外可以结合小甲鱼《加密系列》----系统篇-PE-PE-PE-PE结构详解视频教程学习~~~~若有纰漏之处还望大家不吝指正。(视频教程:://fishc.com/a/shipin/jiemixilie/://fishc.com/a/shipin/jiemixilie/)(注:最左边是文件头的偏移量(注:最左边是文件头的偏移量(注:最左边是文件头的偏移量(注:最左边是文件头的偏移量。。。。))))IMAGE_DOS_HEADERSTRUCT{+0hWORDe_magic//MagicDOSsignatureMZ(4Dh5Ah)DOS可执行文件标记+2hWORDe_cblp//Bytesonlastpageoffile+4hWORDe_cp//Pagesinfile+6hWORDe_crlc//Relocations+8hWORDe_cparhdr//Sizeofheaderinparagraphs+0ahWORDe_minalloc//Minimunextraparagraphsneeds+0chWORDe_maxalloc//Maximunextraparagraphsneeds+0ehWORDe_ss//intial(relative)SSvalueDOS代码的初始化堆栈SS+10hWORDe_sp//intialSPvalueDOS代码的初始化堆栈指针SP+12hWORDe_csum//Checksum+14hWORDe_ip//intialIPvalueDOS代码的初始化指令入口[指针IP]+16hWORDe_cs//intial(relative)CSvalueDOS代码的初始堆栈入口+18hWORDe_lfarlc//FileAddressofrelocationtable+1ahWORDe_ovno//Overlaynumber+1chWORDe_res[4]//Reservedwords+24hWORDe_oemid//OEMidentifier(fore_oeminfo)+26hWORDe_oeminfo//OEMinformation;e_oemidspecific+29hWORDe_res2[10]//Reservedwords+3chDWORDe_lfanew//OffsettostartofPEheader指向PE文件头}IMAGE_DOS_HEADERENDS小甲鱼PE详解之IMAGE_NT_HEADERS结构定义即各个属性的作用PEPEPEPEHeaderHeaderHeaderHeader是PEPEPEPE相关结构NTNTNTNT映像头(IMAGE_NT_HEADERIMAGE_NT_HEADERIMAGE_NT_HEADERIMAGE_NT_HEADER)的简称,里边包含着许多PEPEPEPE装载器用到的重要字段。下边小甲鱼将为大家详细讲解哈~~~~(视频教程:://fishc.com/a/shipin/jiemixilie/://fishc.com/a/shipin/jiemixilie/)首先是IMAGE_NT_HEADERSIMAGE_NT_HEADERSIMAGE_NT_HEADERSIMAGE_NT_HEADERS结构的定义:(啥?结构不会,先看看小甲鱼童鞋的《零基础入门学习CCCC语言》关于结构方面的章节吧~)IMAGE_NT_HEADERSSTRUCT{+0hDWORDSignature//+4hIMAGE_FILE_HEADERFileHeader//+18hIMAGE_OPTIONAL_HEADER32OptionalHeader//}IMAGE_NT_HEADERSENDSSignatureSignatureSignatureSignature字段:在一个有效的PE文件里,Signature字段被设置为00004550h,ASCII码字符是“PE00”。标志这PE文件头的开始。“PE00”字符串是PE文件头的开始,DOS头部的e_lfanew字段正是指向这里。如下图所示:IMAGE_FILE_HEADERIMAGE_FILE_HEADERIMAGE_FILE_HEADERIMAGE_FILE_HEADER结构typedeftypedeftypedeftypedefstructstructstructstruct_IMAGE_FILE_HEADER_IMAGE_FILE_HEADER_IMAGE_FILE_HEADER_IMAGE_FILE_HEADER{+04hWORDMachine;//运行平台+06hWORDNumberOfSections;//文件的区块数目+08hDWORDTimeDateStamp;//文件创建日期和时间+0ChDWORDPointerToSymbolTable;//指向符号表(主要用于调试)+10hDWORDNumberOfSymbols;//符号表中符号个数(同上)+14hWORDSizeOfOptionalHeader;//IMAGE_OPTIONAL_HEADER32结构大小+16hWORDCharacteristics;//文件属性}IMAGE_FILE_HEADER,*PIMAGE_FILE_HEADER;该结构如下图所示:下边,小甲鱼童鞋为大家详细解释各个成员的含义和用法:(1111)MachineMachineMachineMachine:可执行文件的目标CPU类型。ValueMeaningIMAGE_FILE_MACHINE_I3860x014cx86IMAGE_FILE_MACHINE_IA640x0200IntelItaniumIMAGE_FILE_MACHINE_AMD640x8664x64(2222)NumberOfSection:NumberOfSection:NumberOfSection:NumberOfSection:区块的数目。(注:区块表是紧跟在IMAGE_NT_HEADERS后边的)(3333)TimeDataStamp:TimeDataStamp:TimeDataStamp:TimeDataStamp:表明文件是何时被创建的。这个值是自1970年1月1日以来用格林威治时间(GMT)计算的秒数,这个值是比文件系统(FILESYSTEM)的日期时间更加精确的指示器。如何将这个值翻译请看:=9&do=blog&id=555提示:VC的话可以用_ctime函数或者gmtime函数。(4444)PointerToSymbolTable:PointerToSymbolTable:PointerToSymbolTable:PointerToSymbolTable:COFF符号表的文件偏移位置,现在基本没用了。(5555)NumberOfSymbols:NumberOfSymbols:NumberOfSymbols:NumberOfSymbols:如果有COFF符号表,它代表其中的符号数目,COFF符号是一个大小固定的结构,如果想找到COFF符号表的结束位置,则需要这个变量。(6666)SizeOfOptionalHeader:SizeOfOptionalHeader:SizeOfOptionalHeader:SizeOfOptionalHeader:紧跟着IMAGE_FILE_HEADER后边的数据结构(IMAGE_OPTIONAL_HEADER)的大小。(对于32位PE文件,这个值通常是00E0h;对于64位PE32+文件,这个值是00F0h)。(7777)Characteristics:Characteristics:Characteristics:Characteristics:文件属性,有选择的通过几个值可以运算得到。(这些标志的有效值是定义于winnt.h内的IMAGE_FILE_**的值,具体含义见下表。普通的EXE文件这个字段的值一般是0100h,DLL文件这个字段的值一般是210Eh。)小甲鱼温馨提示:多种属性可以通过“或运算”使得同时拥有!Thecharacteristicsoftheimage.Thismembercanbeoneormoreofthefollowingvalues.ValueMeaningIMAGE_FILE_RELOCS_STRIPPED0x0001Relocationinformationwasstrippedfromthefile.Thefilemustbeloadedatitspreferredbaseaddress.Ifthebaseaddressisnotavailable,theloaderreportsanerror.IMAGE_FILE_EXECUTABLE_IMAGE0x0002Thefileisexecutable(therearenounresolvedexternalreferences).IMAGE_FILE_LINE_NUMS_STRIPPED0x0004COFFlinenumberswerestrippedfromthefile.IMAGE_FILE_LOCAL_SYMS_STRIPPED0x0008COFFsymboltableentrieswerestrippedfromfile.IMAGE_FILE_AGGRESIVE_WS_TRIM0x0010Aggressivelytrimtheworkingset.ThisvalueisobsoleteasofWindows2000.IMAGE_FILE_LARGE_ADDRESS_AWARE0x0020Theapplicationcanhandleaddresseslargerthan2GB.IMAGE_FILE_BYTES_REVERSED_LO0x0080Thebytesofthewordarereversed.Thisflagisobsolete.IMAGE_FILE_32BIT_MACHINE0x0100Thecomputersupports32-bitwords.IMAGE_FILE_DEBUG_STRIPPED0x0200Debugginginformationwasremovedandstoredseparatelyinanotherfile.IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP0x0400Iftheimageisonremovablemedia,copyittoandrunitfromtheswapfile.IMAGE_FILE_NET_RUN_FROM_SWAP0x0800Iftheimageisonthenetwork,copyittoandrunitfromtheswapfile.IMAGE_FILE_SYSTEM0x1000Theimageisasystemfile.IMAGE_FILE_DLL0x2000TheimageisaDLLfile.Whileitisanexecutablefile,itcannotberundirectly.IMAGE_FILE_UP_SYSTEM_ONLY0x4000Thefileshouldberunonlyonauniprocessorcomputer.IMAGE_FILE_BY
本文标题:小甲鱼PE结构详解课件
链接地址:https://www.777doc.com/doc-4826695 .html