diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 4fb42572a..c3625c000 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2621,6 +2621,54 @@ namespace bgfx }; static_assert(BX_COUNTOF(s_rendererCreator) == RendererType::Count); + void* findModule(const char* _name) + { +#if BX_PLATFORM_WINDOWS + // NOTE: there was some reason to do it this way instead of simply calling GetModuleHandleA, + // but not sure what it was. + HANDLE process = GetCurrentProcess(); + DWORD size; + BOOL result = EnumProcessModules(process + , NULL + , 0 + , &size + ); + if (0 != result) + { + HMODULE* modules = (HMODULE*)BX_STACK_ALLOC(size); + result = EnumProcessModules(process + , modules + , size + , &size + ); + + if (0 != result) + { + char moduleName[MAX_PATH]; + + for (uint32_t ii = 0, num = uint32_t(size/sizeof(HMODULE) ); ii < num; ++ii) + { + result = GetModuleBaseNameA(process + , modules[ii] + , moduleName + , BX_COUNTOF(moduleName) + ); + + if (0 != result + && 0 == bx::strCmpI(_name, moduleName) ) + { + return (void*)modules[ii]; + } + } + } + } +#else + BX_UNUSED(_name); +#endif // BX_PLATFORM_WINDOWS + + return NULL; + } + bool windowsVersionIs(Condition::Enum _op, uint32_t _version, uint32_t _build) { #if BX_PLATFORM_WINDOWS diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 68a190541..927aa64bf 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -427,6 +427,7 @@ namespace bgfx }; }; + void* findModule(const char* _name); bool windowsVersionIs(Condition::Enum _op, uint32_t _version, uint32_t _build = UINT32_MAX); constexpr bool isShaderType(uint32_t _magic, char _type) diff --git a/src/debug_renderdoc.cpp b/src/debug_renderdoc.cpp index fedbed948..b4d01afd9 100644 --- a/src/debug_renderdoc.cpp +++ b/src/debug_renderdoc.cpp @@ -17,52 +17,6 @@ namespace bgfx { - void* findModule(const char* _name) - { -#if BX_PLATFORM_WINDOWS - // NOTE: there was some reason to do it this way instead of simply calling GetModuleHandleA, - // but not sure what it was. - HANDLE process = GetCurrentProcess(); - DWORD size; - BOOL result = EnumProcessModules(process - , NULL - , 0 - , &size - ); - if (0 != result) - { - HMODULE* modules = (HMODULE*)BX_STACK_ALLOC(size); - result = EnumProcessModules(process - , modules - , size - , &size - ); - - if (0 != result) - { - char moduleName[MAX_PATH]; - for (uint32_t ii = 0, num = uint32_t(size/sizeof(HMODULE) ); ii < num; ++ii) - { - result = GetModuleBaseNameA(process - , modules[ii] - , moduleName - , BX_COUNTOF(moduleName) - ); - if (0 != result - && 0 == bx::strCmpI(_name, moduleName) ) - { - return (void*)modules[ii]; - } - } - } - } -#else - BX_UNUSED(_name); -#endif // BX_PLATFORM_WINDOWS - - return NULL; - } - pRENDERDOC_GetAPI RENDERDOC_GetAPI; static RENDERDOC_API_1_1_2* s_renderDoc = NULL; static void* s_renderDocDll = NULL; diff --git a/src/debug_renderdoc.h b/src/debug_renderdoc.h index 522bba034..025d72bcf 100644 --- a/src/debug_renderdoc.h +++ b/src/debug_renderdoc.h @@ -8,7 +8,6 @@ namespace bgfx { - void* findModule(const char* _name); void* loadRenderDoc(); void unloadRenderDoc(void*); void renderDocTriggerCapture();