Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit d282449

Browse files
committed
Fix up dll search paths when force-loading interposers
1 parent 95f49c1 commit d282449

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

source/wrapper_generic/dllmain.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ HMODULE WINAPI HookedLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD d
6666
{
6767
HMODULE libraryHandle = nullptr;
6868

69-
if (RedirectModule(lpLibFileName, &libraryHandle))
70-
return libraryHandle;
71-
else
69+
if (!RedirectModule(lpLibFileName, &libraryHandle))
7270
libraryHandle = LoadLibraryExW(lpLibFileName, hFile, dwFlags);
7371

7472
PatchImportsForModule(lpLibFileName, libraryHandle);
@@ -79,9 +77,7 @@ HMODULE WINAPI HookedLoadLibraryW(LPCWSTR lpLibFileName)
7977
{
8078
HMODULE libraryHandle = nullptr;
8179

82-
if (RedirectModule(lpLibFileName, &libraryHandle))
83-
return libraryHandle;
84-
else
80+
if (!RedirectModule(lpLibFileName, &libraryHandle))
8581
libraryHandle = LoadLibraryW(lpLibFileName);
8682

8783
PatchImportsForModule(lpLibFileName, libraryHandle);
@@ -184,7 +180,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
184180

185181
wcscat_s(path, interposer);
186182

187-
if (LoadLibraryW(path))
183+
if (LoadLibraryExW(path, nullptr, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS))
188184
break;
189185
}
190186
}

0 commit comments

Comments
 (0)