From 0352e50fe54ef4d97f61df32e7f9d6bed279c39b Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 27 Aug 2018 16:29:05 +0100 Subject: [PATCH] Lock inside FetchOrdinalNames just in case * It's possible for two threads to hit GetProcAddress on the same module at once, try to late-fetch the ordinals, and clash. If we lock then only one thread will perform the fetch, the other thread can wait and bail out once it finds the ordinals already filled out. --- renderdoc/os/win32/win32_hook.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index 73c254257..a6734f899 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -98,9 +98,16 @@ struct DllHookset DWORD OrdinalBase = 0; vector OrdinalNames; std::vector Callbacks; + Threading::CriticalSection ordinallock; void FetchOrdinalNames() { + SCOPED_LOCK(ordinallock); + + // return if we already fetched the ordinals + if(!OrdinalNames.empty()) + return; + byte *baseAddress = (byte *)module; #if ENABLED(VERBOSE_DEBUG_HOOK)