Add effects fixes
This commit is contained in:
@@ -20,6 +20,8 @@ static std::atomic<bool> g_fix_enabled = false;
|
||||
static std::atomic<bool> g_fov_fix_enabled = false;
|
||||
static std::atomic<bool> g_ultrawide_fix_enabled = false;
|
||||
static std::atomic<bool> g_camera_fix_enabled = false;
|
||||
static std::atomic<bool> g_DOF_fix_enabled = false;
|
||||
static std::atomic<bool> g_vignetting_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static float g_cameraDistanceMultiplier = 1.f;
|
||||
|
||||
@@ -34,16 +36,21 @@ static uint8_t* FOVaddress = nullptr;
|
||||
static uint8_t* Ultrawideaddress = nullptr;
|
||||
static uint8_t* Cutscenesaddress = nullptr;
|
||||
static uint8_t* Cameraaddress = nullptr;
|
||||
static uint8_t* DOFaddress = nullptr;
|
||||
static uint8_t* Vignetteaddress = nullptr;
|
||||
|
||||
// Hooking
|
||||
static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid CameraHook{};
|
||||
static SafetyHookMid UWHook{};
|
||||
static SafetyHookMid VignetteHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled();
|
||||
static void UltraWideFixEnabled();
|
||||
static void CameraFixEnabled();
|
||||
static void DOFFixEnabled();
|
||||
static void VignetteFixEnabled();
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
g_fix_enabled = enabled;
|
||||
@@ -52,6 +59,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
constexpr auto FOVStringObfuscated = make_obfuscated<0xFA>("C5 F8 ?? ?? ?? ?? C5 F8 ?? ?? ?? ?? C5 78 ?? ?? ?? ?? C5 FA ?? ?? C5 F2 59 ?? ?? ?? ?? ?? 48 83 ?? ?? C3"); // +0x1e
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x8B>("C5 FA 10 ?? ?? C5 F2 ?? ?? C5 CA ?? ?? E9 ?? ?? ?? ?? C5 FA 10 ?? ?? ?? ?? ?? C5");
|
||||
constexpr auto AspectCutscenesStringObfuscated = make_obfuscated<0x9D>("0F 84 ?? ?? ?? ?? 49 8B 9D ?? ?? ?? ?? 49 63 85 ?? ?? ?? ?? 48 6B ?? ?? 48 ?? ?? 48 ?? ?? 0F 84");
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x84>("48 83 ?? ?? C4 C1 ?? ?? ?? C5 FA ?? ?? C5 F8 ?? ?? C5 F8 ?? ?? ?? ?? C5 F8 ?? ?? ?? C5 F8 ?? ?? 76");
|
||||
constexpr auto VignetteStringObfuscated = make_obfuscated<0x84>("C5 FA ?? ?? ?? 48 83 ?? ?? 0F 85 ?? ?? ?? ?? C5 F8 ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? ?? C6 43");
|
||||
constexpr auto CameraStringObfuscated = make_obfuscated<0x84>("C5 FA 10 ?? ?? ?? ?? ?? 40 38 ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? C5 FA 10");
|
||||
|
||||
using AOBScan::Make;
|
||||
@@ -62,10 +71,12 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
Make(&Ultrawideaddress, AspectStringObfuscated, "Ultrawide"),
|
||||
Make(&Cutscenesaddress, AspectCutscenesStringObfuscated, "Cutscenes"),
|
||||
Make(&Cameraaddress, CameraStringObfuscated, "Camera"),
|
||||
Make(&DOFaddress, DOFStringObfuscated, "Depth of field"),
|
||||
Make(&Vignetteaddress, VignetteStringObfuscated, "Vignette")
|
||||
};
|
||||
// Scan all signature in a batch
|
||||
Memory::AOBScanBatch(signatures, logger);
|
||||
if (FOVaddress && Ultrawideaddress && Cutscenesaddress && Cameraaddress)
|
||||
if (FOVaddress && Ultrawideaddress && Cutscenesaddress && Cameraaddress && DOFaddress && Vignetteaddress)
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
|
||||
logger->info("-------------- Fixes initialisation -------------");
|
||||
@@ -75,6 +86,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
if (!init && FOVaddress) FOVFixEnabled();
|
||||
if (!init && Ultrawideaddress) UltraWideFixEnabled();
|
||||
if (!init && Cameraaddress) CameraFixEnabled();
|
||||
if (!init && DOFaddress) DOFFixEnabled();
|
||||
if (!init && Vignetteaddress) VignetteFixEnabled();
|
||||
}
|
||||
|
||||
// Setters for Reshade addon call
|
||||
@@ -82,6 +95,8 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable
|
||||
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
||||
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
|
||||
if (fix == GameFixes::Camera) { g_camera_fix_enabled = enabled; CameraFixEnabled(); }
|
||||
if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); }
|
||||
if (fix == GameFixes::Vignetting) { g_vignetting_fix_enabled = enabled; VignetteFixEnabled(); }
|
||||
if (fix == GameFixes::None) logger->info("------------------ User inputs ------------------");
|
||||
}
|
||||
|
||||
@@ -89,6 +104,7 @@ extern "C" __declspec(dllexport) void SetValues(GameSetting setting, float value
|
||||
if (setting == GameSetting::FOV) g_AdditionalFOVValue = (int)(value);
|
||||
if (setting == GameSetting::CameraDistance) g_cameraDistanceMultiplier = value;
|
||||
}
|
||||
|
||||
// Getters for Reshade addon call
|
||||
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||
if (!infos) return;
|
||||
@@ -148,7 +164,7 @@ static void CameraFixEnabled() {
|
||||
CameraHook = safetyhook::create_mid(Cameraaddress + 0x8,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_Camera_In = ctx.xmm0.f32[0];
|
||||
ctx.xmm0.f32[0] *= g_cameraDistanceMultiplier;;
|
||||
ctx.xmm0.f32[0] *= g_cameraDistanceMultiplier;
|
||||
g_Camera_Out = ctx.xmm0.f32[0];
|
||||
});
|
||||
}
|
||||
@@ -159,6 +175,30 @@ static void CameraFixEnabled() {
|
||||
logger->info("Camera fix {}", g_fix_enabled && g_camera_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
static void VignetteFixEnabled() {
|
||||
if (!Vignetteaddress) return;
|
||||
if (g_fix_enabled && g_vignetting_fix_enabled) {
|
||||
if (!VignetteHook) {
|
||||
VignetteHook = safetyhook::create_mid(Vignetteaddress,
|
||||
[](SafetyHookContext& ctx) { ctx.xmm3.f32[0] = 0.f; });
|
||||
}
|
||||
else VignetteHook.enable();
|
||||
}
|
||||
else if (VignetteHook) VignetteHook.disable();
|
||||
|
||||
logger->info("Vignetting fix {}", g_fix_enabled && g_vignetting_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
// Memory patch fixes
|
||||
static void DOFFixEnabled() {
|
||||
if (!DOFaddress) return;
|
||||
if (g_fix_enabled && g_DOF_fix_enabled)
|
||||
Memory::PatchBytes(DOFaddress, "\xC3", 1);
|
||||
else Memory::RestoreBytes(DOFaddress);
|
||||
|
||||
logger->info("Depth of field fix {}", g_fix_enabled && g_DOF_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
// Standard dll entry
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
|
||||
Reference in New Issue
Block a user