Addressed an issue where the game would crash with latest update. Add the ability to toggle dev console re-enabling

This commit is contained in:
2025-11-15 17:32:45 +01:00
parent be8839b562
commit 727467345e

View File

@@ -28,6 +28,7 @@ static bool g_CA_fix_enabled = false;
static bool g_Vignetting_fix_enabled = false;
static bool g_Fog_fix_enabled = false;
static int g_AdditionalFOVValue = 0;
static bool g_Console = false;
// Shared values
static float g_FOV_In = 60.f;
@@ -36,7 +37,6 @@ static bool g_Console_Enabled = false;
// AOB Unreal Engine offsets addresses
static uint8_t* GObjectsaddress = nullptr;
static uint8_t* GNamesaddress = nullptr;
static uint8_t* AppendStringaddress = nullptr;
static uint8_t* ProcessEventaddress = nullptr;
@@ -152,14 +152,14 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
AOBScanDone = true;
}
if (!GObjectsaddress || !GNamesaddress || !AppendStringaddress || !ProcessEventaddress) {
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
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");
GObjectsaddress = Memory::AOBScan("", GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
constexpr auto GNamesStringObfuscated = make_obfuscated<0x4A>("48 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 0F ?? ?? 4C");
GNamesaddress = Memory::AOBScan("", GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 ?? F2 8B ?? 48 ?? ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C");
AppendStringaddress = Memory::AOBScan("", AppendStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D 8B");
ProcessEventaddress = Memory::AOBScan("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
@@ -171,12 +171,13 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
}
if (!GNamesaddress)
logger->warn("GNames signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
if (!AppendStringaddress)
logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else {
uint32_t gNamesOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) - baseModule);
logger->info("GNames offset is: 0x{:X}.", gNamesOffset);
Offsets::GNames = static_cast<UC::uint32>(gNamesOffset); // Update GNames offset
std::optional<uint32_t> gAppendStringOffsetOpt = UE::CalculateOffset("", AppendStringaddress);
uint32_t gAppendStringOffset = *gAppendStringOffsetOpt;
logger->info("AppendString offset is: 0x{:X}.", gAppendStringOffset);
Offsets::AppendString = static_cast<UC::uint32>(gAppendStringOffset);// Update AppendString
}
if (!ProcessEventaddress)
@@ -203,7 +204,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
// Setters for Reshade addon call
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled)
{ // Set each fix individually
if (fix == GameFixes::DevConsole) EnableConsole();
if (fix == GameFixes::DevConsole) { g_Console = enabled; EnableConsole(); };
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
if (fix == GameFixes::Framerate) { g_FPS_fix_enabled = enabled; FPSFixEnabled(); }
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
@@ -325,8 +326,13 @@ static void VignettingFixEnabled() {
// UE Console creation
static void EnableConsole()
{
if (!(g_fix_enabled && g_Console)) {
logger->info("------------------ User inputs ------------------");
return;
}
logger->info("-------------- Console re-enabling --------------");
if (!GObjectsaddress || !GNamesaddress || !ProcessEventaddress) {
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
logger->warn("Could not re-enable console");
logger->info("------------------ User inputs ------------------");
return;