From 3d47587957e989794d6f04cb8b3e77ba7adaef53 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 23 Aug 2015 21:47:56 +0200 Subject: [PATCH] Add Process::LoadLibrary OS-specific function --- renderdoc/os/linux/linux_process.cpp | 5 +++++ renderdoc/os/os_specific.h | 1 + renderdoc/os/win32/win32_process.cpp | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/renderdoc/os/linux/linux_process.cpp b/renderdoc/os/linux/linux_process.cpp index 5e31606ee..af1cb2adc 100644 --- a/renderdoc/os/linux/linux_process.cpp +++ b/renderdoc/os/linux/linux_process.cpp @@ -396,6 +396,11 @@ void Process::StartGlobalHook(const char *pathmatch, const char *logfile, const RDCUNIMPLEMENTED("Global hooking of all processes on linux"); } +bool Process::LoadLibrary(const char *module) +{ + return dlopen(module, RTLD_NOW) != NULL; +} + void *Process::GetFunctionAddress(const char *module, const char *function) { void *handle = dlopen(module, RTLD_NOW); diff --git a/renderdoc/os/os_specific.h b/renderdoc/os/os_specific.h index 3eb968104..998735822 100644 --- a/renderdoc/os/os_specific.h +++ b/renderdoc/os/os_specific.h @@ -50,6 +50,7 @@ namespace Process uint32_t LaunchProcess(const char *app, const char *workingDir, const char *cmdLine); uint32_t LaunchAndInjectIntoProcess(const char *app, const char *workingDir, const char *cmdLine, const char *logfile, const CaptureOptions *opts, bool waitForExit); + bool LoadLibrary(const char *module); void *GetFunctionAddress(const char *module, const char *function); uint32_t GetCurrentPID(); }; diff --git a/renderdoc/os/win32/win32_process.cpp b/renderdoc/os/win32/win32_process.cpp index bf3cf1dd8..b9309d325 100644 --- a/renderdoc/os/win32/win32_process.cpp +++ b/renderdoc/os/win32/win32_process.cpp @@ -553,6 +553,15 @@ void Process::StartGlobalHook(const char *pathmatch, const char *logfile, const #endif } +bool LoadLibrary(const char *module) +{ + HMODULE mod = GetModuleHandleA(module); + if(mod != NULL) + return true; + + return LoadLibraryA(module) != NULL; +} + void *Process::GetFunctionAddress(const char *module, const char *function) { HMODULE mod = GetModuleHandleA(module);