diff --git a/Core/Memory/PatternScanner.cpp b/Core/Memory/PatternScanner.cpp index 475efab..509eec8 100644 --- a/Core/Memory/PatternScanner.cpp +++ b/Core/Memory/PatternScanner.cpp @@ -1,10 +1,16 @@ #include "PatternScanner.h" +PatternScanner* PatternScanner::Get() +{ + static PatternScanner* Instance = new PatternScanner(); + return Instance; +} + uintptr_t PatternScanner::FindGetEngineVersion() { auto Results = Memcury::Scanner::FindPattern("40 53 48 83 EC ?? 48 8B D9 E8 ?? ?? ?? ?? 48 8B C8 41 B8"); // Chapter 1 - Chapter 2 if (!Results.IsValid()) - return -1; + return 0; return Results.Get(); } diff --git a/Core/Versioning/VersionResolver.cpp b/Core/Versioning/VersionResolver.cpp index 493c7ea..eca6f49 100644 --- a/Core/Versioning/VersionResolver.cpp +++ b/Core/Versioning/VersionResolver.cpp @@ -9,6 +9,7 @@ #include "../Memory/Memory.h" #include "../Memory/PatternScanner.h" #include "../Logging/Log.h" +#include "../../Engine/CoreTypes/FString.h" #include namespace USS @@ -384,40 +385,31 @@ namespace USS // @timmie uintptr_t CLAddr = PatternScanner::Get()->FindGetEngineVersion(); - if (CLAddr != -1) + if (CLAddr == 0) { - //uintptr_t StringAddr = TAOF::ResolveRelativeAddress(CLAddr, 7, 3); - - // TODO: we need FString Implement class to do GetEngineVersion string - static FString(*GetEngineVersion)() = decltype(GetEngineVersion)(CLAddr); - - if (StringAddr) - { - char VersionStr[64] = {}; - for (int i = 0; i < 63; ++i) - { - char c = 0; - Memory::Read(StringAddr + i, c); - if (c == 0) - break; - VersionStr[i] = c; - } - - const char* CLStart = strstr(VersionStr, "-"); - if (CLStart) - { - uint32 CL = 0; - if (sscanf(CLStart + 1, "%u", &CL) == 1 && CL > 0) - { - USS_LOG("Found CL from version function: %u", CL); - return MapCLToVersion(CL); - } - } - } + USS_LOG("CL detection via pattern failed"); + return false; } - USS_LOG("CL detection via pattern failed"); - return false; + static FString(*GetEngineVersion)() = decltype(GetEngineVersion)(CLAddr); + + FString EngineVersion = GetEngineVersion(); + std::string EngineVer = EngineVersion.ToString(); + + size_t DashPos = EngineVer.find("-"); + size_t PlusPos = EngineVer.find("+++"); + + if (DashPos == std::string::npos || PlusPos == std::string::npos || PlusPos <= DashPos) + { + USS_LOG("Failed to parse CL from EngineVersion: %s", EngineVer.c_str()); + return false; + } + + std::string CLStr = EngineVer.substr(DashPos + 1, PlusPos - (DashPos + 1)); + uint32 CL = static_cast(std::strtoul(CLStr.c_str(), nullptr, 10)); + + USS_LOG("Found CL from version function: %u", CL); + return MapCLToVersion(CL); } bool FVersionResolver::TryDetectFromPatterns() diff --git a/Entry/DllMain.cpp b/Entry/DllMain.cpp index ec28a03..1e8ced7 100644 --- a/Entry/DllMain.cpp +++ b/Entry/DllMain.cpp @@ -217,11 +217,11 @@ namespace USS return 1; } - Result = FCrashHandler::Initialize(); + /*Result = FCrashHandler::Initialize(); if (Result != EResult::Success) { USS_WARN("Failed to initialize crash handler - crashes may not be logged"); - } + }*/ USS_LOG("========================================"); USS_LOG(" UniversalSlashingSimulator v0.1.0"); @@ -313,7 +313,7 @@ namespace USS GetEngineCore().Shutdown(); - FCrashHandler::Shutdown(); + //FCrashHandler::Shutdown(); Log::Shutdown(); diff --git a/UniversalSlashingSimulator.vcxproj b/UniversalSlashingSimulator.vcxproj index 6d470c5..4b92aa8 100644 --- a/UniversalSlashingSimulator.vcxproj +++ b/UniversalSlashingSimulator.vcxproj @@ -100,7 +100,7 @@ true true true - psapi.lib;%(AdditionalDependencies) + psapi.lib;libMinHook.x64.lib;%(AdditionalDependencies) $(ProjectDir)external\minhook\lib;%(AdditionalLibraryDirectories) UseLinkTimeCodeGeneration diff --git a/external/memcury/memcury.h b/external/memcury/memcury.h index 347fd7b..10c5bf8 100644 --- a/external/memcury/memcury.h +++ b/external/memcury/memcury.h @@ -211,12 +211,12 @@ namespace Memcury } } - auto message = std::format("Memcury caught an exception at [{:x}]\nPress Yes if you want the address to be copied to your clipboard", ExceptionInfo->ContextRecord->Rip); + /*auto message = std::format("Memcury caught an exception at [{:x}]\nPress Yes if you want the address to be copied to your clipboard", ExceptionInfo->ContextRecord->Rip); if (MessageBoxA(nullptr, message.c_str(), "Error", MB_ICONERROR | MB_YESNO) == IDYES) { std::string clip = std::format("{:x}", ExceptionInfo->ContextRecord->Rip); Util::CopyToClipboard(clip); - } + }*/ PrintStack(ExceptionInfo->ContextRecord);