Skip to content

Commit 80e9b82

Browse files
committed
Switch to dynamic offsets for SDK.
1 parent c37e059 commit 80e9b82

File tree

3 files changed

+83
-43
lines changed

3 files changed

+83
-43
lines changed

src/SDK/Basic.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ using namespace UC;
3131
*/
3232
namespace Offsets
3333
{
34-
constexpr int32 GObjects = 0x043F9320;
35-
constexpr int32 AppendString = 0x00EBA200;
36-
constexpr int32 GNames = 0x043BCFC0;
37-
constexpr int32 GWorld = 0x0453D030;
38-
constexpr int32 ProcessEvent = 0x010B2340;
39-
constexpr int32 ProcessEventIdx = 0x00000044;
34+
inline int32 GObjects = 0x0; // 0x043F9320;
35+
inline int32 AppendString = 0x0; // 0x00EBA200;
36+
inline int32 GNames = 0x0; // 0x043BCFC0;
37+
inline int32 GWorld = 0x0; // 0x0453D030;
38+
inline int32 ProcessEvent = 0x0; // 0x010B2340;
39+
inline int32 ProcessEventIdx = 0x00000044;
4040
}
4141

4242
namespace InSDKUtils

src/SDK/Engine_functions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -77714,7 +77714,7 @@ void UKismetGuidLibrary::Parse_StringToGuid(const class FString& GuidString, str
7771477714

7771577715
class UWorld* UWorld::GetWorld()
7771677716
{
77717-
if constexpr (Offsets::GWorld != 0)
77717+
if (Offsets::GWorld != 0)
7771877718
return *reinterpret_cast<UWorld**>(InSDKUtils::GetImageBase() + Offsets::GWorld);
7771977719

7772077720
if (UEngine* Engine = UEngine::GetEngine())

src/dllmain.cpp

+76-36
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ HMODULE baseModule = GetModuleHandle(NULL);
2525

2626
// Version
2727
std::string sFixName = "SMTVFix";
28-
std::string sFixVer = "0.9.4";
28+
std::string sFixVer = "0.9.5";
2929
std::string sLogFile = sFixName + ".log";
3030

3131
// Logger
@@ -336,6 +336,43 @@ void ReadConfig()
336336
CalculateAspectRatio();
337337
}
338338

339+
void UpdateOffsets()
340+
{
341+
// GObjects
342+
uint8_t* GObjectsScanResult = Memory::PatternScan(baseModule, "48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33 ?? 8B ?? ?? C1 ??");
343+
if (GObjectsScanResult) {
344+
spdlog::info("Offsets: GObjects: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)GObjectsScanResult - (uintptr_t)baseModule);
345+
uintptr_t GObjectsAddr = Memory::GetAbsolute((uintptr_t)GObjectsScanResult + 0x3);
346+
SDK::Offsets::GObjects = (uintptr_t)GObjectsAddr - (uintptr_t)baseModule;
347+
spdlog::info("Offsets: GObjects: Offset: {:x}", SDK::Offsets::GObjects);
348+
}
349+
else if (!GObjectsScanResult) {
350+
spdlog::error("Offsets: GObjects: Pattern scan failed.");
351+
}
352+
353+
// AppendString
354+
uint8_t* AppendStringScanResult = Memory::PatternScan(baseModule, "48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 8B ?? 48 8B ?? 8B ?? 44 0F ?? ?? C1 ?? 10 48 8B ?? 80 3D ?? ?? ?? ?? 00 89 ?? ?? ?? 44 89 ?? ?? ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C ?? ?? C6 ?? ?? ?? ?? ?? 01 48 8B ?? ?? ?? 48 8B ?? 48 ?? ?? ?? 8D ?? ?? 49 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 ?? ?? 00");
355+
if (AppendStringScanResult) {
356+
spdlog::info("Offsets: AppendString: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)AppendStringScanResult - (uintptr_t)baseModule);
357+
SDK::Offsets::AppendString = (uintptr_t)AppendStringScanResult - (uintptr_t)baseModule;
358+
spdlog::info("Offsets: AppendString: Offset: {:x}", SDK::Offsets::AppendString);
359+
}
360+
else if (!AppendStringScanResult) {
361+
spdlog::error("Offsets: AppendString: Pattern scan failed.");
362+
}
363+
364+
// ProcessEvent
365+
uint8_t* ProcessEventScanResult = Memory::PatternScan(baseModule, "40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 33 ?? 48 89 ?? ?? ?? ?? ?? 8B ?? ?? 45 33 ??");
366+
if (ProcessEventScanResult) {
367+
spdlog::info("Offsets: ProcessEvent: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)ProcessEventScanResult - (uintptr_t)baseModule);
368+
SDK::Offsets::ProcessEvent = (uintptr_t)ProcessEventScanResult - (uintptr_t)baseModule;
369+
spdlog::info("Offsets: ProcessEvent: Offset: {:x}", SDK::Offsets::ProcessEvent);
370+
}
371+
else if (!ProcessEventScanResult) {
372+
spdlog::error("Offsets: ProcessEvent: Pattern scan failed.");
373+
}
374+
}
375+
339376
void GetCVARs()
340377
{
341378
// Get console objects
@@ -1012,53 +1049,55 @@ void EnableConsole()
10121049
{
10131050
if (bEnableConsole)
10141051
{
1015-
// Get GEngine
1016-
SDK::UEngine* engine = nullptr;
1052+
if (SDK::Offsets::GObjects && SDK::Offsets::AppendString) {
1053+
// Get GEngine
1054+
SDK::UEngine* engine = nullptr;
10171055

1018-
int i = 0;
1019-
while (i < 100) { // 10s
1020-
engine = SDK::UEngine::GetEngine();
1056+
int i = 0;
1057+
while (i < 100) { // 10s
1058+
engine = SDK::UEngine::GetEngine();
10211059

1022-
if (engine) {
1023-
if (engine->ConsoleClass && engine->GameViewport) {
1024-
break;
1060+
if (engine) {
1061+
if (engine->ConsoleClass && engine->GameViewport) {
1062+
break;
1063+
}
10251064
}
1026-
}
10271065

1028-
std::this_thread::sleep_for(std::chrono::milliseconds(100));
1029-
i++;
1030-
}
1066+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
1067+
i++;
1068+
}
10311069

1032-
if (i == 100) {
1033-
spdlog::error("Construct Console: Failed to find GEngine address after 10 seconds.");
1034-
return;
1035-
}
1070+
if (i == 100) {
1071+
spdlog::error("Construct Console: Failed to find GEngine address after 10 seconds.");
1072+
return;
1073+
}
10361074

1037-
spdlog::info("Construct Console: GEngine address = {:x}", (uintptr_t)engine);
1075+
spdlog::info("Construct Console: GEngine address = {:x}", (uintptr_t)engine);
10381076

1039-
// Construct console
1040-
if (engine->ConsoleClass && engine->GameViewport) {
1041-
SDK::UObject* NewObject = SDK::UGameplayStatics::SpawnObject(engine->ConsoleClass, engine->GameViewport);
1042-
if (NewObject) {
1043-
engine->GameViewport->ViewportConsole = static_cast<SDK::UConsole*>(NewObject);
1044-
spdlog::info("Construct Console: Console object constructed.");
1077+
// Construct console
1078+
if (engine->ConsoleClass && engine->GameViewport) {
1079+
SDK::UObject* NewObject = SDK::UGameplayStatics::SpawnObject(engine->ConsoleClass, engine->GameViewport);
1080+
if (NewObject) {
1081+
engine->GameViewport->ViewportConsole = static_cast<SDK::UConsole*>(NewObject);
1082+
spdlog::info("Construct Console: Console object constructed.");
1083+
}
1084+
else {
1085+
spdlog::error("Construct Console: Failed to construct console object.");
1086+
return;
1087+
}
10451088
}
10461089
else {
1047-
spdlog::error("Construct Console: Failed to construct console object.");
1090+
spdlog::error("Construct Console: Failed to construct console object - ConsoleClass or GameViewport is null.");
10481091
return;
10491092
}
1050-
}
1051-
else {
1052-
spdlog::error("Construct Console: Failed to construct console object - ConsoleClass or GameViewport is null.");
1053-
return;
1054-
}
10551093

1056-
// Log console key
1057-
if (SDK::UInputSettings::GetInputSettings()->ConsoleKeys && SDK::UInputSettings::GetInputSettings()->ConsoleKeys.Num() > 0) {
1058-
spdlog::info("Construct Console: Console enabled - access it using key: {}.", SDK::UInputSettings::GetInputSettings()->ConsoleKeys[0].KeyName.ToString());
1059-
}
1060-
else {
1061-
spdlog::error("Console enabled but no console key is bound.\nAdd this to %LOCALAPPDATA%\\SMT5V\\Saved\\Config\\WindowsNoEditor\\Input.ini -\n[/Script/Engine.InputSettings]\nConsoleKeys = Tilde");
1094+
// Log console key
1095+
if (SDK::UInputSettings::GetInputSettings()->ConsoleKeys && SDK::UInputSettings::GetInputSettings()->ConsoleKeys.Num() > 0) {
1096+
spdlog::info("Construct Console: Console enabled - access it using key: {}.", SDK::UInputSettings::GetInputSettings()->ConsoleKeys[0].KeyName.ToString());
1097+
}
1098+
else {
1099+
spdlog::error("Console enabled but no console key is bound.\nAdd this to %LOCALAPPDATA%\\SMT5V\\Saved\\Config\\WindowsNoEditor\\Input.ini -\n[/Script/Engine.InputSettings]\nConsoleKeys = Tilde");
1100+
}
10621101
}
10631102
}
10641103
}
@@ -1186,6 +1225,7 @@ DWORD __stdcall Main(void*)
11861225
{
11871226
Logging();
11881227
ReadConfig();
1228+
UpdateOffsets();
11891229
CurrentResolution();
11901230
GetCVARs();
11911231
IntroSkip();

0 commit comments

Comments
 (0)