From 27039d539083b64ad1e189c072001d10db9ce1c8 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Mon, 19 Jan 2026 18:41:54 +0100 Subject: [PATCH] Code refactoring. Unnecessary code removal --- Cronos The New Dawn/dllmain.cpp | 95 ++++----------------------------- 1 file changed, 10 insertions(+), 85 deletions(-) diff --git a/Cronos The New Dawn/dllmain.cpp b/Cronos The New Dawn/dllmain.cpp index adb95e8..755d19e 100644 --- a/Cronos The New Dawn/dllmain.cpp +++ b/Cronos The New Dawn/dllmain.cpp @@ -1,10 +1,6 @@ #include "CommonHeaders.h" -#include "GameFixes.h" -#include "GameInformations.h" -#include "Memory.hpp"; -#include "Maths.hpp"; #include "UEngine.hpp"; -#include "ObfuscateString.h" +#include "UEvars.hpp" #include "SDK/Engine_classes.hpp" using namespace SDK; @@ -51,11 +47,6 @@ static uint8_t* Vignettingaddress = nullptr; static uint8_t* Fogaddress = nullptr; static uint8_t* CameraDistanceaddress = nullptr; -// AOB Unreal Engine offsets addresses -static uint8_t* GObjectsaddress = nullptr; -static uint8_t* AppendStringaddress = nullptr; -static uint8_t* ProcessEventaddress = nullptr; - // Hooking static SafetyHookMid FOVHook{}; static SafetyHookMid AspectHook{}; @@ -245,13 +236,11 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); } } -extern "C" __declspec(dllexport) void SetFOV(int fov) -{ +extern "C" __declspec(dllexport) void SetFOV(int fov) { g_AdditionalFOVValue = fov; } -extern "C" __declspec(dllexport) void SetCameraDistance(float cameraDistance) -{ +extern "C" __declspec(dllexport) void SetCameraDistance(float cameraDistance) { g_cameraDistanceMultiplier = cameraDistance; } @@ -360,67 +349,9 @@ static void CameraDistanceFixEnabled() { logger->info("Camera distance fix disabled"); } } -// Debuggin function intended to find specific class or object -// UE Process Event signature to search for : 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48 ?? ?? 4C ?? ?? 48 ?? ?? 0F 84 -//static void ProcessEvent() { -// HMODULE gameHandle = nullptr; -// static uint8_t* ProcessEventaddress = nullptr; -// -// while ((gameHandle = GetModuleHandleA("Cronos-Win64-Shipping.exe")) == nullptr) -// std::this_thread::sleep_for(std::chrono::milliseconds(100)); -// -// uintptr_t base_module = (uintptr_t)GetModuleHandle(NULL); -// static auto lastLogTime = std::chrono::steady_clock::now(); -// -// ProcessEventaddress = reinterpret_cast(base_module + static_cast(Offsets::ProcessEvent)); -// -// if (!PEHook && ProcessEventaddress + 0x3c) { // Hook only once -// PEHook = safetyhook::create_mid(ProcessEventaddress, -// [](SafetyHookContext& ctx) { -// UObject* object = (UObject*)ctx.rcx; -// UFunction* func = (UFunction*)ctx.rdx; -// -// if (object && object->GetFullName().contains("PlayerHudWidget_BP_C") && func->GetFullName().contains("Tick")) { -// //logger->info("PlayerHudWidget trouve: {} = {}", object->GetFullName(), func->GetFullName()); -// static double NormallastX = 0, NormallastY = 0, UltralastX = 0, UltralastY = 0, SuperlastX = 0, SuperlastY = 0; -// auto* HUDWidget = reinterpret_cast(object); -// if (HUDWidget) { -// static auto lastLogTime = std::chrono::steady_clock::now(); -// -// auto* aspectZone = HUDWidget->KeepAspectZone_0; -// if (aspectZone && aspectZone->IsA(UKeepAspectZone::StaticClass())) { -// auto now = std::chrono::steady_clock::now(); -// auto diff = std::chrono::duration_cast(now - lastLogTime).count(); -// -// if (diff > 1000) { // une fois par seconde -// lastLogTime = now; -// -// const FVector2D ratioNormal = aspectZone->DesireAspectRatio; -// const FVector2D ratioUltra = aspectZone->DesireAspectRatioUltraWide; -// const FVector2D ratioSuper = aspectZone->DesireAspectRatioSuperUltraWide; -// -// if (ratioNormal.X != NormallastX || ratioNormal.Y != NormallastY || -// ratioUltra.X != UltralastX || ratioUltra.Y != UltralastY || -// ratioSuper.X != SuperlastX || ratioSuper.Y != SuperlastY) { -// logger->info("Classe: {} // Ratio Normal X = {:.4f}, Y = {:.4f} // Ratio Super X = {:.4f}, Y = {:.4f} // Ratio Ultra X = {:.4f}, Y = {:.4f} ", -// object->GetName(), ratioNormal.X, ratioNormal.Y, ratioSuper.X, ratioSuper.Y, ratioUltra.X, ratioUltra.Y); -// -// NormallastX = ratioNormal.X; NormallastY = ratioNormal.Y; -// UltralastX = ratioUltra.X; UltralastY = ratioUltra.Y; -// SuperlastX = ratioSuper.X; SuperlastY = ratioSuper.Y; -// } -// } -// } -// -// } -// } -// }); -// } -//} // UE Console creation -static void EnableConsole() -{ +static void EnableConsole() { if (!g_Console) { logger->info("------------------ User inputs ------------------"); return; @@ -472,33 +403,27 @@ static void EnableConsole() } // Logging -static void InitializeLogger() -{ - try - { +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->flush_on(spdlog::level::debug); // Flush automatically } - catch (const spdlog::spdlog_ex& ex) - { + 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) - { +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) - { + else if (reason == DLL_PROCESS_DETACH) { logger->info("Plugin {} unloaded.", PLUGIN_NAME); spdlog::drop_all(); }