简单几行代码就可以解析PE文件

通过下面的代码就可以解析完红色范围的内容,下面就是具体的节数据了。可以通过已红色范围内的部分定位到!

简单几行代码就可以解析PE文件_第1张图片

BOOL Parse(PBYTE pImage) { m_pImage=pImage; //Read Dos Header m_pDosHeader=(PIMAGE_DOS_HEADER)m_pImage; if(m_pDosHeader->e_magic!= IMAGE_DOS_SIGNATURE) { MessageBox(NULL,"DOS Header Error!","Invalid PE File",MB_ICONWARNING); return FALSE; } //Read NT Header m_pNTHeaders=(PIMAGE_NT_HEADERS)(m_pImage+m_pDosHeader->e_lfanew); if(m_pNTHeaders->Signature != IMAGE_NT_SIGNATURE) { MessageBox(NULL,"NT Header Error!","Invalid PE File",MB_ICONWARNING); return FALSE; } //Read FileHeader m_pFileHeader=&m_pNTHeaders->FileHeader; //Read OptionalHeader m_pOptionalHeader=&m_pNTHeaders->OptionalHeader; //Read Section Table m_numberOfSections = m_pFileHeader->NumberOfSections; //Get First IMAGE_SECTION_HEADER m_pSectionHeader = IMAGE_FIRST_SECTION(m_pNTHeaders); return TRUE; } 

你可能感兴趣的:(image,header,File,dos,null)