-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackModule.cpp
More file actions
77 lines (70 loc) · 1.84 KB
/
HackModule.cpp
File metadata and controls
77 lines (70 loc) · 1.84 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
#include "HackModule.hpp"
constexpr auto sleepTime = std::chrono::milliseconds(200);
void threadWorker(bool& enabled, std::string moduleName, char& activateKey, Proc& proc, size_t& address, std::vector<uint8_t>& replacement)
{
bool previousEnable = enabled;
while (1)
{
if (proc.closed)
{
std::cout << "Proc closed, closing " << moduleName << '\n';
break;
}
if (_getch() == activateKey)
{
std::cout << "Toggled " << moduleName << '\n';
enabled = !enabled;
}
else if (_getch() == 'n')
{
proc.~Proc();
}
if (previousEnable != enabled)
{
switch (enabled)
{
case true:
//switch the feature on
std::cout << "1\n";
break;
case false:
//switch feature off
std::cout << "0\n";
break;
}
//optimization to put it here
previousEnable = enabled;
}
std::this_thread::sleep_for(sleepTime);
}
}
HackModule::HackModule(std::vector<uint8_t> aob, std::vector<uint8_t> replacementBytes, std::string moduleName, Proc& proc, bool enabled, char keyActivate) : aob(aob), replace(replacementBytes), enabled(enabled), keyActivate(keyActivate)
{
//aob scan when we init the module
if (proc.AOBScanUsefulRegions(aob, this->address))
{
//successfully scanned, proceed with everything.
std::cout << "Successfully scanned with address " << std::hex << this->address << std::dec << ", creating thread...\n";
std::thread worker(threadWorker, std::ref(enabled), moduleName, std::ref(keyActivate),
std::ref(proc), std::ref(address), std::ref(replacementBytes));
worker.detach();
}
else
{
//not scanned.
Close(1);
return;
}
}
void HackModule::Close(int code = 0)
{
switch (code)
{
case 0: //this is regular
break;
case 1: //AOB scan went wrong
//handle it
std::cerr << "AOB scan went wrong!\n";
break;
}
}