aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2024-08-29 17:48:27 +0100
committerGitHub <noreply@github.com>2024-08-29 18:48:27 +0200
commitefecb84a9fac99dabe16c332b61bd3c6c70ddec7 (patch)
tree7b8610709688059e7006f2f024fc1c4b31aca3d8
parentc9059104ab8d3a8acc8f6feffda39eeb8cf94f7b (diff)
downloadNorthstarLauncher-1.27.5-rc1.tar.gz
NorthstarLauncher-1.27.5-rc1.zip
Fix module callbacks related crash (#790)v1.27.5-rc1
Check optional headers size Check size and address of the image directory
-rw-r--r--primedev/thirdparty/silver-bun/module.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/primedev/thirdparty/silver-bun/module.cpp b/primedev/thirdparty/silver-bun/module.cpp
index dceb602a..26e9b6b6 100644
--- a/primedev/thirdparty/silver-bun/module.cpp
+++ b/primedev/thirdparty/silver-bun/module.cpp
@@ -69,11 +69,15 @@ void CModule::Init()
// Get the location of IMAGE_IMPORT_DESCRIPTOR for this module by adding the IMAGE_DIRECTORY_ENTRY_IMPORT relative virtual address onto our
// module base address.
- IMAGE_IMPORT_DESCRIPTOR* pImageImportDescriptors = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(
- m_pModuleBase + m_pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
- if (!pImageImportDescriptors)
+
+ if (m_pNTHeaders->FileHeader.SizeOfOptionalHeader == 0)
+ return;
+
+ IMAGE_DATA_DIRECTORY& imageDirectory = m_pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
+ if (imageDirectory.Size == 0 || imageDirectory.VirtualAddress == 0)
return;
+ IMAGE_IMPORT_DESCRIPTOR* pImageImportDescriptors = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(m_pModuleBase + imageDirectory.VirtualAddress);
for (IMAGE_IMPORT_DESCRIPTOR* pIID = pImageImportDescriptors; pIID->Name != 0; pIID++)
{
// Get virtual relative Address of the imported module name. Then add module base Address to get the actual location.