#Fix for certain game reading wrongly the base address

This commit is contained in:
ENEMY345 2025-03-31 01:16:15 -06:00
parent c017eb630a
commit 2fd3f57fc9

View File

@ -196,12 +196,20 @@ Image Xex2LoadImage(const uint8_t* data, size_t dataSize)
image.data = std::move(result);
image.size = security->imageSize;
image.base = security->loadAddress;
// Map image
const auto* dosHeader = reinterpret_cast<IMAGE_DOS_HEADER*>(image.data.get());
const auto* ntHeaders = reinterpret_cast<IMAGE_NT_HEADERS32*>(image.data.get() + dosHeader->e_lfanew);
if (image.base == 0)
{
image.base = ntHeaders->OptionalHeader.ImageBase;
}
if (image.entry_point == 0)
{
image.entry_point = image.base + ntHeaders->OptionalHeader.AddressOfEntryPoint;
}
image.base = ntHeaders->OptionalHeader.ImageBase;
image.entry_point = image.base + ntHeaders->OptionalHeader.AddressOfEntryPoint;
const auto numSections = ntHeaders->FileHeader.NumberOfSections;