diff options
author | Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> | 2024-03-08 23:20:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-09 00:20:49 +0100 |
commit | d3ee91c1f5cf7eeacbb091c28e248bc3b88d5a6e (patch) | |
tree | eec9fa8e13dd90294ffdecdfb4ff08196ac9b052 /primedev/thirdparty/silver-bun/module.cpp | |
parent | 85a2fb9c56c1942958c09c8aeafd14ddefb6e0c3 (diff) | |
download | NorthstarLauncher-d3ee91c1f5cf7eeacbb091c28e248bc3b88d5a6e.tar.gz NorthstarLauncher-d3ee91c1f5cf7eeacbb091c28e248bc3b88d5a6e.zip |
Fix crash in silver-bun (#679)v1.24.6-rc1v1.24.4-rc2v1.24.4
Diffstat (limited to 'primedev/thirdparty/silver-bun/module.cpp')
-rw-r--r-- | primedev/thirdparty/silver-bun/module.cpp | 14 |
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(); |