sceMp4: don't reload the modules, read the effective flags, check four bytes

Three from a read-through of the sceMp4 firmware-module path:

Clearing the module UIDs when the game says it's done with the MP4 module
didn't unload anything - it only meant the next load brought in a second copy
of libmp4.prx and mp4msv.prx, some 220KB at the top of user memory each time.
Keep them for the boot instead; __UtilityInit clears them per game, which is
the point at which they really are gone.

The flag test read g_Config directly, so it ignored the very fallback
CheckDisableHLEAvailability computes when the dump is missing - it would go and
try to load modules that aren't there while import resolution had correctly
stayed on HLE. It also ignored a boundary restored from a savestate.

sceKernelGetModuleGPByAddress checked one byte of the pointer it writes four to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik Rydgård
2026-09-09 16:59:21 -06:00
committed by Henrik Rydgård
co-authored by Claude Opus 5
parent e5b98b07e8
commit 95d03449b3
2 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -2773,7 +2773,9 @@ struct GetModuleIdByAddressArg
// needs the callee's gp in place. libmp4.prx uses it on the three callbacks it is given.
// Named after what it does; the official name isn't known.
static u32 sceKernelGetModuleGPByAddress(u32 addr, u32 gpPtr) {
if (!Memory::IsValidAddress(gpPtr)) {
// Four bytes get written, so check for four - IsValidAddress would pass on the last three
// bytes of a region.
if (!Memory::IsValidRange(gpPtr, 4)) {
return hleLogError(Log::sceModule, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "bad gp pointer");
}