-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDllMain.cpp
63 lines (53 loc) · 1.16 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
60
61
62
63
/*!
@author Arves100
@brief DLL Entrypoint
@date 01/11/2020
*/
#include "StdAfx.h"
#include "Globals.h"
#include "LDetours.h"
#ifdef _DEBUG
static BOOL InitDbgConsole()
{
if (!AllocConsole())
{
MessageBox(nullptr, L"Unable to initialize the debug console", L"Fatal error", MB_OK | MB_ICONERROR);
return FALSE;
}
FILE* d;
freopen_s(&d, "CONOUT$", "w", stderr);
freopen_s(&d, "CONOUT$", "w", stdout);
SetConsoleTitle(L"Fur Fighters - Loader console");
printf("Build: %s (Arves100)\n", __TIMESTAMP__);
return TRUE;
}
static void DelDbgConsole()
{
FreeConsole();
}
#endif
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
#ifdef _DEBUG
if (!InitDbgConsole())
return FALSE;
#endif
if (!Globals::Get()->TheLoader->Init())
return FALSE;
DetourInit();
break;
default:
break;
case DLL_PROCESS_DETACH:
DetourDeinit();
delete Globals::Get();
#ifdef _DEBUG
DelDbgConsole();
#endif
break;
}
return TRUE;
}