Add camera informations. Fog fix improvement

This commit is contained in:
2025-10-11 22:16:44 +02:00
parent 430205e033
commit 4b2372a4a9

View File

@@ -3,6 +3,7 @@
#include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/rotating_file_sink.h>
#include <filesystem> #include <filesystem>
#include <safetyhook.hpp> #include <safetyhook.hpp>
#include "GameInformations.h"
#include "ObfuscateString.h" #include "ObfuscateString.h"
#include "Memory.hpp"; #include "Memory.hpp";
#include "Maths.hpp"; #include "Maths.hpp";
@@ -50,6 +51,8 @@ static float g_cameraHeight = -15.f;
static float g_FOV_In = 70.f; static float g_FOV_In = 70.f;
static float g_Compensated_FOV = 70.f; static float g_Compensated_FOV = 70.f;
static float g_FOV_Out = 70.f; static float g_FOV_Out = 70.f;
static float g_Camera_In = 550.f;
static float g_Camera_Out = 550.f;
static bool g_Console_Enabled = false; static bool g_Console_Enabled = false;
// AOB Unreal Engine offsets addresses // AOB Unreal Engine offsets addresses
@@ -190,7 +193,9 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
} }
if (Fogaddress == nullptr) { if (Fogaddress == nullptr) {
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("0F 84 ?? ?? ?? ?? F6 ?? ?? ?? 0F 84 ?? ?? ?? ?? 83 BF"); // 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); Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
//"HellIsUs-Win64-Shipping.exe" + 22B77C8 - 74 11 - je "HellIsUs-Win64-Shipping.exe" + 22B77DB //"HellIsUs-Win64-Shipping.exe" + 22B77C8 - 74 11 - je "HellIsUs-Win64-Shipping.exe" + 22B77DB
//"HellIsUs-Win64-Shipping.exe" + 22B77CA - 48 8B 05 8F 23 08 07 - mov rax, ["HellIsUs-Win64-Shipping.exe" + 9339B60] //"HellIsUs-Win64-Shipping.exe" + 22B77CA - 48 8B 05 8F 23 08 07 - mov rax, ["HellIsUs-Win64-Shipping.exe" + 9339B60]
@@ -204,6 +209,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin."); logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else { else {
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress)); logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
Fogaddress += 0x31; // 0x57
} }
} }
@@ -387,20 +393,15 @@ extern "C" __declspec(dllexport) void SetHUD(int HUDValue)
} }
// Getters for Reshade addon call // Getters for Reshade addon call
extern "C" __declspec(dllexport) float GetFOVIn() { extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
return g_FOV_In; if (!infos) return;
}
extern "C" __declspec(dllexport) float GetCompensatedFOV() { infos->FOVIn = g_FOV_In;
return g_Compensated_FOV; infos->CompensatedFOV = g_Compensated_FOV;
} infos->FOVOut = g_FOV_Out;
infos->cameraIn = g_Camera_In;
extern "C" __declspec(dllexport) float GetFOVOut() { infos->cameraOut = g_Camera_Out;
return g_FOV_Out; infos->consoleEnabled = g_Console_Enabled;
}
extern "C" __declspec(dllexport) bool GetConsoleEnabled() {
return g_Console_Enabled;
} }
// Code injection functions // Code injection functions
@@ -443,7 +444,10 @@ static void CameraFixEnabled(ECharlieCameraMode mode) {
if (!CameraHook) { // Hook only once +0x4e or start to test +0x13 if (!CameraHook) { // Hook only once +0x4e or start to test +0x13
CameraHook = safetyhook::create_mid(Cameraaddress + 0x4e, CameraHook = safetyhook::create_mid(Cameraaddress + 0x4e,
[](SafetyHookContext& ctx) { [](SafetyHookContext& ctx) {
g_Camera_In = ctx.xmm0.f32[0];
ctx.xmm0.f32[0] *= (g_Camera_fix_enabled ? g_cameraDistanceMultiplier : 1.f); ctx.xmm0.f32[0] *= (g_Camera_fix_enabled ? g_cameraDistanceMultiplier : 1.f);
g_Camera_Out = ctx.xmm0.f32[0];
// Retrieve player camera object // Retrieve player camera object
auto* charlieCameraBaseConfig = reinterpret_cast<UCharlieCameraBaseConfig*>(ctx.rax); auto* charlieCameraBaseConfig = reinterpret_cast<UCharlieCameraBaseConfig*>(ctx.rax);
if (charlieCameraBaseConfig && charlieCameraBaseConfig->IsA(UCharlieCameraBaseConfig::StaticClass())) { if (charlieCameraBaseConfig && charlieCameraBaseConfig->IsA(UCharlieCameraBaseConfig::StaticClass())) {
@@ -553,22 +557,23 @@ static void VignettingFixEnabled() {
} }
} }
static void FogFixEnabled() { static void FogFixEnabled() {
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) { if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
if (!FogHook) { if (!FogHook) {
FogHook = safetyhook::create_mid(Fogaddress, FogHook = safetyhook::create_mid(Fogaddress,
[](SafetyHookContext& ctx) { [](SafetyHookContext& ctx) {
ctx.rflags |= 0x40; // ZF=1 r.VolumetricFog = 0 if (!ctx.rax) return;
uintptr_t* rax = reinterpret_cast<uintptr_t*>(ctx.rax);
bool* bFog = reinterpret_cast<bool*>(reinterpret_cast<uint8_t*>(rax) + 0x04);
*bFog = g_fix_enabled && g_Fog_fix_enabled ? false : true;
}); });
} }
else FogHook.enable();
logger->info("Fog fix enabled"); logger->info("Fog fix enabled");
} }
if (!(g_fix_enabled && g_Fog_fix_enabled) && Fogaddress) { if (!(g_fix_enabled && g_Fog_fix_enabled) && Fogaddress)
if (FogHook) FogHook.disable();
logger->info("Fog fix disabled"); logger->info("Fog fix disabled");
} }
}
// UE Console creation // UE Console creation
static void EnableConsole() static void EnableConsole()
@@ -604,6 +609,8 @@ static void EnableConsole()
logger->info("Successfully spawned console object"); logger->info("Successfully spawned console object");
// Set the console viewport so that it will be displayed // Set the console viewport so that it will be displayed
Engine->GameViewport->ViewportConsole = static_cast<UConsole*>(NewObject); Engine->GameViewport->ViewportConsole = static_cast<UConsole*>(NewObject);
//Engine->GameViewport->ViewportConsole->ConsoleTargetPlayer->ViewportClient
auto end = std::chrono::high_resolution_clock::now(); auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end - start; std::chrono::duration<double> elapsed = end - start;