-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
228 lines (187 loc) · 8.35 KB
/
main.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include "memory.h"
#include "vector.h"
#include <thread>
#include <functional>
#include <Windows.h>
namespace offset
{
// all offsets are named as they are named in the hazedumper file included.
constexpr ::std::ptrdiff_t dwLocalPlayer = 0xDEF97C;
constexpr ::std::ptrdiff_t dwEntityList = 0x4E051DC;
constexpr ::std::ptrdiff_t dwViewMatrix = 0x4DF6024;
constexpr ::std::ptrdiff_t dwClientState = 0x59F19C;
constexpr ::std::ptrdiff_t dwClientState_ViewAngles = 0x4D90;
constexpr ::std::ptrdiff_t dwClientState_GetLocalPlayer = 0x180;
constexpr ::std::ptrdiff_t m_dwBoneMatrix = 0x26A8;
constexpr ::std::ptrdiff_t m_bDormant = 0xED;
constexpr ::std::ptrdiff_t m_iTeamNum = 0xF4;
constexpr ::std::ptrdiff_t m_lifeState = 0x25F;
constexpr ::std::ptrdiff_t m_vecOrigin = 0x138;
constexpr ::std::ptrdiff_t m_vecViewOffset = 0x108;
constexpr ::std::ptrdiff_t m_aimPunchAngle = 0x303C;
constexpr ::std::ptrdiff_t m_bSpottedByMask = 0x980;
constexpr ::std::ptrdiff_t dwForceJump = 0x52C0F50;
constexpr ::std::ptrdiff_t m_fFlags = 0x104;
constexpr ::std::ptrdiff_t dwGlowObjectManager = 0x535FCB8;
constexpr ::std::ptrdiff_t m_iGlowIndex = 0x10488;
constexpr ::std::ptrdiff_t dwForceAttack = 0x3233024;
constexpr ::std::ptrdiff_t m_iCrosshairId = 0x11838;
}
struct Color
{
constexpr Color(float r, float g, float b, float a = 1.f) noexcept :
r(r), g(g), b(b), a(a) {}
float r, g, b, a;
};
Vector3 CalculateAngle(
const Vector3& localPosition,
const Vector3& enemyPosition,
const Vector3& viewAngles) noexcept
{
return ((enemyPosition - localPosition).ToAngle() - viewAngles);
}
void GlowLogic(Memory& memory, uintptr_t client, int localTeam)
{
const auto color = Color(1.f, 1.f, 1.f);
while (true)
{
std::this_thread::sleep_for(std::chrono::milliseconds(0));
for (auto i = 1; i <= 64; ++i)
{
const auto player = memory.Read<std::uintptr_t>(client + offset::dwEntityList + i * 0x10);
if (player == 0) continue;
const auto teamNum = memory.Read<std::int32_t>(player + offset::m_iTeamNum);
const auto lifeState = memory.Read<std::int32_t>(player + offset::m_lifeState);
if (teamNum != localTeam && lifeState == 0)
{
const auto glowObjectManager = memory.Read<std::uintptr_t>(client + offset::dwGlowObjectManager);
const auto glowIndex = memory.Read<std::int32_t>(player + offset::m_iGlowIndex);
if (glowIndex >= 0)
{
memory.Write<Color>(glowObjectManager + (glowIndex * 0x38) + 0x8, color); // Color
memory.Write<bool>(glowObjectManager + (glowIndex * 0x38) + 0x27, true); // Render
memory.Write<bool>(glowObjectManager + (glowIndex * 0x38) + 0x28, true); // Render
}
}
}
}
}
// Bunny hop logic
void BunnyHop(Memory& memory, uintptr_t client, uintptr_t localPlayer) {
while (true) {
const auto onground = memory.Read<std::int32_t>(localPlayer + offset::m_fFlags);
if (GetAsyncKeyState(VK_SPACE) && (onground & (1 << 0))) {
memory.Write<BYTE>(client + offset::dwForceJump, 6);
}
std::this_thread::sleep_for(std::chrono::milliseconds(0));
}
}
// Triggerbot logic
void TriggerBot(Memory& memory, uintptr_t client, uintptr_t localPlayer) {
while (true) {
if (GetAsyncKeyState(VK_XBUTTON2)) { // Mouse button for triggerbot
const auto crosshairId = memory.Read<std::int32_t>(localPlayer + offset::m_iCrosshairId);
if (crosshairId > 0 && crosshairId <= 64) {
const auto target = memory.Read<uintptr_t>(client + offset::dwEntityList + (crosshairId - 1) * 0x10);
const auto targetTeam = memory.Read<std::int32_t>(target + offset::m_iTeamNum);
const auto localTeam = memory.Read<std::int32_t>(localPlayer + offset::m_iTeamNum);
if (targetTeam != localTeam) {
memory.Write<int>(client + offset::dwForceAttack, 6);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
memory.Write<int>(client + offset::dwForceAttack, 4);
}
}
}
}
}
// Main Thread
int main()
{
Memory memory{ "csgo.exe" };
const auto client = memory.GetModuleAddress("client.dll");
const auto engine = memory.GetModuleAddress("engine.dll");
if (!engine || !client)
{
printf("Couldn't find client.dll or engine.dll");
return -1;
}
else
{
printf("Hooked\n");
}
const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::dwLocalPlayer);
if (localPlayer == 0)
return 1;
const auto localTeam = memory.Read<std::int32_t>(localPlayer + offset::m_iTeamNum);
std::thread glowThread([&memory, client, localTeam]() {
printf("Glow thread initialized\n");
GlowLogic(memory, client, localTeam);
});
std::thread bunnyHopThread([&memory, client, localPlayer]() {
printf("BunnyHop thread initialized\n");
BunnyHop(memory, client, localPlayer);
});
std::thread triggerBotThread([&memory, client, localPlayer]() {
printf("Triggerbot thread initialized\n");
TriggerBot(memory, client, localPlayer);
});
while (true)
{
const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::dwLocalPlayer);
if (localPlayer == 0)
continue;
const auto localTeam = memory.Read<std::int32_t>(localPlayer + offset::m_iTeamNum);
const auto localEyePosition = memory.Read<Vector3>(localPlayer + offset::m_vecOrigin) +
memory.Read<Vector3>(localPlayer + offset::m_vecViewOffset);
const auto clientState = memory.Read<std::uintptr_t>(engine + offset::dwClientState);
const auto localPlayerId = memory.Read<std::int32_t>(clientState + offset::dwClientState_GetLocalPlayer);
const auto viewAngles = memory.Read<Vector3>(clientState + offset::dwClientState_ViewAngles);
const auto aimPunch = memory.Read<Vector3>(localPlayer + offset::m_aimPunchAngle) * 2;
auto bestFov = 360.f;
auto bestAngle = Vector3{};
bool foundValidTarget = false;
if (GetAsyncKeyState(VK_XBUTTON2))
{
for (auto i = 1; i <= 64; ++i)
{
const auto player = memory.Read<std::uintptr_t>(client + offset::dwEntityList + i * 0x10);
if (player == 0)
continue;
const auto teamNum = memory.Read<std::int32_t>(player + offset::m_iTeamNum);
const auto lifeState = memory.Read<std::int32_t>(player + offset::m_lifeState);
if (teamNum == localTeam || lifeState != 0)
continue;
const auto boneMatrix = memory.Read<std::uintptr_t>(player + offset::m_dwBoneMatrix);
if (boneMatrix == 0)
continue;
const auto playerHeadPosition = Vector3{
memory.Read<float>(boneMatrix + 0x30 * 8 + 0x0C),
memory.Read<float>(boneMatrix + 0x30 * 8 + 0x1C),
memory.Read<float>(boneMatrix + 0x30 * 8 + 0x2C)
};
if (playerHeadPosition == Vector3{})
continue;
const auto angle = CalculateAngle(
localEyePosition,
playerHeadPosition,
viewAngles + aimPunch);
const auto fov = std::hypot(angle.x, angle.y);
if (fov < bestFov)
{
bestFov = fov;
bestAngle = angle;
foundValidTarget = true;
}
}
if (foundValidTarget)
{
memory.Write<Vector3>(clientState + offset::dwClientState_ViewAngles, viewAngles + bestAngle / 1);
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
glowThread.join();
bunnyHopThread.join();
triggerBotThread.join();
return 0;
}