From f2e55278780b2c22067f69672ec5d9d23e40ca9d Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sun, 2 Jan 2022 01:20:02 +0000 Subject: setup for rpak filesystem hooks --- NorthstarDedicatedTest/rpakfilesystem.cpp | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 NorthstarDedicatedTest/rpakfilesystem.cpp (limited to 'NorthstarDedicatedTest/rpakfilesystem.cpp') 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(&LoadCommonPaksForMap)); +} \ No newline at end of file -- cgit v1.2.3