mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-06-05 08:42:05 +00:00
#Fix for certain game reading wrongly the base address
This commit is contained in:
parent
c017eb630a
commit
2fd3f57fc9
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user