diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-10-25 00:45:40 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-10-25 00:45:40 +0100 |
commit | 7e1f1d8270dbdfbe2374e9da664cea2e00dfd465 (patch) | |
tree | 3d5fe484721c570d12bee33aa55b1b91f7b7df40 /NorthstarDedicatedTest | |
parent | 48acde84bd58c82eaa3a9838757dfcd05ab4ebf5 (diff) | |
download | NorthstarLauncher-7e1f1d8270dbdfbe2374e9da664cea2e00dfd465.tar.gz NorthstarLauncher-7e1f1d8270dbdfbe2374e9da664cea2e00dfd465.zip |
fixing some dedi crashes
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/dedicated.cpp | 19 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dedicatedmaterialsystem.cpp | 121 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dedicatedmaterialsystem.h | 3 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dllmain.cpp | 2 |
4 files changed, 141 insertions, 4 deletions
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp index 1468f9d1..b6db8583 100644 --- a/NorthstarDedicatedTest/dedicated.cpp +++ b/NorthstarDedicatedTest/dedicated.cpp @@ -281,7 +281,7 @@ void InitialiseDedicated(HMODULE engineAddress) // CEngineAPI::Init char* ptr = (char*)engineAddress + 0x1C60CE; TempReadWrite rw(ptr); - + // remove call to something or other that reads video settings *ptr = (char)0x90; *(ptr + 1) = (char)0x90; @@ -289,18 +289,31 @@ void InitialiseDedicated(HMODULE engineAddress) *(ptr + 3) = (char)0x90; *(ptr + 4) = (char)0x90; } - + { // some inputsystem bullshit char* ptr = (char*)engineAddress + 0x1CEE28; TempReadWrite rw(ptr); - + // nop an accessviolation: temp because we still create game window atm *ptr = (char)0x90; *(ptr + 1) = (char)0x90; *(ptr + 2) = (char)0x90; } + { + // no clue what this is + char* ptr = (char*)engineAddress + 0x1CD146; + TempReadWrite rw(ptr); + + // nop a crashing call + *ptr = (char)0x90; + *(ptr + 1) = (char)0x90; + *(ptr + 2) = (char)0x90; + *(ptr + 3) = (char)0x90; + *(ptr + 4) = (char)0x90; + } + //{ // // CEngineAPI::ModInit // char* ptr = (char*)engineAddress + 0x1C67D1; diff --git a/NorthstarDedicatedTest/dedicatedmaterialsystem.cpp b/NorthstarDedicatedTest/dedicatedmaterialsystem.cpp index 531885a7..67e5db94 100644 --- a/NorthstarDedicatedTest/dedicatedmaterialsystem.cpp +++ b/NorthstarDedicatedTest/dedicatedmaterialsystem.cpp @@ -51,6 +51,86 @@ void InitialiseDedicatedMaterialSystem(HMODULE baseAddress) if (DisableDedicatedWindowCreation()) { { + // materialsystem rpak type registrations + char* ptr = (char*)baseAddress + 0x22B5; + TempReadWrite rw(ptr); + + // nop a call that crashes, not needed on dedi + *ptr = 0x90; + *(ptr + 1) = (char)0x90; + *(ptr + 2) = (char)0x90; + *(ptr + 3) = (char)0x90; + *(ptr + 4) = (char)0x90; + } + + // these don't work, they cause game to hang on rpak init, needs reworking + { + // materialsystem rpak type: texture + char* ptr = (char*)baseAddress + 0x2B00; + TempReadWrite rw(ptr); + + // make it return 0 + // mov rax,0 + *ptr = 0x48; + *(ptr + 1) = (char)0xB8; + *(ptr + 2) = (char)0x00; + *(ptr + 3) = (char)0x00; + *(ptr + 4) = (char)0x00; + *(ptr + 5) = (char)0x00; + *(ptr + 6) = (char)0x00; + *(ptr + 7) = (char)0x00; + *(ptr + 8) = (char)0x00; + *(ptr + 9) = (char)0x00; + + // ret + *(ptr + 10) = (char)0xC3; + } + + { + // materialsystem rpak type: material + char* ptr = (char*)baseAddress + 0x50AA0; + TempReadWrite rw(ptr); + + // make it return 0 + // mov rax,0 + *ptr = 0x48; + *(ptr + 1) = (char)0xB8; + *(ptr + 2) = (char)0x00; + *(ptr + 3) = (char)0x00; + *(ptr + 4) = (char)0x00; + *(ptr + 5) = (char)0x00; + *(ptr + 6) = (char)0x00; + *(ptr + 7) = (char)0x00; + *(ptr + 8) = (char)0x00; + *(ptr + 9) = (char)0x00; + + // ret + *(ptr + 10) = (char)0xC3; + } + + { + // materialsystem rpak type: shader + char* ptr = (char*)baseAddress + 0x2850; + TempReadWrite rw(ptr); + + // make it return 0 + // mov rax,0 + *ptr = 0x48; + *(ptr + 1) = (char)0xB8; + *(ptr + 2) = (char)0x00; + *(ptr + 3) = (char)0x00; + *(ptr + 4) = (char)0x00; + *(ptr + 5) = (char)0x00; + *(ptr + 6) = (char)0x00; + *(ptr + 7) = (char)0x00; + *(ptr + 8) = (char)0x00; + *(ptr + 9) = (char)0x00; + + // ret + *(ptr + 10) = (char)0xC3; + } + + { // some renderthread stuff char* ptr = (char*)baseAddress + 0x8C10; TempReadWrite rw(ptr); @@ -60,4 +140,45 @@ void InitialiseDedicatedMaterialSystem(HMODULE baseAddress) *(ptr + 1) = (char)0x90; } } +} + +// rpak pain +struct RpakTypeDefinition +{ + int64_t magic; + char* longName; + + // more fields but they don't really matter for what we use them for +}; + +typedef void*(*RegisterRpakTypeType)(RpakTypeDefinition* rpakStruct, unsigned int a1, unsigned int a2); +RegisterRpakTypeType RegisterRpakType; + +typedef void(*RegisterMaterialSystemRpakTypes)(); + +void* RegisterRpakTypeHook(RpakTypeDefinition* rpakStruct, unsigned int a1, unsigned int a2) +{ + // make sure this prints right + char magicName[5]; + memcpy(magicName, &rpakStruct->magic, 4); + magicName[4] = 0; + + spdlog::info("rpak type {} {} registered {} {}", magicName, rpakStruct->longName, a1, a2); + + // reregister rpak types that aren't registered on a windowless dedi + if (IsDedicated() && DisableDedicatedWindowCreation() && rpakStruct->magic == 0x64636C72) // rlcd, this one is registered last + ((RegisterMaterialSystemRpakTypes)((char*)GetModuleHandleA("materialsystem_dx11.dll") + 0x22A0))(); // slightly hellish call + + return RegisterRpakType(rpakStruct, a1, a2); +} + +void InitialiseDedicatedRtechGame(HMODULE baseAddress) +{ + HookEnabler hook; + ENABLER_CREATEHOOK(hook, (char*)GetModuleHandleA("rtech_game.dll") + 0x7BE0, &RegisterRpakTypeHook, reinterpret_cast<LPVOID*>(&RegisterRpakType)); + + if (!IsDedicated()) + return; + + }
\ No newline at end of file diff --git a/NorthstarDedicatedTest/dedicatedmaterialsystem.h b/NorthstarDedicatedTest/dedicatedmaterialsystem.h index 284444e6..38343d17 100644 --- a/NorthstarDedicatedTest/dedicatedmaterialsystem.h +++ b/NorthstarDedicatedTest/dedicatedmaterialsystem.h @@ -1,2 +1,3 @@ #pragma once -void InitialiseDedicatedMaterialSystem(HMODULE baseAddress);
\ No newline at end of file +void InitialiseDedicatedMaterialSystem(HMODULE baseAddress); +void InitialiseDedicatedRtechGame(HMODULE baseAddress);
\ No newline at end of file diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp index bc1bfd77..2ecaf3db 100644 --- a/NorthstarDedicatedTest/dllmain.cpp +++ b/NorthstarDedicatedTest/dllmain.cpp @@ -74,6 +74,8 @@ void InitialiseNorthstar() AddDllLoadCallback("engine.dll", InitialiseDedicated); AddDllLoadCallback("launcher.dll", InitialiseDedicatedOrigin); AddDllLoadCallback("materialsystem_dx11.dll", InitialiseDedicatedMaterialSystem); + // this fucking sucks, but seemingly we somehow load after rtech_game???? unsure how, but because of this we have to apply patches here, not on rtech_game load + AddDllLoadCallback("engine.dll", InitialiseDedicatedRtechGame); } AddDllLoadCallback("engine.dll", InitialiseConVars); |