File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44#include " df/gamest.h"
55
6+ #ifdef _WIN32
7+ # define WIN32_LEAN_AND_MEAN
8+ # include < Windows.h>
9+ # include < libloaderapi.h>
10+ #else
11+ # include < dlfcn.h>
12+ #endif
13+
614static bool disabled = false ;
715
816DFhackCExport const int32_t dfhooks_priority = 100 ;
917
10- static std::filesystem::path basepath{" ./hack" };
18+ static std::filesystem::path getModulePath ()
19+ {
20+ #ifdef _WIN32
21+ HMODULE module = nullptr ;
22+ GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)getModulePath, &module );
23+ if (!module ) return std::filesystem::path (); // should never happen, but just in case, return an empty path instead of crashing
24+
25+ wchar_t path[MAX_PATH];
26+ GetModuleFileNameW (module , path, MAX_PATH);
27+ return std::filesystem::path (path);
28+ #else
29+ DL_info info;
30+ dladdr (getModulePath, &info);
31+ return std::filesystem::path (info.dli_fname );
32+ #endif
33+ }
34+
35+ static std::filesystem::path basepath{getModulePath ()};
1136
1237// called by the chainloader before the main thread is initialized and before any other hooks are called.
1338DFhackCExport void dfhooks_preinit (std::filesystem::path dllpath)
You can’t perform that action at this time.
0 commit comments