From 75e008b2cd7b203d996085a9814a59d3c3ec5742 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sun, 4 Jan 2026 19:33:02 +0100 Subject: [PATCH] Add new cheats. Add cheatmanager enabling. Code refactoring --- The Callisto Protocol/dllmain.cpp | 114 +++++++++++++++++------------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/The Callisto Protocol/dllmain.cpp b/The Callisto Protocol/dllmain.cpp index ba91edc..0035984 100644 --- a/The Callisto Protocol/dllmain.cpp +++ b/The Callisto Protocol/dllmain.cpp @@ -1,11 +1,6 @@ #define NOMINMAX #include #include "CommonHeaders.h" -#include "GameFixes.h" -#include "GameInformations.h" -#include "ObfuscateString.h" -#include "Memory.hpp" -#include "Maths.hpp" #include "UEngine.hpp" #include "UEMath.hpp" #include "SDK/Basic.hpp" @@ -40,6 +35,8 @@ static bool g_CA_fix_enabled = false; static bool g_Vignetting_fix_enabled = false; static bool g_Fog_fix_enabled = false; static bool g_TimeDilation_fix_enabled = false; +static bool g_GodMode_fix_enabled = false; +static bool g_Invulnerable_fix_enabled = false; static int g_AdditionalFOVValue = 0; static int g_CameraOffset = 0; static float g_WorldTimeDilationValue = 1.f; @@ -75,13 +72,13 @@ static uint8_t* ProcessEventaddress = nullptr; static uint8_t* FOVaddress = nullptr; static uint8_t* ConstrainAspectaddress = nullptr; static uint8_t* Cameraaddress = nullptr; -static uint8_t* CameraObjectaddress = nullptr; static uint8_t* HUDaddress = nullptr; static uint8_t* CAaddress = nullptr; static uint8_t* Vignettingaddress = nullptr; static uint8_t* Fogaddress = nullptr; static uint8_t* WorldTimedilationaddress = nullptr; static uint8_t* SetBenchmarkModeaddress = nullptr; +static uint8_t* CheatManageraddress = nullptr; // Hooking static SafetyHookMid FOVHook{}; @@ -91,6 +88,7 @@ static SafetyHookMid FogHook{}; static SafetyHookMid WorldTimeDilationHook{}; static SafetyHookMid BenchmarkHook{}; static SafetyHookMid PEHook{}; +static SafetyHookMid CheatsHook{}; // Prototypes static void FOVFixEnabled(); @@ -101,8 +99,8 @@ static void DOFFixEnabled(); static void CAFixEnabled(); static void VignettingFixEnabled(); static void FogFixEnabled(); -static void TimeDilation(); static void EnableConsole(); +static void EnableCheats(Cheat cheat); // Unreal Engine camera struct struct BlueprintModifyCamera_Params @@ -126,7 +124,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) using AOBScan::Make; using OffsetScan::Make; - constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B"); constexpr auto CameraStringObfuscated = make_obfuscated<0x2F>("49 8B ?? ?? ?? ?? ?? 48 ?? ?? 74 ?? 48 8D ?? ?? ?? E8 ?? ?? ?? ?? 49 8B ?? ?? ?? ?? ?? EB"); constexpr auto BenchMarkStringObfuscated = make_obfuscated<0xC3>("88 86 58 03 ?? ?? 48 8B ?? ?? ?? 48 83 ?? ?? 5F C3"); @@ -135,6 +132,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) constexpr auto VignettingStringObfuscated = make_obfuscated<0x97>("8B ?? 83 ?? ?? 7D ?? 89 B3"); constexpr auto FogStringObfuscated = make_obfuscated<0x46>("83 ?? ?? ?? 75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8"); constexpr auto WorldTimeDilationStringObfuscated = make_obfuscated<0x6E>("F3 0F 10 ?? ?? ?? ?? ?? F3 0F 10 ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? C3"); + constexpr auto CheatManagerStringObfuscated = make_obfuscated<0xAB>("FF 90 ?? ?? ?? ?? 84 ?? 75 ?? 84 ?? 0F 84 ?? ?? ?? ?? 48 89"); // Prepare all data for scanning std::vector signatures = { Make(&FOVaddress, FOVStringObfuscated, "FOV"), @@ -144,13 +142,14 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) Make(&CAaddress, CAStringObfuscated, "Chromatic aberrations"), Make(&Vignettingaddress, VignettingStringObfuscated, "Vignetting"), Make(&Fogaddress, FogStringObfuscated, "Fog"), - Make(&WorldTimedilationaddress, WorldTimeDilationStringObfuscated, "World time dilation") + Make(&WorldTimedilationaddress, WorldTimeDilationStringObfuscated, "World time dilation"), + Make(&CheatManageraddress, CheatManagerStringObfuscated, "Cheat manager"), }; // Scan all signature in a batch Memory::AOBScanBatch(signatures, logger); if (FOVaddress && Cameraaddress && SetBenchmarkModeaddress && HUDaddress && - CAaddress && Vignettingaddress && Fogaddress && WorldTimedilationaddress) + CAaddress && Vignettingaddress && Fogaddress && WorldTimedilationaddress && CheatManageraddress) logger->info("All AOB signatures found. Ready to patch..."); AOBScanDone = true; @@ -184,7 +183,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!init && CAaddress) CAFixEnabled(); if (!init && Vignettingaddress) VignettingFixEnabled(); if (!init && Fogaddress) FogFixEnabled(); - if (!init && WorldTimedilationaddress) TimeDilation(); if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress) EnableConsole(); if (FOVaddress) UltraWideFixEnabled(); } @@ -198,7 +196,9 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable if (fix == GameFixes::ChromaticAberrations) { g_CA_fix_enabled = enabled; CAFixEnabled(); } if (fix == GameFixes::Vignetting) { g_Vignetting_fix_enabled = enabled; VignettingFixEnabled(); } if (fix == GameFixes::Fog) { g_Fog_fix_enabled = enabled; FogFixEnabled(); } - if (fix == GameFixes::WorldTimeDilation) { g_TimeDilation_fix_enabled = enabled; TimeDilation(); } + 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::Invulnerable) { g_Invulnerable_fix_enabled = enabled; EnableCheats(Cheat::Invulnerability); } } extern "C" __declspec(dllexport) void SetFOV(int fov) { @@ -248,6 +248,17 @@ static APawn* GetPawnFromWorld(UWorld* world = nullptr) { return pawn; } +static APhxCharacter* GetPhxCharacterFromPawn(APawn* pawn) { + void* inventoryComp = *(void**)((uintptr_t)pawn + 0x6d8); // inventoryComp offset from SDK + void* moveComp = *(void**)((uintptr_t)pawn + 0x908); // moveComp offset FROM SDK + + if (inventoryComp && moveComp) { + APhxCharacter* phxChar = static_cast(pawn); + if (phxChar) return phxChar; + } + return nullptr; +} + // Miscellaneous functions static inline double NowSeconds() { @@ -333,13 +344,9 @@ static void CameraFixEnabled() { APawn* pawn = GetPawnFromWorld(world); if (!pawn) return; - // Retrieve Character class - void* inventoryComp = *(void**)((uintptr_t)pawn + 0x6d8); // inventoryComp offset from SDK - void* moveComp = *(void**)((uintptr_t)pawn + 0x908); // moveComp offset FROM SDK - if (inventoryComp && moveComp) { - APhxCharacter* phxChar = static_cast(pawn); - if (phxChar) bIsAiming = phxChar->bIsAiming; // Is player aiming ? - } + // Retrieve PhxCharacter class + APhxCharacter* phxChar = GetPhxCharacterFromPawn(pawn); + if (phxChar) bIsAiming = phxChar->bIsAiming; // Is player aiming ? // --- Positions --- FVector pawnPos = pawn->K2_GetActorLocation(); @@ -490,42 +497,47 @@ static void HUDFixEnabled() { } } -static void TimeDilation() { - if (g_fix_enabled && g_TimeDilation_fix_enabled && WorldTimedilationaddress) { - if (!WorldTimeDilationHook) { - WorldTimeDilationHook = safetyhook::create_mid(WorldTimedilationaddress + 0x20, - [](SafetyHookContext& ctx) { - ctx.xmm0.f32[0] = g_TimeDilation_fix_enabled ? g_WorldTimeDilationValue : 1.f; +static void EnableCheats(Cheat cheat) { + if (WorldTimedilationaddress && !WorldTimeDilationHook) { + WorldTimeDilationHook = safetyhook::create_mid(WorldTimedilationaddress + 0x20, + [](SafetyHookContext& ctx) { + // From AWorldSettings retrieved from world->K2_GetWorldSettings() + ctx.xmm0.f32[0] = g_TimeDilation_fix_enabled ? g_WorldTimeDilationValue : 1.f; - ULONGLONG now = GetTickCount64(); - if (now - lastScanTick < DEFAULT_ACTORS_SCAN_BETWEEN_TICKS) return; + ULONGLONG now = GetTickCount64(); + if (now - lastScanTick < DEFAULT_ACTORS_SCAN_BETWEEN_TICKS) return; - lastScanTick = now; - UWorld* world = UWorld::GetWorld(); - if (!world) return; - APawn* pawn = GetPawnFromWorld(world); - if (!pawn) return; + lastScanTick = now; + UWorld* world = UWorld::GetWorld(); + if (!world) return; + APawn* pawn = GetPawnFromWorld(world); + if (!pawn) return; + // Enemies time dilation, + for (int i = 0; i < world->Levels.Num(); i++) { // Loop through level to find actors + ULevel* Level = world->Levels[i]; + if (!Level) continue; - for (int i = 0; i < world->Levels.Num(); i++) { // Loop through level to find actors - ULevel* Level = world->Levels[i]; - if (!Level) continue; + for (int j = 0; j < Level->Actors.Num(); j++) { // Loop through actors + AActor* actor = Level->Actors[j]; + if (!actor) continue; + if (actor == pawn) continue; // We don't want to affect Jacob + if (!actor->IsA(ACharacter::StaticClass()) && !actor->IsA(APawn::StaticClass())) + continue; // We want to affect only enemies - for (int j = 0; j < Level->Actors.Num(); j++) { // Loop through actors - AActor* actor = Level->Actors[j]; - if (!actor) continue; - if (actor == pawn) continue; // We don't want to affect Jacob - if (!actor->IsA(ACharacter::StaticClass()) && !actor->IsA(APawn::StaticClass())) - continue; // We want to affect only enemies - - actor->CustomTimeDilation = g_TimeDilation_fix_enabled ? g_AITimeDilationValue : 1.f; - } + actor->CustomTimeDilation = g_TimeDilation_fix_enabled ? g_AITimeDilationValue : 1.f; } - }); - } - logger->info("Time dilation fix enabled"); + } + // God mode + AActor* jacob = static_cast(pawn); + if (jacob) jacob->bCanBeDamaged = g_GodMode_fix_enabled ? false : true; // Jacob won't be hurt + // Invulnerability + APhxCharacter* phxChar = GetPhxCharacterFromPawn(pawn); + if (phxChar) phxChar->bInvulnerable = g_Invulnerable_fix_enabled ? true : false; // Make Jacob invulnerable + }); } - if (!(g_fix_enabled && g_TimeDilation_fix_enabled) && WorldTimedilationaddress) - logger->info("Time dilation fix disabled"); + 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::Invulnerability) logger->info("Ignore hits cheat {}", g_Invulnerable_fix_enabled ? "enabled" : "disabled"); } static void FogFixEnabled() { @@ -619,6 +631,10 @@ static void EnableConsole() logger->info("Console fully reactivated in {:.3f}s and bound to key F2", elapsed.count()); logger->info("------------------ User inputs ------------------"); + // Enable cheat commands through console + if (CheatManageraddress) + Memory::PatchBytes(CheatManageraddress, "\xB0\x01\x90\x90\x90\x90", 6); // mov al,1 + g_Console_Enabled = true; } else {