Rewritten original project. Add cheats. Code refactoring.
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
#include "Memory.hpp";
|
||||
#include "Maths.hpp";
|
||||
#include "ObfuscateString.h"
|
||||
#include <string>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
#include <filesystem>
|
||||
#include "CommonHeaders.h"
|
||||
#include "UEngine.hpp"
|
||||
#include "UETools.hpp"
|
||||
#include "UEvars.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "SDK/Basic.hpp"
|
||||
#include "SDK/Engine_classes.hpp"
|
||||
#include "SDK/BP_CombatCharacter_Player_Final_classes.hpp"
|
||||
#include "SDK/ExtendedStatComponent_Stamina_classes.hpp"
|
||||
#include "SDK/Impl_BaseAIController_classes.hpp"
|
||||
|
||||
using namespace SDK;
|
||||
|
||||
// Constants
|
||||
const std::string PLUGIN_NAME = "WuchangFF";
|
||||
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
|
||||
const std::string gameExecutable = "Project_Plague-Win64-Shipping.exe";
|
||||
const float defaultAspect = 1.777778; // Default aspect that must not be compensated because FOV is already HOR+
|
||||
constexpr ULONGLONG DEFAULT_DELAY_BETWEEN_TICK = 500; // Used ProcessEvent tick
|
||||
constexpr ULONGLONG DEFAULT_DELAY_BETWEEN_ACTOR_TICK = 30; // Used for enemies tick
|
||||
|
||||
// Logger
|
||||
std::shared_ptr<spdlog::logger> logger;
|
||||
@@ -18,402 +23,397 @@ std::shared_ptr<spdlog::logger> logger;
|
||||
// Screen informations
|
||||
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
static float aspectRatio = (float)screenWidth / screenHeight;
|
||||
static float baseAspect = 2.2222223; // Base game aspect ratio
|
||||
static float g_AspectRatio = (float)screenWidth / screenHeight;
|
||||
float baseAspect = 1.777778f;
|
||||
|
||||
// Plugin states
|
||||
static bool AOBScanDone = false;
|
||||
static bool g_fix_enabled = false;
|
||||
static bool g_fov_fix_enabled = false;
|
||||
static bool g_aspect_ratio_fix_enabled = false;
|
||||
static bool g_DOF_fix_enabled = false;
|
||||
static bool g_Vignetting_fix_enabled = false;
|
||||
static bool g_Fog_fix_enabled = false;
|
||||
static bool g_Console = false;
|
||||
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_HUD_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_CA_fix_enabled = false;
|
||||
static std::atomic<bool> g_Vignetting_fix_enabled = false;
|
||||
static std::atomic<bool> g_Fog_fix_enabled = false;
|
||||
static std::atomic<bool> g_TimeDilation_fix_enabled = false;
|
||||
static std::atomic<bool> g_GodMode_fix_enabled = false;
|
||||
static std::atomic<bool> g_Stamina_fix_enabled = false;
|
||||
static std::atomic<bool> g_Stealth_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
|
||||
static float g_CameraMultiplier = 1.f;
|
||||
static float g_WorldTimeDilationValue = 1.f;
|
||||
static float g_AITimeDilationValue = 1.f;
|
||||
static bool user_inputs_logged = false;
|
||||
// Player stats
|
||||
double g_Health = 0.0;
|
||||
double g_Stamina = 0.0;
|
||||
// Shared values
|
||||
static float g_FOV_In = 0;
|
||||
static float g_Compensated_FOV = 0;
|
||||
static float g_FOV_Out = 0;
|
||||
static float g_FOV_In = 80.f;
|
||||
static float g_CompensatedFOV = 80.f;
|
||||
static float g_FOV_Out = 80.f;
|
||||
static float g_CameraIn = 350.f;
|
||||
static float g_CameraOut = 350.f;
|
||||
|
||||
// AOB Scan pointers
|
||||
static uint8_t* FOVaddress = nullptr;
|
||||
static uint8_t* Aspectaddress_1 = nullptr;
|
||||
static uint8_t* Aspectaddress_2 = nullptr;
|
||||
static uint8_t* CameraComponentaddress = nullptr;
|
||||
static uint8_t* CameraDistanceaddress = nullptr;
|
||||
static uint8_t* DOFaddress = nullptr;
|
||||
static uint8_t* CAaddress = nullptr;
|
||||
static uint8_t* Vignettingaddress = nullptr;
|
||||
static uint8_t* Fogaddress = nullptr;
|
||||
static uint8_t* WorldTimedilationaddress = nullptr;
|
||||
static uint8_t* Timedilationaddress = nullptr;
|
||||
// Hooking
|
||||
static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid UWHook{};
|
||||
static SafetyHookMid CameraHook{};
|
||||
static SafetyHookMid PEHook{};
|
||||
static SafetyHookMid WorldTimeDilationHook{};
|
||||
static SafetyHookMid TimeDilationHook{};
|
||||
|
||||
// FOV Addresses
|
||||
uintptr_t t_fov_address_to_patch = 0;
|
||||
uintptr_t t_aspect_address_to_patch = 0;
|
||||
// Prototypes
|
||||
static void FOVFixEnabled();
|
||||
static void UltraWideFixEnabled(GameFixes fix);
|
||||
static void CameraDistanceFixEnabled();
|
||||
static void DOFFixEnabled();
|
||||
static void CAFixEnabled();
|
||||
static void VignettingFixEnabled();
|
||||
static void FogFixEnabled();
|
||||
static void EnableConsole();
|
||||
static void EnableCheats(Cheat cheat);
|
||||
static void ProcessEvent();
|
||||
|
||||
// VEH debugger handles
|
||||
PVOID vehFOVHandle = nullptr;
|
||||
PVOID vehApectHandle_1 = nullptr;
|
||||
PVOID vehApectHandle_2 = nullptr;
|
||||
|
||||
// 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);
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
||||
{
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
g_fix_enabled = enabled;
|
||||
if (g_fix_enabled && !AOBScanDone) {
|
||||
if (!AOBScanDone) { // Unreal Engine 5.1.1
|
||||
logger->info("--------------- AOB scan started ---------------");
|
||||
if (FOVaddress == nullptr) {
|
||||
constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 0F ?? ?? 8B");
|
||||
FOVaddress = Memory::AOBScan(gameExecutable, FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Project_Plague-Win64-Shipping.exe" + 3E1037A - EB 08 - jmp "Project_Plague-Win64-Shipping.exe" + 3E10384
|
||||
//"Project_Plague-Win64-Shipping.exe" + 3E1037C - F3 0F 10 83 E0 02 00 00 - movss xmm0, [rbx + 000002E0]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 3E10384 - F3 0F 11 47 30 - movss[rdi + 30], xmm0
|
||||
//"Project_Plague-Win64-Shipping.exe" + 3E10389 - 0F 57 C0 - xorps xmm0, xmm0
|
||||
//"Project_Plague-Win64-Shipping.exe" + 3E1038C - 8B 83 F0 02 00 00 - mov eax, [rbx + 000002F0]
|
||||
constexpr auto CameraComponentStringObfuscated = make_obfuscated<0x8B>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 0F ?? ?? 8B");
|
||||
constexpr auto CameraDistanceStringObfuscated = make_obfuscated<0x5A>("48 8D 8F ?? ?? ?? ?? F2 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 0F 5A");
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x6B>("48 ?? ?? 8B ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? 48 6B ?? ?? 48 8D");
|
||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0xB3>("8B ?? 83 ?? ?? 7D ?? 89 B3 ?? ?? ?? ?? EB");
|
||||
constexpr auto FogStringObfuscated = make_obfuscated<0x32>("75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 8B");
|
||||
constexpr auto WorldTimeDilationStringObfuscated = make_obfuscated<0x59>("F3 0F 10 ?? ?? ?? ?? ?? F3 0F 59 ?? ?? ?? ?? ?? F3 0F 59 ?? ?? ?? ?? ?? C3");
|
||||
constexpr auto TimeDilationStringObfuscated = make_obfuscated<0x44>("F3 0F ?? ?? ?? ?? ?? ?? EB ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8B ?? ?? 4C ?? ?? F3 0F ?? ?? 44");
|
||||
|
||||
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; // Offset for the target opcode
|
||||
}
|
||||
}
|
||||
using AOBScan::Make;
|
||||
using OffsetScan::Make;
|
||||
// Prepare all data for scanning
|
||||
std::vector<AOBScanEntry> signatures = {
|
||||
Make(&CameraComponentaddress, CameraComponentStringObfuscated, "Camera component"),
|
||||
Make(&CameraDistanceaddress, CameraDistanceStringObfuscated, "Camera distance"),
|
||||
Make(&DOFaddress, DOFStringObfuscated, "Depth of field"),
|
||||
Make(&Vignettingaddress, VignettingStringObfuscated, "Vignetting"),
|
||||
Make(&Fogaddress, FogStringObfuscated, "Fog"),
|
||||
Make(&WorldTimedilationaddress, WorldTimeDilationStringObfuscated, "World time dilation"),
|
||||
Make(&Timedilationaddress, TimeDilationStringObfuscated, "Actor time dilation")
|
||||
};
|
||||
// Scan all signature in a batch
|
||||
Memory::AOBScanBatch(signatures, logger);
|
||||
|
||||
if (Aspectaddress_1 == nullptr) {
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("C3 CC CC CC CC CC CC CC CC 48 89 ?? ?? ?? 57 48 ?? ?? ?? 0F ?? ?? 48 ?? ?? 48 ?? ?? 0F ?? ?? ?? 0F ?? ?? ?? F2 0F");
|
||||
Aspectaddress_1 = Memory::AOBScan(gameExecutable, AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Project_Plague-Win64-Shipping.exe" + 10A7443 - 89 41 44 - mov[rcx + 44], eax
|
||||
//"Project_Plague-Win64-Shipping.exe" + 10A7446 - 8B 42 48 - mov eax, [rdx + 48]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 10A7449 - 89 41 48 - mov[rcx + 48], eax
|
||||
//"Project_Plague-Win64-Shipping.exe" + 10A744C - 8B 49 4C - mov ecx, [rcx + 4C]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 10A744F - 33 4A 4C - xor ecx, [rdx + 4C]
|
||||
|
||||
if (!Aspectaddress_1)
|
||||
logger->warn("Aspect ratio #1 signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Aspect ratio #1 signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Aspectaddress_1));
|
||||
Aspectaddress_1 += 0x62;
|
||||
}
|
||||
}
|
||||
|
||||
if (Aspectaddress_2 == nullptr) {
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("C3 CC CC CC CC CC 48 89 ?? ?? ?? 57 48 ?? ?? ?? 0F ?? ?? 48 ?? ?? 48 ?? ?? 0F ?? ?? ?? 0F ?? ?? ?? F2 0F");
|
||||
Aspectaddress_2 = Memory::AOBScan(gameExecutable, AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Project_Plague-Win64-Shipping.exe" + 1914483 - 89 41 44 - mov[rcx + 44], eax
|
||||
//"Project_Plague-Win64-Shipping.exe" + 1914486 - 8B 42 48 - mov eax, [rdx + 48]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 1914489 - 89 41 48 - mov[rcx + 48], eax
|
||||
//"Project_Plague-Win64-Shipping.exe" + 191448C - 8B 49 4C - mov ecx, [rcx + 4C]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 191448F - 33 4A 4C - xor ecx, [rdx + 4C]
|
||||
|
||||
if (!Aspectaddress_2)
|
||||
logger->warn("Aspect ratio #2 signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||
else {
|
||||
logger->info("Aspect ratio #2 signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Aspectaddress_2));
|
||||
Aspectaddress_2 += 0x5F;
|
||||
}
|
||||
}
|
||||
|
||||
if (DOFaddress == nullptr) {
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("48 ?? ?? 8B ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? 48 6B ?? ?? 48 8D");
|
||||
DOFaddress = Memory::AOBScan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Project_Plague-Win64-Shipping.exe" + 2BD06A4 - 48 8B 05 1D 15 9D 05 - mov rax, ["Project_Plague-Win64-Shipping.exe" + 85A1BC8]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 2BD06AB - 48 8B CB - mov rcx, rbx
|
||||
//"Project_Plague-Win64-Shipping.exe" + 2BD06AE - 8B 78 04 - mov edi, [rax + 04]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 2BD06B1 - E8 AA 5F 8A 01 - call "Project_Plague-Win64-Shipping.exe" + 4476660
|
||||
//"Project_Plague-Win64-Shipping.exe" + 2BD06B6 - 48 63 C8 - movsxd rcx, eax
|
||||
|
||||
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 += 0x3;
|
||||
}
|
||||
}
|
||||
|
||||
if (Vignettingaddress == nullptr) {
|
||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3 ?? ?? ?? ?? EB");
|
||||
Vignettingaddress = Memory::AOBScan(gameExecutable, VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Project_Plague-Win64-Shipping.exe" + 4474088 - C7 83 B0 1F 00 00 00 00 80 3F - mov[rbx + 00001FB0], 3F800000
|
||||
//"Project_Plague-Win64-Shipping.exe" + 4474092 - 48 8B 05 87 FE 1F 04 - mov rax, ["Project_Plague-Win64-Shipping.exe" + 8673F20]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 4474099 - 8B 08 - mov ecx, [rax]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 447409B - 83 F9 02 - cmp ecx, 02
|
||||
//"Project_Plague-Win64-Shipping.exe" + 447409E - 7D 08 - jnl "Project_Plague-Win64-Shipping.exe" + 44740A8
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
if (Fogaddress == nullptr) {
|
||||
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 8B");
|
||||
Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"Project_Plague-Win64-Shipping.exe" + 28E27FD - 48 8B 05 54 9A C6 05 - mov rax, ["Project_Plague-Win64-Shipping.exe" + 854C258]
|
||||
//"Project_Plague-Win64-Shipping.exe" + 28E2804 - 83 78 04 01 - cmp dword ptr[rax + 04], 01
|
||||
//"Project_Plague-Win64-Shipping.exe" + 28E2808 - 75 04 - jne "Project_Plague-Win64-Shipping.exe" + 28E280E
|
||||
//"Project_Plague-Win64-Shipping.exe" + 28E280A - B3 01 - mov bl, 01
|
||||
//"Project_Plague-Win64-Shipping.exe" + 28E280C - EB 02 - jmp "Project_Plague-Win64-Shipping.exe" + 28E2810
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
if (FOVaddress && Aspectaddress_1 && Aspectaddress_2 && DOFaddress && Vignettingaddress && Fogaddress) {
|
||||
if (CameraComponentaddress && DOFaddress && CameraDistanceaddress
|
||||
&& Vignettingaddress && Fogaddress && WorldTimedilationaddress && Timedilationaddress)
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
AOBScanDone = true;
|
||||
|
||||
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<0x8D>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
||||
constexpr auto GWorldStringObfuscated = make_obfuscated<0x5B>("48 8B 05 ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 48 8B ?? ?? 48 89 ?? ?? 48 8D ?? ?? E8");
|
||||
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x80>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 ?? F2 8B ?? 48 ?? ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C");
|
||||
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x56>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D");
|
||||
|
||||
// Prepare all data for scanning
|
||||
std::vector<OffsetScanEntry> UEoffsetsScans = {
|
||||
Make(&GObjectsaddress, GObjetcsStringObfuscated, "GObjects", OffsetCalcType::GetOffsetFromOpcode, &Offsets::GObjects, 0x3),
|
||||
Make(&GWorldaddress, GWorldStringObfuscated, "GWorld", OffsetCalcType::GetOffsetFromOpcode, &Offsets::GWorld, 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, "");
|
||||
}
|
||||
|
||||
logger->info("--------------- AOB scan finished ---------------");
|
||||
logger->info("-------------- Fixes initialisation -------------");
|
||||
AOBScanDone = true;
|
||||
}
|
||||
|
||||
if (g_fix_enabled) {
|
||||
if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled || g_aspect_ratio_fix_enabled);
|
||||
if (Aspectaddress_1 && Aspectaddress_2) AspectFixEnabled(g_aspect_ratio_fix_enabled);
|
||||
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
|
||||
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
|
||||
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
|
||||
if (!init && CameraComponentaddress) {
|
||||
FOVFixEnabled();
|
||||
UltraWideFixEnabled(GameFixes::UltraWide);
|
||||
}
|
||||
else {
|
||||
if (FOVaddress) FOVFixEnabled(false);
|
||||
if (Aspectaddress_1 && Aspectaddress_2) AspectFixEnabled(false);
|
||||
if (DOFaddress) DOFFixEnabled(false);
|
||||
if (Vignettingaddress) VignettingFixEnabled(false);
|
||||
if (Fogaddress) FogFixEnabled(false);
|
||||
logger->info("All fixes disabled.");
|
||||
if (!init && CameraDistanceaddress) CameraDistanceFixEnabled();
|
||||
if (!init && DOFaddress) DOFFixEnabled();
|
||||
if (!init && Vignettingaddress) VignettingFixEnabled();
|
||||
if (!init && Fogaddress) FogFixEnabled();
|
||||
if (!init && WorldTimedilationaddress) {
|
||||
EnableCheats(Cheat::TimeDilation);
|
||||
EnableCheats(Cheat::GodMode);
|
||||
EnableCheats(Cheat::Stamina);
|
||||
EnableCheats(Cheat::Stealth);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFOVFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_fov_fix_enabled = enabled;
|
||||
if (!init) FOVFixEnabled(g_fov_fix_enabled || g_aspect_ratio_fix_enabled); // FOV fix must be enabled when aspect ratio is too to compensate FOV
|
||||
ProcessEvent();
|
||||
}
|
||||
|
||||
// Setters for Reshade addon call
|
||||
extern "C" __declspec(dllexport) void SetAspectRatioFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_aspect_ratio_fix_enabled = enabled;
|
||||
if (!init) AspectFixEnabled(g_aspect_ratio_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_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(GameFixes::UltraWide); }
|
||||
if (fix == GameFixes::Camera) { g_Camera_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(); }
|
||||
if (fix == GameFixes::TimeDilation) { g_TimeDilation_fix_enabled = enabled; EnableCheats(Cheat::TimeDilation); }
|
||||
if (fix == GameFixes::GodMode) { g_GodMode_fix_enabled = enabled; EnableCheats(Cheat::GodMode); }
|
||||
if (fix == GameFixes::Stamina) { g_Stamina_fix_enabled = enabled; EnableCheats(Cheat::Stamina); }
|
||||
if (fix == GameFixes::Stealth) { g_Stealth_fix_enabled = enabled; EnableCheats(Cheat::Stealth); }
|
||||
}
|
||||
|
||||
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 SetValues(GameSetting setting, float value) {
|
||||
if (setting == GameSetting::FOV) g_AdditionalFOVValue = (int)(value);
|
||||
if (setting == GameSetting::CameraDistance) g_CameraMultiplier = value;
|
||||
if (setting == GameSetting::WorldTimeDilation) g_WorldTimeDilationValue = value;
|
||||
if (setting == GameSetting::AITimeDilation) g_AITimeDilationValue = value;
|
||||
}
|
||||
|
||||
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 SetFOV(int fov)
|
||||
{
|
||||
g_AdditionalFOVValue = fov;
|
||||
}
|
||||
|
||||
// Getters for Reshade addon call
|
||||
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;
|
||||
}
|
||||
|
||||
// VEH debugger breakpoint fixes
|
||||
LONG WINAPI FOVVehHandler(PEXCEPTION_POINTERS ep) {
|
||||
if (!ep || !ep->ContextRecord || !ep->ExceptionRecord) return EXCEPTION_CONTINUE_SEARCH;
|
||||
if (ep->ExceptionRecord->ExceptionCode != EXCEPTION_SINGLE_STEP) return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
CONTEXT* ctx = ep->ContextRecord; // Check if instruction breakpoint is the one targeted
|
||||
if (ctx->Rip == reinterpret_cast<uintptr_t>(FOVaddress)) {
|
||||
t_fov_address_to_patch = static_cast<uintptr_t>(ctx->Rdi) + 0x30;
|
||||
|
||||
float* xmm0 = reinterpret_cast<float*>(&ctx->Xmm0);
|
||||
g_FOV_In = *xmm0;
|
||||
// Calculate compensated FOV if aspect fix is checked
|
||||
if (g_aspect_ratio_fix_enabled && baseAspect > defaultAspect)
|
||||
g_Compensated_FOV = *xmm0 = Maths::CompensateHorizontalFOV(g_FOV_In, baseAspect, aspectRatio);
|
||||
else
|
||||
g_Compensated_FOV = *xmm0;
|
||||
|
||||
*xmm0 += (g_fov_fix_enabled ? g_AdditionalFOVValue : 0);
|
||||
g_FOV_Out = *xmm0;
|
||||
|
||||
*reinterpret_cast<float*>(t_fov_address_to_patch) = g_FOV_Out; // Patch new FOV value in memory
|
||||
|
||||
// Skip original opcode size in bytes otherwise the game will crash
|
||||
ctx->Rip += 5;
|
||||
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
LONG WINAPI AspectVehHandler_1(PEXCEPTION_POINTERS ep) {
|
||||
if (!ep || !ep->ContextRecord || !ep->ExceptionRecord) return EXCEPTION_CONTINUE_SEARCH;
|
||||
if (ep->ExceptionRecord->ExceptionCode != EXCEPTION_SINGLE_STEP) return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
CONTEXT* ctx = ep->ContextRecord; // Check if instruction breakpoint is the one targeted
|
||||
if (ctx->Rip == reinterpret_cast<uintptr_t>(Aspectaddress_1)) {
|
||||
// Retrieves the addresse where aspect ratio will be stored
|
||||
t_aspect_address_to_patch = static_cast<uintptr_t>(ctx->Rcx) + 0x48;
|
||||
// Retrieves where the base aspect ratio is actually stored
|
||||
baseAspect = *reinterpret_cast<float*>(&ctx->Rax);
|
||||
*reinterpret_cast<float*>(t_aspect_address_to_patch) = baseAspect; // Patch base aspect ratio
|
||||
|
||||
// Skip original opcode size in bytes otherwise the game will crash
|
||||
ctx->Rip += 3;
|
||||
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
LONG WINAPI AspectVehHandler_2(PEXCEPTION_POINTERS ep) {
|
||||
if (!ep || !ep->ContextRecord || !ep->ExceptionRecord) return EXCEPTION_CONTINUE_SEARCH;
|
||||
if (ep->ExceptionRecord->ExceptionCode != EXCEPTION_SINGLE_STEP) return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
CONTEXT* ctx = ep->ContextRecord; // Check if instruction breakpoint is the one targeted
|
||||
if (ctx->Rip == reinterpret_cast<uintptr_t>(Aspectaddress_2)) {
|
||||
// Retrieves the addresse where aspect ratio will be stored
|
||||
t_aspect_address_to_patch = static_cast<uintptr_t>(ctx->Rcx) + 0x48;
|
||||
*reinterpret_cast<float*>(t_aspect_address_to_patch) = aspectRatio; // Patch new aspect ratio value in memory
|
||||
|
||||
// Skip original opcode size in bytes otherwise the game will crash
|
||||
ctx->Rip += 3;
|
||||
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
infos->FOVIn = g_FOV_In;
|
||||
infos->CompensatedFOV = g_CompensatedFOV;
|
||||
infos->FOVOut = g_FOV_Out;
|
||||
infos->cameraIn = g_CameraIn;
|
||||
infos->cameraOut = g_CameraOut;
|
||||
infos->consoleEnabled = g_Console_Enabled;
|
||||
infos->Health = (float)g_Health;
|
||||
infos->Stamina = (float)g_Stamina;
|
||||
infos->screenWidth = screenWidth;
|
||||
infos->screenHeight = screenHeight;
|
||||
infos->aspectRatio = g_AspectRatio;
|
||||
}
|
||||
|
||||
// Code injection functions
|
||||
static void FOVFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && FOVaddress) {
|
||||
vehFOVHandle = nullptr;
|
||||
vehFOVHandle = Memory::SetupOrClearHardwareBreakPointForAllThreads(reinterpret_cast<uintptr_t>(FOVaddress), vehFOVHandle ,true, FOVVehHandler, 0);
|
||||
if (vehFOVHandle)
|
||||
logger->info("FOV fix enabled and hardware breakpoint armed");
|
||||
}
|
||||
if (!fix_enabled && FOVaddress) {
|
||||
if (vehFOVHandle)
|
||||
vehFOVHandle = Memory::SetupOrClearHardwareBreakPointForAllThreads(reinterpret_cast<uintptr_t>(FOVaddress), vehFOVHandle, false, nullptr, 0);
|
||||
if (!vehFOVHandle)
|
||||
logger->info("FOV fix disabled and hardware breakpoint disarmed");
|
||||
static ULONGLONG lastScanResolutionTick = 0; // Last time Actors were scanned for enemies time dilation
|
||||
static void ProcessEvent() {
|
||||
if (!PEHook && ProcessEventaddress) {
|
||||
PEHook = safetyhook::create_mid(ProcessEventaddress + 0xc,
|
||||
[](SafetyHookContext& ctx) {
|
||||
UObject* object = (UObject*)ctx.rcx;
|
||||
UFunction* func = (UFunction*)ctx.rdx;
|
||||
|
||||
ULONGLONG now = GetTickCount64();
|
||||
if (now - lastScanResolutionTick >= DEFAULT_DELAY_BETWEEN_TICK) { // Delay between each tick to avoid ProcessEvent stuttering
|
||||
lastScanResolutionTick = now;
|
||||
GetResolution(screenWidth, screenHeight, g_AspectRatio);
|
||||
}
|
||||
if (object && func) {
|
||||
std::string funcName = func->GetName();
|
||||
std::string objectName = object->GetName();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void AspectFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Aspectaddress_1 && Aspectaddress_2) {
|
||||
vehApectHandle_1 = nullptr;
|
||||
vehApectHandle_2 = nullptr;
|
||||
vehApectHandle_1 = Memory::SetupOrClearHardwareBreakPointForAllThreads(reinterpret_cast<uintptr_t>(Aspectaddress_1), vehApectHandle_1, true, AspectVehHandler_1, 1);
|
||||
vehApectHandle_2 = Memory::SetupOrClearHardwareBreakPointForAllThreads(reinterpret_cast<uintptr_t>(Aspectaddress_2), vehApectHandle_2, true, AspectVehHandler_2, 2);
|
||||
|
||||
if (vehApectHandle_1 && vehApectHandle_2)
|
||||
logger->info("Aspect ratio fix enabled and hardware breakpoint armed");
|
||||
|
||||
if (FOVaddress) FOVFixEnabled(true); // Compensate FOV if aspect fix is checked
|
||||
static bool bHastoCompensateFOV = false;
|
||||
static float currentAspect = 0.f;
|
||||
static void FOVFixEnabled() {
|
||||
if (CameraComponentaddress) {
|
||||
if (!FOVHook) { // Hook only once
|
||||
FOVHook = safetyhook::create_mid(CameraComponentaddress + 0xa,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_FOV_In = ctx.xmm0.f32[0];
|
||||
if (g_fix_enabled && bHastoCompensateFOV)
|
||||
ctx.xmm0.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, currentAspect, g_AspectRatio);
|
||||
g_CompensatedFOV = ctx.xmm0.f32[0];
|
||||
ctx.xmm0.f32[0] += (g_fix_enabled && g_fov_fix_enabled ? g_AdditionalFOVValue : 0);
|
||||
g_FOV_Out = ctx.xmm0.f32[0];
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!fix_enabled && Aspectaddress_1) {
|
||||
if (vehApectHandle_1)
|
||||
vehApectHandle_1 = Memory::SetupOrClearHardwareBreakPointForAllThreads(reinterpret_cast<uintptr_t>(Aspectaddress_1), vehApectHandle_1, false, nullptr, 1);
|
||||
logger->info("FOV fix {}", g_fix_enabled && g_fov_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
if (vehApectHandle_2)
|
||||
vehApectHandle_2 = Memory::SetupOrClearHardwareBreakPointForAllThreads(reinterpret_cast<uintptr_t>(Aspectaddress_2), vehApectHandle_2, false, nullptr, 2);
|
||||
if (!vehApectHandle_1 && !vehApectHandle_2)
|
||||
logger->info("Aspect ratio fix disabled and hardware breakpoint disarmed");
|
||||
static void UltraWideFixEnabled(GameFixes fix) {
|
||||
if (g_fix_enabled && g_ultrawide_fix_enabled && CameraComponentaddress/* && ARatioAxisConstraintaddress*/) {
|
||||
Memory::PatchBytes(CameraComponentaddress + 0x1b, "\x31\xC9\x90\x90\x90\x90\x90", 7); // xor ecx,ecx bConstrainAspectRatio = false (for cutscenes)
|
||||
if (!UWHook) { // Hook only once
|
||||
UWHook = safetyhook::create_mid(CameraComponentaddress + 0x12,
|
||||
[](SafetyHookContext& ctx) {
|
||||
if (!ctx.rbx) return;
|
||||
|
||||
// When aspect fix is unchecked no more FOV compensation is needed
|
||||
if (FOVaddress && !g_fov_fix_enabled) FOVFixEnabled(false);
|
||||
currentAspect = *(float*)(ctx.rbx + 0x2f0);
|
||||
if (currentAspect > baseAspect) bHastoCompensateFOV = true;
|
||||
else bHastoCompensateFOV = false;
|
||||
});
|
||||
}
|
||||
else UWHook.enable();
|
||||
logger->info("Ultrawide fix enabled");
|
||||
}
|
||||
if (!(g_fix_enabled && g_ultrawide_fix_enabled) && CameraComponentaddress) {
|
||||
Memory::RestoreBytes(CameraComponentaddress + 0x1b);
|
||||
if (UWHook) UWHook.disable();
|
||||
bHastoCompensateFOV = false;
|
||||
logger->info("Ultrawide fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void CameraDistanceFixEnabled() {
|
||||
if (g_fix_enabled && g_Camera_fix_enabled && CameraDistanceaddress) {
|
||||
if (!CameraHook) { // Hook only once
|
||||
CameraHook = safetyhook::create_mid(CameraDistanceaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_CameraIn = ctx.xmm0.f32[0];
|
||||
ctx.xmm0.f32[0] *= g_CameraMultiplier;
|
||||
g_CameraOut = ctx.xmm0.f32[0];
|
||||
});
|
||||
}
|
||||
else CameraHook.enable();
|
||||
logger->info("Camera distance fix enabled");
|
||||
}
|
||||
if (!(g_fix_enabled && g_Camera_fix_enabled) && CameraDistanceaddress) {
|
||||
if (CameraHook) CameraHook.disable();
|
||||
logger->info("Camera distance fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// -- Cheats --
|
||||
static ULONGLONG lastScanActorTick = 0; // Last time Actors were scanned for applying cheats
|
||||
static void EnableCheats(Cheat cheat) {
|
||||
if (WorldTimedilationaddress && !WorldTimeDilationHook) {
|
||||
WorldTimeDilationHook = safetyhook::create_mid(WorldTimedilationaddress + 0x10,
|
||||
[](SafetyHookContext& ctx) { // From AWorldSettings retrieved from world->K2_GetWorldSettings()
|
||||
ctx.xmm0.f32[0] *= g_TimeDilation_fix_enabled ? g_WorldTimeDilationValue : 1.f;
|
||||
});
|
||||
}
|
||||
// Enemies time dilation
|
||||
if (Timedilationaddress && !TimeDilationHook) {
|
||||
TimeDilationHook = safetyhook::create_mid(Timedilationaddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
if (!ctx.rbx) return;
|
||||
UObject* object = (UObject*)ctx.rbx;
|
||||
if (!object || !object->Class) return;
|
||||
|
||||
ULONGLONG now = GetTickCount64();
|
||||
if (now - lastScanActorTick >= DEFAULT_DELAY_BETWEEN_ACTOR_TICK) { // Delay between each tick to avoid ProcessEvent stuttering
|
||||
lastScanActorTick = now;
|
||||
if (object->IsA(ACharacter::StaticClass())) {
|
||||
auto* character = static_cast<ACharacter*>(object);
|
||||
if (!character) return;
|
||||
|
||||
if (!character->IsPlayerControlled()) { // NPC or enemy
|
||||
auto* controller = character->GetController();
|
||||
if (controller && controller->IsA(AImpl_BaseAIController_C::StaticClass())) { // enemy spotted
|
||||
auto* aiController = static_cast<AImpl_BaseAIController_C*>(controller);
|
||||
if (aiController && aiController->Perception) {
|
||||
if (g_Stealth_fix_enabled) aiController->EnableAlertPerception(false);
|
||||
else {
|
||||
aiController->EnableAlertPerception(true);
|
||||
aiController->FlushEnableSense();
|
||||
aiController->UpdateSenseTarget();
|
||||
}
|
||||
}
|
||||
character->CustomTimeDilation = g_TimeDilation_fix_enabled ? g_AITimeDilationValue : 1.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (object->IsA(ABP_CombatCharacter_Player_Final_C::StaticClass())) {
|
||||
auto* character = static_cast<ABP_CombatCharacter_Player_Final_C*>(object);
|
||||
if (character) {
|
||||
if (character->IsPlayerControlled()) {
|
||||
double maxHP = 0.0;
|
||||
double maxStamina = 0.0;
|
||||
character->GetHp(&g_Health);
|
||||
character->GetMaxHp(&maxHP);
|
||||
|
||||
UExtendedStatComponent_Stamina_C* staminaPtr = nullptr;
|
||||
character->GetMyStamina(&staminaPtr);
|
||||
if (staminaPtr) {
|
||||
staminaPtr->GetCurrentValue(&g_Stamina);
|
||||
staminaPtr->GetMaxValue(&maxStamina);
|
||||
if (g_Stamina_fix_enabled) staminaPtr->SetCurrentValue(maxStamina);
|
||||
}
|
||||
if (g_GodMode_fix_enabled) character->SetHp(maxHP);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (cheat == Cheat::TimeDilation) logger->info("Time dilation cheat {}", g_TimeDilation_fix_enabled ? "enabled" : "disabled");
|
||||
if (cheat == Cheat::GodMode) logger->info("God mode cheat {}", g_GodMode_fix_enabled ? "enabled" : "disabled");
|
||||
if (cheat == Cheat::Stamina) logger->info("Stamina cheat {}", g_Stamina_fix_enabled ? "enabled" : "disabled");
|
||||
if (cheat == Cheat::Stealth) logger->info("Stealth cheat {}", g_Stealth_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
// Memory patch fixes
|
||||
static void DOFFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && DOFaddress) {
|
||||
Memory::PatchBytes(DOFaddress, "\x31\xFF\x90", 3); // xor edi,edi r.DepthOfFieldQuality = 0
|
||||
static void DOFFixEnabled() {
|
||||
if (g_fix_enabled && g_DOF_fix_enabled && DOFaddress) {
|
||||
Memory::PatchBytes(DOFaddress + 0x3, "\x31\xFF\x90", 3); // xor edi,edi r.DepthOfFieldQuality = 0
|
||||
logger->info("Depth of field fix enabled");
|
||||
}
|
||||
if (!fix_enabled && DOFaddress) {
|
||||
Memory::RestoreBytes(DOFaddress);
|
||||
if (!(g_fix_enabled && g_DOF_fix_enabled) && DOFaddress) {
|
||||
Memory::RestoreBytes(DOFaddress + 0x3);
|
||||
logger->info("Depth of field fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void VignettingFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && Vignettingaddress) {
|
||||
static void CAFixEnabled() {
|
||||
if (g_fix_enabled && g_CA_fix_enabled && CAaddress) {
|
||||
Memory::PatchBytes(CAaddress, "\x90\x90", 2); // NOP x 2 r.SceneColorFringeQuality = 0
|
||||
logger->info("Chromatics aberrations fix enabled");
|
||||
}
|
||||
if (!(g_fix_enabled && g_CA_fix_enabled) && CAaddress) {
|
||||
Memory::RestoreBytes(CAaddress);
|
||||
logger->info("Chromatics aberrations 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
|
||||
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) {
|
||||
Memory::PatchBytes(Fogaddress, "\xEB", 1); // jmp "Project_Plague-Win64-Shipping.exe"+28E280E r.Fog = 0
|
||||
static void FogFixEnabled() {
|
||||
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
||||
Memory::PatchBytes(Fogaddress, "\xEB", 1); // jmp -> r.Fog 0
|
||||
logger->info("Fog fix enabled");
|
||||
}
|
||||
if (!fix_enabled && Fogaddress) {
|
||||
if (!(g_fix_enabled && g_Fog_fix_enabled) && Fogaddress) {
|
||||
Memory::RestoreBytes(Fogaddress);
|
||||
logger->info("Fog fix disabled");
|
||||
}
|
||||
}
|
||||
// UE Console creation
|
||||
static void EnableConsole() {
|
||||
if (g_Console_Enabled || !g_Console || !GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||
if (!g_Console && !user_inputs_logged) {
|
||||
logger->info("------------------ User inputs ------------------");
|
||||
user_inputs_logged = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void InitializeLogger()
|
||||
{
|
||||
try
|
||||
{
|
||||
std::filesystem::path log_path = std::filesystem::absolute(PLUGIN_LOG);
|
||||
if (std::filesystem::exists(log_path))
|
||||
std::filesystem::remove(log_path);
|
||||
logger = std::make_shared<spdlog::logger>("Wuchang Fallen Feathers", std::make_shared<spdlog::sinks::rotating_file_sink_st>(PLUGIN_LOG, 10 * 1024 * 1024, 1));
|
||||
logger->flush_on(spdlog::level::debug); // Flush automatically
|
||||
}
|
||||
catch (const spdlog::spdlog_ex& ex)
|
||||
{
|
||||
std::string plugin_error_message = "Could not open " + PLUGIN_LOG;
|
||||
MessageBoxA(nullptr, plugin_error_message.c_str(), "Logger Error", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
logger->info("-------------- Console re-enabling --------------");
|
||||
ReactivateDevConsole(logger);
|
||||
}
|
||||
|
||||
|
||||
// Standard dll entry
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID)
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
InitializeLogger();
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
logger = InitializeLogger("Wuchang: Fallen Feathers", PLUGIN_LOG, false);
|
||||
logger->info("Plugin {} loaded.", PLUGIN_NAME);
|
||||
}
|
||||
else if (reason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
else if (reason == DLL_PROCESS_DETACH) {
|
||||
logger->info("Plugin {} unloaded.", PLUGIN_NAME);
|
||||
spdlog::drop_all();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user