aboutsummaryrefslogtreecommitdiff
path: root/primedev/thirdparty/silver-bun
diff options
context:
space:
mode:
Diffstat (limited to 'primedev/thirdparty/silver-bun')
-rw-r--r--primedev/thirdparty/silver-bun/module.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/primedev/thirdparty/silver-bun/module.cpp b/primedev/thirdparty/silver-bun/module.cpp
index 4b9330e0..84f4da9e 100644
--- a/primedev/thirdparty/silver-bun/module.cpp
+++ b/primedev/thirdparty/silver-bun/module.cpp
@@ -15,11 +15,21 @@
//-----------------------------------------------------------------------------
CModule::CModule(HMODULE hModule)
{
- m_pModuleBase = reinterpret_cast<uintptr_t>(hModule);
+ MODULEINFO mInfo {0};
+
+ if (hModule && hModule != INVALID_HANDLE_VALUE)
+ GetModuleInformation(GetCurrentProcess(), hModule, &mInfo, sizeof(MODULEINFO));
+
+ m_nModuleSize = static_cast<size_t>(mInfo.SizeOfImage);
+ m_pModuleBase = reinterpret_cast<uintptr_t>(mInfo.lpBaseOfDll);
+
+ if (!m_nModuleSize || !m_pModuleBase)
+ return;
CHAR szModuleName[MAX_PATH];
DWORD dwSize = GetModuleFileNameA(hModule, szModuleName, sizeof(szModuleName));
- m_ModuleName = strrchr(szModuleName, '\\') + 1;
+ char* chLast = strrchr(szModuleName, '\\');
+ m_ModuleName = chLast == nullptr ? szModuleName : chLast + 1;
Init();