From 2fd3f57fc9886ff8d6899973b373253be09a026a Mon Sep 17 00:00:00 2001 From: ENEMY345 Date: Mon, 31 Mar 2025 01:16:15 -0600 Subject: [PATCH] #Fix for certain game reading wrongly the base address --- XenonUtils/xex.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/XenonUtils/xex.cpp b/XenonUtils/xex.cpp index d1972c0..a9e66a6 100644 --- a/XenonUtils/xex.cpp +++ b/XenonUtils/xex.cpp @@ -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.data.get()); const auto* ntHeaders = reinterpret_cast(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;