-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPEBaseClass.h
More file actions
60 lines (45 loc) · 1.66 KB
/
PEBaseClass.h
File metadata and controls
60 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef PEBASECLASS__H
#define PEBASECLASS__H
#include <windows.h>
#include <winnt.h>
#include "StringTemplate.h"
#include "PEOptionHeader.h"
//用来存放PE文件中前面几个大小确定的结构体的一些信息,包括DOSheader,ntheader,section
class PEBase
{
private:
TCHAR fFullPath[256]; //PE文件的全路径
StringTemplate st;
public:
static const char CharacterStr[16][50];
static const char DataDirectoryName[16][25];
static const char SectionCharacteristics_Base5[][50];
static const char SectionCharacteristics_Base25[][50];
IMAGE_DOS_HEADER dosHeader;
IMAGE_FILE_HEADER fileHeader;
PEOptionHeader * optionHeader;
LPVOID pSection;
TCHAR ErrorString[256];
private :
// 将会向文件里输出以下格式的数据: {...},{...},{...},{...},{...}
void writeDOSHeader( HANDLE hFile );
void writeNTFileHeader( HANDLE hFile );
void writeNTOptionalDataDirectory( HANDLE hFile );
void writeSectionInfo( HANDLE hFile,int index );
// 释放申请的内存
void Release();
public:
PEBase ( TCHAR filePath[] );
// 获取文件的dosheader和NTheader结构体和Section信息,并核查是否符合PE文件格式要求
BOOL getDosNTSection();
// 获取pe文件的路径名,但是无法保证该文件完全符合pe规范,仅仅是将该类初始化时的传入的文件名传出去
const TCHAR * getPEFilePath();
// 将数据写到temp文件中,文件的名字可以通过getTempFileName()获取到
BOOL writeToTempFile();
const TCHAR * GetTempFileName( ){
return TEXT("temp\\dos_header.txt");
}
// 通过section内的信息获取rva对应的foa
ULONGLONG RvaToFoa(ULONGLONG rva);
};
#endif