diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-18 17:00:31 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-18 17:00:31 +0000 |
commit | 682a00eaac30139929b1bb179ae7f4aa1a038572 (patch) | |
tree | 7297415c1af1d125758efc9fbe1cd792192ffe8b /NorthstarDedicatedTest | |
parent | b0232efab1845cd47c639ad3cbc4e6d6db42c81e (diff) | |
download | NorthstarLauncher-682a00eaac30139929b1bb179ae7f4aa1a038572.tar.gz NorthstarLauncher-682a00eaac30139929b1bb179ae7f4aa1a038572.zip |
attempting to fix a client crash
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dllmain.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/miscclientfixes.cpp | 40 | ||||
-rw-r--r-- | NorthstarDedicatedTest/miscclientfixes.h | 2 |
5 files changed, 52 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index 2e7053ea..be96b515 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -317,6 +317,7 @@ <ClInclude Include="main.h" /> <ClInclude Include="masterserver.h" /> <ClInclude Include="memalloc.h" /> + <ClInclude Include="miscclientfixes.h" /> <ClInclude Include="misccommands.h" /> <ClInclude Include="modlocalisation.h" /> <ClInclude Include="modmanager.h" /> @@ -351,6 +352,7 @@ <ClCompile Include="hookutils.cpp" /> <ClCompile Include="keyvalues.cpp" /> <ClCompile Include="memalloc.cpp" /> + <ClCompile Include="miscclientfixes.cpp" /> <ClCompile Include="misccommands.cpp" /> <ClCompile Include="modlocalisation.cpp" /> <ClCompile Include="logging.cpp" /> diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters index f1856a7c..76a7f754 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters @@ -591,6 +591,9 @@ <ClInclude Include="scriptmainmenupromos.h"> <Filter>Header Files\Client</Filter> </ClInclude> + <ClInclude Include="miscclientfixes.h"> + <Filter>Header Files\Client</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="dllmain.cpp"> @@ -695,6 +698,9 @@ <ClCompile Include="scriptmainmenupromos.cpp"> <Filter>Source Files\Client</Filter> </ClCompile> + <ClCompile Include="miscclientfixes.cpp"> + <Filter>Source Files\Client</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <None Include="include\spdlog\fmt\bundled\LICENSE.rst"> diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp index f0265f67..212b5711 100644 --- a/NorthstarDedicatedTest/dllmain.cpp +++ b/NorthstarDedicatedTest/dllmain.cpp @@ -23,6 +23,7 @@ #include "clientauthhooks.h" #include "scriptbrowserhooks.h" #include "scriptmainmenupromos.h" +#include "miscclientfixes.h" #include "memalloc.h" bool initialised = false; @@ -102,6 +103,7 @@ void InitialiseNorthstar() AddDllLoadCallback("engine.dll", InitialiseClientAuthHooks); AddDllLoadCallback("engine.dll", InitialiseScriptExternalBrowserHooks); AddDllLoadCallback("client.dll", InitialiseScriptMainMenuPromos); + AddDllLoadCallback("client.dll", InitialiseMiscClientFixes); } AddDllLoadCallback("server.dll", InitialiseServerSquirrel); diff --git a/NorthstarDedicatedTest/miscclientfixes.cpp b/NorthstarDedicatedTest/miscclientfixes.cpp new file mode 100644 index 00000000..d9fab647 --- /dev/null +++ b/NorthstarDedicatedTest/miscclientfixes.cpp @@ -0,0 +1,40 @@ +#include "pch.h" +#include "miscclientfixes.h" +#include "hookutils.h" +#include "dedicated.h" + +typedef void*(*CrashingWeaponActivityFuncType)(void* a1); +CrashingWeaponActivityFuncType CrashingWeaponActivityFunc0; +CrashingWeaponActivityFuncType CrashingWeaponActivityFunc1; + +void* CrashingWeaponActivityFunc0Hook(void* a1) +{ + // this return is safe, other functions that use this value seemingly dont care about it being null + if (!a1) + return 0; + + return CrashingWeaponActivityFunc0(a1); +} + +void* CrashingWeaponActivityFunc1Hook(void* a1) +{ + // this return is safe, other functions that use this value seemingly dont care about it being null + if (!a1) + return 0; + + return CrashingWeaponActivityFunc1(a1); +} + +void InitialiseMiscClientFixes(HMODULE baseAddress) +{ + if (IsDedicated()) + return; + + HookEnabler hook; + + // these functions will occasionally pass a null pointer on respawn, unsure what causes this but seems easiest just to return null if null, which seems to work fine + // fucking sucks this has to be fixed like this but unsure what exactly causes this serverside, breaks vanilla compatibility to a degree tho + // will say i have about 0 clue what exactly these functions do, testing this it doesn't even seem like they do much of anything i can see tbh + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x5A92D0, &CrashingWeaponActivityFunc0Hook, reinterpret_cast<LPVOID*>(&CrashingWeaponActivityFunc0)); + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x5A9310, &CrashingWeaponActivityFunc1Hook, reinterpret_cast<LPVOID*>(&CrashingWeaponActivityFunc1)); +}
\ No newline at end of file diff --git a/NorthstarDedicatedTest/miscclientfixes.h b/NorthstarDedicatedTest/miscclientfixes.h new file mode 100644 index 00000000..1f0ad807 --- /dev/null +++ b/NorthstarDedicatedTest/miscclientfixes.h @@ -0,0 +1,2 @@ +#pragma once +void InitialiseMiscClientFixes(HMODULE baseAddress);
\ No newline at end of file |