From 48f4ac3edbd38ef6200595cc5923f1126a2b6d37 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 11 Oct 2018 14:04:08 +0100 Subject: [PATCH] Re-fetch original function pointers if hooked DLL reloads somewhere else --- renderdoc/os/win32/win32_hook.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index a6734f899..2c01d1856 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -256,6 +256,16 @@ struct CachedHookData { // previous module is no longer loaded or there's a new file there now, add this as the // new location + RDCWARN("%s moved from %p to %p, re-initialising orig pointers", it->first.c_str(), + it->second.module, module); + + // we also need to re-initialise the hooks as the orig pointers are now stale + for(FunctionHook &hook : it->second.FunctionHooks) + { + if(hook.orig) + *hook.orig = GetProcAddress(module, hook.function.c_str()); + } + it->second.module = module; } }