Scan modules that only exist in a savestate for functions

A module the game loaded before the state was saved, but that this run never loaded, was never
scanned, so loading such a state left all of its code without function replacements and hooks
(and without functions in the debugger). Scan any loaded module with no analyzed functions in its
text range before rehashing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-15 11:22:06 +02:00
1 parent 3e41ecba63
commit a738fe9b86
3 files changed
+25

No files matched your search

+13
View File
@@ -587,6 +587,19 @@ void __KernelModuleDoState(PointerWrap &p) {
}
}
}
// A module that was only loaded in the state was never scanned, so nothing in it could be
// replaced or hooked (or show up as functions in the debugger.)
for (SceUID moduleId : loadedModules) {
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
if (!module || module->isFake || module->textEnd <= module->textStart) {
continue;
}
// textEnd is inclusive.
if (Memory::IsValid4AlignedRange(module->textStart, module->textEnd + 4 - module->textStart) &&
!MIPSAnalyst::HasFunctionsInRange(module->textStart, module->textEnd + 4)) {
MIPSAnalyst::ScanForFunctions(module->textStart, module->textEnd, true);
}
}
// The functions were found in memory from before the load, where other code may have been
// (an overlay module, say.) Hash them from what's there now, so a hook only goes where it matches.
MIPSAnalyst::RehashFunctions();