aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/dedicatedmaterialsystem.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-25 00:45:40 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-25 00:45:40 +0100
commit7e1f1d8270dbdfbe2374e9da664cea2e00dfd465 (patch)
tree3d5fe484721c570d12bee33aa55b1b91f7b7df40 /NorthstarDedicatedTest/dedicatedmaterialsystem.cpp
parent48acde84bd58c82eaa3a9838757dfcd05ab4ebf5 (diff)
downloadNorthstarLauncher-7e1f1d8270dbdfbe2374e9da664cea2e00dfd465.tar.gz
NorthstarLauncher-7e1f1d8270dbdfbe2374e9da664cea2e00dfd465.zip
fixing some dedi crashes
Diffstat (limited to 'NorthstarDedicatedTest/dedicatedmaterialsystem.cpp')
-rw-r--r--NorthstarDedicatedTest/dedicatedmaterialsystem.cpp121
1 files changed, 121 insertions, 0 deletions
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