forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
65 lines (53 loc) · 1.86 KB
/
main.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
64
65
/**
* Copyright (C) 2014 Patrick Mours. All rights reserved.
* License: https://github.com/crosire/reshade#license
*/
#include "log.hpp"
#include "filesystem.hpp"
#include "input.hpp"
#include "runtime.hpp"
#include "hook_manager.hpp"
#include "version.h"
#include <Windows.h>
HMODULE g_module_handle = nullptr;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpvReserved)
{
UNREFERENCED_PARAMETER(lpvReserved);
using namespace reshade;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
g_module_handle = hModule;
runtime::s_reshade_dll_path = filesystem::get_module_path(hModule);
runtime::s_target_executable_path = filesystem::get_module_path(nullptr);
const filesystem::path system_path = filesystem::get_special_folder_path(filesystem::special_folder::system);
log::open(filesystem::path(runtime::s_reshade_dll_path).replace_extension(".log"));
#ifdef WIN64
#define VERSION_PLATFORM "64-bit"
#else
#define VERSION_PLATFORM "32-bit"
#endif
LOG(INFO) << "Initializing crosire's ReShade version '" VERSION_STRING_FILE "' (" << VERSION_PLATFORM << ") built on '" VERSION_DATE " " VERSION_TIME "' loaded from " << runtime::s_reshade_dll_path << " to " << runtime::s_target_executable_path << " ...";
hooks::register_module(system_path / "d3d9.dll");
hooks::register_module(system_path / "d3d10.dll");
hooks::register_module(system_path / "d3d10_1.dll");
hooks::register_module(system_path / "d3d11.dll");
hooks::register_module(system_path / "dxgi.dll");
hooks::register_module(system_path / "opengl32.dll");
hooks::register_module(system_path / "user32.dll");
hooks::register_module(system_path / "ws2_32.dll");
LOG(INFO) << "Initialized.";
break;
}
case DLL_PROCESS_DETACH:
{
LOG(INFO) << "Exiting ...";
input::uninstall();
hooks::uninstall();
LOG(INFO) << "Exited.";
break;
}
}
return TRUE;
}