-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathAddSection.h
83 lines (51 loc) · 1.43 KB
/
AddSection.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#ifndef ADDSECTION_H_
#define ADDSECTION_H_
/*
类名称:AddSection
用途:添加一个区段
时间:2018/11/30
*/
class AddSection
{
public:
AddSection();
~AddSection();
public:
void puInti(CString sFilePath) {
m_FilePath = sFilePath;
this->Init();
}
void puFree() {
m_FilePath.Empty();
this->Free();
}
void puModifySectioNumber(){ this->ModifySectionNumber(); }
void puModifyProgramEntryPoint(){ this->ModifyProgramEntryPoint(); }
void puModifySizeofImage(){ this->ModifySizeofImage(); }
BOOL puModifySectionInfo(BYTE* Name, const DWORD & size){ return this->ModifySectionInfo(Name, size); }
BOOL puAddNewSectionByData(const DWORD & size){ return this->AddNewSectionByteData(size); }
void* puGetNewBaseAddress(){ return this->m_newlpBase; }
DWORD puGetNewBaseSize(){ return this->FileSize + 0x1000; }
private:
BOOL Init();
BOOL Free();
BOOL ModifySectionNumber();
BOOL ModifySectionInfo(const BYTE* Name, const DWORD & size);
BOOL ModifyProgramEntryPoint();
BOOL ModifySizeofImage();
BOOL AddNewSectionByteData(const DWORD & size);
private:
void* pFileBaseData = nullptr;
void* pNtHeadre = nullptr;
void* pSectionHeadre = nullptr;
DWORD SectionSizeof = 0;
DWORD FileSize = 0;
HANDLE FileHandle = nullptr;
PIMAGE_SECTION_HEADER NewpSection = { 0 };
DWORD64 OldOep = 0;
CString m_FilePath;
char* m_newlpBase = nullptr;
};
#endif
using SingleAddSection = ustdex::Singleton<AddSection>;