-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.cpp
62 lines (47 loc) · 1.45 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
#include "../dependencies/utilities/csgo.hpp"
#include "features/features.hpp"
unsigned long WINAPI initialize(void* instance) {
while (!GetModuleHandleA("serverbrowser.dll"))
Sleep(200);
#ifdef _DEBUG
console::initialize("csgo-cheat console");
#endif
try {
interfaces::initialize();
render::initialize();
hooks::initialize();
}
catch (const std::runtime_error & error) {
MessageBoxA(nullptr, error.what(), "csgo-cheat error!", MB_OK | MB_ICONERROR);
FreeLibraryAndExitThread(static_cast<HMODULE>(instance), 0);
}
while (!GetAsyncKeyState(VK_END))
std::this_thread::sleep_for(std::chrono::milliseconds(50));
//close menu so input is restored to user in the hooks::paint_traverse::hook hook.
variables::menu::opened = false;
//wait for paint_traverse::hook to be called and restore input.
std::this_thread::sleep_for(std::chrono::milliseconds(50));
FreeLibraryAndExitThread(static_cast<HMODULE>(instance), 0);
}
unsigned long WINAPI release() {
hooks::release();
#ifdef _DEBUG
console::release();
#endif
return TRUE;
}
std::int32_t WINAPI DllMain(const HMODULE instance [[maybe_unused]], const unsigned long reason, const void* reserved [[maybe_unused]] ) {
DisableThreadLibraryCalls(instance);
switch (reason) {
case DLL_PROCESS_ATTACH: {
if (auto handle = CreateThread(nullptr, NULL, initialize, instance, NULL, nullptr))
CloseHandle(handle);
break;
}
case DLL_PROCESS_DETACH: {
release();
break;
}
}
return true;
}