-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
83 lines (61 loc) · 1.55 KB
/
Copy pathmain.cpp
File metadata and controls
83 lines (61 loc) · 1.55 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
78
79
80
81
82
83
#include <chrono>
#include <thread>
#include <Windows.h>
#include "Hooks.h"
#include "Menu.h"
#include "SDK/SDK.h"
#include "Utilities/Options.h"
#include "Utilities/Utils.h"
#include "Utilities/Config/Config.h"
#include "Utilities/Render/Render.h"
#include <windows.h>
unsigned long WINAPI Init(void* instance)
{
while (!GetModuleHandleA("serverbrowser.dll"))
Sleep(200);
#ifdef _DEBUG
Utils::AttachConsole("Wiiner");
#endif
try
{
Interfaces::Init();
Hooks::Init();
Render::Init();
C::Setup("default.cfg");
} catch (const std::runtime_error& error)
{
MessageBoxA(nullptr, error.what(), "GBase Error!", MB_OK | MB_ICONERROR);
FreeLibraryAndExitThread(static_cast<HMODULE>(instance), 0);
}
while (!GetAsyncKeyState(VK_END))
std::this_thread::sleep_for(std::chrono::milliseconds(50));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
FreeLibraryAndExitThread(static_cast<HMODULE>(instance), 0);
}
unsigned long WINAPI Detach()
{
#ifdef _DEBUG
Utils::DetachConsole();
#endif
Hooks::Detatch();
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, Init, instance, NULL, nullptr))
{
CloseHandle(handle);
}
break;
}
case DLL_PROCESS_DETACH: {
Detach();
break;
}
}
return true;
}