Skip to content

Commit

Permalink
Merge pull request oneapi-src#1673 from kswiecicki/adapters-search-wi…
Browse files Browse the repository at this point in the history
…n-fix

[UR] Fix adapter search on Windows
  • Loading branch information
kbenzie authored Jun 5, 2024
2 parents f06bc02 + 5263630 commit 5136177
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 5136177

Please sign in to comment.