From e73c3a0d6b8c387fec3cd6b32d21ed1dddfe4bb5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 11 Feb 2019 14:34:26 +0000 Subject: [PATCH] When plt hooking on linux, need to patch all hooked functions * If a library is loaded as RTLD_DEEPBIND it might be linked directly against libGL, in which case we need to plt hook the functions we care about as well as just dlopen. --- renderdoc/os/posix/linux/linux_hook.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/renderdoc/os/posix/linux/linux_hook.cpp b/renderdoc/os/posix/linux/linux_hook.cpp index bc65bae2d..7e964d1cc 100644 --- a/renderdoc/os/posix/linux/linux_hook.cpp +++ b/renderdoc/os/posix/linux/linux_hook.cpp @@ -85,6 +85,15 @@ void plthook_lib(void *handle) return; plthook_replace(plthook, "dlopen", (void *)dlopen, NULL); + + for(FunctionHook &hook : functionHooks) + { + void *orig = NULL; + plthook_replace(plthook, hook.function.c_str(), hook.hook, &orig); + if(hook.orig && *hook.orig == NULL && orig) + *hook.orig = orig; + } + plthook_close(plthook); }