Skip to content

Commit 5263630

Browse files
committed
[UR] Fix adapter search on Windows
The loader mistakenly searched for adapters in the directory of the executable that linked it, instead of its own directory.
1 parent 8e47ab5 commit 5263630

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)