-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDllMain.cpp
More file actions
74 lines (60 loc) · 1.61 KB
/
Copy pathDllMain.cpp
File metadata and controls
74 lines (60 loc) · 1.61 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
#include "core/engine/LuaEngine.h"
#include "hooks/Hooks.h"
#include "hooks/FrameHooks.h"
#include "hooks/GlueHooks.h"
#include "core/native/GlueAPI.h"
#include "hooks/ConsoleHooks.h"
#include "runtime/Runtime.h"
#include "runtime/console/ConsoleManager.h"
#include "runtime/console/LogCapture.h"
#include "runtime/events/EventPipe.h"
#include <Windows.h>
#include <deps/Detours/detours.h>
static void OnAttach()
{
Runtime::LogCapture::Initialize();
Runtime::LogCapture::SetConfig(256, false);
Hooks::Console::SetCallback(Runtime::LogCapture::OnConsoleMessage);
Runtime::EventPipe::Initialize();
DetourTransactionBegin();
Hooks::initialize();
DetourTransactionCommit();
Hooks::Frame::Initialize();
Hooks::Glue::Initialize();
LuaEngine::initialize();
Runtime::initialize();
Hooks::Frame::SetOnFrame(Runtime::onFrame);
}
static void OnDetach()
{
Runtime::LogCapture::Shutdown();
Runtime::EventPipe::Shutdown();
Hooks::Events::Shutdown();
Hooks::Frame::Shutdown();
Hooks::Glue::Shutdown();
LuaEngine::shutdown();
Runtime::shutdown();
Runtime::ConsoleManager::Shutdown();
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID)
{
if (reason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
CreateThread(
nullptr,
0,
[](LPVOID) -> DWORD
{
OnAttach();
return 0;
},
nullptr,
0,
nullptr
);
}
else if (reason == DLL_PROCESS_DETACH) {
OnDetach();
}
return TRUE;
}