From 81ee6a47b010f233bf6857406695ff776a37f468 Mon Sep 17 00:00:00 2001 From: Baldur Karlsson Date: Wed, 6 Aug 2014 11:50:37 +0100 Subject: [PATCH] Refresh module handle if NULL when hitting GetProcAddress * This might be a more serious problem in future... * We only hook all loaded modules once, at init time, in Win32_IAT_EndHooks * If a LoadLibrary call afterwards implicitly loads some modules we don't see them. Potentially we should rehook all loaded modules again each time LoadLibrary is called but then there would be a lot of redundant work unless we tracked module unload/loads to see if a module has been hooked before or not. For now assume we don't need to hook these modules and get away with just updating module handles --- renderdoc/os/win32/win32_hook.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index 244972f77..bb34f7897 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -220,6 +220,9 @@ FARPROC WINAPI Hooked_GetProcAddress(HMODULE mod, LPCSTR func) for(auto it=s_HookData->DllHooks.begin(); it != s_HookData->DllHooks.end(); ++it) { + if(it->second.module == NULL) + it->second.module = GetModuleHandleA(it->first.c_str()); + if(mod == it->second.module) { FunctionHook search(func, NULL, NULL);