-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDllLauncher.hpp
More file actions
96 lines (74 loc) · 2.03 KB
/
Copy pathDllLauncher.hpp
File metadata and controls
96 lines (74 loc) · 2.03 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
#include <Common/Common.hpp>
#include <string>
#pragma pack(push, 8)
struct ArgsBase
{
long long size = 0;
};
struct ManualMapParam_t : public ArgsBase
{
char m_DllDir[MAX_PATH] = { 0 };
};
#pragma pack(pop)
class CDllLauncher final
{
public:
auto OnDllMain( LPVOID lpReserved , HINSTANCE hInstace ) -> void;
auto OnDestroy() -> void;
public:
inline auto GetDllImage() -> HINSTANCE
{
return m_hDllImage;
}
public:
inline auto GetSizeOfImage() -> DWORD
{
return m_SizeofImage;
}
inline auto GetBaseOfCode() -> DWORD
{
return m_BaseOfCode;
}
public:
inline auto IsCheatAddress( void* pAddress )
{
auto StartCheatAddress = reinterpret_cast<uint64_t>( m_hDllImage );
auto EndCheatAddress = reinterpret_cast<uint64_t>( reinterpret_cast<PBYTE>( m_hDllImage ) + GetSizeOfImage() );
auto AddressCheck = reinterpret_cast<uint64_t>( pAddress );
if ( AddressCheck >= StartCheatAddress && AddressCheck <= EndCheatAddress )
return true;
return false;
}
private:
inline auto GetSizeOfImageInternal() -> DWORD
{
const auto pDosHeader = reinterpret_cast<PIMAGE_DOS_HEADER>( m_hDllImage );
const auto pNtHeaders = reinterpret_cast<PIMAGE_NT_HEADERS>( (BYTE*)pDosHeader + pDosHeader->e_lfanew );
return pNtHeaders->OptionalHeader.SizeOfImage;
}
inline auto GetBaseOfCodeInternal() -> DWORD
{
const auto pDosHeader = reinterpret_cast<PIMAGE_DOS_HEADER>( m_hDllImage );
const auto pNtHeaders = reinterpret_cast<PIMAGE_NT_HEADERS>( (BYTE*)pDosHeader + pDosHeader->e_lfanew );
return pNtHeaders->OptionalHeader.BaseOfCode;
}
public:
static auto WINAPI StartCheatTheard( LPVOID lpThreadParameter )->DWORD;
private:
friend auto GetDllDir()->std::string&;
friend auto GetDeadLockDir()->std::string;
private:
std::string m_DllDir;
std::string m_DeadLockDir;
private:
HINSTANCE m_hDllImage = nullptr;
private:
DWORD m_SizeofImage = 0;
DWORD m_BaseOfCode = 0;
private:
bool m_bDestroyed = false;
};
auto GetDllDir() -> std::string&;
auto GetDeadLockDir() -> std::string;
auto GetDllLauncher() -> CDllLauncher*;