From 3ed6f1696445467946dc5877b7dc37ab2c26fb7b Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Mon, 29 Sep 2025 11:58:57 +0200 Subject: [PATCH] Add unique function to retrieve game informations --- SilentHillF/dllmain.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/SilentHillF/dllmain.cpp b/SilentHillF/dllmain.cpp index a9f17db..88bb3d5 100644 --- a/SilentHillF/dllmain.cpp +++ b/SilentHillF/dllmain.cpp @@ -3,6 +3,7 @@ #include #include #include +#include "GameInformations.h" #include "ObfuscateString.h" #include "Memory.hpp"; #include "Maths.hpp"; @@ -21,11 +22,6 @@ const float BASE_ASPECT = 1.777777791; // Logger std::shared_ptr logger; -// Screen informations -static int screenWidth = GetSystemMetrics(SM_CXSCREEN); -static int screenHeight = GetSystemMetrics(SM_CYSCREEN); -static float aspectRatio = (float)screenWidth / screenHeight; - // Plugin states static bool AOBScanDone = false; static bool g_fix_enabled = false; @@ -39,9 +35,10 @@ static int g_AdditionalFOVValue = 0; static float g_CameraDistance = 1.f; // Shared values -static float g_reference_FOV = 65.f; -static float g_FOV_In = 0.f; -static float g_FOV_Out = 0.f; +static float g_FOV_In = 65.f; +static float g_FOV_Out = 65.f; +static float g_Camera_In = 230.f; +static float g_Camera_Out = 230.f; static bool g_Console_Enabled = false; // AOB Unreal Engine offsets addresses @@ -175,7 +172,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) } } - if (FOVaddress && DOFaddress && CAaddress && Vignettingaddress && VolumetricFogaddress) { + if (FOVaddress && Cameraaddress && DOFaddress && CAaddress && Vignettingaddress && VolumetricFogaddress) { logger->info("All AOB signatures found. Ready to patch..."); AOBScanDone = true; } @@ -290,16 +287,14 @@ extern "C" __declspec(dllexport) void SetCameraDistance(float multiplier) { } // Getters for Reshade addon call -extern "C" __declspec(dllexport) float GetFOVIn() { - return g_FOV_In; -} +extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) { + if (!infos) return; -extern "C" __declspec(dllexport) float GetFOVOut() { - return g_FOV_Out; -} - -extern "C" __declspec(dllexport) bool GetConsoleEnabled() { - return g_Console_Enabled; + infos->FOVIn = g_FOV_In; + infos->FOVOut = g_FOV_Out; + infos->cameraIn = g_Camera_In; + infos->cameraOut = g_Camera_Out; + infos->consoleEnabled = g_Console_Enabled; } // Code injection functions @@ -328,7 +323,9 @@ static void CameraFixEnabled() { if (!CameraHook) { CameraHook = safetyhook::create_mid(Cameraaddress, [](SafetyHookContext& ctx) { + g_Camera_In = ctx.xmm0.f32[0]; ctx.xmm0.f32[0] *= g_CameraDistance; + g_Camera_Out = ctx.xmm0.f32[0]; }); } else CameraHook.enable();