aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-01-02 01:20:02 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-01-02 01:20:02 +0000
commitf2e55278780b2c22067f69672ec5d9d23e40ca9d (patch)
tree7c727ece76fea93c5299d0d298afbc95d8049fd9 /NorthstarDedicatedTest
parentf341986b591cee533994597de418df1752ad5e97 (diff)
downloadNorthstarLauncher-f2e55278780b2c22067f69672ec5d9d23e40ca9d.tar.gz
NorthstarLauncher-f2e55278780b2c22067f69672ec5d9d23e40ca9d.zip
setup for rpak filesystem hooks
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj2
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters6
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp9
-rw-r--r--NorthstarDedicatedTest/masterserver.h2
-rw-r--r--NorthstarDedicatedTest/rpakfilesystem.cpp44
-rw-r--r--NorthstarDedicatedTest/rpakfilesystem.h4
6 files changed, 65 insertions, 2 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index 03481a2c..67e9126f 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -598,6 +598,7 @@
<ClInclude Include="pdef.h" />
<ClInclude Include="playlist.h" />
<ClInclude Include="miscserverscript.h" />
+ <ClInclude Include="rpakfilesystem.h" />
<ClInclude Include="scriptbrowserhooks.h" />
<ClInclude Include="scriptmainmenupromos.h" />
<ClInclude Include="securitypatches.h" />
@@ -640,6 +641,7 @@
</ClCompile>
<ClCompile Include="pdef.cpp" />
<ClCompile Include="playlist.cpp" />
+ <ClCompile Include="rpakfilesystem.cpp" />
<ClCompile Include="scriptbrowserhooks.cpp" />
<ClCompile Include="scriptmainmenupromos.cpp" />
<ClCompile Include="securitypatches.cpp" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index e4ddd92c..6e379a71 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -1422,6 +1422,9 @@
<ClInclude Include="include\libcurl\include\curl\urlapi.h">
<Filter>Header Files\include\libcurl</Filter>
</ClInclude>
+ <ClInclude Include="rpakfilesystem.h">
+ <Filter>Header Files\Shared</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -1532,6 +1535,9 @@
<ClCompile Include="miscserverfixes.cpp">
<Filter>Source Files\Server</Filter>
</ClCompile>
+ <ClCompile Include="rpakfilesystem.cpp">
+ <Filter>Source Files\Shared</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="include\spdlog\fmt\bundled\LICENSE.rst">
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index 78edb297..6acd4798 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -25,6 +25,7 @@
#include "scriptmainmenupromos.h"
#include "miscclientfixes.h"
#include "miscserverfixes.h"
+#include "rpakfilesystem.h"
#include "memalloc.h"
bool initialised = false;
@@ -66,6 +67,13 @@ void WaitForDebugger(HMODULE baseAddress)
// in the future this will be called from launcher instead of dllmain
void InitialiseNorthstar()
{
+ if (initialised)
+ {
+ spdlog::error("Called InitialiseNorthstar more than once!");
+ return;
+ }
+ initialised = true;
+
InitialiseLogging();
// apply initial hooks
@@ -116,6 +124,7 @@ void InitialiseNorthstar()
AddDllLoadCallback("engine.dll", InitialisePlaylistHooks);
AddDllLoadCallback("filesystem_stdio.dll", InitialiseFilesystem);
+ AddDllLoadCallback("engine.dll", InitialiseEngineRpakFilesystem);
AddDllLoadCallback("engine.dll", InitialiseKeyValues);
// mod manager after everything else
diff --git a/NorthstarDedicatedTest/masterserver.h b/NorthstarDedicatedTest/masterserver.h
index 1c57904b..b4d0d476 100644
--- a/NorthstarDedicatedTest/masterserver.h
+++ b/NorthstarDedicatedTest/masterserver.h
@@ -1,6 +1,5 @@
#pragma once
#include "convar.h"
-#include "httplib.h"
#include <WinSock2.h>
struct RemoteModInfo
@@ -67,7 +66,6 @@ class MasterServerManager
private:
bool m_requestingServerList = false;
bool m_authenticatingWithGameServer = false;
- httplib::Client* m_httpClient = nullptr;
public:
char m_ownServerId[33];
diff --git a/NorthstarDedicatedTest/rpakfilesystem.cpp b/NorthstarDedicatedTest/rpakfilesystem.cpp
new file mode 100644
index 00000000..006a57c5
--- /dev/null
+++ b/NorthstarDedicatedTest/rpakfilesystem.cpp
@@ -0,0 +1,44 @@
+#include "pch.h"
+#include "rpakfilesystem.h"
+#include "hookutils.h"
+#include "modmanager.h"
+
+typedef void*(*LoadCommonPaksForMapType)(char* map);
+LoadCommonPaksForMapType LoadCommonPaksForMap;
+
+typedef void*(*LoadPakSyncType)(char* path, void* unknownSingleton, int flags);
+typedef void*(*LoadPakAsyncType)(char* path, void* unknownSingleton, int flags, void* callback0, void* callback1);
+
+// there are more i'm just too lazy to add
+struct PakLoadFuncs
+{
+ void* unknown[2];
+ LoadPakSyncType func2;
+ LoadPakAsyncType LoadPakAsync;
+};
+
+PakLoadFuncs* g_pakLoadApi;
+void** pUnknownPakLoadSingleton;
+
+void LoadPakAsync(char* path)
+{
+ g_pakLoadApi->LoadPakAsync(path, *pUnknownPakLoadSingleton, 2, nullptr, nullptr);
+}
+
+void LoadCommonPaksForMapHook(char* map)
+{
+ LoadCommonPaksForMap(map);
+
+ // for sp => mp conversions, load the sp rpaks
+ if (!strcmp(map, "mp_skyway_v1") || !strcmp(map, "mp_crashsite") || !strcmp(map, "mp_hub_timeshift"))
+ map[0] = 's';
+}
+
+void InitialiseEngineRpakFilesystem(HMODULE baseAddress)
+{
+ g_pakLoadApi = (PakLoadFuncs*)((char*)baseAddress + 0x5BED78);
+ pUnknownPakLoadSingleton = (void**)((char*)baseAddress + 0x7C5E20);
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x15AD20, &LoadCommonPaksForMapHook, reinterpret_cast<LPVOID*>(&LoadCommonPaksForMap));
+} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/rpakfilesystem.h b/NorthstarDedicatedTest/rpakfilesystem.h
new file mode 100644
index 00000000..a9cc9a93
--- /dev/null
+++ b/NorthstarDedicatedTest/rpakfilesystem.h
@@ -0,0 +1,4 @@
+#pragma once
+
+void InitialiseEngineRpakFilesystem(HMODULE baseAddress);
+void LoadPakAsync(char* path); \ No newline at end of file