Fix optimizations
This commit is contained in:
@@ -1,26 +1,17 @@
|
||||
#include <string>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
#include <safetyhook.hpp>
|
||||
#include <chrono>
|
||||
#include "CommonHeaders.h"
|
||||
#include "GameFixes.h"
|
||||
#include "GameInformations.h"
|
||||
#include "Memory.hpp";
|
||||
#include "Maths.hpp";
|
||||
#include "UEngine.hpp";
|
||||
#include "ObfuscateString.h"
|
||||
//#include "SDK/CoreUObject_classes.hpp"
|
||||
#include "SDK/Engine_classes.hpp"
|
||||
//#include "SDK/Engine_structs.hpp"
|
||||
//#include "SDK/Cronos_classes.hpp"
|
||||
//#include "SDK/PlayerHudWidget_BP_classes.hpp"
|
||||
|
||||
using namespace SDK;
|
||||
|
||||
// Constants
|
||||
const std::string PLUGIN_NAME = "CronosTND";
|
||||
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
|
||||
const std::string gameExecutable = "Cronos-Win64-Shipping.exe";
|
||||
const float baseAspect = 1.7777778;
|
||||
|
||||
// Logger
|
||||
@@ -33,6 +24,7 @@ static float aspectRatio = (float)screenWidth / screenHeight;
|
||||
|
||||
// Plugin states
|
||||
static bool AOBScanDone = false;
|
||||
static bool g_Console = false;
|
||||
static bool g_fix_enabled = false;
|
||||
static bool g_fov_fix_enabled = false;
|
||||
static bool g_aspect_fix_enabled = false;
|
||||
@@ -47,11 +39,12 @@ static float g_cameraDistanceMultiplier = 1.f;
|
||||
static float g_FOV_In = 0;
|
||||
static float g_Compensated_FOV = 0;
|
||||
static float g_FOV_Out = 0;
|
||||
static float g_Camera_In = 180;
|
||||
static float g_Camera_Out = 180;
|
||||
static bool g_Console_Enabled = false;
|
||||
|
||||
// AOB Scan pointers
|
||||
static uint8_t* FOVaddress = nullptr;
|
||||
static uint8_t* FPSaddress = nullptr;
|
||||
static uint8_t* Aspectaddress = nullptr;
|
||||
static uint8_t* DOFaddress = nullptr;
|
||||
static uint8_t* Vignettingaddress = nullptr;
|
||||
@@ -68,28 +61,24 @@ static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid AspectHook{};
|
||||
static SafetyHookMid FogHook{};
|
||||
static SafetyHookMid CameraDistanceHook{};
|
||||
static SafetyHookMid PEHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled(bool fix_enabled);
|
||||
static void AspectFixEnabled(bool fix_enabled);
|
||||
static void DOFFixEnabled(bool fix_enabled);
|
||||
static void VignettingFixEnabled(bool fix_enabled);
|
||||
static void FogFixEnabled(bool fix_enabled);
|
||||
static void CameraDistanceFixEnabled(bool fix_enabled);
|
||||
static void FOVFixEnabled();
|
||||
static void AspectFixEnabled();
|
||||
static void DOFFixEnabled();
|
||||
static void VignettingFixEnabled();
|
||||
static void FogFixEnabled();
|
||||
static void CameraDistanceFixEnabled();
|
||||
static void EnableConsole();
|
||||
static void ProcessEvent();
|
||||
|
||||
uint8_t* basePtr = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr));
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_fix_enabled = enabled;
|
||||
if (g_fix_enabled && !AOBScanDone) {
|
||||
if (g_fix_enabled && !AOBScanDone) { // Unreal Engine 5.5.4
|
||||
logger->info("--------------- AOB scan started ---------------");
|
||||
if (FOVaddress == nullptr) {
|
||||
constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 83 ?? ?? ?? ?? 89");
|
||||
FOVaddress = Memory::AOBScan(gameExecutable, FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
FOVaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ, logger);
|
||||
//"Cronos-Win64-Shipping.exe" + 36B636C - EB 08 - jmp "Cronos-Win64-Shipping.exe" + 36B6376
|
||||
//"Cronos-Win64-Shipping.exe" + 36B636E - F3 0F 10 83 30 02 00 00 - movss xmm0, [rbx + 00000230]
|
||||
//"Cronos-Win64-Shipping.exe" + 36B6376 - F3 0F 11 47 30 - movss[rdi + 30], xmm0
|
||||
@@ -106,7 +95,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
|
||||
if (Aspectaddress == nullptr) {
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("C7 43 ?? 39 8E E3 3F C7 87 ?? ?? ?? ?? 39 8E E3 3F 48 83 ?? ?? ?? ?? ?? ?? 75");
|
||||
Aspectaddress = Memory::AOBScan(gameExecutable, AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
Aspectaddress = Memory::AOBScan("", AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Cronos-Win64-Shipping.exe" + 54C4600 - 83 4B 68 01 - or dword ptr[rbx + 68], 01
|
||||
//"Cronos-Win64-Shipping.exe" + 54C4604 - 80 8F 59 02 00 00 01 - or byte ptr[rdi + 00000259], 01
|
||||
//"Cronos-Win64-Shipping.exe" + 54C460B - C7 43 5C 39 8E E3 3F - mov[rbx + 5C], 3FE38E39
|
||||
@@ -123,7 +112,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
|
||||
if (DOFaddress == nullptr) {
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("74 ?? 48 ?? ?? 8B ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 0F");
|
||||
DOFaddress = Memory::AOBScan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
DOFaddress = Memory::AOBScan("", DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Cronos-Win64-Shipping.exe" + 2712F87 - 74 03 - je "Cronos-Win64-Shipping.exe" + 2712F8C
|
||||
//"Cronos-Win64-Shipping.exe" + 2712F89 - 48 8B C3 - mov rax, rbx
|
||||
//"Cronos-Win64-Shipping.exe" + 2712F8C - 8B 34 30 - mov esi, [rax + rsi]
|
||||
@@ -140,7 +129,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
|
||||
if (Vignettingaddress == nullptr) {
|
||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 44 89");
|
||||
Vignettingaddress = Memory::AOBScan(gameExecutable, VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
Vignettingaddress = Memory::AOBScan("", VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Cronos-Win64-Shipping.exe" + 3E079F4 - 8B 08 - mov ecx, [rax]
|
||||
//"Cronos-Win64-Shipping.exe" + 3E079F6 - 83 F9 02 - cmp ecx, 02
|
||||
//"Cronos-Win64-Shipping.exe" + 3E079F9 - 7D 09 - jnl "Cronos-Win64-Shipping.exe" + 3E07A04
|
||||
@@ -157,7 +146,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
|
||||
if (Fogaddress == nullptr) {
|
||||
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("F6 ?? ?? ?? ?? 74 ?? 48 8B ?? ?? ?? ?? ?? 83 78 ?? ?? 75 ?? B3");
|
||||
Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
Fogaddress = Memory::AOBScan("", FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Cronos-Win64-Shipping.exe" + 231B60A - 48 8B 05 BF EC AD 08 - mov rax, ["Cronos-Win64-Shipping.exe" + ADFA2D0]
|
||||
//"Cronos-Win64-Shipping.exe" + 231B611 - 83 78 04 01 - cmp dword ptr[rax + 04], 01
|
||||
//"Cronos-Win64-Shipping.exe" + 231B615 - 75 04 - jne "Cronos-Win64-Shipping.exe" + 231B61B
|
||||
@@ -174,7 +163,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
|
||||
if (CameraDistanceaddress == nullptr) {
|
||||
constexpr auto CamDistanceStringObfuscated = make_obfuscated<0x4A>("E8 ?? ?? ?? ?? F2 0F ?? ?? ?? ?? 48 8D ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 0F");
|
||||
CameraDistanceaddress = Memory::AOBScan(gameExecutable, CamDistanceStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
CameraDistanceaddress = Memory::AOBScan("", CamDistanceStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Cronos-Win64-Shipping.exe" + 55E908F - F2 0F 10 44 24 68 - movsd xmm0, [rsp + 68]
|
||||
//"Cronos-Win64-Shipping.exe" + 55E9095 - 48 8D 55 D8 - lea rdx, [rbp - 28]
|
||||
//"Cronos-Win64-Shipping.exe" + 55E9099 - F3 0F 10 8F 30 02 00 00 - movss xmm1, [rdi + 00000230]
|
||||
@@ -197,19 +186,19 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
// Unreal Engine Offsets updates (needed when the game reveives an update and to prevent the fix from crashing the game)
|
||||
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||
logger->info("------------ UEngine offsets search ------------");
|
||||
uint8_t* baseModule = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); // Get game base address
|
||||
|
||||
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
||||
GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
GObjectsaddress = Memory::AOBScan("", GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 8B F2 8B");
|
||||
AppendStringaddress = Memory::AOBScan(gameExecutable, AppendStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
AppendStringaddress = Memory::AOBScan("", 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");
|
||||
ProcessEventaddress = Memory::AOBScan(gameExecutable, ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
ProcessEventaddress = Memory::AOBScan("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
|
||||
if (!GObjectsaddress)
|
||||
logger->warn("GObjects signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
uint32_t gObjectsOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GObjectsaddress + 0x3) -
|
||||
reinterpret_cast<uint8_t*>(GetModuleHandleA(gameExecutable.c_str())));
|
||||
uint32_t gObjectsOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GObjectsaddress + 0x3) - baseModule);
|
||||
logger->info("GObjects offset is: 0x{:X}.", gObjectsOffset);
|
||||
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
|
||||
}
|
||||
@@ -217,7 +206,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
if (!AppendStringaddress)
|
||||
logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
std::optional<uint32_t> gAppendStringOffsetOpt = UE::CalculateOffset(gameExecutable, AppendStringaddress); // Get Offset from opcode
|
||||
std::optional<uint32_t> gAppendStringOffsetOpt = UE::CalculateOffset("", AppendStringaddress); // Get Offset from opcode
|
||||
uint32_t gAppendStringOffset = *gAppendStringOffsetOpt;
|
||||
logger->info("AppendString offset is: 0x{:X}.", gAppendStringOffset);
|
||||
Offsets::AppendString = static_cast<UC::uint32>(gAppendStringOffset); // Update AppendString offset
|
||||
@@ -226,7 +215,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
if (!ProcessEventaddress)
|
||||
logger->warn("Process Event signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
std::optional<uint32_t> gProcessEventOffsetOpt = UE::CalculateOffset(gameExecutable, ProcessEventaddress);
|
||||
std::optional<uint32_t> gProcessEventOffsetOpt = UE::CalculateOffset("", ProcessEventaddress);
|
||||
uint32_t gProcessEventOffset = *gProcessEventOffsetOpt;
|
||||
logger->info("Process Event offset is: 0x{:X}.", gProcessEventOffset);
|
||||
Offsets::ProcessEvent = static_cast<UC::uint32>(gProcessEventOffset);// Update ProcessEvent offset
|
||||
@@ -236,61 +225,24 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
logger->info("-------------- Fixes initialisation -------------");
|
||||
}
|
||||
|
||||
if (g_fix_enabled) {
|
||||
if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled || g_aspect_fix_enabled);
|
||||
if (Aspectaddress) AspectFixEnabled(g_aspect_fix_enabled);
|
||||
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
|
||||
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
||||
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
|
||||
if (CameraDistanceaddress) CameraDistanceFixEnabled(g_cam_distance_fix_enabled);
|
||||
//ProcessEvent();
|
||||
}
|
||||
else {
|
||||
if (FOVaddress) FOVFixEnabled(false);
|
||||
if (Aspectaddress) AspectFixEnabled(false);
|
||||
if (DOFaddress) DOFFixEnabled(false);
|
||||
if (Vignettingaddress) VignettingFixEnabled(false);
|
||||
if (Fogaddress) FogFixEnabled(false);
|
||||
if (CameraDistanceaddress) CameraDistanceFixEnabled(false);
|
||||
logger->info("All fixes disabled");
|
||||
}
|
||||
if (!init && FOVaddress) FOVFixEnabled();
|
||||
if (!init && Aspectaddress) AspectFixEnabled();
|
||||
if (!init && DOFaddress) DOFFixEnabled();
|
||||
if (!init && Vignettingaddress) VignettingFixEnabled();
|
||||
if (!init && Fogaddress) FogFixEnabled();
|
||||
if (!init && CameraDistanceaddress) CameraDistanceFixEnabled();
|
||||
}
|
||||
|
||||
// Setters for Reshade addon calls
|
||||
extern "C" __declspec(dllexport) void SetFOVFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_fov_fix_enabled = enabled;
|
||||
if (!init) FOVFixEnabled(g_fov_fix_enabled || g_aspect_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetAspectRatioFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_aspect_fix_enabled = enabled;
|
||||
if (!init) AspectFixEnabled(g_aspect_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetDOFFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_DOF_fix_enabled = enabled;
|
||||
if (!init) DOFFixEnabled(g_DOF_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetVignettingFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_Vignetting_fix_enabled = enabled;
|
||||
if (!init) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFogFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_Fog_fix_enabled = enabled;
|
||||
if (!init) FogFixEnabled(g_Fog_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetCameraDistanceFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_cam_distance_fix_enabled = enabled;
|
||||
if (!init) CameraDistanceFixEnabled(g_cam_distance_fix_enabled);
|
||||
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled)
|
||||
{ // Set each fix individually
|
||||
if (fix == GameFixes::DevConsole) { g_Console = enabled; EnableConsole(); }
|
||||
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
||||
if (fix == GameFixes::UltraWide) { g_aspect_fix_enabled = enabled; AspectFixEnabled(); }
|
||||
if (fix == GameFixes::Camera) { g_cam_distance_fix_enabled = enabled; CameraDistanceFixEnabled(); }
|
||||
if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); }
|
||||
if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); }
|
||||
if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); }
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
||||
@@ -303,31 +255,21 @@ extern "C" __declspec(dllexport) void SetCameraDistance(float cameraDistance)
|
||||
g_cameraDistanceMultiplier = cameraDistance;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetConsole()
|
||||
{
|
||||
EnableConsole();
|
||||
}
|
||||
|
||||
// Getters for Reshade addon calls
|
||||
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 GetCompensatedFOV() {
|
||||
return g_Compensated_FOV;
|
||||
}
|
||||
|
||||
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->CompensatedFOV = g_Compensated_FOV;
|
||||
infos->cameraIn = g_Camera_In;
|
||||
infos->cameraOut = g_Camera_Out;
|
||||
infos->consoleEnabled = g_Console_Enabled;
|
||||
}
|
||||
|
||||
// Code injection functions
|
||||
static void FOVFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && FOVaddress) {
|
||||
static void FOVFixEnabled() {
|
||||
if (g_fix_enabled && (g_fov_fix_enabled || g_aspect_fix_enabled) && FOVaddress) {
|
||||
if (!FOVHook) { // Hook only once
|
||||
FOVHook = safetyhook::create_mid(FOVaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
@@ -343,52 +285,52 @@ static void FOVFixEnabled(bool fix_enabled) {
|
||||
|
||||
logger->info("FOV fix enabled");
|
||||
}
|
||||
if (!fix_enabled) {
|
||||
if (!(g_fix_enabled && (g_fov_fix_enabled || g_aspect_fix_enabled)) && FOVaddress) {
|
||||
if (FOVHook) FOVHook.disable();
|
||||
logger->info("FOV fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// Memory patch fixes
|
||||
static void AspectFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Aspectaddress) {
|
||||
static void AspectFixEnabled() {
|
||||
if (g_fix_enabled && g_aspect_fix_enabled && Aspectaddress) {
|
||||
const char* newAspectRatio = Memory::Float32ToHexBytes(aspectRatio); // Converts new apsect ratio in 4 char bytes
|
||||
Memory::PatchBytes(Aspectaddress, newAspectRatio, 4); // mov [rdi+00000254],3FE38E39 <= patched
|
||||
logger->info("Aspect fix enabled");
|
||||
FOVFixEnabled(fix_enabled);
|
||||
FOVFixEnabled();
|
||||
}
|
||||
if (!fix_enabled && Aspectaddress) {
|
||||
if (!(g_fix_enabled && g_aspect_fix_enabled) && Aspectaddress) {
|
||||
Memory::RestoreBytes(Aspectaddress);
|
||||
logger->info("Aspect ratio fix disabled");
|
||||
if (!g_fov_fix_enabled)
|
||||
FOVFixEnabled(fix_enabled);
|
||||
FOVFixEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
static void DOFFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && DOFaddress) {
|
||||
static void DOFFixEnabled() {
|
||||
if (g_fix_enabled && g_DOF_fix_enabled && DOFaddress) {
|
||||
Memory::PatchBytes(DOFaddress, "\x31\xF6\x90", 3); // xor esi,esi r.DepthOfFieldQuality = 0
|
||||
logger->info("Depth of field fix enabled");
|
||||
}
|
||||
if (!fix_enabled && DOFaddress) {
|
||||
if (!(g_fix_enabled && g_DOF_fix_enabled) && DOFaddress) {
|
||||
Memory::RestoreBytes(DOFaddress);
|
||||
logger->info("Depth of field fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void VignettingFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Vignettingaddress) {
|
||||
static void VignettingFixEnabled() {
|
||||
if (g_fix_enabled && g_Vignetting_fix_enabled && Vignettingaddress) {
|
||||
Memory::PatchBytes(Vignettingaddress, "\x31\xC9", 2); // xor ecx,ecx r.Tonemapper.Quality=0
|
||||
logger->info("Vignetting fix enabled");
|
||||
}
|
||||
if (!fix_enabled && Vignettingaddress) {
|
||||
if (!(g_fix_enabled && g_Vignetting_fix_enabled) && Vignettingaddress) {
|
||||
Memory::RestoreBytes(Vignettingaddress);
|
||||
logger->info("Vignetting fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void FogFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Fogaddress) {
|
||||
static void FogFixEnabled() {
|
||||
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
||||
if (!FogHook) { // Hook only once
|
||||
FogHook = safetyhook::create_mid(Fogaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
@@ -399,19 +341,21 @@ static void FogFixEnabled(bool fix_enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
static void CameraDistanceFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && CameraDistanceaddress) {
|
||||
static void CameraDistanceFixEnabled() {
|
||||
if (g_fix_enabled && g_cam_distance_fix_enabled && CameraDistanceaddress) {
|
||||
if (!CameraDistanceHook) { // Hook only once
|
||||
CameraDistanceHook = safetyhook::create_mid(CameraDistanceaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_Camera_In = ctx.xmm1.f32[0];
|
||||
ctx.xmm1.f32[0] *= g_cameraDistanceMultiplier;
|
||||
g_Camera_Out = ctx.xmm1.f32[0];
|
||||
});
|
||||
}
|
||||
else CameraDistanceHook.enable();
|
||||
|
||||
logger->info("Camera distance fix enabled");
|
||||
}
|
||||
if (!fix_enabled) {
|
||||
if (!(g_fix_enabled && g_cam_distance_fix_enabled) && CameraDistanceaddress) {
|
||||
if (CameraDistanceHook) CameraDistanceHook.disable();
|
||||
logger->info("Camera distance fix disabled");
|
||||
}
|
||||
@@ -469,21 +413,6 @@ static void CameraDistanceFixEnabled(bool fix_enabled) {
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// auto* camModifier = reinterpret_cast<UCameraModifier*>(object);
|
||||
// auto* camOwner = camModifier->CameraOwner;
|
||||
//
|
||||
// if (camModifier && camOwner) {
|
||||
// FTViewTarget viewTarget = camOwner->ViewTarget;
|
||||
// AActor* pawn = viewTarget.Target;
|
||||
// if (pawn) {
|
||||
// auto* springArm = reinterpret_cast<USpringArmComponent*>(pawn->GetComponentByClass(USHCharacterPlaySpringArmComponent::StaticClass()));
|
||||
//
|
||||
// if (springArm && springArm->GetOwner() == pawn && springArm->IsA(USHCharacterPlaySpringArmComponent::StaticClass())) {
|
||||
// logger->info("springarm trouve: {:p} = {} == {}", reinterpret_cast<void*>(&springArm->TargetArmLength), springArm->TargetArmLength, springArm->GetFullName());
|
||||
// springArm->TargetArmLength = 250.f;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
@@ -492,6 +421,11 @@ static void CameraDistanceFixEnabled(bool fix_enabled) {
|
||||
// UE Console creation
|
||||
static void EnableConsole()
|
||||
{
|
||||
if (!g_Console) {
|
||||
logger->info("------------------ User inputs ------------------");
|
||||
return;
|
||||
}
|
||||
|
||||
logger->info("-------------- Console re-enabling --------------");
|
||||
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||
logger->warn("Could not re-enable console");
|
||||
|
||||
Reference in New Issue
Block a user