Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in ReadFileAsync #521

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
9 changes: 9 additions & 0 deletions primedev/core/filesystem/rpakfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,20 @@ 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)
{
return ReadFileAsync(pPath, pCallback);
}

fs::path path(pPath);
std::string newPath = "";
fs::path filename = path.filename();
Expand Down