#include "CommonHeaders.h" #include "UEngine.hpp" #include "UETools.hpp" #include "UEvars.hpp" #include "SDK/Basic.hpp" #include "SDK/Engine_classes.hpp" #include "SDK/Cronos_classes.hpp" using namespace SDK; // Constants const std::string PLUGIN_NAME = "CronosTND"; const std::string PLUGIN_LOG = PLUGIN_NAME + ".log"; const float baseAspect = 1.7777778; // Logger std::shared_ptr logger; // Screen informations static int screenWidth = GetSystemMetrics(SM_CXSCREEN); static int screenHeight = GetSystemMetrics(SM_CYSCREEN); static float aspectRatio = (float)screenWidth / screenHeight; // Plugin states static bool AOBScanDone = false; static bool g_Console = false; static bool g_fix_enabled = false; static bool g_fov_fix_enabled = false; static bool g_aspect_fix_enabled = false; static bool g_HUD_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_cam_distance_fix_enabled = false; static bool g_SkipIntro_fix_enabled = false; static bool g_TimeDilation_fix_enabled = false; static bool g_GodMode_fix_enabled = false; static bool g_IgnoreHits_fix_enabled = false; static bool g_Stealth_fix_enabled = false; static int g_AdditionalFOVValue = 0; static int g_HUDOffsets = 0; static int g_UIOffsets = 0; static float g_cameraDistanceMultiplier = 1.f; static float g_WorldTimeDilationValue = 1.f; static float g_AITimeDilationValue = 1.f; static bool user_inputs_logged = false; // Shared values static float g_FOV_In = 0; static float g_Compensated_FOV = 0; static float g_FOV_Out = 0; static float g_Camera_In = 180; static float g_Camera_Out = 180; static float g_PlayerHealth = 0; // AOB Scan pointers static uint8_t* FOVaddress = nullptr; static uint8_t* Aspectaddress = nullptr; static uint8_t* DOFaddress = nullptr; static uint8_t* Vignettingaddress = nullptr; static uint8_t* Fogaddress = nullptr; static uint8_t* FogOpacityEngineaddress = nullptr; static uint8_t* CameraDistanceaddress = nullptr; static uint8_t* WorldTimedilationaddress = nullptr; static uint8_t* Timedilationaddress = nullptr; static uint8_t* GodModeaddress = nullptr; static uint8_t* StealthModeaddress = nullptr; // Hooking static SafetyHookMid FOVHook{}; static SafetyHookMid AspectHook{}; static SafetyHookMid FogHook{}; static SafetyHookMid FogMaxOpacityHook{}; static SafetyHookMid CameraDistanceHook{}; static SafetyHookMid PEHook{}; static SafetyHookMid WorldTimeDilationHook{}; static SafetyHookMid TimeDilationHook{}; static SafetyHookMid StealthHook{}; // Prototypes static void FOVFixEnabled(); static void UltrawideFixEnabled(); static void HUDFixEnabled(UWidget* widget, int offset, bool writeLog, int depth = INT_MAX); static void DOFFixEnabled(); static void VignettingFixEnabled(); static void FogFixEnabled(); static void CameraDistanceFixEnabled(); static void EnableConsole(); static void ProcessEvent(); static void EnableCheats(Cheat cheat); // UEngine variable UWidget* g_HUDWidget = nullptr; UWidget* g_WorkbenchWidget = nullptr; UWidget* g_SettingsWidget = nullptr; UWidget* g_TutorialWidget = nullptr; extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) { g_fix_enabled = enabled; if (!AOBScanDone) { // Unreal Engine 5.5.4 logger->info("--------------- AOB scan started ---------------"); using AOBScan::Make; using OffsetScan::Make; 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<0x35>("40 ?? 48 83 ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? 48 8D ?? ?? 48 8D ?? ?? ?? E8"); constexpr auto FogOpacityStringObfuscated = make_obfuscated<0xB3>("0F 2E ?? C4 02 ?? ?? 74 ?? F3 0F ?? ?? ?? ?? ?? ?? E9 ?? ?? ?? ?? C3"); constexpr auto CamDistanceStringObfuscated = make_obfuscated<0xF2>("E8 ?? ?? ?? ?? F2 0F ?? ?? ?? ?? 48 8D ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 0F"); 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"); constexpr auto GodModeStringObfuscated = make_obfuscated<0XB8>("F3 41 0F ?? ?? 80 B8 ?? ?? ?? ?? ?? F3 0F ?? ?? F3 0F ?? ?? 74"); constexpr auto StealthStringObfuscated = make_obfuscated<0XDB>("FF 90 C0 04 ?? ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8 ?? ?? ?? ?? 48 8B ?? ?? ?? 48 8B ?? ?? ?? 48 83 ?? ?? 5F C3"); // Prepare all data for scanning std::vector 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"), Make(&FogOpacityEngineaddress, FogOpacityStringObfuscated, "Fog opacity"), Make(&WorldTimedilationaddress, WorldTimeDilationStringObfuscated, "World time dilation"), Make(&Timedilationaddress, TimeDilationStringObfuscated, "Actor time dilation"), Make(&GodModeaddress, GodModeStringObfuscated, "God mode"), Make(&StealthModeaddress, StealthStringObfuscated, "Stealth") }; // Scan all signature in a batch Memory::AOBScanBatch(signatures, logger); if (FOVaddress && Aspectaddress && DOFaddress && Vignettingaddress && FogOpacityEngineaddress && CameraDistanceaddress && WorldTimedilationaddress && Timedilationaddress && GodModeaddress && StealthModeaddress) logger->info("All AOB signatures found. Ready to patch..."); // 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(GetModuleHandleA(nullptr)); // Get game base address constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x33>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33"); 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 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"); // Prepare all data for scanning std::vector 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, ""); } AOBScanDone = true; logger->info("-------------- Fixes initialisation -------------"); } if (!init && FOVaddress) FOVFixEnabled(); if (!init && Aspectaddress) UltrawideFixEnabled(); if (!init) { HUDFixEnabled(g_HUDWidget, g_HUDOffsets, true); HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1); HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1); HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1); } if (!init && DOFaddress) DOFFixEnabled(); if (!init && Vignettingaddress) VignettingFixEnabled(); if (!init && Fogaddress && FogOpacityEngineaddress) FogFixEnabled(); if (!init && CameraDistanceaddress) CameraDistanceFixEnabled(); if (!init && WorldTimedilationaddress) { EnableCheats(Cheat::TimeDilation); EnableCheats(Cheat::GodMode); EnableCheats(Cheat::IgnoreHits); EnableCheats(Cheat::Stealth); } ProcessEvent(); } // Setters for Reshade addon calls 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; UltrawideFixEnabled(); } if (fix == GameFixes::HUD) { g_HUD_fix_enabled = enabled; HUDFixEnabled(g_HUDWidget, g_HUDOffsets, true); HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1); HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1); HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1); } if (fix == GameFixes::Camera) { g_cam_distance_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::SkipIntro) { g_SkipIntro_fix_enabled = enabled; } 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::IgnoreHits) { g_IgnoreHits_fix_enabled = enabled; EnableCheats(Cheat::IgnoreHits); } if (fix == GameFixes::Stealth) { g_Stealth_fix_enabled = enabled; EnableCheats(Cheat::Stealth); } } 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; if (setting == GameSetting::WorldTimeDilation) g_WorldTimeDilationValue = value; if (setting == GameSetting::AITimeDilation) g_AITimeDilationValue = value; if (setting == GameSetting::HUD) { g_HUDOffsets = ((int)value * screenWidth) / 100; HUDFixEnabled(g_HUDWidget, g_HUDOffsets, false); } if (setting == GameSetting::UI) { g_UIOffsets = ((int)value * screenWidth) / 100; HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1); HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1); HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1); } } // Getters for Reshade addon calls extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) { if (!infos) return; infos->FOVIn = g_FOV_In; infos->FOVOut = g_FOV_Out; infos->CompensatedFOV = g_Compensated_FOV; infos->cameraIn = g_Camera_In; infos->cameraOut = g_Camera_Out; infos->consoleEnabled = g_Console_Enabled; infos->Health = g_PlayerHealth; } 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) { std::string funcName = func->GetName(); if (object->IsA(UStartGameWidget::StaticClass())) { auto* widget = static_cast(object); if (widget && widget->Class && funcName == "OnNext" && !inContinue) { inContinue = true; if (g_SkipIntro_fix_enabled) widget->Continue(); inContinue = false; } } else if (object->IsA(UUserWidget::StaticClass()) && (funcName == "Construct" || funcName == "Destruct" || funcName == "Tick")) { // UI scaling if (object->IsA(UCronosExtendedTutorialWidget::StaticClass())) { auto* widget = static_cast(object); if (funcName == "Construct" && widget->WidgetTree && widget->WidgetTree->RootWidget) { g_TutorialWidget = widget->WidgetTree->RootWidget; HUDFixEnabled(g_TutorialWidget, g_UIOffsets, false, 1); } else if (funcName == "Destruct") g_TutorialWidget = nullptr; } else if (object->IsA(USettingsWidget::StaticClass())) { auto* settingsWidget = static_cast(object); if (funcName == "Construct") { if (settingsWidget && settingsWidget->Class && settingsWidget->Main_panel) { g_SettingsWidget = settingsWidget->Main_panel; HUDFixEnabled(g_SettingsWidget, g_UIOffsets, false, 1); } } else if (funcName == "Destruct") g_SettingsWidget = nullptr; } else if (object->IsA(UBTUpgradeMenuWidget::StaticClass())) { auto* widget = static_cast(object); if (funcName == "Construct") { if (widget && widget->WidgetTree && widget->WidgetTree->RootWidget) { g_WorkbenchWidget = widget->WidgetTree->RootWidget; if (g_WorkbenchWidget) HUDFixEnabled(g_WorkbenchWidget, g_UIOffsets, false, 1); } } else if (funcName == "Destruct") g_WorkbenchWidget = nullptr; } // HUD scaling else if (object->IsA(USHGameplayHudWidget::StaticClass())) { USHGameplayHudWidget* HUDWidget = static_cast(object); if (!HUDWidget) return; if (funcName == "Construct") { if (HUDWidget && HUDWidget->WidgetTree) { g_HUDWidget = HUDWidget->WidgetTree->RootWidget; if (g_HUDWidget) HUDFixEnabled(g_HUDWidget, g_HUDOffsets, false); } } else if (funcName == "Tick") { for (auto* collectWidget : HUDWidget->CollectItemsWidgets) { if (!collectWidget) continue; // Apply offset to collectible objects ApplyOverlayOffsetRecursive(collectWidget->MainOverlay, g_fix_enabled && g_HUD_fix_enabled ? g_HUDOffsets - 100 : 0, EHorizontalAlignment::HAlign_Fill, { "VerticalBox" }); } } else if (funcName == "Destruct") g_HUDWidget = nullptr; } } } }); } } // 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 + 0xa, [](SafetyHookContext& ctx) { g_FOV_In = 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); }); } else FOVHook.enable(); logger->info("FOV fix enabled"); } if (!(g_fix_enabled && (g_fov_fix_enabled || g_aspect_fix_enabled)) && FOVaddress) { if (FOVHook) FOVHook.disable(); logger->info("FOV fix disabled"); } } // HUD fix hook UUserWidget -> AddToViewPort to log and know which HUD widget will be targeted static void HUDFixEnabled(UWidget* widget, int offset, bool writeLog, int depth) { if (writeLog) logger->info("HUD fix {}", g_fix_enabled && g_HUD_fix_enabled ? "enabled" : "disabled"); if (!widget) return; float targetOffset = g_fix_enabled && g_HUD_fix_enabled ? offset : 0.f; if (widget->IsA(UCanvasPanel::StaticClass())) // Apply offsets To CanvasPanel ApplyOffsetsRecursive(widget, targetOffset, targetOffset, depth); else // Apply offsets to OvelaySlot ApplyOverlayOffsetRecursive(widget, targetOffset, EHorizontalAlignment::HAlign_Fill, { "VerticalBox" }, depth); } static UExponentialHeightFogComponent* fogComponent = nullptr; static UWorld* previousWorld = nullptr; static void FogFixEnabled() { if (FogOpacityEngineaddress) { if (!FogMaxOpacityHook) FogMaxOpacityHook = safetyhook::create_mid(FogOpacityEngineaddress, [](SafetyHookContext& ctx) { if (ctx.rcx) fogComponent = reinterpret_cast(ctx.rcx); ctx.xmm1.f32[0] = g_fix_enabled && g_Fog_fix_enabled ? 0.f : 1.f; }); } if (Fogaddress) { if (!FogHook) FogHook = safetyhook::create_mid(Fogaddress + 0x5c, // Generic hook for fogs fixes [](SafetyHookContext& ctx) { UWorld* world = UWorld::GetWorld(); if (world != previousWorld) { previousWorld = world; fogComponent = nullptr; } if (fogComponent) { fogComponent->SetFogMaxOpacity(g_fix_enabled && g_Fog_fix_enabled ? 0.f : 1.f); } }); } if (g_fix_enabled && g_Fog_fix_enabled && FogOpacityEngineaddress) logger->info("Fog fix enabled"); if (!(g_fix_enabled && g_Fog_fix_enabled) && FogOpacityEngineaddress) logger->info("Fog fix disabled"); } // 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; if (object->IsA(ACronosBaseEnemyCharacter::StaticClass())) { ACronosBaseEnemyCharacter* character = static_cast(object); if (character->Controller && character->Controller->IsA(AAIController::StaticClass())) { AActor* enemy = static_cast(character); if (enemy) enemy->CustomTimeDilation = g_TimeDilation_fix_enabled ? g_AITimeDilationValue : 1.f; } } else if (object->IsA(ASHCharacterPlay::StaticClass())) { auto* traveler = static_cast(object); if (traveler && traveler->Class && traveler->Health) { g_PlayerHealth = traveler->Health->HealthValue; if (g_IgnoreHits_fix_enabled && traveler->bCanBeDamaged) traveler->bCanBeDamaged = false; if (!g_IgnoreHits_fix_enabled && !traveler->bCanBeDamaged) traveler->bCanBeDamaged = true; } } }); } if (StealthModeaddress && !StealthHook) { // Hook function UAIPerceptionComponent -> GetPerceivedHostileActors StealthHook = safetyhook::create_mid(StealthModeaddress - 0x86, [](SafetyHookContext& ctx) { if (!g_Stealth_fix_enabled || !ctx.rcx) return; auto perception = reinterpret_cast(ctx.rcx); if (!perception) return; perception->ForgetAll(); }); } if (g_GodMode_fix_enabled && GodModeaddress) Memory::PatchBytes(GodModeaddress, "\x90\x90\x90\x90\x90", 5); // subss xmm6,xmm9 if (!g_GodMode_fix_enabled && GodModeaddress) Memory::RestoreBytes(GodModeaddress); 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::IgnoreHits) logger->info("Ignore hits cheat {}", g_IgnoreHits_fix_enabled ? "enabled" : "disabled"); if (cheat == Cheat::Stealth) logger->info("Stealth cheat {}", g_Stealth_fix_enabled ? "enabled" : "disabled"); } // Memory patch fixes static void UltrawideFixEnabled() { 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 + 0x3, newAspectRatio, 4); // mov [rdi+00000254],3FE38E39 <= patched logger->info("Aspect fix enabled"); } if (!(g_fix_enabled && g_aspect_fix_enabled) && Aspectaddress) { Memory::RestoreBytes(Aspectaddress + 0x3); logger->info("Aspect ratio fix disabled"); } } static void DOFFixEnabled() { if (g_fix_enabled && g_DOF_fix_enabled && DOFaddress) { 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 + 0x5); logger->info("Depth of field fix disabled"); } } static void VignettingFixEnabled() { if (g_fix_enabled && g_Vignetting_fix_enabled && Vignettingaddress) { 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 + 0x5); logger->info("Vignetting fix disabled"); } } static void CameraDistanceFixEnabled() { if (g_fix_enabled && g_cam_distance_fix_enabled && CameraDistanceaddress) { if (!CameraDistanceHook) { // Hook only once CameraDistanceHook = safetyhook::create_mid(CameraDistanceaddress + 0x17, [](SafetyHookContext& ctx) { g_Camera_In = ctx.xmm1.f32[0]; ctx.xmm1.f32[0] *= g_cameraDistanceMultiplier; g_Camera_Out = ctx.xmm1.f32[0]; }); } else CameraDistanceHook.enable(); logger->info("Camera distance fix enabled"); } if (!(g_fix_enabled && g_cam_distance_fix_enabled) && CameraDistanceaddress) { if (CameraDistanceHook) CameraDistanceHook.disable(); logger->info("Camera distance 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; } logger->info("-------------- Console re-enabling --------------"); ReactivateDevConsole(logger); } // Logging 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("Cronos : The New Dawn", std::make_shared(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) { std::string plugin_error_message = "Could not open " + PLUGIN_LOG; MessageBoxA(nullptr, plugin_error_message.c_str(), "Logger Error", MB_ICONERROR | MB_OK); } } // Standard dll entry BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) { if (reason == DLL_PROCESS_ATTACH) { InitializeLogger(); logger->info("Plugin {} loaded.", PLUGIN_NAME); } else if (reason == DLL_PROCESS_DETACH) { logger->info("Plugin {} unloaded.", PLUGIN_NAME); spdlog::drop_all(); } return TRUE; }