Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions code/components/gta-core-rdr3/src/GameInitRage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,20 @@ static void LogStubLog1(void* stub, const char* type, const char* format, ...)

trace("%s: %s\n", type, buffer);
}
}

static bool (*g_fiAssetManagerExists)(void*, const char*, const char*);
static bool fiAssetManagerExists(void* self, const char* name, const char* extension)
{
if ((extension && strcmp(extension, "meta") == 0) && strcmp(name, "platformcrc:/data/startup") == 0)
{
return false;
}

return g_fiAssetManagerExists(self, name, extension);
}

static void* (*g_loadStartupFile)(void*, const char*, uint8_t, void*);
static void* LoadStartupFile(void* self, const char* filePath, uint8_t a3, void* a4)
{
// Hasn't changed between gamebuilds.
static const size_t kMetaOffset = 0xE1;
assert(*(uint8_t*)((uintptr_t)g_loadStartupFile + kMetaOffset) == 0x74);

// Skip loading .meta for startup even if the file exists.
hook::put<uint8_t>((uintptr_t)g_loadStartupFile + kMetaOffset, 0xEB);
void* retnResult = g_loadStartupFile(self, filePath, a3, a4);
hook::put<uint8_t>((uintptr_t)g_loadStartupFile + kMetaOffset, 0x74);
return retnResult;
}

static HookFunction hookFunctionNet([]()
Expand Down Expand Up @@ -296,9 +299,11 @@ static HookFunction hookFunctionNet([]()

// allow the game to ensure static bounds, but don't block on it.
hook::nop(hook::get_pattern("E8 ? ? ? ? 66 44 39 65 ? 74 ? 48 8B 4D ? E8 ? ? ? ? 4C 8D 5C 24 ? 49 8B 5B ? 49 8B 73 ? 49 8B 7B ? 4D 8B 63"), 5);

// Block loading of custom startup.meta file. Completely breaks game loading
MH_Initialize();
MH_CreateHook(hook::get_call(hook::get_pattern("E8 ? ? ? ? 3C ? 75 ? 48 8B 0D")), fiAssetManagerExists, (void**)&g_fiAssetManagerExists);
MH_EnableHook(MH_ALL_HOOKS);

// Don't allow the game to load a startup.meta file if present. This breaks game loading entirely.
{
auto location = hook::get_pattern("E8 ? ? ? ? 40 8A CE E8 ? ? ? ? E8");
hook::set_call(&g_loadStartupFile, location);
hook::call(location, LoadStartupFile);
}
});
Loading