diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index 89a9ecf2c..29c88fd99 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -474,7 +474,7 @@ FARPROC WINAPI Hooked_GetProcAddress(HMODULE mod, LPCSTR func) if(mod == NULL || func == NULL) return (FARPROC)NULL; - if(mod == s_HookData->ownmodule || OrdinalAsString((void *)func)) + if(mod == s_HookData->ownmodule) return GetProcAddress(mod, func); for(auto it = s_HookData->DllHooks.begin(); it != s_HookData->DllHooks.end(); ++it) @@ -484,6 +484,29 @@ FARPROC WINAPI Hooked_GetProcAddress(HMODULE mod, LPCSTR func) if(mod == it->second.module) { + if(OrdinalAsString((void *)func)) + { + uint32_t ordinal = (uint16_t)func; + + if(ordinal < it->second.OrdinalBase) + { + RDCERR("Unexpected ordinal - lower than ordinalbase %u for %s", + (uint32_t)it->second.OrdinalBase, it->first.c_str()); + return GetProcAddress(mod, func); + } + + ordinal -= it->second.OrdinalBase; + + if(ordinal >= it->second.OrdinalNames.size()) + { + RDCERR("Unexpected ordinal - higher than fetched ordinal names (%u) for %s", + (uint32_t)it->second.OrdinalNames.size(), it->first.c_str()); + return GetProcAddress(mod, func); + } + + func = it->second.OrdinalNames[ordinal].c_str(); + } + FunctionHook search(func, NULL, NULL); auto found =