Add Journal FOV fix. Add console disabling

This commit is contained in:
2025-11-12 10:43:10 +01:00
parent feceb24d94
commit be8839b562

View File

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