Skip to content

Commit

Permalink
check size and address of the image directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ASpoonPlaysGames committed Aug 28, 2024
1 parent 555156d commit e0a9c20
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions primedev/thirdparty/silver-bun/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ void CModule::Init()
if (m_pNTHeaders->FileHeader.SizeOfOptionalHeader == 0)
return;

IMAGE_IMPORT_DESCRIPTOR* pImageImportDescriptors = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(
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<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.
Expand Down

0 comments on commit e0a9c20

Please sign in to comment.