-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
124 lines (97 loc) · 2.47 KB
/
Copy pathdllmain.cpp
File metadata and controls
124 lines (97 loc) · 2.47 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <iostream>
#include "mem.h"
#include "hook.h"
#include "glDraw.h"
#include "gltext.h"
#include "esp.h"
uintptr_t moduleBase = (uintptr_t)GetModuleHandle(L"ac_client.exe");
bool bHealth = false, bAmmo = false, bRecoil = false;
typedef BOOL(__stdcall* twglSwapBuffers) (HDC hDc);
twglSwapBuffers owglSwapBuffers;
twglSwapBuffers wglSwapBuffersGateway;
GL::Font glFont;
const int FONT_HEIGHT = 15;
const int FONT_WIDTH = 9;
ESP esp;
void Draw()
{
HDC currentHDC = wglGetCurrentDC();
if (!glFont.bBuilt || currentHDC != glFont.hdc)
{
glFont.Build(FONT_HEIGHT);
}
GL::SetupOrtho();
esp.Draw(glFont);
esp.DrawL(glFont);
GL::RestoreGL();
}
BOOL __stdcall hkwglSwapBuffers(HDC hDc)
{
if (GetAsyncKeyState(VK_HOME) & 1)
bHealth = !bHealth;
if (GetAsyncKeyState(VK_DELETE) & 1)
{
bAmmo = !bAmmo;
}
//no recoil NOP
if (GetAsyncKeyState(VK_INSERT) & 1)
{
bRecoil = !bRecoil;
if (bRecoil)
{
mem::Nop((BYTE*)(moduleBase + 0x63786), 10);
}
else
{
//50 8D 4C 24 1C 51 8B CE FF D2 the original stack setup and call
mem::Patch((BYTE*)(moduleBase + 0x63786), (BYTE*)"\x50\x8D\x4C\x24\x1C\x51\x8B\xCE\xFF\xD2", 10);
}
}
//need to use uintptr_t for pointer arithmetic later
uintptr_t* localPlayerPtr = (uintptr_t*)(moduleBase + 0x10F4F4);
//continuous writes / freeze
if (*localPlayerPtr)
{
if (bHealth)
{
*(int*)(*localPlayerPtr + 0xF8) = 1337;
}
if (bAmmo)
{
*(int*)mem::FindDMAAddy(moduleBase + 0x10F4F4, { 0x374, 0x14, 0x0 }) = 1337;
}
}
Draw();
return wglSwapBuffersGateway(hDc);
}
DWORD WINAPI HackThread(HMODULE hModule)
{
//Create Console
AllocConsole();
FILE* f;
freopen_s(&f, "CONOUT$", "w", stdout);
std::cout << "OG for a fee, stay sippin' fam\n";
// Hook
Hook SwapBuffersHook("wglSwapBuffers", "opengl32.dll", (BYTE*)hkwglSwapBuffers, (BYTE*)&wglSwapBuffersGateway, 5);
SwapBuffersHook.Enable();
if (GetAsyncKeyState(VK_END) & 1) {
SwapBuffersHook.Disable();
}
//fclose(f);
FreeConsole();
//FreeLibraryAndExitThread(hModule, 0);
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CloseHandle(CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)HackThread, hModule, 0, nullptr));
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}