diff --git a/VampireTMBL2/dllmain.cpp b/VampireTMBL2/dllmain.cpp index 290568d..c4516a2 100644 --- a/VampireTMBL2/dllmain.cpp +++ b/VampireTMBL2/dllmain.cpp @@ -21,6 +21,7 @@ std::shared_ptr logger; // Plugin states static bool AOBScanDone = false; +static bool g_Console = false; static bool g_fix_enabled = false; static bool g_fov_fix_enabled = false; static bool g_ultrawide_fix_enabled = false; @@ -39,7 +40,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; @@ -57,9 +57,7 @@ static uint8_t* AspectRatioAxisConstraintaddress = nullptr; // Hooking static SafetyHookMid FOVHook{}; -static SafetyHookMid CameraHook{}; static SafetyHookMid FogHook{}; -static SafetyHookMid ProcessEventHook{}; // Prototypes static void FOVFixEnabled(); @@ -157,14 +155,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(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); @@ -176,12 +174,13 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) Offsets::GObjects = static_cast(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(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) - baseModule); - logger->info("GNames offset is: 0x{:X}.", gNamesOffset); - Offsets::GNames = static_cast(gNamesOffset); // Update GNames offset + std::optional gAppendStringOffsetOpt = UE::CalculateOffset("", AppendStringaddress); + uint32_t gAppendStringOffset = *gAppendStringOffsetOpt; + logger->info("AppendString offset is: 0x{:X}.", gAppendStringOffset); + Offsets::AppendString = static_cast(gAppendStringOffset);// Update AppendString } if (!ProcessEventaddress) @@ -208,7 +207,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::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); } if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); } @@ -330,8 +329,13 @@ static void VolumetricFogFixEnabled() { // UE Console creation static void EnableConsole() { + if (!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; @@ -370,14 +374,13 @@ static void EnableConsole() UInputSettings::GetDefaultObj()->ConsoleKeys[i].KeyName = UKismetStringLibrary::Conv_StringToName(L"F2"); } logger->info("Console fully reactivated in {:.3f}s and bound to key F2", elapsed.count()); - logger->info("------------------ User inputs ------------------"); - g_Console_Enabled = true; } - else { + else logger->error("Could not spawn console object"); - } - }).detach(); + + logger->info("------------------ User inputs ------------------"); + }).detach(); } static void InitializeLogger()