From 935b325a75ed5591162d46afb9c80dde17e99d81 Mon Sep 17 00:00:00 2001 From: F1F7Y Date: Thu, 27 Jul 2023 23:50:31 +0200 Subject: [PATCH 1/2] Fix Null Deref crash --- NorthstarDLL/core/filesystem/rpakfilesystem.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp index 8d50b07a6..d766898e2 100644 --- a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp +++ b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp @@ -255,11 +255,21 @@ void*, __fastcall, (int nPakHandle, void* pCallback)) // we hook this exclusively for resolving stbsp paths, but seemingly it's also used for other stuff like vpk, rpak, mprj and starpak loads // tbh this actually might be for memory mapped files or something, would make sense i think +// rtech_game.dll + 0x1e20 // clang-format off HOOK(ReadFileAsyncHook, ReadFileAsync, void*, __fastcall, (const char* pPath, void* pCallback)) // clang-format on { + // NOTE [Fifty]: For some reason some users are getting pPath as null when + // loading a server, ReadFileAsync uses CreateFileA and checks + // its return value so this is completely safe + if (pPath == NULL || pCallback == NULL) + { + NS::log::rpak->warn("ReadFileAsync: pPath or pCallback were NULL, returning!"); + return ReadFileAsync(pPath, pCallback); + } + fs::path path(pPath); std::string newPath = ""; fs::path filename = path.filename(); From c70e387b198ecda9c93905e6fbd3afb70ac24ef7 Mon Sep 17 00:00:00 2001 From: F1F7Y <64418963+F1F7Y@users.noreply.github.com> Date: Sun, 30 Jul 2023 10:57:24 +0200 Subject: [PATCH 2/2] Remove print --- NorthstarDLL/core/filesystem/rpakfilesystem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp index d766898e2..24c440c7b 100644 --- a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp +++ b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp @@ -264,9 +264,8 @@ void*, __fastcall, (const char* pPath, void* pCallback)) // NOTE [Fifty]: For some reason some users are getting pPath as null when // loading a server, ReadFileAsync uses CreateFileA and checks // its return value so this is completely safe - if (pPath == NULL || pCallback == NULL) + if (pPath == NULL) { - NS::log::rpak->warn("ReadFileAsync: pPath or pCallback were NULL, returning!"); return ReadFileAsync(pPath, pCallback); }