-
Notifications
You must be signed in to change notification settings - Fork 7
/
dllmain.cpp
59 lines (45 loc) · 1.13 KB
/
dllmain.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
#include "hooks/hooks.h"
BOOL WINAPI dll_detach()
{
hooks::shutdown();
render_manager::shutdown();
#ifdef _DEBUG
utilities::detach_console();
#endif
return TRUE;
}
DWORD WINAPI dll_entry(LPVOID thread_parameter)
{
while (!utilities::game_is_full_loaded())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#ifdef _DEBUG
utilities::attach_console();
#endif
interfaces::initialize();
hooks::initialize();
while (!globals::unload)
std::this_thread::sleep_for(std::chrono::milliseconds(100));
dll_detach();
FreeLibraryAndExitThread(static_cast<HMODULE>(thread_parameter), EXIT_SUCCESS);
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(instance);
HANDLE handle = CreateThread(nullptr, NULL, dll_entry, instance, NULL, nullptr);
if (handle)
CloseHandle(handle);
break;
}
case DLL_PROCESS_DETACH:
{
if (reserved == nullptr)
dll_detach();
break;
}
}
return TRUE;
}