Addressed an issue where wrong offsets would be returned making game to crash

This commit is contained in:
2025-10-10 14:35:43 +02:00
parent cf03aab0bc
commit 5b974969d1

View File

@@ -138,6 +138,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
if (!GObjectsaddress || !GNamesaddress || !AppendStringaddress || !ProcessEventaddress) { if (!GObjectsaddress || !GNamesaddress || !AppendStringaddress || !ProcessEventaddress) {
logger->info("------------ UEngine offsets search ------------"); logger->info("------------ UEngine offsets search ------------");
uint8_t* baseModule = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); // Get game base address
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33"); constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ); GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
@@ -149,8 +150,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
if (!GObjectsaddress) if (!GObjectsaddress)
logger->warn("GObjects signature not found. Maybe your game has been updated and is no more compatible with this plugin."); logger->warn("GObjects signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else { else {
uint32_t gObjectsOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GObjectsaddress + 0x3) - uint32_t gObjectsOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GObjectsaddress + 0x3) - baseModule);
reinterpret_cast<uint8_t*>(GetModuleHandleA(gameExecutable.c_str())));
logger->info("GObjects offset is: 0x{:X}.", gObjectsOffset); logger->info("GObjects offset is: 0x{:X}.", gObjectsOffset);
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
} }
@@ -158,8 +158,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
if (!GNamesaddress) if (!GNamesaddress)
logger->warn("GNames signature not found. Maybe your game has been updated and is no more compatible with this plugin."); logger->warn("GNames signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else { else {
uint32_t gNamesOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) - uint32_t gNamesOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) - baseModule);
reinterpret_cast<uint8_t*>(GetModuleHandleA(gameExecutable.c_str())));
logger->info("GNames offset is: 0x{:X}.", gNamesOffset); logger->info("GNames offset is: 0x{:X}.", gNamesOffset);
Offsets::GNames = static_cast<UC::uint32>(gNamesOffset); // Update GNames offset Offsets::GNames = static_cast<UC::uint32>(gNamesOffset); // Update GNames offset
} }