Skip to content

Commit 8f8db09

Browse files
committed
Fix for people not using C: as the system drive
1 parent 9dd16ac commit 8f8db09

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

‎DirectXHook/DllMain.cpp‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ FARPROC originalFunctions[21];
77

88
DWORD WINAPI HookThread(LPVOID lpParam)
99
{
10-
originalDll = LoadLibrary("C:\\Windows\\System32\\dxgi.dll");
10+
Sleep(5000);
11+
std::string systemPath = "";
12+
char dummy[1];
13+
UINT pathLength = GetSystemDirectoryA(dummy, 1);
14+
systemPath.resize(pathLength);
15+
LPSTR lpSystemPath = const_cast<char*>(systemPath.c_str());
16+
GetSystemDirectoryA(lpSystemPath, systemPath.size());
17+
systemPath = lpSystemPath;
18+
originalDll = LoadLibraryA(std::string(systemPath + "\\dxgi.dll").c_str());
1119
if (originalDll)
1220
{
1321
// Set function addresses we need for forward exporting

‎DirectXHook/Logger.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <string>
4+
#include <cstdarg>
45

56
class Logger
67
{
@@ -12,7 +13,7 @@ class Logger
1213
FILE* logFile = LogFile(nullptr);
1314
if (logFile == nullptr)
1415
{
15-
fopen_s(&logFile, "hook_log.txt", "w");
16+
fopen_s(&logFile, "directx_hook_log.txt", "w");
1617
LogFile(logFile);
1718
}
1819
}

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## DirectXHook + Overlay Framework
22
This is a DirectX hook that works with DirectX 11 and DirectX 12. A straightforward but primitive overlay framework is included.
33

4+
**The readme is a little bit outdated because I restructured the code for higher stability a while back.**
5+
46
### Overlay examples
57
#### A mod for Monster Hunter Rise, ["Rise DPS Meter" found on NexusMods](https://www.nexusmods.com/monsterhunterrise/mods/289)
68

0 commit comments

Comments
 (0)