diff --git a/VoidTrain/dllmain.cpp b/VoidTrain/dllmain.cpp index 6a7a9cc..367f70d 100644 --- a/VoidTrain/dllmain.cpp +++ b/VoidTrain/dllmain.cpp @@ -33,6 +33,9 @@ static bool g_Vignetting_fix_enabled = false; static bool g_Fog_fix_enabled = false; static bool g_HUD_fix_enabled = false; static int g_AdditionalFOVValue = 0; +static int g_AdditionalJournalFOVValue = 0; +static bool g_Console = false; +static bool isJournalEnabled = false; // HUD safe zone static float leftOffset = 0.f; @@ -52,6 +55,7 @@ static uint8_t* ProcessEventaddress = nullptr; // AOB Scan pointers static uint8_t* FOVaddress = nullptr; +static uint8_t* JournalFOVaddress = nullptr; static uint8_t* DOFaddress = nullptr; static uint8_t* CAaddress = nullptr; static uint8_t* Vignettingaddress = nullptr; @@ -61,6 +65,7 @@ static uint8_t* HUDaddress = nullptr; // Hooking static SafetyHookMid FOVHook{}; +static SafetyHookMid JournalFOVHook{}; static SafetyHookMid FogHook{}; static SafetyHookMid HUDHook{}; @@ -81,7 +86,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) logger->info("--------------- AOB scan started ---------------"); if (!FOVaddress) { constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("C6 84 ?? ?? ?? ?? ?? ?? 48 ?? ?? 74 ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 8B"); - FOVaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + FOVaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ, logger); if (!FOVaddress) logger->warn("FOV signature not found. Maybe your game has been updated and is no more compatible with this plugin."); @@ -91,6 +96,16 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) } } + if (!JournalFOVaddress) { + constexpr auto JournalFOVStringObfuscated = make_obfuscated<0x4A>("88 91 ?? ?? ?? ?? 44 89 ?? ?? ?? ?? ?? C3"); + JournalFOVaddress = Memory::AOBScan("", JournalFOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + + if (!JournalFOVaddress) + logger->warn("Journal FOV signature not found. Maybe your game has been updated and is no more compatible with this plugin."); + else + logger->info("Journal FOV signature found at address: 0x{:X}.", reinterpret_cast(JournalFOVaddress)); + } + if (!DOFaddress) { constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("8B ?? ?? E8 ?? ?? ?? ?? 8B ?? E8 ?? ?? ?? ?? 84 ?? 74 ?? 48"); DOFaddress = Memory::AOBScan("", DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ); @@ -210,13 +225,13 @@ 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 && enabled) EnableConsole(); - if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); } - if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); } - if (fix == GameFixes::ChromaticAberrations) { g_CA_fix_enabled = enabled; CAFixEnabled(); } - if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); } - if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); } - if (fix == GameFixes::HUD) { g_HUD_fix_enabled = enabled; HUDFixEnabled(); } + if (fix == GameFixes::DevConsole) { g_Console = enabled; EnableConsole(); }; + if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); } + if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); } + if (fix == GameFixes::ChromaticAberrations) { g_CA_fix_enabled = enabled; CAFixEnabled(); } + if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); } + if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); } + if (fix == GameFixes::HUD) { g_HUD_fix_enabled = enabled; HUDFixEnabled(); } } extern "C" __declspec(dllexport) void SetFOV(int fov) @@ -224,6 +239,11 @@ extern "C" __declspec(dllexport) void SetFOV(int fov) g_AdditionalFOVValue = fov; } +extern "C" __declspec(dllexport) void SetJournalFOV(int fov) +{ + g_AdditionalJournalFOVValue = fov; +} + extern "C" __declspec(dllexport) void SetHUD(int percentage) { leftOffset = (float)percentage / 100; @@ -242,24 +262,39 @@ extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) { // Code injection functions static void FOVFixEnabled() { - if (g_fix_enabled && g_fov_fix_enabled && FOVaddress) { + if (g_fix_enabled && g_fov_fix_enabled && FOVaddress && JournalFOVaddress) { + if (!JournalFOVHook) { + JournalFOVHook = safetyhook::create_mid(JournalFOVaddress, + [](SafetyHookContext& ctx) { + isJournalEnabled = static_cast(ctx.rdx & 1); + }); + } + else JournalFOVHook.enable(); + if (!FOVHook) { // Hook only once FOVHook = safetyhook::create_mid(FOVaddress, [](SafetyHookContext& ctx) { g_FOV_In = ctx.xmm6.f32[0]; - if (aspectRatio > baseAspect) // Compensation for ultrawide screens - ctx.xmm6.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, baseAspect, aspectRatio); - g_CompensatedFOV = ctx.xmm6.f32[0]; - // Additional FOV - ctx.xmm6.f32[0] += (g_fix_enabled && g_fov_fix_enabled ? g_AdditionalFOVValue : 0); + if (!isJournalEnabled) { + if (aspectRatio > baseAspect) // Compensation for ultrawide screens + ctx.xmm6.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, baseAspect, aspectRatio); + g_CompensatedFOV = ctx.xmm6.f32[0]; + // Additional FOV + ctx.xmm6.f32[0] += (g_fix_enabled && g_fov_fix_enabled ? g_AdditionalFOVValue : 0); + } + else { + g_CompensatedFOV = ctx.xmm6.f32[0]; + ctx.xmm6.f32[0] += (g_fix_enabled && g_fov_fix_enabled ? g_AdditionalJournalFOVValue : 0); + } g_FOV_Out = ctx.xmm6.f32[0]; }); } else FOVHook.enable(); logger->info("FOV fix enabled"); } - if (!(g_fix_enabled && g_fov_fix_enabled) && FOVaddress) { + if (!(g_fix_enabled && g_fov_fix_enabled) && FOVaddress && JournalFOVaddress) { if (FOVHook) FOVHook.disable(); + if (JournalFOVHook) JournalFOVHook.disable(); logger->info("FOV fix disabled"); } } @@ -338,7 +373,11 @@ static void VignettingFixEnabled() { // UE Console creation static void EnableConsole() { - if (!g_fix_enabled) return; + if (!(g_fix_enabled && g_Console)) { + logger->info("------------------ User inputs ------------------"); + return; + } + logger->info("-------------- Console re-enabling --------------"); if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) { logger->warn("Could not re-enable console");