Ads skip intro. Code refactoring
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "UEngine.hpp";
|
||||
#include "UEvars.hpp"
|
||||
#include "SDK/Engine_classes.hpp"
|
||||
#include "SDK/GameBase_classes.hpp"
|
||||
|
||||
using namespace SDK;
|
||||
|
||||
@@ -28,8 +29,10 @@ static bool g_DOF_fix_enabled = false;
|
||||
static bool g_Vignetting_fix_enabled = false;
|
||||
static bool g_Fog_fix_enabled = false;
|
||||
static bool g_cam_distance_fix_enabled = false;
|
||||
static bool g_SkipIntro_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static float g_cameraDistanceMultiplier = 1.f;
|
||||
static bool user_inputs_logged = false;
|
||||
|
||||
// Shared values
|
||||
static float g_FOV_In = 0;
|
||||
@@ -52,6 +55,7 @@ static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid AspectHook{};
|
||||
static SafetyHookMid FogHook{};
|
||||
static SafetyHookMid CameraDistanceHook{};
|
||||
static SafetyHookMid PEHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled();
|
||||
@@ -61,158 +65,57 @@ static void VignettingFixEnabled();
|
||||
static void FogFixEnabled();
|
||||
static void CameraDistanceFixEnabled();
|
||||
static void EnableConsole();
|
||||
static void ProcessEvent();
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_fix_enabled = enabled;
|
||||
if (g_fix_enabled && !AOBScanDone) { // Unreal Engine 5.5.4
|
||||
if (!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("", 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
|
||||
//"Cronos-Win64-Shipping.exe" + 36B637B - 8B 83 54 02 00 00 - mov eax, [rbx + 00000254]
|
||||
//"Cronos-Win64-Shipping.exe" + 36B6381 - 89 47 5C - mov[rdi + 5C], eax
|
||||
|
||||
if (!FOVaddress)
|
||||
logger->warn("FOV signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("FOV signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(FOVaddress));
|
||||
FOVaddress += 0xa;
|
||||
}
|
||||
}
|
||||
using AOBScan::Make;
|
||||
using OffsetScan::Make;
|
||||
|
||||
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("", 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
|
||||
//"Cronos-Win64-Shipping.exe" + 54C4612 - C7 87 54 02 00 00 398EE33F - mov[rdi + 00000254], 3FE38E39
|
||||
//"Cronos-Win64-Shipping.exe" + 54C461C - 48 83 BF 98 00 00 00 00 - cmp qword ptr[rdi + 00000098], 00
|
||||
constexpr auto FOVStringObfuscated = make_obfuscated<0x8B>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 83 ?? ?? ?? ?? 89");
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x39>("C7 43 ?? 39 8E E3 3F C7 87 ?? ?? ?? ?? 39 8E E3 3F 48 83 ?? ?? ?? ?? ?? ?? 75");
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x0F>("74 ?? 48 ?? ?? 8B ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 0F");
|
||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0x7D>("8B ?? 83 ?? ?? 7D ?? 44 89");
|
||||
constexpr auto FogStringObfuscated = make_obfuscated<0xB3>("F6 ?? ?? ?? ?? 74 ?? 48 8B ?? ?? ?? ?? ?? 83 78 ?? ?? 75 ?? B3");
|
||||
constexpr auto CamDistanceStringObfuscated = make_obfuscated<0xF2>("E8 ?? ?? ?? ?? F2 0F ?? ?? ?? ?? 48 8D ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 0F");
|
||||
// Prepare all data for scanning
|
||||
std::vector<AOBScanEntry> signatures = {
|
||||
Make(&FOVaddress, FOVStringObfuscated, "FOV"),
|
||||
Make(&Aspectaddress, AspectStringObfuscated, "Ultrawide"),
|
||||
Make(&CameraDistanceaddress, CamDistanceStringObfuscated, "Camera distance"),
|
||||
Make(&DOFaddress, DOFStringObfuscated, "DOF"),
|
||||
Make(&Vignettingaddress, VignettingStringObfuscated, "Vignetting"),
|
||||
Make(&Fogaddress, FogStringObfuscated, "Fog")
|
||||
};
|
||||
// Scan all signature in a batch
|
||||
Memory::AOBScanBatch(signatures, logger);
|
||||
|
||||
if (!Aspectaddress)
|
||||
logger->warn("Aspect ratio signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Aspect ratio signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Aspectaddress));
|
||||
Aspectaddress += 0x3;
|
||||
}
|
||||
}
|
||||
|
||||
if (DOFaddress == nullptr) {
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("74 ?? 48 ?? ?? 8B ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 0F");
|
||||
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]
|
||||
//"Cronos-Win64-Shipping.exe" + 2712F8F - 48 8B CF - mov rcx, rdi
|
||||
//"Cronos-Win64-Shipping.exe" + 2712F92 - E8 29 8D 6F 01 - call "Cronos-Win64-Shipping.exe" + 3E0BCC0
|
||||
|
||||
if (!DOFaddress)
|
||||
logger->warn("DOF signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("DOF signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(DOFaddress));
|
||||
DOFaddress += 0x5;
|
||||
}
|
||||
}
|
||||
|
||||
if (Vignettingaddress == nullptr) {
|
||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 44 89");
|
||||
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
|
||||
//"Cronos-Win64-Shipping.exe" + 3E079FB - 44 89 BB C8 22 00 00 - mov[rbx + 000022C8], r15d
|
||||
//"Cronos-Win64-Shipping.exe" + 3E07A02 - EB 05 - jmp "Cronos-Win64-Shipping.exe" + 3E07A09
|
||||
|
||||
if (!Vignettingaddress)
|
||||
logger->warn("Vignetting signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Vignetting signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Vignettingaddress));
|
||||
Vignettingaddress += 0x5;
|
||||
}
|
||||
}
|
||||
|
||||
if (Fogaddress == nullptr) {
|
||||
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("F6 ?? ?? ?? ?? 74 ?? 48 8B ?? ?? ?? ?? ?? 83 78 ?? ?? 75 ?? B3");
|
||||
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
|
||||
//"Cronos-Win64-Shipping.exe" + 231B617 - B3 01 - mov bl, 01
|
||||
//"Cronos-Win64-Shipping.exe" + 231B619 - EB 02 - jmp "Cronos-Win64-Shipping.exe" + 231B61D
|
||||
|
||||
if (!Fogaddress)
|
||||
logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
|
||||
Fogaddress += 0x12;
|
||||
}
|
||||
}
|
||||
|
||||
if (CameraDistanceaddress == nullptr) {
|
||||
constexpr auto CamDistanceStringObfuscated = make_obfuscated<0x4A>("E8 ?? ?? ?? ?? F2 0F ?? ?? ?? ?? 48 8D ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 0F");
|
||||
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]
|
||||
//"Cronos-Win64-Shipping.exe" + 55E90A1 - 48 8D 8D B0 02 00 00 - lea rcx, [rbp + 000002B0]
|
||||
//"Cronos-Win64-Shipping.exe" + 55E90A8 - 0F5A C9 - cvtps2pd xmm1, xmm1
|
||||
|
||||
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<uintptr_t>(CameraDistanceaddress));
|
||||
CameraDistanceaddress += 0x17;
|
||||
}
|
||||
}
|
||||
|
||||
if (FOVaddress && Aspectaddress && DOFaddress && Vignettingaddress && Fogaddress && CameraDistanceaddress) {
|
||||
if (FOVaddress && Aspectaddress && DOFaddress && Vignettingaddress && Fogaddress && CameraDistanceaddress)
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
AOBScanDone = true;
|
||||
}
|
||||
|
||||
// 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("", 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("", 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("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x33>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
||||
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x80>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 8B F2 8B");
|
||||
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x56>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 33 ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48");
|
||||
|
||||
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) - baseModule);
|
||||
logger->info("GObjects offset is: 0x{:X}.", gObjectsOffset);
|
||||
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
|
||||
}
|
||||
|
||||
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("", 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
|
||||
}
|
||||
|
||||
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("", ProcessEventaddress);
|
||||
uint32_t gProcessEventOffset = *gProcessEventOffsetOpt;
|
||||
logger->info("Process Event offset is: 0x{:X}.", gProcessEventOffset);
|
||||
Offsets::ProcessEvent = static_cast<UC::uint32>(gProcessEventOffset);// Update ProcessEvent offset
|
||||
}
|
||||
// Prepare all data for scanning
|
||||
std::vector<OffsetScanEntry> UEoffsetsScans = {
|
||||
Make(&GObjectsaddress, GObjetcsStringObfuscated, "GObjects", OffsetCalcType::GetOffsetFromOpcode, &Offsets::GObjects, 0x3),
|
||||
Make(&AppendStringaddress, AppendStringStringObfuscated, "AppendString", OffsetCalcType::UE_CalculateOffset, &Offsets::AppendString),
|
||||
Make(&ProcessEventaddress, ProcessEventStringObfuscated, "ProcessEvent", OffsetCalcType::UE_CalculateOffset, &Offsets::ProcessEvent)
|
||||
};
|
||||
// Retrieve all Unreal Engine offsets in a batch
|
||||
Memory::OffsetScanBatch(UEoffsetsScans, baseModule, logger, "");
|
||||
}
|
||||
|
||||
AOBScanDone = true;
|
||||
logger->info("-------------- Fixes initialisation -------------");
|
||||
}
|
||||
|
||||
@@ -222,11 +125,11 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
||||
if (!init && Vignettingaddress) VignettingFixEnabled();
|
||||
if (!init && Fogaddress) FogFixEnabled();
|
||||
if (!init && CameraDistanceaddress) CameraDistanceFixEnabled();
|
||||
ProcessEvent();
|
||||
}
|
||||
|
||||
// Setters for Reshade addon calls
|
||||
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled)
|
||||
{ // Set each fix individually
|
||||
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(); }
|
||||
@@ -234,6 +137,8 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable
|
||||
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(); }
|
||||
if (fix == GameFixes::SkipIntro) { g_SkipIntro_fix_enabled = enabled; }
|
||||
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFOV(int fov) {
|
||||
@@ -256,17 +161,42 @@ extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||
infos->consoleEnabled = g_Console_Enabled;
|
||||
}
|
||||
|
||||
static bool inContinue = false;
|
||||
static void ProcessEvent() {
|
||||
if (!PEHook && ProcessEventaddress) {
|
||||
PEHook = safetyhook::create_mid(ProcessEventaddress + 0xc,
|
||||
[](SafetyHookContext& ctx) {
|
||||
UObject* object = (UObject*)ctx.rcx;
|
||||
UFunction* func = (UFunction*)ctx.rdx;
|
||||
|
||||
if (object && func && g_DOF_fix_enabled) {
|
||||
std::string funcName = func->GetName();
|
||||
std::string objectName = object->GetName();
|
||||
std::string objectFullName = object->GetFullName();
|
||||
// Skip disclaimers
|
||||
if (objectName.contains("StartGameMenuWidget")) {
|
||||
auto* widget = static_cast<UStartGameWidget*>(object);
|
||||
if (widget && widget->Class && widget->IsA(UStartGameWidget::StaticClass()) && funcName == "OnNext" && !inContinue) {
|
||||
inContinue = true;
|
||||
if (g_SkipIntro_fix_enabled) widget->Continue();
|
||||
inContinue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Code injection functions
|
||||
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,
|
||||
FOVHook = safetyhook::create_mid(FOVaddress + 0xa,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_FOV_In = ctx.xmm0.f32[0];
|
||||
if (g_aspect_fix_enabled)
|
||||
g_Compensated_FOV = ctx.xmm0.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, baseAspect, aspectRatio);
|
||||
else
|
||||
g_Compensated_FOV = ctx.xmm0.f32[0];
|
||||
if (g_fix_enabled && g_aspect_fix_enabled)
|
||||
ctx.xmm0.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, baseAspect, aspectRatio);
|
||||
g_Compensated_FOV = ctx.xmm0.f32[0];
|
||||
g_FOV_Out = ctx.xmm0.f32[0] += (g_fov_fix_enabled ? g_AdditionalFOVValue : 0);
|
||||
});
|
||||
}
|
||||
@@ -284,36 +214,33 @@ static void FOVFixEnabled() {
|
||||
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
|
||||
Memory::PatchBytes(Aspectaddress + 0x3, newAspectRatio, 4); // mov [rdi+00000254],3FE38E39 <= patched
|
||||
logger->info("Aspect fix enabled");
|
||||
FOVFixEnabled();
|
||||
}
|
||||
if (!(g_fix_enabled && g_aspect_fix_enabled) && Aspectaddress) {
|
||||
Memory::RestoreBytes(Aspectaddress);
|
||||
Memory::RestoreBytes(Aspectaddress + 0x3);
|
||||
logger->info("Aspect ratio fix disabled");
|
||||
if (!g_fov_fix_enabled)
|
||||
FOVFixEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
Memory::PatchBytes(DOFaddress + 0x5, "\x31\xF6\x90", 3); // xor esi,esi r.DepthOfFieldQuality = 0
|
||||
logger->info("Depth of field fix enabled");
|
||||
}
|
||||
if (!(g_fix_enabled && g_DOF_fix_enabled) && DOFaddress) {
|
||||
Memory::RestoreBytes(DOFaddress);
|
||||
Memory::RestoreBytes(DOFaddress + 0x5);
|
||||
logger->info("Depth of field fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
Memory::PatchBytes(Vignettingaddress + 0x5, "\x31\xC9", 2); // xor ecx,ecx r.Tonemapper.Quality=0
|
||||
logger->info("Vignetting fix enabled");
|
||||
}
|
||||
if (!(g_fix_enabled && g_Vignetting_fix_enabled) && Vignettingaddress) {
|
||||
Memory::RestoreBytes(Vignettingaddress);
|
||||
Memory::RestoreBytes(Vignettingaddress + 0x5);
|
||||
logger->info("Vignetting fix disabled");
|
||||
}
|
||||
}
|
||||
@@ -321,7 +248,7 @@ static void VignettingFixEnabled() {
|
||||
static void FogFixEnabled() {
|
||||
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
||||
if (!FogHook) { // Hook only once
|
||||
FogHook = safetyhook::create_mid(Fogaddress,
|
||||
FogHook = safetyhook::create_mid(Fogaddress + 0x12,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ctx.rflags &= ~0x40; // ZF=0
|
||||
});
|
||||
@@ -333,7 +260,7 @@ static void FogFixEnabled() {
|
||||
static void CameraDistanceFixEnabled() {
|
||||
if (g_fix_enabled && g_cam_distance_fix_enabled && CameraDistanceaddress) {
|
||||
if (!CameraDistanceHook) { // Hook only once
|
||||
CameraDistanceHook = safetyhook::create_mid(CameraDistanceaddress,
|
||||
CameraDistanceHook = safetyhook::create_mid(CameraDistanceaddress + 0x17,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_Camera_In = ctx.xmm1.f32[0];
|
||||
ctx.xmm1.f32[0] *= g_cameraDistanceMultiplier;
|
||||
@@ -352,17 +279,15 @@ static void CameraDistanceFixEnabled() {
|
||||
|
||||
// UE Console creation
|
||||
static void EnableConsole() {
|
||||
if (!g_Console) {
|
||||
logger->info("------------------ User inputs ------------------");
|
||||
if (g_Console_Enabled || !g_Console || !GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||
if (!g_Console && !user_inputs_logged) {
|
||||
logger->info("------------------ User inputs ------------------");
|
||||
user_inputs_logged = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
logger->info("-------------- Console re-enabling --------------");
|
||||
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||
logger->warn("Could not re-enable console");
|
||||
logger->info("------------------ User inputs ------------------");
|
||||
return;
|
||||
}
|
||||
|
||||
std::thread([&]() {
|
||||
auto start = std::chrono::high_resolution_clock::now(); // Measure the time to renable console
|
||||
@@ -384,8 +309,7 @@ static void EnableConsole() {
|
||||
|
||||
/* Creates a new UObject of class-type specified by Engine->ConsoleClass */
|
||||
UObject* NewObject = UGameplayStatics::SpawnObject(Engine->ConsoleClass, Engine->GameViewport);
|
||||
if (NewObject)
|
||||
{
|
||||
if (NewObject) {
|
||||
logger->info("Successfully spawned console object");
|
||||
// Set the console viewport so that it will be displayed
|
||||
Engine->GameViewport->ViewportConsole = static_cast<UConsole*>(NewObject);
|
||||
@@ -409,6 +333,7 @@ static void InitializeLogger() {
|
||||
if (std::filesystem::exists(log_path))
|
||||
std::filesystem::remove(log_path);
|
||||
logger = std::make_shared<spdlog::logger>("Cronos : The New Dawn", std::make_shared<spdlog::sinks::rotating_file_sink_st>(PLUGIN_LOG, 10 * 1024 * 1024, 1));
|
||||
logger->set_level(spdlog::level::debug);
|
||||
logger->flush_on(spdlog::level::debug); // Flush automatically
|
||||
}
|
||||
catch (const spdlog::spdlog_ex& ex) {
|
||||
|
||||
Reference in New Issue
Block a user