2026-04-10 00:18:11 +02:00
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
#include "CommonHeaders.h"
|
|
|
|
|
|
#include "CommonUEHeaders.h"
|
2026-04-11 09:36:12 +02:00
|
|
|
|
#include "SDK/CJ_classes.hpp"
|
2026-04-12 11:09:54 +02:00
|
|
|
|
#include "SDK/CJScreenNavigation_classes.hpp"
|
2026-04-11 09:36:12 +02:00
|
|
|
|
#include "SDK/BP_VehicleBase_classes.hpp"
|
|
|
|
|
|
#include "SDK/BP_NitroComponent_classes.hpp"
|
2026-04-12 11:09:54 +02:00
|
|
|
|
#include "SDK/WBP_UILayout_classes.hpp"
|
2026-04-10 00:18:11 +02:00
|
|
|
|
|
|
|
|
|
|
using namespace SDK;
|
|
|
|
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
|
|
const std::string PLUGIN_NAME = "Samson";
|
|
|
|
|
|
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
|
2026-04-12 11:09:54 +02:00
|
|
|
|
constexpr ULONGLONG DEFAULT_DELAY_BETWEEN_TICK = 250; // Used in ProcessEvent
|
2026-04-10 00:18:11 +02:00
|
|
|
|
constexpr ULONGLONG DEFAULT_DELAY_BETWEEN_WTD_TICK = 100; // Used for World time dilation
|
2026-04-11 09:36:12 +02:00
|
|
|
|
constexpr ULONGLONG DEFAULT_DELAY_BETWEEN_TD_TICK = 200; // Used for AActor custom time dilation
|
2026-04-10 00:18:11 +02:00
|
|
|
|
// Logger
|
|
|
|
|
|
std::shared_ptr<spdlog::logger> logger;
|
|
|
|
|
|
// Screen informations
|
|
|
|
|
|
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
|
|
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
|
|
float g_AspectRatio = (float)screenWidth / screenHeight;
|
|
|
|
|
|
// Plugin states
|
|
|
|
|
|
static bool AOBScanDone = false;
|
|
|
|
|
|
static std::atomic<bool> g_fix_enabled = false;
|
|
|
|
|
|
static std::atomic<bool> g_fov_fix_enabled = false;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static std::atomic<bool> g_ultrawide_fix_enabled = false;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static std::atomic<bool> g_HUD_fix_enabled = false;
|
|
|
|
|
|
static std::atomic<bool> g_Camera_fix_enabled = false;
|
|
|
|
|
|
static std::atomic<bool> g_Letterboxing_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_Stealth_fix_enabled = false;
|
2026-04-11 09:36:12 +02:00
|
|
|
|
static std::atomic<bool> g_Nitro_fix_enabled = false;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static int g_AdditionalFOVValue = 0;
|
|
|
|
|
|
static float g_CameraMultiplier = 1.f;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static float g_CamVehicleMultiplier = 1.f;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static float g_WorldTimeDilationValue = 1.f;
|
|
|
|
|
|
static float g_AITimeDilationValue = 1.f;
|
|
|
|
|
|
static int g_HUDOffsets = 0;
|
|
|
|
|
|
static int g_UIOffsets = 0;
|
|
|
|
|
|
static float g_PlayerHealth = 0.f;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
bool g_bIsInVehicule = false;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
// Shared values
|
|
|
|
|
|
static float g_FOV_In = 75.f;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static float g_CompensatedFOV = 75.f;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static float g_FOV_Out = 75.f;
|
|
|
|
|
|
static float g_CameraIn = 189.26f;
|
|
|
|
|
|
static float g_CameraOut = 189.26f;
|
|
|
|
|
|
// AOB Scan pointers
|
|
|
|
|
|
static uint8_t* CameraComponentaddress = nullptr;
|
|
|
|
|
|
static uint8_t* Cameraaddress = nullptr;
|
|
|
|
|
|
static uint8_t* WorldTimedilationaddress = nullptr;
|
|
|
|
|
|
static uint8_t* Timedilationaddress = nullptr;
|
|
|
|
|
|
// Hooking
|
|
|
|
|
|
static SafetyHookMid FOVHook{};
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static SafetyHookMid UWHook{};
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static SafetyHookMid CameraHook{};
|
|
|
|
|
|
static SafetyHookMid PEHook{};
|
|
|
|
|
|
static SafetyHookMid WorldTimeDilationHook{};
|
|
|
|
|
|
static SafetyHookMid TimeDilationHook{};
|
|
|
|
|
|
// Prototypes
|
|
|
|
|
|
static void FOVFixEnabled();
|
|
|
|
|
|
static void CameraFixEnabled();
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static void UltraWideFixEnabled();
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static void HUDUpdate(bool writeLog);
|
|
|
|
|
|
static void EnableConsole();
|
|
|
|
|
|
static void EnableCheats(Cheat cheat);
|
|
|
|
|
|
static void ProcessEvent();
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
|
|
|
|
|
g_fix_enabled = enabled;
|
|
|
|
|
|
if (init) {
|
|
|
|
|
|
logger = InitializeLogger("Samson", PLUGIN_LOG);
|
|
|
|
|
|
logger->info("Plugin {} loaded.", PLUGIN_NAME);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!AOBScanDone) { // Unreal Engine 5.7.4
|
|
|
|
|
|
logger->info("--------------- AOB scan started ---------------");
|
|
|
|
|
|
constexpr auto CameraComponentStringObfuscated = make_obfuscated<0xF3>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 83 ?? ?? ?? ?? 89");
|
|
|
|
|
|
constexpr auto CameraStringObfuscated = make_obfuscated<0xF3>("48 8D ?? ?? 0F ?? ?? 48 8D 8D ?? ?? ?? ?? 0F ?? ?? 0F ?? ?? F2");
|
|
|
|
|
|
constexpr auto WorldTimeDilationStringObfuscated = make_obfuscated<0xF6>("F6 81 ?? ?? ?? ?? ?? 74 ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? C3");
|
|
|
|
|
|
constexpr auto TimeDilationStringObfuscated = make_obfuscated<0x44>("F3 0F ?? ?? ?? EB ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8B ?? ?? 4C ?? ?? F3 0F ?? ?? 44");
|
|
|
|
|
|
|
|
|
|
|
|
using AOBScan::Make;
|
|
|
|
|
|
using OffsetScan::Make;
|
|
|
|
|
|
// Prepare all data for scanning
|
|
|
|
|
|
std::vector<AOBScanEntry> signatures = {
|
|
|
|
|
|
Make(&CameraComponentaddress, CameraComponentStringObfuscated, "Camera component"),
|
|
|
|
|
|
Make(&Cameraaddress, CameraStringObfuscated, "Camera"),
|
|
|
|
|
|
Make(&WorldTimedilationaddress, WorldTimeDilationStringObfuscated, "World time dilation"),
|
|
|
|
|
|
Make(&Timedilationaddress, TimeDilationStringObfuscated, "Actor time dilation"),
|
|
|
|
|
|
};
|
|
|
|
|
|
// Scan all signature in a batch
|
|
|
|
|
|
Memory::AOBScanBatch(signatures, logger);
|
|
|
|
|
|
|
|
|
|
|
|
if (CameraComponentaddress && Cameraaddress && WorldTimedilationaddress && Timedilationaddress)
|
|
|
|
|
|
logger->info("All AOB signatures found. Ready to patch...");
|
|
|
|
|
|
|
|
|
|
|
|
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<0xC7>("48 8D 05 ?? ?? ?? ?? C7 83 ?? ?? ?? ?? ?? ?? ?? ?? C6 83 ?? ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48");
|
|
|
|
|
|
constexpr auto GWorldStringObfuscated = make_obfuscated<0x5B>("48 8B 05 ?? ?? ?? ?? 48 ?? ?? 75 ?? 48 83 ?? ?? 5B C3");
|
|
|
|
|
|
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 ?? ?? ?? ?? ?? 8B 41");
|
|
|
|
|
|
|
|
|
|
|
|
// 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("-------------- Fixes initialisation -------------");
|
|
|
|
|
|
AOBScanDone = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ProcessEvent();
|
|
|
|
|
|
if (init) return;
|
|
|
|
|
|
FOVFixEnabled();
|
2026-04-12 11:09:54 +02:00
|
|
|
|
UltraWideFixEnabled();
|
2026-04-10 00:18:11 +02:00
|
|
|
|
CameraFixEnabled();
|
|
|
|
|
|
SetAllEffectsToBeToggled();
|
|
|
|
|
|
LogFixToggle(GameFixes::None, g_fix_enabled);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Setters for Reshade addon call
|
|
|
|
|
|
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled) { // Set each fix individually
|
|
|
|
|
|
bool bVisual = g_fix_enabled && enabled;
|
|
|
|
|
|
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
|
2026-04-10 00:18:11 +02:00
|
|
|
|
if (fix == GameFixes::Camera) { g_Camera_fix_enabled = enabled; CameraFixEnabled(); }
|
|
|
|
|
|
if (fix == GameFixes::Cutscenes) { g_Letterboxing_fix_enabled = enabled; }
|
|
|
|
|
|
if (fix == GameFixes::ChromaticAberrations) { g_CA_fix_enabled = enabled; gPendingCA = true; LogFixToggle(fix, bVisual); }
|
|
|
|
|
|
if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; gPendingVignetting = true; LogFixToggle(fix, bVisual); }
|
|
|
|
|
|
if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; gPendingFog = true; LogFixToggle(fix, bVisual); }
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (fix == GameFixes::HUD) { g_HUD_fix_enabled = enabled; }
|
2026-04-10 00:18:11 +02:00
|
|
|
|
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::Stealth) { g_Stealth_fix_enabled = enabled; EnableCheats(Cheat::Stealth); }
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (fix == GameFixes::Boost) { g_Nitro_fix_enabled = enabled; EnableCheats(Cheat::Boost); }
|
2026-04-10 00:18:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" __declspec(dllexport) void SetValues(GameSetting setting, float value) {
|
|
|
|
|
|
if (setting == GameSetting::FOV) g_AdditionalFOVValue = (int)(value);
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (setting == GameSetting::HUD) g_HUDOffsets = (value * screenWidth) / 100;
|
|
|
|
|
|
if (setting == GameSetting::UI) g_UIOffsets = (value * screenWidth) / 100;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
if (setting == GameSetting::CameraDistance) g_CameraMultiplier = value;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (setting == GameSetting::CamAltDistance) g_CamVehicleMultiplier = value;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
if (setting == GameSetting::WorldTimeDilation) g_WorldTimeDilationValue = value;
|
|
|
|
|
|
if (setting == GameSetting::AITimeDilation) g_AITimeDilationValue = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
// Getters for Reshade addon call
|
|
|
|
|
|
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
|
|
|
|
|
if (!infos) return;
|
|
|
|
|
|
infos->FOVIn = g_FOV_In;
|
|
|
|
|
|
infos->FOVOut = g_FOV_Out;
|
|
|
|
|
|
infos->cameraIn = g_CameraIn;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
infos->CompensatedFOV = g_CompensatedFOV;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
infos->cameraOut = g_CameraOut;
|
|
|
|
|
|
infos->Health = g_PlayerHealth;
|
|
|
|
|
|
infos->screenWidth = screenWidth;
|
|
|
|
|
|
infos->screenHeight = screenHeight;
|
|
|
|
|
|
infos->aspectRatio = (float)screenWidth / screenHeight;
|
|
|
|
|
|
infos->consoleEnabled = g_Console_Enabled;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -- Code injection functions --
|
|
|
|
|
|
// Tracking sets
|
|
|
|
|
|
std::unordered_set<UUserWidget*> g_TrackedCenteredUIWidgets;
|
|
|
|
|
|
std::unordered_set<UUserWidget*> g_TrackedLeftSidedWidgets;
|
|
|
|
|
|
std::unordered_set<UUserWidget*> g_TrackedRightSidedWidgets;
|
|
|
|
|
|
// Left, right sided and centered widgets
|
|
|
|
|
|
std::unordered_set<std::string> g_LeftSidedWidgets = {
|
2026-04-11 09:36:12 +02:00
|
|
|
|
"WBP_MiniMap_C", "WBP_HUD_MissionGameplay_C", "WBP_TimeTrialTimeItem_C",
|
2026-04-12 11:09:54 +02:00
|
|
|
|
"WBP_HUD_HealthStatus_C", "WBP_HUD_CurrentLocation_C", "WBP_HUD_HintItem_C", "WBP_LocateItem_C"
|
2026-04-10 00:18:11 +02:00
|
|
|
|
};
|
2026-04-12 11:09:54 +02:00
|
|
|
|
std::unordered_set<std::string> g_CenteredUIWidgets = { "WBP_UILayout_C" };
|
|
|
|
|
|
std::unordered_set<std::string> g_RightSidedWidgets = { "WBP_HUD_VehicleWidget_C", "WBP_HUD_HourToHour_C" };
|
2026-04-10 00:18:11 +02:00
|
|
|
|
|
|
|
|
|
|
static UUserWidget* letterBoxWidget = nullptr;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static UWidget* menu = nullptr; // Container menu
|
|
|
|
|
|
bool bInMainMenu = false;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static void ProcessEvent() {
|
|
|
|
|
|
if (!PEHook && ProcessEventaddress) {
|
|
|
|
|
|
PEHook = safetyhook::create_mid(ProcessEventaddress + 0xc,
|
|
|
|
|
|
[](SafetyHookContext& ctx) {
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static ULONGLONG lastScanTick = 0; // Last time tick was called
|
|
|
|
|
|
|
2026-04-10 00:18:11 +02:00
|
|
|
|
ULONGLONG now = GetTickCount64();
|
|
|
|
|
|
if (now - lastScanTick >= DEFAULT_DELAY_BETWEEN_TICK) { // Delay between each tick to avoid ProcessEvent stuttering
|
|
|
|
|
|
lastScanTick = now;
|
|
|
|
|
|
GetResolution(screenWidth, screenHeight, g_AspectRatio);
|
|
|
|
|
|
HUDUpdate(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UObject* object = (UObject*)ctx.rcx;
|
|
|
|
|
|
UFunction* func = (UFunction*)ctx.rdx;
|
|
|
|
|
|
if (!object || !func) return;
|
|
|
|
|
|
|
|
|
|
|
|
if (object->IsA(UUserWidget::StaticClass())) {
|
2026-04-12 11:09:54 +02:00
|
|
|
|
const std::string funcName = func->GetName();
|
|
|
|
|
|
const std::string className = object->Class->GetName();
|
|
|
|
|
|
const std::string objectFullName = object->GetFullName();
|
2026-04-10 00:18:11 +02:00
|
|
|
|
auto* widget = static_cast<UUserWidget*>(object);
|
|
|
|
|
|
|
|
|
|
|
|
if (funcName == "Construct") {
|
|
|
|
|
|
if (g_LeftSidedWidgets.contains(className)) g_TrackedLeftSidedWidgets.insert(widget);
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (objectFullName.find("ExitProgressBar") != std::string::npos)
|
2026-04-10 00:18:11 +02:00
|
|
|
|
g_TrackedLeftSidedWidgets.insert(widget);
|
|
|
|
|
|
if (g_RightSidedWidgets.contains(className)) g_TrackedRightSidedWidgets.insert(widget);
|
|
|
|
|
|
if (g_CenteredUIWidgets.contains(className)) g_TrackedCenteredUIWidgets.insert(widget);
|
|
|
|
|
|
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (className == "WBP_Letterbox_Overlay_C") { // Letterboxing removal
|
2026-04-10 00:18:11 +02:00
|
|
|
|
letterBoxWidget = widget;
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (IsValidUObj(widget) && g_fix_enabled && g_Letterboxing_fix_enabled)
|
2026-04-10 00:18:11 +02:00
|
|
|
|
widget->SetVisibility(ESlateVisibility::Collapsed);
|
|
|
|
|
|
}
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (className == "WBP_UILayout_C") {
|
|
|
|
|
|
if (object->IsA(UWBP_UILayout_C::StaticClass())) {
|
|
|
|
|
|
auto* UILayout = static_cast<UWBP_UILayout_C*>(object);
|
|
|
|
|
|
if (UILayout && IsValidUObj(UILayout->Menu)) menu = UILayout->Menu;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (className == "WBP_StartMenu_C") {
|
|
|
|
|
|
EnableConsole(); // Enable console only when Main menu is reached
|
|
|
|
|
|
bInMainMenu = true;
|
|
|
|
|
|
}
|
2026-04-10 00:18:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
if (funcName == "Destruct") {
|
|
|
|
|
|
g_TrackedLeftSidedWidgets.erase(widget);
|
|
|
|
|
|
g_TrackedRightSidedWidgets.erase(widget);
|
|
|
|
|
|
g_TrackedCenteredUIWidgets.erase(widget);
|
|
|
|
|
|
if (className == "WBP_Letterbox_Overlay_C") letterBoxWidget = nullptr;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (className == "WBP_UILayout_C") menu = nullptr;
|
|
|
|
|
|
if (className == "WBP_StartMenu_C") bInMainMenu = false;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// -- HUD positionning --
|
|
|
|
|
|
static void HUDUpdate(bool writeLog) {
|
|
|
|
|
|
if (writeLog) logger->info("HUD fix {}", g_fix_enabled && g_HUD_fix_enabled ? "enabled" : "disabled");
|
2026-04-11 09:36:12 +02:00
|
|
|
|
|
|
|
|
|
|
float HUDoffset = g_fix_enabled && g_HUD_fix_enabled ? (float)g_HUDOffsets : 0.f;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
|
|
|
|
|
|
// Copy sets to avoid race conditions
|
|
|
|
|
|
std::unordered_set<UUserWidget*> copyLeftWidgets = g_TrackedLeftSidedWidgets;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
std::unordered_set<UUserWidget*> copyCenteredWidgets = g_TrackedCenteredUIWidgets;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
std::unordered_set<UUserWidget*> copyRightWidgets = g_TrackedRightSidedWidgets;
|
|
|
|
|
|
|
|
|
|
|
|
for (auto* widget : copyLeftWidgets) {
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (!IsValidUObj(widget)) continue; // Ensure the widget is valid
|
2026-04-10 00:18:11 +02:00
|
|
|
|
ApplyTransformOffset(widget, HUDoffset);
|
|
|
|
|
|
}
|
|
|
|
|
|
for (auto* widget : copyRightWidgets) {
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (!IsValidUObj(widget)) continue; // Ensure the widget is valid
|
2026-04-10 00:18:11 +02:00
|
|
|
|
ApplyTransformOffset(widget, -HUDoffset);
|
|
|
|
|
|
}
|
2026-04-12 11:09:54 +02:00
|
|
|
|
for (auto* widget : copyCenteredWidgets) {
|
|
|
|
|
|
if (!IsValidUObj(widget)) continue;
|
|
|
|
|
|
if (IsValidUObj(menu)) {
|
|
|
|
|
|
if (menu->IsVisible()) CenterWidget(widget, g_UIOffsets, screenWidth, screenHeight);
|
|
|
|
|
|
else CenterWidget(widget, 0.f, screenWidth, screenHeight);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-10 00:18:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-12 11:09:54 +02:00
|
|
|
|
float desiredAspect = 0.f;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static void FOVFixEnabled() {
|
|
|
|
|
|
if (!CameraComponentaddress) return;
|
|
|
|
|
|
if (!FOVHook) { // Hook only once
|
|
|
|
|
|
FOVHook = safetyhook::create_mid(CameraComponentaddress + 0xa,
|
|
|
|
|
|
[](SafetyHookContext& ctx) {
|
|
|
|
|
|
g_FOV_In = ctx.xmm0.f32[0];
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (g_fix_enabled && g_ultrawide_fix_enabled && !bInMainMenu)
|
|
|
|
|
|
ctx.xmm0.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, desiredAspect, g_AspectRatio);
|
|
|
|
|
|
g_CompensatedFOV = ctx.xmm0.f32[0];
|
2026-04-10 00:18:11 +02:00
|
|
|
|
ctx.xmm0.f32[0] += g_fix_enabled && g_fov_fix_enabled ? g_AdditionalFOVValue : 0.f;
|
|
|
|
|
|
g_FOV_Out = ctx.xmm0.f32[0];
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
logger->info("FOV fix {}", g_fix_enabled && g_fov_fix_enabled ? "enabled" : "disabled");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-12 11:09:54 +02:00
|
|
|
|
static void UltraWideFixEnabled() {
|
|
|
|
|
|
if (!CameraComponentaddress) return;
|
|
|
|
|
|
if (g_fix_enabled && g_ultrawide_fix_enabled) {
|
|
|
|
|
|
if (!UWHook) {
|
|
|
|
|
|
UWHook = safetyhook::create_mid(CameraComponentaddress + 0x15,
|
|
|
|
|
|
[](SafetyHookContext& ctx) {
|
|
|
|
|
|
desiredAspect = std::bit_cast<float>(static_cast<uint32_t>(ctx.rax & 0xFFFFFFFF)); // Retrieve desired aspect ratio from rax
|
|
|
|
|
|
ctx.rax = static_cast<uintptr_t>(std::bit_cast<uint32_t>(g_AspectRatio)); // Force rendering aspect ratio if not HOR+
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
else UWHook.enable();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (UWHook) UWHook.disable();
|
|
|
|
|
|
|
|
|
|
|
|
logger->info("Ultrawide fix {}", g_fix_enabled && g_ultrawide_fix_enabled ? "enabled" : "disabled");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-10 00:18:11 +02:00
|
|
|
|
static void CameraFixEnabled() {
|
|
|
|
|
|
if (!Cameraaddress) return;
|
|
|
|
|
|
if (g_fix_enabled && g_Camera_fix_enabled) {
|
|
|
|
|
|
if (!CameraHook) {
|
|
|
|
|
|
CameraHook = safetyhook::create_mid(Cameraaddress,
|
|
|
|
|
|
[](SafetyHookContext& ctx) {
|
|
|
|
|
|
g_CameraIn = ctx.xmm1.f32[0];
|
2026-04-12 11:09:54 +02:00
|
|
|
|
ctx.xmm1.f32[0] *= g_fix_enabled && g_Camera_fix_enabled ?
|
|
|
|
|
|
(!g_bIsInVehicule ? g_CameraMultiplier : g_CamVehicleMultiplier) : 1.f;
|
2026-04-10 00:18:11 +02:00
|
|
|
|
g_CameraOut = ctx.xmm1.f32[0];
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
else CameraHook.enable();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (CameraHook) CameraHook.disable();
|
|
|
|
|
|
|
|
|
|
|
|
logger->info("Camera distance fix {}", g_fix_enabled && g_Camera_fix_enabled ? "enabled" : "disabled");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -- Cheats --
|
|
|
|
|
|
static void EnableCheats(Cheat cheat) {
|
|
|
|
|
|
if (WorldTimedilationaddress && !WorldTimeDilationHook) {
|
|
|
|
|
|
WorldTimeDilationHook = safetyhook::create_mid(WorldTimedilationaddress + 0x19,
|
|
|
|
|
|
[](SafetyHookContext& ctx) { // From AWorldSettings retrieved from world->K2_GetWorldSettings()
|
|
|
|
|
|
ctx.xmm0.f32[0] *= g_TimeDilation_fix_enabled ? g_WorldTimeDilationValue : 1.f;
|
|
|
|
|
|
|
2026-04-11 09:36:12 +02:00
|
|
|
|
static ULONGLONG lastScanWTDTick = 0; // Last time tick was called
|
2026-04-10 00:18:11 +02:00
|
|
|
|
ULONGLONG now = GetTickCount64();
|
|
|
|
|
|
if (now - lastScanWTDTick >= DEFAULT_DELAY_BETWEEN_WTD_TICK) { // Delay between each tick to avoid ProcessEvent stuttering
|
|
|
|
|
|
lastScanWTDTick = now;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (letterBoxWidget) letterBoxWidget->SetVisibility(g_fix_enabled && g_Letterboxing_fix_enabled ?
|
|
|
|
|
|
ESlateVisibility::Collapsed : ESlateVisibility::Visible);
|
2026-04-10 00:18:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
// Apply visual effects only in hook main thread to ensure they will be applied correctly
|
|
|
|
|
|
if (!g_Console_Enabled) return; // It relies on dev console being reactivated
|
|
|
|
|
|
if (gPendingFog.exchange(false))
|
|
|
|
|
|
ApplyVisualEffect(GameFixes::Fog, g_fix_enabled && g_Fog_fix_enabled);
|
|
|
|
|
|
if (gPendingCA.exchange(false))
|
|
|
|
|
|
ApplyVisualEffect(GameFixes::ChromaticAberrations, g_fix_enabled && g_CA_fix_enabled);
|
|
|
|
|
|
if (gPendingVignetting.exchange(false))
|
|
|
|
|
|
ApplyVisualEffect(GameFixes::Vignetting, g_fix_enabled && g_Vignetting_fix_enabled);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// 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;
|
2026-04-11 09:36:12 +02:00
|
|
|
|
|
|
|
|
|
|
if (object->IsA(ACJCharacter::StaticClass())) {
|
|
|
|
|
|
ACJCharacter* character = static_cast<ACJCharacter*>(object);
|
|
|
|
|
|
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (!character || !character->Class) return;
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (character->IsPlayer()) {
|
2026-04-12 11:09:54 +02:00
|
|
|
|
g_bIsInVehicule = character->IsInVehicle();
|
2026-04-11 09:36:12 +02:00
|
|
|
|
static ULONGLONG lastScanTDTick = 0; // Last time tick was called
|
|
|
|
|
|
ULONGLONG now = GetTickCount64();
|
2026-04-12 11:09:54 +02:00
|
|
|
|
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (now - lastScanTDTick >= DEFAULT_DELAY_BETWEEN_TD_TICK) { // Delay between each tick to avoid spamming
|
|
|
|
|
|
lastScanTDTick = now;
|
2026-04-12 11:09:54 +02:00
|
|
|
|
|
|
|
|
|
|
if (g_GodMode_fix_enabled && character->HealthComponent) // God mode
|
2026-04-11 09:36:12 +02:00
|
|
|
|
character->HealthComponent->FullyRestore();
|
|
|
|
|
|
|
|
|
|
|
|
g_PlayerHealth = character->GetHealth(); // Retrieves player health
|
|
|
|
|
|
if (auto vehicle = character->GetVehicle()) {
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (g_GodMode_fix_enabled && vehicle && vehicle->DestructionComponent) // Indestructible vehicle
|
2026-04-11 09:36:12 +02:00
|
|
|
|
vehicle->DestructionComponent->RestoreVehicle();
|
|
|
|
|
|
|
|
|
|
|
|
if (g_Nitro_fix_enabled && vehicle->IsA(ABP_VehicleBase_C::StaticClass())) {
|
|
|
|
|
|
if (auto vehicleBase = static_cast<ABP_VehicleBase_C*>(vehicle)) {
|
|
|
|
|
|
auto nitro = vehicleBase->BP_NitroComponent;
|
|
|
|
|
|
// IsValidUObj alias SDK::UKismetSystemLibrary::IsValid
|
|
|
|
|
|
if (IsValidUObj(nitro)) { // Infinite nitro
|
|
|
|
|
|
nitro->ReplenishNitrous();
|
|
|
|
|
|
nitro->UpdateNitrousState();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-12 11:09:54 +02:00
|
|
|
|
if (g_Stealth_fix_enabled && character->StimEventSourceComponent && character->SpatialAwarenessComponent) { // Stealth
|
2026-04-11 09:36:12 +02:00
|
|
|
|
character->StimEventSourceComponent->ActiveStimEvents = {};
|
|
|
|
|
|
character->StimEventSourceComponent->Deactivate();
|
|
|
|
|
|
character->SpatialAwarenessComponent->Deactivate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!character->bIsPedestrian) // Apply only time dilation to enemies
|
|
|
|
|
|
character->CustomTimeDilation = g_TimeDilation_fix_enabled ? g_AITimeDilationValue : 1.f;
|
|
|
|
|
|
}
|
2026-04-10 00:18:11 +02:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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::Stealth) logger->info("Stealth cheat {}", g_Stealth_fix_enabled ? "enabled" : "disabled");
|
2026-04-11 09:36:12 +02:00
|
|
|
|
if (cheat == Cheat::Boost) logger->info("Nitro cheat {}", g_Nitro_fix_enabled ? "enabled" : "disabled");
|
2026-04-10 00:18:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UE Console creation
|
|
|
|
|
|
static void EnableConsole() {
|
|
|
|
|
|
if (g_Console_Enabled || !GObjectsaddress || !AppendStringaddress || !ProcessEventaddress)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
logger->info("-------------- Console re-enabling --------------");
|
|
|
|
|
|
ReactivateDevConsole(logger);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Standard dll entry
|
|
|
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
|
|
|
|
|
|
if (reason == DLL_PROCESS_DETACH) {
|
|
|
|
|
|
logger->info("Plugin {} unloaded.", PLUGIN_NAME);
|
|
|
|
|
|
spdlog::drop_all();
|
|
|
|
|
|
}
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
}
|