diff --git a/src/SDK/Basic.hpp b/src/SDK/Basic.hpp index 94ba45f..040d9cb 100644 --- a/src/SDK/Basic.hpp +++ b/src/SDK/Basic.hpp @@ -31,12 +31,12 @@ using namespace UC; */ namespace Offsets { - constexpr int32 GObjects = 0x1D76CC30; - constexpr int32 AppendString = 0x0CD72A90; - constexpr int32 GNames = 0x1D6CDC00; - constexpr int32 GWorld = 0x1D8CF0F0; - constexpr int32 ProcessEvent = 0x0CF09080; - constexpr int32 ProcessEventIdx = 0x0000004A; + inline int32 GObjects = 0x0; // 0x1D76CC30; + inline int32 AppendString = 0x0; // 0x0CD72A90; + inline int32 GNames = 0x0; // 0x1D6CDC00; + inline int32 GWorld = 0x0; // 0x1D8CF0F0; + inline int32 ProcessEvent = 0x0; // 0x0CF09080; + inline int32 ProcessEventIdx = 0x0000004A; } namespace InSDKUtils diff --git a/src/SDK/Engine_functions.cpp b/src/SDK/Engine_functions.cpp index 6f8fde6..9a17f1a 100644 --- a/src/SDK/Engine_functions.cpp +++ b/src/SDK/Engine_functions.cpp @@ -14474,7 +14474,7 @@ void UStreamableRenderAsset::SetForceMipLevelsToBeResident(float Seconds, int32 class UWorld* UWorld::GetWorld() { - if constexpr (Offsets::GWorld != 0) + if (Offsets::GWorld != 0) return *reinterpret_cast(InSDKUtils::GetImageBase() + Offsets::GWorld); if (UEngine* Engine = UEngine::GetEngine()) diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 0a58a08..597451d 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -238,53 +238,58 @@ void EnableConsole() { // Enable developer console if (bEnableConsole) { - // Get GEngine - SDK::UEngine* engine = nullptr; + if (SDK::Offsets::GObjects && SDK::Offsets::AppendString) { + // Get GEngine + SDK::UEngine* engine = nullptr; - int i = 0; - while (i < 300) { // 30s - engine = SDK::UEngine::GetEngine(); + int i = 0; + while (i < 300) { // 30s + engine = SDK::UEngine::GetEngine(); - if (engine) { - if (engine->ConsoleClass && engine->GameViewport) { - break; + if (engine) { + if (engine->ConsoleClass && engine->GameViewport) { + break; + } } - } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - i++; - } + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + i++; + } - if (i == 100) { - spdlog::error("Construct Console: Failed to find GEngine address after 30 seconds."); - return; - } + if (i == 100) { + spdlog::error("Construct Console: Failed to find GEngine address after 30 seconds."); + return; + } - spdlog::info("Construct Console: GEngine address = {:x}", (uintptr_t)engine); + spdlog::info("Construct Console: GEngine address = {:x}", (uintptr_t)engine); - // Construct console - if (engine->ConsoleClass && engine->GameViewport) { - SDK::UObject* NewObject = SDK::UGameplayStatics::SpawnObject(engine->ConsoleClass, engine->GameViewport); - if (NewObject) { - engine->GameViewport->ViewportConsole = static_cast(NewObject); - spdlog::info("Construct Console: Console object constructed."); + // Construct console + if (engine->ConsoleClass && engine->GameViewport) { + SDK::UObject* NewObject = SDK::UGameplayStatics::SpawnObject(engine->ConsoleClass, engine->GameViewport); + if (NewObject) { + engine->GameViewport->ViewportConsole = static_cast(NewObject); + spdlog::info("Construct Console: Console object constructed."); + } + else { + spdlog::error("Construct Console: Failed to construct console object."); + return; + } } else { - spdlog::error("Construct Console: Failed to construct console object."); + spdlog::error("Construct Console: Failed to construct console object - ConsoleClass or GameViewport is null."); return; } - } - else { - spdlog::error("Construct Console: Failed to construct console object - ConsoleClass or GameViewport is null."); - return; - } - // Log console key - if (SDK::UInputSettings::GetInputSettings()->ConsoleKeys && SDK::UInputSettings::GetInputSettings()->ConsoleKeys.Num() > 0) { - spdlog::info("Construct Console: Console enabled - access it using key: {}.", SDK::UInputSettings::GetInputSettings()->ConsoleKeys[0].KeyName.ToString()); + // Log console key + if (SDK::UInputSettings::GetInputSettings()->ConsoleKeys && SDK::UInputSettings::GetInputSettings()->ConsoleKeys.Num() > 0) { + spdlog::info("Construct Console: Console enabled - access it using key: {}.", SDK::UInputSettings::GetInputSettings()->ConsoleKeys[0].KeyName.ToString()); + } + else { + spdlog::warn("Console enabled but no console key is bound.\nAdd this to %LOCALAPPDATA%\\b1\\Saved\\Config\\Windows\\Input.ini -\n[/Script/Engine.InputSettings]\nConsoleKeys = Tilde"); + } } else { - spdlog::warn("Console enabled but no console key is bound.\nAdd this to %LOCALAPPDATA%\\b1\\Saved\\Config\\Windows\\Input.ini -\n[/Script/Engine.InputSettings]\nConsoleKeys = Tilde"); + spdlog::error("Construct Console: GObjects or AppendString offset invalid."); } } } @@ -476,10 +481,48 @@ void AspectFOV() } } +void UpdateOffsets() +{ + // GObjects + uint8_t* GObjectsScanResult = Memory::PatternScan(baseModule, "48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33 ?? 8B ?? ?? C1 ??"); + if (GObjectsScanResult) { + spdlog::info("Offsets: GObjects: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)GObjectsScanResult - (uintptr_t)baseModule); + uintptr_t GObjectsAddr = Memory::GetAbsolute((uintptr_t)GObjectsScanResult + 0x3); + SDK::Offsets::GObjects = (uintptr_t)GObjectsAddr - (uintptr_t)baseModule; + spdlog::info("Offsets: GObjects: Offset: {:x}", SDK::Offsets::GObjects); + } + else if (!GObjectsScanResult) { + spdlog::error("Offsets: GObjects: Pattern scan failed."); + } + + // AppendString + uint8_t* AppendStringScanResult = Memory::PatternScan(baseModule, "48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? 00 48 8B ?? 48 8B ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C ?? ?? C6 ?? ?? ?? ?? ?? 01 8B ?? 8B ?? 0F ?? ?? C1 ?? 10 89 ?? ?? ?? 89 ?? ?? ?? 48 8B ?? ?? ?? 48 ?? ?? ?? 8D ?? ?? 49 ?? ?? ?? ?? 48 8B ?? E8 ?? ?? ?? ?? 83 ?? ?? 00"); + if (AppendStringScanResult) { + spdlog::info("Offsets: AppendString: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)AppendStringScanResult - (uintptr_t)baseModule); + SDK::Offsets::AppendString = (uintptr_t)AppendStringScanResult - (uintptr_t)baseModule; + spdlog::info("Offsets: AppendString: Offset: {:x}", SDK::Offsets::AppendString); + } + else if (!AppendStringScanResult) { + spdlog::error("Offsets: AppendString: Pattern scan failed."); + } + + // ProcessEvent + uint8_t* ProcessEventScanResult = Memory::PatternScan(baseModule, "40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48 ?? ?? 4C ?? ?? 48 ?? ??"); + if (ProcessEventScanResult) { + spdlog::info("Offsets: ProcessEvent: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)ProcessEventScanResult - (uintptr_t)baseModule); + SDK::Offsets::ProcessEvent = (uintptr_t)ProcessEventScanResult - (uintptr_t)baseModule; + spdlog::info("Offsets: ProcessEvent: Offset: {:x}", SDK::Offsets::ProcessEvent); + } + else if (!ProcessEventScanResult) { + spdlog::error("Offsets: ProcessEvent: Pattern scan failed."); + } +} + DWORD __stdcall Main(void*) { Logging(); Configuration(); + UpdateOffsets(); CurrentResolution(); EnableConsole(); GetCVARs();