From 42f081055cb90bacfac47331acd9d200d748d903 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sat, 15 Nov 2025 19:20:32 +0100 Subject: [PATCH] Several optimizations --- HellIsUs/dllmain.cpp | 111 +++++++++++-------------------------------- 1 file changed, 27 insertions(+), 84 deletions(-) diff --git a/HellIsUs/dllmain.cpp b/HellIsUs/dllmain.cpp index 2135136..5f7098a 100644 --- a/HellIsUs/dllmain.cpp +++ b/HellIsUs/dllmain.cpp @@ -1,12 +1,9 @@ -#include -#include -#include -#include -#include +#include "CommonHeaders.h" +#include "GameFixes.h" #include "GameInformations.h" #include "ObfuscateString.h" -#include "Memory.hpp"; -#include "Maths.hpp"; +#include "Memory.hpp" +#include "Maths.hpp" #include "UEngine.hpp"; #include "SDK/Basic.hpp" #include "SDK/Engine_classes.hpp" @@ -46,6 +43,7 @@ static bool g_HUD_fix_enabled = false; static int g_AdditionalFOVValue = 0; static float g_cameraDistanceMultiplier = 1.f; static float g_cameraHeight = -15.f; +static bool g_Console = false; // Shared values static float g_FOV_In = 70.f; @@ -57,7 +55,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; @@ -103,7 +100,7 @@ static void CameraFixEnabled(ECharlieCameraMode Mode); static void HUDFixEnabled(); static void EnableConsole(); -extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) +extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) { g_fix_enabled = enabled; if (g_fix_enabled && !AOBScanDone) { @@ -193,8 +190,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) } if (Fogaddress == nullptr) { - // 40 ?? 48 83 ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? 48 8D ?? ?? 48 8D ?? ?? ?? E8 - //constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("0F 84 ?? ?? ?? ?? F6 ?? ?? ?? 0F 84 ?? ?? ?? ?? 83 BF"); constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("40 ?? 48 83 ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? 48 8D ?? ?? 48 8D ?? ?? ?? E8"); Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ); //"HellIsUs-Win64-Shipping.exe" + 22B77C8 - 74 11 - je "HellIsUs-Win64-Shipping.exe" + 22B77DB @@ -257,8 +252,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33"); GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ); - constexpr auto GNamesStringObfuscated = make_obfuscated<0x4A>("48 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 0F ?? ?? 4C"); - GNamesaddress = Memory::AOBScan(gameExecutable, GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ); constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 8B F2 8B ?? 48"); AppendStringaddress = Memory::AOBScan(gameExecutable, 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 33 ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48"); @@ -273,15 +266,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) 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."); - else { - uint32_t gNamesOffset = static_cast(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) - - reinterpret_cast(GetModuleHandleA(gameExecutable.c_str()))); - logger->info("GNames offset is: 0x{:X}.", gNamesOffset); - Offsets::GNames = static_cast(gNamesOffset); // Update GNames offset - } - if (!AppendStringaddress) logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin."); else { @@ -304,70 +288,29 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) logger->info("-------------- Fixes initialisation -------------"); } - if (FOVaddress) FOVFixEnabled(); - if (Aspectaddress) AspectFixEnabled(); - if (Cameraaddress) CameraFixEnabled(ECharlieCameraMode::Camera); - if (Cameraaddress) CameraFixEnabled(ECharlieCameraMode::FOV); - if (DOFaddress) DOFFixEnabled(); - if (CAaddress) CAFixEnabled(); - if (Vignettingaddress) VignettingFixEnabled(); - if (Fogaddress) FogFixEnabled(); - if (GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress && HUDaddress) + if (!init && FOVaddress) FOVFixEnabled(); + if (!init && Aspectaddress) AspectFixEnabled(); + if (!init && Cameraaddress) CameraFixEnabled(ECharlieCameraMode::Camera); + if (!init && Cameraaddress) CameraFixEnabled(ECharlieCameraMode::FOV); + if (!init && DOFaddress) DOFFixEnabled(); + if (!init && CAaddress) CAFixEnabled(); + if (!init && Vignettingaddress) VignettingFixEnabled(); + if (!init && Fogaddress) FogFixEnabled(); + if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress && HUDaddress) HUDFixEnabled(); - if (!g_Console_Enabled && GObjectsaddress && GNamesaddress && AppendStringaddress && ProcessEventaddress) - EnableConsole(); } // Setters for Reshade addon call -extern "C" __declspec(dllexport) void SetFOVFixEnabled(bool enabled, bool init) -{ - g_fov_fix_enabled = enabled; - if (!init) { - FOVFixEnabled(); - CameraFixEnabled(ECharlieCameraMode::FOV); - } -} - -extern "C" __declspec(dllexport) void SetAspectRatioFixEnabled(bool enabled, bool init) -{ - g_aspect_fix_enabled = enabled; - if (!init) AspectFixEnabled(); -} - -extern "C" __declspec(dllexport) void SetDOFFixEnabled(bool enabled, bool init) -{ - g_DOF_fix_enabled = enabled; - if (!init) DOFFixEnabled(); -} - -extern "C" __declspec(dllexport) void SetCAFixEnabled(bool enabled, bool init) -{ - g_CA_fix_enabled = enabled; - if (!init) CAFixEnabled(); -} - -extern "C" __declspec(dllexport) void SetVignettingFixEnabled(bool enabled, bool init) -{ - g_Vignetting_fix_enabled = enabled; - if (!init) VignettingFixEnabled(); -} - -extern "C" __declspec(dllexport) void SetFogFixEnabled(bool enabled, bool init) -{ - g_Fog_fix_enabled = enabled; - if (!init) FogFixEnabled(); -} - -extern "C" __declspec(dllexport) void SetCameraFixEnabled(bool enabled, bool init) -{ - g_Camera_fix_enabled = enabled; - if (!init) CameraFixEnabled(ECharlieCameraMode::Camera); -} - -extern "C" __declspec(dllexport) void SetHUDFixEnabled(bool enabled, bool init) -{ - g_HUD_fix_enabled = enabled; - if (!init) HUDFixEnabled(); +extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled) { + if (fix == GameFixes::DevConsole) { g_Console = enabled; EnableConsole(); }; + if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); CameraFixEnabled(ECharlieCameraMode::FOV); } + if (fix == GameFixes::UltraWide) { g_aspect_fix_enabled = enabled; AspectFixEnabled(); } + if (fix == GameFixes::Camera) { g_Camera_fix_enabled = enabled; CameraFixEnabled(ECharlieCameraMode::Camera); }; + 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) @@ -452,10 +395,10 @@ static void CameraFixEnabled(ECharlieCameraMode mode) { auto* charlieCameraBaseConfig = reinterpret_cast(ctx.rax); if (charlieCameraBaseConfig && charlieCameraBaseConfig->IsA(UCharlieCameraBaseConfig::StaticClass())) { // Camera height - charlieCameraBaseConfig->DefaultHeightFromPlayer = (g_fix_enabled && g_Camera_fix_enabled ? g_cameraHeight : DEFAULT_CAMERA_HEIGHT); + charlieCameraBaseConfig->DefaultHeightFromPlayer = g_fix_enabled && g_Camera_fix_enabled ? g_cameraHeight : DEFAULT_CAMERA_HEIGHT; // World FOV charlieCameraBaseConfig->FieldOfView = DEFAULT_WORLD_FOV - + (g_fix_enabled && g_fov_fix_enabled ? g_AdditionalFOVValue : 0.f); + + g_fix_enabled && g_fov_fix_enabled ? g_AdditionalFOVValue : 0.f; } }); }