GENERATE_INTERCEPT_HEADER(LoadLibraryExW, HMODULE, WINAPI, _In_ LPCWSTR lpLibFileName, _Reserved_ HANDLE hFile, _In_ DWORD dwFlags) { SDLOG(2, "DetouredLoadLibraryExW %s\n", CW2A(lpLibFileName)); string fn((CW2A(lpLibFileName))); if(fn.find("GeDoSaTo") != fn.npos) return GetCurrentModule(); // find out why we need this HMODULE mod = TrueLoadLibraryExW(lpLibFileName, hFile, dwFlags); // restart detour in case we missed anything if(mod) restartDetour(CW2A(lpLibFileName)); return mod; }
HMODULE WINAPI HookLL::HookLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) { if (!InputHookManager::Get().GetInputHook().GetState(InputHook::HOOK_LL)) return TrueLoadLibraryExW(lpLibFileName, hFile, dwFlags); if (SelfCheckW(lpLibFileName)) { PrintLog("LoadLibraryExW"); InputHookManager::Get().GetInputHook().StartTimeoutThread(); std::wstring path; if (ModulePath(&path, InputHookManager::Get().GetInputHook().GetEmulator())) return TrueLoadLibraryExW(path.c_str(), hFile, dwFlags); else return TrueLoadLibraryExW(lpLibFileName, hFile, dwFlags); } return TrueLoadLibraryExW(lpLibFileName, hFile, dwFlags); }