-
Notifications
You must be signed in to change notification settings - Fork 11
/
HackFunction.cpp
311 lines (289 loc) · 9.45 KB
/
HackFunction.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#include "stdafx.h"
#include "HackFunction.h"
#include "QQMacro.h"
#include "newMenu.h"
#include "utils.h"
#define infoBaseAddress 0x024B16BC //00 00 EF 28 18 57 C2 20 00 00 00 00 00 00
//#define infoBaseAddress 0x024B26BC //00 00 EF 28 18 57 C2 20 00 00 00 00 00 00
#define weaponBaseAddress 0x024DA524 //00 A8 7F 90 40 1A 4C 18 01 00 00 00 00 00 00 00
//#define weaponBaseAddress 0x024D9BCC //00 A8 7F 90 40 1A 4C 18 01 00 00 00 00 00 00 00
using namespace function;
class Memory memory;
BYTE orignal_name[22] = { NULL };
std::wstring utf8_to_utf16(const std::string& utf8)
{
std::vector<unsigned long> unicode;
size_t i = 0;
while (i < utf8.size())
{
unsigned long uni;
size_t todo;
bool error = false;
unsigned char ch = utf8[i++];
if (ch <= 0x7F)
{
uni = ch;
todo = 0;
}
else if (ch <= 0xBF)
{
throw std::logic_error("not a UTF-8 string");
}
else if (ch <= 0xDF)
{
uni = ch & 0x1F;
todo = 1;
}
else if (ch <= 0xEF)
{
uni = ch & 0x0F;
todo = 2;
}
else if (ch <= 0xF7)
{
uni = ch & 0x07;
todo = 3;
}
else
{
throw std::logic_error("not a UTF-8 string");
}
for (size_t j = 0; j < todo; ++j)
{
if (i == utf8.size())
throw std::logic_error("not a UTF-8 string");
unsigned char ch = utf8[i++];
if (ch < 0x80 || ch > 0xBF)
throw std::logic_error("not a UTF-8 string");
uni <<= 6;
uni += ch & 0x3F;
}
if (uni >= 0xD800 && uni <= 0xDFFF)
throw std::logic_error("not a UTF-8 string");
if (uni > 0x10FFFF)
throw std::logic_error("not a UTF-8 string");
unicode.push_back(uni);
}
std::wstring utf16;
for (size_t i = 0; i < unicode.size(); ++i)
{
unsigned long uni = unicode[i];
if (uni <= 0xFFFF)
{
utf16 += (wchar_t)uni;
}
else
{
uni -= 0x10000;
utf16 += (wchar_t)((uni >> 10) + 0xD800);
utf16 += (wchar_t)((uni & 0x3FF) + 0xDC00);
}
}
return utf16;
}
void DoChangeRank() {
if (menu::item::checkbox_ChangeRank) {
vector<DWORD> offsets = { 0x90, 0x48 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
WriteProcessMemory(utils::hProcess, (LPVOID)p, &menu::item::slider_Rank, sizeof(menu::item::slider_Rank), 0);
}
}
void DoChangeName() {
if (menu::item::checkbox_ChangeName) {
vector<DWORD> offsets = { 0x90, 0x28 };
//0242F044
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
if (p == 0) {
//error
console::message("ChangeName failed", 1);
}
else {
if (orignal_name[0] == 0x0) ReadProcessMemory(utils::hProcess, (LPCVOID)p, &orignal_name, sizeof(orignal_name), 0);
//41 00 48 00 51 00 20 00 41 00 66 00 74 00 65 00 52 00
//BYTE name[] = { 0x61, 0x00, 0x68, 0x00, 0x71, 0x00, 0x5F, 0x00, 0x41, 0x00, 0x66, 0x00, 0x74, 0x00, 0x65, 0x00, 0x52, 0x00 ,0x00 ,0x00, 0x00 ,0x00 };
wstring buf = utf8_to_utf16(menu::item::input_ChangeName);
const BYTE* w = reinterpret_cast<const BYTE*>(buf.c_str());
BYTE name[22] = { 0x0 };
for (int i = 0; i < sizeof(name) / sizeof(BYTE); ++i) {
name[i] = w[i];
}
WriteProcessMemory(utils::hProcess, (LPVOID)p, &name, sizeof(name), 0);
}
} else if(orignal_name[0] != 0x0) {
vector<DWORD> offsets = { 0x90, 0x28 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
if (p == 0) {
//error
console::message("ChangeName failed", 1);
}
else {
WriteProcessMemory(utils::hProcess, (LPVOID)p, &orignal_name, sizeof(orignal_name), 0);
}
}
}
void DoQQMacro() {
if (menu::item::checkbox_QQMacro && (GetAsyncKeyState(VK_LBUTTON) & 0x1) && utils::isFocusOnAVA && !menu::isMENU) {
function::QQMacro::doQQMacro();
}
}
void DoUnlimitAmmo() {
if (menu::item::checkbox_unlimitAmmo) {
vector<DWORD> offsets = { 0x428, 0x284, 0x7AE + 0x110 };
//vector<DWORD> offsets = { 0x428, 0x288, 0x7AE };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
BYTE myval[1] = { 0x1 };
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval, sizeof(myval), 0);
offsets = { 0x428, 0x284 + 0x4, 0x338 + 0xC };
p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
myval[0] = { 0x0 };
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval, sizeof(myval), 0);
}
}
void DoNoSpread() {
if (menu::item::checkbox_noSpread) {
//sway (unchecked)
vector<DWORD> offsets = { 0x428, 0x284, 0x87C + 0x110 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
float myval = 0;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval, sizeof(myval), 0);
//aim accuracy
offsets = { 0x428, 0x284, 0x8CC + 0x110 };
p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
int myval2 = 0;
if(!menu::item::checkbox_disableNoAccuracy) WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval2, sizeof(myval2), 0);
//crossfire size (unchecked)
offsets = { 0x428, 0x284, 0x7A9 + 0x110 };
p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
BYTE myval3 = 0x0;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval3, sizeof(myval3), 0);
//minCrossfire
/*
BYTE myvalmin = 0xc3;
WriteProcessMemory(utils::hProcess, (LPVOID)(utils::baseAddress + 0x8FABF0), &myvalmin, sizeof(myvalmin), 0);
*/
//no Spread (up down)
offsets = { 0x428, 0x284, 0x9BF + 0x110 };
p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
BYTE myval4 = 0x0;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval4, sizeof(myval4), 0);
//no Spread (left right)
offsets = { 0x428, 0x284, 0x9BB + 0x110 };
p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
BYTE myval5 = 0x0;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval5, sizeof(myval5), 0);
}
}
// (reload buggy)
void DoUAVHack() {
static bool isUav = false;
if (menu::item::checkbox_UAV) {
//UAV
vector<DWORD> offsets = { 0x428, 0x284, 0x7B6 + 0xC + 0x110 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
//BYTE myval = 0x50;
BYTE myval = 0xB0; //128
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval, sizeof(myval), 0);
isUav = true;
}
else if(isUav) {
//UAV
vector<DWORD> offsets = { 0x428, 0x284, 0x7B6 + 0xC + 0x110 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
//BYTE myval = 0xC0;
BYTE myval = 0x1; // 1
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval, sizeof(myval), 0);
isUav = false;
}
}
void DoSuperWeapon() {
static bool isSuperWeapon = false;
static int original_val = 0 ;
if (menu::item::checkbox_SuperWeapon) {
//SuperWeapon
vector<DWORD> offsets = { 0x428, 0x284, 0x7BC + 0xC + 0x110 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
int myval = menu::item::slider_superWeapon_ammo;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &myval, sizeof(myval), 0);
if (isSuperWeapon == false) ReadProcessMemory(utils::hProcess, (LPCVOID)p, &original_val, sizeof(original_val), 0);
isSuperWeapon = true;
}
else if(isSuperWeapon) {
//restore SuperWeapon
vector<DWORD> offsets = { 0x428, 0x284, 0x7BC + 0xC + 0x110 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
if (original_val == 0) original_val = 1;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &original_val, sizeof(original_val), 0);
isSuperWeapon = false;
}
}
/* not working */
void DoAntiReport() {
//6 in game
//5 in game room
//4 in channel
//3 in channel list
static bool anti = false;
if (menu::item::checkbox_antiReport) {
vector<DWORD> offsets = { 0x90, 0x0 };
BYTE v[1] = { 0x0 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
ReadProcessMemory(utils::hProcess, (LPCVOID)p, &v, sizeof(v), 0);
if (v[0] == 0x6) {
v[0] = 0x5;
WriteProcessMemory(utils::hProcess, (LPVOID)p, &v, sizeof(v), 0);
}
/*
if (v[0] == 0x5) {
ReadProcessMemory(utils::hProcess, (LPCVOID)(utils::baseAddress + weaponBaseAddress), &v, sizeof(v), 0);
if (v[0] > 1) { //is Ingame
v[0] = 0x6;
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
WriteProcessMemory(utils::hProcess, (LPVOID)p, &v, sizeof(v), 0);
}
}
*/
anti = true;
}
else {
/*
if (anti) {
BYTE val[1] = { 0x6 };
vector<DWORD> offsets = { 0x90, 0x0 };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + weaponBaseAddress, offsets);
WriteProcessMemory(utils::hProcess, (LPVOID)p, &val, sizeof(val), 0);
anti = false;
}
*/
}
}
/* is working ? */
void DoGainVIP() {
static bool isCheck = false;
if (menu::item::checkbox_gainVIP) {
vector<DWORD> offsets = { 0x90, 0x60 - 0xA };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
BYTE val[1] = { 0x1 };
WriteProcessMemory(utils::hProcess, (LPVOID)p, &val, sizeof(val), 0);
isCheck = true;
}
else {
if (isCheck) {
vector<DWORD> offsets = { 0x90, 0x60 - 0xA };
DWORD p = memory.readPointer(utils::hProcess, utils::baseAddress + infoBaseAddress, offsets);
BYTE val[1] = { 0x0 };
WriteProcessMemory(utils::hProcess, (LPVOID)p, &val, sizeof(val), 0);
isCheck = false;
}
}
}
void DoMemoryHack() {
DoQQMacro();
DoChangeRank();
DoChangeName();
DoUnlimitAmmo();
DoNoSpread();
DoUAVHack();
DoSuperWeapon();
DoAntiReport();
DoGainVIP();
}