Skip to content

Commit

Permalink
[UR] Fix adapter search on Windows
Browse files Browse the repository at this point in the history
The loader mistakenly searched for adapters in the directory of the executable
that linked it, instead of its own directory.
  • Loading branch information
kswiecicki committed Jun 5, 2024
1 parent 8e47ab5 commit 5263630
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion source/loader/windows/adapter_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ namespace fs = filesystem;
namespace ur_loader {

std::optional<fs::path> getLoaderLibPath() {
HMODULE hModule = NULL;
char pathStr[MAX_PATH_LEN_WIN];
if (GetModuleFileNameA(nullptr, pathStr, MAX_PATH_LEN_WIN)) {

if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCSTR>(&getLoaderLibPath),
&hModule) &&
GetModuleFileNameA(hModule, pathStr, MAX_PATH_LEN_WIN)) {
auto libPath = fs::path(pathStr);
if (fs::exists(libPath)) {
return fs::absolute(libPath).parent_path();
Expand Down

0 comments on commit 5263630

Please sign in to comment.