From e0a9c20f948316e0cb4cedb1116c0964d279ccf5 Mon Sep 17 00:00:00 2001 From: ASpoonPlaysGames <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:10:09 +0100 Subject: [PATCH] check size and address of the image directory --- primedev/thirdparty/silver-bun/module.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/primedev/thirdparty/silver-bun/module.cpp b/primedev/thirdparty/silver-bun/module.cpp index 35a05059b..26e9b6b65 100644 --- a/primedev/thirdparty/silver-bun/module.cpp +++ b/primedev/thirdparty/silver-bun/module.cpp @@ -73,11 +73,11 @@ void CModule::Init() if (m_pNTHeaders->FileHeader.SizeOfOptionalHeader == 0) return; - IMAGE_IMPORT_DESCRIPTOR* pImageImportDescriptors = reinterpret_cast( - m_pModuleBase + m_pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); - if (!pImageImportDescriptors) + 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(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.