Add chromatic aberrations. Improved ultrawide fix.

This commit is contained in:
2025-09-02 14:51:45 +02:00
parent bf54e6aacc
commit 8c8fce42cf
40 changed files with 257493 additions and 19 deletions

View File

@@ -6,7 +6,10 @@
#include <spdlog/sinks/rotating_file_sink.h>
#include <filesystem>
#include <safetyhook.hpp>
#include "SDK/Basic.hpp"
#include "SDK/Engine_classes.hpp"
using namespace SDK;
// Constants
const std::string PLUGIN_NAME = "MGSDSE";
@@ -34,6 +37,7 @@ static bool g_FPS_fix_enabled = false;
static bool g_resolution_fix_enabled = false;
static bool g_aspect_fix_enabled = false;
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 int g_AdditionalFOVValue = 0;
@@ -51,13 +55,15 @@ static uint8_t* Resolutionaddress_2 = nullptr;
static uint8_t* Aspectaddress = nullptr;
static uint8_t* AspectMenuaddress = nullptr;
static uint8_t* DOFaddress = nullptr;
static uint8_t* CAaddress = nullptr;
static uint8_t* Vignettingaddress = nullptr;
static uint8_t* Fogaddress = nullptr;
// Hooking
static SafetyHookMid FOVHook{};
static SafetyHookMid FPSHook{};
static SafetyHookMid ResolutionHook{};
static SafetyHookMid ResolutionHook_1{};
static SafetyHookMid ResolutionHook_2{};
static SafetyHookMid AspectHook{};
static SafetyHookMid AspectMenuHook{};
static SafetyHookMid FogHook{};
@@ -68,10 +74,13 @@ static void FPSFixEnabled(bool fix_enabled);
static void ResolutionFixEnabled(bool fix_enabled);
static void AspectFixEnabled(bool fix_enabled);
static void DOFFixEnabled(bool fix_enabled);
static void CAFixEnabled(bool fix_enabled);
static void VignettingFixEnabled(bool fix_enabled);
static void FogFixEnabled(bool fix_enabled);
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
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) {
@@ -96,11 +105,11 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
if (Resolutionaddress_1 == nullptr) {
constexpr auto ResolutionStringObfuscated = make_obfuscated<0x4A>("C7 44 ?? ?? ?? ?? ?? ?? 0F 11 ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? 89 ?? ?? ?? C6 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 66");
Resolutionaddress_1 = Memory::AOBScan(gameExecutable, ResolutionStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
//"MGSDelta-Win64-Shipping.exe" + 43A6B64 - 48 8B 01 - mov rax, [rcx]
//"MGSDelta-Win64-Shipping.exe" + 43A6B67 - FF 90 48 07 00 00 - call qword ptr[rax + 00000748]
//"MGSDelta-Win64-Shipping.exe" + 43A6B6D - F3 0F 10 40 30 - movss xmm0, [rax + 30]
//"MGSDelta-Win64-Shipping.exe" + 43A6B72 - 48 83 C4 28 - add rsp, 28
//"MGSDelta-Win64-Shipping.exe" + 43A6B76 - C3 - ret
//"MGSDelta-Win64-Shipping.exe" + 4EAC202 - 74 28 - je "MGSDelta-Win64-Shipping.exe" + 4EAC22C
//"MGSDelta-Win64-Shipping.exe" + 4EAC204 - 0F57 C9 - xorps xmm1, xmm1
//"MGSDelta-Win64-Shipping.exe" + 4EAC207 - C7 44 24 20 00 00 F0 44 - mov[rsp + 20], 44F00000
//"MGSDelta-Win64-Shipping.exe" + 4EAC20F - 0F 11 4C 24 28 - movups[rsp + 28], xmm1
//"MGSDelta-Win64-Shipping.exe" + 4EAC214 - 48 8D 54 24 20 - lea rdx, [rsp + 20]
if (!Resolutionaddress_1)
logger->warn("Resolution signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
@@ -129,7 +138,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
}
if (Aspectaddress == nullptr) {
constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("C3 CC CC CC CC CC CC CC CC CC 48 89 ?? ?? ?? 57 48 83 ?? ?? 0F ?? ?? 48 ?? ?? 48 ?? ?? 0F ?? ?? F2 0F ?? ?? ?? F2 0F ?? ?? ?? 0F");
//constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("C3 CC CC CC CC CC CC CC CC CC 48 89 ?? ?? ?? 57 48 83 ?? ?? 0F ?? ?? 48 ?? ?? 48 ?? ?? 0F ?? ?? F2 0F ?? ?? ?? F2 0F ?? ?? ?? 0F");
constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 87 ?? ?? ?? ?? 89 ?? ?? 0F");
Aspectaddress = Memory::AOBScan(gameExecutable, AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
//"MGSDelta-Win64-Shipping.exe" + 3A03453 - 89 41 44 - mov[rcx + 44], eax
//"MGSDelta-Win64-Shipping.exe" + 3A03456 - 8B 42 48 - mov eax, [rdx + 48]
@@ -138,10 +148,11 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
//"MGSDelta-Win64-Shipping.exe" + 3A03460 - 48 83 C1 4C - add rcx, 4C
if (!Aspectaddress)
logger->warn("Aspect ratio ratio signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
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 = Aspectaddress + 0x63;
//Aspectaddress = Aspectaddress + 0x63;
Aspectaddress = Aspectaddress + 0x13;
}
}
@@ -177,6 +188,22 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
}
}
if (CAaddress == nullptr) {
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("7F ?? 89 B3 ?? ?? ?? ?? 8B ?? ?? 39 05");
CAaddress = Memory::AOBScan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
//"MGSDelta-Win64-Shipping.exe" + 4497760 - 48 8B 05 A1 05 04 10 - mov rax, ["MGSDelta-Win64-Shipping.exe" + 144D7D08]
//"MGSDelta-Win64-Shipping.exe" + 4497767 - 39 30 - cmp[rax], esi
//"MGSDelta-Win64-Shipping.exe" + 4497769 - 7F 06 - jg "MGSDelta-Win64-Shipping.exe" + 4497771
//"MGSDelta-Win64-Shipping.exe" + 449776B - 89 B3 EC 1E 00 00 - mov[rbx + 00001EEC], esi
//"MGSDelta-Win64-Shipping.exe" + 4497771 - 8B 04 2F - mov eax, [rdi + rbp]
if (!CAaddress)
logger->warn("Chromatic aberrations signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else {
logger->info("Chromatic aberrations found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(CAaddress));
}
}
if (Vignettingaddress == nullptr) {
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3 ?? ?? ?? ?? EB");
Vignettingaddress = Memory::AOBScan(gameExecutable, VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
@@ -210,7 +237,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
}
}
if (FOVaddress && Resolutionaddress_1 && FPSaddress && Aspectaddress && AspectMenuaddress && DOFaddress && Vignettingaddress && Fogaddress) {
if (FOVaddress && Resolutionaddress_1 && FPSaddress && Aspectaddress && AspectMenuaddress &&
DOFaddress && CAaddress && Vignettingaddress && Fogaddress) {
logger->info("All AOB signatures found. Ready to patch...");
AOBScanDone = true;
}
@@ -223,6 +251,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
if (Resolutionaddress_1) ResolutionFixEnabled(g_resolution_fix_enabled);
if (Aspectaddress) AspectFixEnabled(g_aspect_fix_enabled);
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
if (CAaddress) CAFixEnabled(g_CA_fix_enabled);
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
}
@@ -232,6 +261,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
if (Resolutionaddress_1) ResolutionFixEnabled(false);
if (Aspectaddress) AspectFixEnabled(false);
if (DOFaddress) DOFFixEnabled(false);
if (CAaddress) CAFixEnabled(false);
if (Vignettingaddress) VignettingFixEnabled(false);
if (Fogaddress) FogFixEnabled(false);
logger->info("All fixes disabled.");
@@ -269,6 +299,12 @@ extern "C" __declspec(dllexport) void SetDOFFixEnabled(bool enabled, bool init)
if (!init) DOFFixEnabled(g_DOF_fix_enabled);
}
extern "C" __declspec(dllexport) void SetCAFixEnabled(bool enabled, bool init)
{
g_CA_fix_enabled = enabled;
if (!init) CAFixEnabled(g_CA_fix_enabled);
}
extern "C" __declspec(dllexport) void SetVignettingFixEnabled(bool enabled, bool init)
{
g_Vignetting_fix_enabled = enabled;
@@ -326,17 +362,17 @@ static void ResolutionFixEnabled(bool fix_enabled) {
if (g_fix_enabled && fix_enabled && Resolutionaddress_1 && Resolutionaddress_2) {
Memory::PatchBytes(Resolutionaddress_1, bytesWidth, 4); // patch scree nwidth in memory
if (!ResolutionHook) { // Hook only once
ResolutionHook = safetyhook::create_mid(Resolutionaddress_2,
if (!ResolutionHook_2) { // Hook only once
ResolutionHook_2 = safetyhook::create_mid(Resolutionaddress_2,
[](SafetyHookContext& ctx) {
ctx.xmm0.f32[0] = (float)screenHeight;
});
}
else ResolutionHook.enable();
else ResolutionHook_2.enable();
logger->info("Resolution fix enabled");
}
if (!fix_enabled) {
if (ResolutionHook) ResolutionHook.disable();
if (ResolutionHook_2) ResolutionHook_2.disable();
Memory::RestoreBytes(Resolutionaddress_1);
logger->info("Resolution fix disabled");
}
@@ -373,7 +409,14 @@ static void AspectFixEnabled(bool fix_enabled) {
if (!AspectMenuHook) {
AspectMenuHook = safetyhook::create_mid(AspectMenuaddress,
[](SafetyHookContext& ctx) {
ctx.xmm0.f64[0] = static_cast<double>(aspectRatio);
if (!ctx.rbx) return;
auto obj = reinterpret_cast<UObject*>(ctx.rbx);
constexpr auto PauseBackScreenStringObfuscated = make_obfuscated<0x4A>("WP_PauseBackScreen");
const char* pauseBackScreen = PauseBackScreenStringObfuscated.decrypt().c_str();
if (obj->GetName().contains(pauseBackScreen))
ctx.xmm0.f64[0] = static_cast<double>(aspectRatio);
});
}
else AspectMenuHook.enable();
@@ -403,6 +446,17 @@ static void DOFFixEnabled(bool fix_enabled) {
}
}
static void CAFixEnabled(bool fix_enabled) {
if (g_fix_enabled && fix_enabled && CAaddress) {
Memory::PatchBytes(CAaddress, "\x90\x90", 2); // jg => NOP r.SceneColorFringeQuality=0
logger->info("Chromatic aberrations fix enabled");
}
if (!fix_enabled && CAaddress) {
Memory::RestoreBytes(CAaddress);
logger->info("Chromatic aberrations fix disabled");
}
}
static void VignettingFixEnabled(bool fix_enabled) {
if (g_fix_enabled && fix_enabled && Vignettingaddress) {
Memory::PatchBytes(Vignettingaddress, "\x31\xC9", 2); // xor ecx,ecx r.Tonemapper.Quality=0
@@ -443,8 +497,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID)
{
if (reason == DLL_PROCESS_ATTACH)
{
InitializeLogger();
logger->info("Plugin {} loaded.", PLUGIN_NAME);
if (reason == DLL_PROCESS_ATTACH)
{
InitializeLogger();
logger->info("Plugin {} loaded.", PLUGIN_NAME);
}
}
else if (reason == DLL_PROCESS_DETACH)
{