-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
57 lines (43 loc) · 1.42 KB
/
Copy pathdllmain.cpp
File metadata and controls
57 lines (43 loc) · 1.42 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
#include "pch.h"
#include "config.h"
#include "logger.h"
#include "hook.h"
#include "hooks.h"
#define TARGET_PROCESS_NAME "CivilizationVI.exe"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
char aProcessName[MAX_PATH];
GetModuleFileNameA(NULL, aProcessName, MAX_PATH);
const std::string processPath = aProcessName;
const std::string processName = processPath.substr(processPath.find_last_of("\\") + 1);
if (processName != TARGET_PROCESS_NAME)
{
return TRUE;
}
const auto config = Config::Get();
if (config->bDebug)
{
AllocConsole();
SetConsoleTitle(L"Creco by CiVIH");
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
}
Logger::Log(Info, "Starting Creco...");
Localization_StringDictionary_HasKeyHook::Get();
PlaySoundHook::Get();
Hook::Initialize();
Logger::Log(Info, "Creco hooked and ready!");
Bridge::Get()->Start();
}
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
{
Logger::Log(Info, "Stopping Creco...");
Bridge::Get()->Stop();
Logger::Log(Info, "Creco stopped!");
}
return TRUE;
}