Skip to content

Commit 5136177

Browse files
authored
Merge pull request #1673 from kswiecicki/adapters-search-win-fix
[UR] Fix adapter search on Windows
2 parents f06bc02 + 5263630 commit 5136177

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

source/loader/windows/adapter_search.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ namespace fs = filesystem;
2323
namespace ur_loader {
2424

2525
std::optional<fs::path> getLoaderLibPath() {
26+
HMODULE hModule = NULL;
2627
char pathStr[MAX_PATH_LEN_WIN];
27-
if (GetModuleFileNameA(nullptr, pathStr, MAX_PATH_LEN_WIN)) {
28+
29+
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
30+
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
31+
reinterpret_cast<LPCSTR>(&getLoaderLibPath),
32+
&hModule) &&
33+
GetModuleFileNameA(hModule, pathStr, MAX_PATH_LEN_WIN)) {
2834
auto libPath = fs::path(pathStr);
2935
if (fs::exists(libPath)) {
3036
return fs::absolute(libPath).parent_path();

0 commit comments

Comments
 (0)