-
Notifications
You must be signed in to change notification settings - Fork 1
/
dllmain.cpp
43 lines (32 loc) · 1.25 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
#include <thread>
#include <Windows.h>
#include "Logger.hpp"
#include "Utility.hpp"
#include "Defines.hpp"
#include "Instance.hpp"
DWORD WINAPI Initialize(LPVOID data)
{
const HMODULE hModule = reinterpret_cast<HMODULE>(data);
while (!Memory::GetBaseModuleHandle("navsystem.dll") || !Memory::GetBaseModuleHandle("matchmaking.dll"))
std::this_thread::sleep_for(std::chrono::milliseconds(250));
Logger::Initialize();
Logger::Info("Initialized logger.");
Utility::Initialize(hModule, FOLDER_PATH, FILE_EXTENSION);
Instance::Initialize(hModule);
while (!Instance::Unload)
std::this_thread::sleep_for(std::chrono::milliseconds(50));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
FreeLibraryAndExitThread(reinterpret_cast<HMODULE>(data), EXIT_SUCCESS);
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD callReason, LPVOID lpReserved)
{
if (callReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
if (const HANDLE threadHandle = CreateThread(NULL, NULL, Initialize, hModule, NULL, NULL); threadHandle != nullptr)
CloseHandle(threadHandle);
}
if (callReason == DLL_PROCESS_DETACH && !lpReserved)
Instance::Shutdown();
return TRUE;
}