From 5896b9e5514482952dc87143cbb61b6d54b18e7e Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Mon, 15 Sep 2025 11:48:37 +0200 Subject: [PATCH] Add camera distance --- HellIsUs/dllmain.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/HellIsUs/dllmain.cpp b/HellIsUs/dllmain.cpp index 5f536c1..46956cc 100644 --- a/HellIsUs/dllmain.cpp +++ b/HellIsUs/dllmain.cpp @@ -36,7 +36,9 @@ static bool g_DOF_fix_enabled = false; static bool g_CA_fix_enabled = false; static bool g_Vignetting_fix_enabled = false; static bool g_Fog_fix_enabled = false; +static bool g_Camera_distance_fix_enabled = false; static int g_AdditionalFOVValue = 0; +static float g_cameraDistanceMultiplier = 1.f; // Shared values static float g_FOV_In = 0; @@ -58,11 +60,13 @@ static uint8_t* DOFaddress = nullptr; static uint8_t* CAaddress = nullptr; static uint8_t* Vignettingaddress = nullptr; static uint8_t* Fogaddress = nullptr; +static uint8_t* CameraDistanceaddress = nullptr; // Hooking static SafetyHookMid FOVHook{}; static SafetyHookMid AspectHook{}; static SafetyHookMid FogHook{}; +static SafetyHookMid CameraDistanceHook{}; // Prototypes static void FOVFixEnabled(bool fix_enabled); @@ -71,6 +75,7 @@ static void DOFFixEnabled(bool fix_enabled); static void CAFixEnabled(bool fix_enabled); static void VignettingFixEnabled(bool fix_enabled); static void FogFixEnabled(bool fix_enabled); +static void CameraDistanceFixEnabled(bool fix_enabled); static void EnableConsole(); extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) @@ -181,6 +186,22 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) } } + if (CameraDistanceaddress == nullptr) { + constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("28 C3 48 83 ?? ?? 48 8B ?? ?? ?? ?? ?? 48 8B ?? 48 85 ?? 75"); + CameraDistanceaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + //"HellIsUs-Win64-Shipping.exe" + 4E9D3F2 - 48 85 C0 - test rax, rax + //"HellIsUs-Win64-Shipping.exe" + 4E9D3F5 - 74 0A - je "HellIsUs-Win64-Shipping.exe" + 4E9D401 + //"HellIsUs-Win64-Shipping.exe" + 4E9D3F7 - F3 0F 10 40 4C - movss xmm0, [rax + 4C] + //"HellIsUs-Win64-Shipping.exe" + 4E9D3FC - 48 83 C4 28 - add rsp, 28 + //"HellIsUs-Win64-Shipping.exe" + 4E9D400 - C3 - ret + + if (!CameraDistanceaddress) + logger->warn("Camera distance signature not found. Maybe your game has been updated and is no more compatible with this plugin."); + else { + logger->info("Camera distance signature found at address: 0x{:X}.", reinterpret_cast(CameraDistanceaddress)); + } + } + if (FOVaddress && FOVOtheraddress && Aspectaddress && DOFaddress && CAaddress && Vignettingaddress && Fogaddress) { logger->info("All AOB signatures found. Ready to patch..."); AOBScanDone = true; @@ -293,11 +314,22 @@ extern "C" __declspec(dllexport) void SetFogFixEnabled(bool enabled, bool init) if (!init) FogFixEnabled(g_Fog_fix_enabled); } +extern "C" __declspec(dllexport) void SetCameraDistanceFixEnabled(bool enabled, bool init) +{ + g_Camera_distance_fix_enabled = enabled; + if (!init) CameraDistanceFixEnabled(g_Camera_distance_fix_enabled); +} + extern "C" __declspec(dllexport) void SetFOV(int fov) { g_AdditionalFOVValue = fov; } +extern "C" __declspec(dllexport) void SetCameraDistance(float cameraDistance) +{ + g_cameraDistanceMultiplier = cameraDistance; +} + extern "C" __declspec(dllexport) void SetConsole() { EnableConsole(); @@ -408,6 +440,18 @@ static void FogFixEnabled(bool fix_enabled) { } } +static void CameraDistanceFixEnabled(bool fix_enabled) { + if (g_fix_enabled && fix_enabled && CameraDistanceaddress) { + if (!CameraDistanceHook) { // Hook only once +0x4e or start to test +0x13 + CameraDistanceHook = safetyhook::create_mid(CameraDistanceaddress + 0x4e, + [](SafetyHookContext& ctx) { + ctx.xmm0.f32[0] *= g_cameraDistanceMultiplier; + }); + } + logger->info("CameraDistance fix enabled"); + } +} + // UE Console creation static void EnableConsole() {