-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllmain.cpp
139 lines (116 loc) · 2.98 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include "mem.h"
#include "proc.h"
// Created with ReClass.NET 1.2 by KN4CK3R
struct Vector3 { float x, y, z; };
#define STR_MERGE_IMPL(a, b) a##b
#define STR_MERGE(a, b) STR_MERGE_IMPL(a, b)
#define MAKE_PAD(size) STR_MERGE(_pad, __COUNTER__)[size]
#define DEFINE_MEMBER_N(type, name, offset) struct {unsigned char MAKE_PAD(offset); type name;}
class weapon
{
public:
union
{
DEFINE_MEMBER_N(int*, ammoptr, 0x0014);
};
};
class ent
{
public:
union
{
DEFINE_MEMBER_N(Vector3, poshead, 0x0004);
DEFINE_MEMBER_N(Vector3, pos, 0x0034);
DEFINE_MEMBER_N(Vector3, angle, 0x0040);
DEFINE_MEMBER_N(int32_t, health, 0x00F8);
DEFINE_MEMBER_N(int32_t, armor, 0x00FC);
DEFINE_MEMBER_N(weapon*, curweapon, 0x0374);
};
};
DWORD WINAPI HackThread(HMODULE hModule)
{
// create console
AllocConsole();
FILE* f;
freopen_s(&f, "CONOUT$", "w", stdout);
std::cout << "Hi\n";
// get module base
uintptr_t moduleBase = (uintptr_t)GetModuleHandle(L"ac_client.exe");
bool bHealth = false, bAmmo = false, bRecoil = false, bArmor = false;
// hack loop
while (true)
{
// key input
if (GetAsyncKeyState(VK_END) & 1)
{
break;
}
if (GetAsyncKeyState(VK_F1) & 1)
{
bHealth = !bHealth;
}
if (GetAsyncKeyState(VK_F2) & 1)
{
bAmmo = !bAmmo;
}
if (GetAsyncKeyState(VK_F3) & 1)
{
bRecoil = !bRecoil;
if (bRecoil)
{
mem::Nop((BYTE*)(moduleBase + 0x63786), 10);
}
else
{
mem::Patch((BYTE*)(moduleBase + 0x63786), (BYTE*)"\x50\x8d\x4c\x24\x1c\x51\x8b\xce\xff\xd2", 10);
}
}
if (GetAsyncKeyState(VK_F4) & 1)
{
bArmor = !bArmor;
}
// continus write/freeze
ent* localPlayer = *(ent**)(moduleBase + 0x10f4f4);
if (localPlayer)
{
if (bHealth)
{
localPlayer->health = 1337;
}
if (bArmor)
{
localPlayer->armor = 1337;
}
if (bAmmo)
{
*localPlayer->curweapon->ammoptr = 1337;
}
}
Sleep(5);
}
// cleanup & eject
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;
}