This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdllmain.cpp
113 lines (98 loc) · 2.77 KB
/
dllmain.cpp
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <Windows.h>
#include "D:\work\SDK\Utils.h"
class EAC_VirtualFunctions
{
public:
virtual void RegisterInitCallbacks(void* clbk0, void* clbk1, void* p_g_hEAC) = 0;
virtual void Unload(void) = 0;
virtual void Initialize(void) = 0;
virtual bool DoSomeChecks(void* ptr1, void* ptr2) = 0;
virtual void UnkVirtFunc_0x20(void* unk1, int unk2) = 0; //not sure with return type
virtual void RegisterUnkCallback(void* clbk, int unk_Flags, void* unk_pObject) = 0;
virtual void UnkVirtFunc_0x30() = 0;
virtual void UnkVirtFunc_0x38() = 0;
virtual void UnkVirtFunc_0x40() = 0;
virtual void UnkVirtFunc_0x48() = 0;
virtual void UnkVirtFunc_0x50(int unk1, int unk2) = 0;
};
class EAC_Interface : public EAC_VirtualFunctions
{
public:
void RegisterInitCallbacks(void* clbk0, void* clbk1, void* p_g_hEAC)
{
return; //clbk0 = xor eax,eax; ret; & clbk1 = ret; so really does not matter if we call them or not
}
void Unload(void)
{
return;
}
void Initialize(void)
{
return;
}
bool DoSomeChecks(void* ptr1, void* ptr2)
{
return false; //if returned false then called only once, otherwise called in a loop until returned false
}
void UnkVirtFunc_0x20(void* unk1, int unk2)
{
return;
}
void RegisterUnkCallback(void* clbk, int unk_Flags, void* unk_pObject)
{
return; //clbk directly calls some virt func, lets better not call it
}
void UnkVirtFunc_0x30()
{
return;
}
void UnkVirtFunc_0x38()
{
return;
}
void UnkVirtFunc_0x40()
{
return;
}
void UnkVirtFunc_0x48()
{
return;
}
void UnkVirtFunc_0x50(int unk1, int unk2)
{
return;
}
};
void* CreateGameClient(char* szInterfaceNameWithVersion)
{
return (new EAC_Interface);
}
typedef HMODULE(*fnLoadLibraryExW)(LPCWSTR, HANDLE, DWORD);
fnLoadLibraryExW oLoadLibraryExW;
typedef LPVOID(*fnGetProcAddress)(HMODULE, LPCSTR);
fnGetProcAddress oGetProcAddress;
HMODULE g_hModule;
HMODULE hkLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
if (wcsstr(lpLibFileName, L"easyanticheat_x64.dll"))
return g_hModule;
return oLoadLibraryExW(lpLibFileName, hFile, dwFlags);
}
LPVOID hkGetProcAddress(HMODULE hModule, LPCSTR lpProcName)
{
if (strstr(lpProcName, "CreateGameClient"))
return CreateGameClient;
return oGetProcAddress(hModule, lpProcName);
}
BOOLEAN WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason != DLL_PROCESS_ATTACH)
return TRUE;
g_hModule = hModule;
HMODULE hKERNEL32 = GetModuleHandleA("KERNEL32.DLL");
oLoadLibraryExW = (fnLoadLibraryExW)GetProcAddress(hKERNEL32, "LoadLibraryExW");
oGetProcAddress = (fnGetProcAddress)GetProcAddress(hKERNEL32, "GetProcAddress");
Utils_HookImport("enlisted.exe", "KERNEL32.DLL", "LoadLibraryExW", hkLoadLibraryExW);
Utils_HookImport("enlisted.exe", "KERNEL32.DLL", "GetProcAddress", hkGetProcAddress);
return TRUE;
}