aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/rpakfilesystem.cpp
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/rpakfilesystem.cpp
parentf341986b591cee533994597de418df1752ad5e97 (diff)
downloadNorthstarLauncher-f2e55278780b2c22067f69672ec5d9d23e40ca9d.tar.gz
NorthstarLauncher-f2e55278780b2c22067f69672ec5d9d23e40ca9d.zip
setup for rpak filesystem hooks
Diffstat (limited to 'NorthstarDedicatedTest/rpakfilesystem.cpp')
-rw-r--r--NorthstarDedicatedTest/rpakfilesystem.cpp44
1 files changed, 44 insertions, 0 deletions
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