diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 6af14c266c..15eeec6a21 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -503,6 +503,9 @@ void __KernelModuleDoState(PointerWrap &p) { } } } + // 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(); if (g_Config.bFuncReplacements) { MIPSAnalyst::ReplaceFunctions(); } diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 4a6b05628f..c3d55859f9 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1279,6 +1279,12 @@ skip: return false; } + void RehashFunctions() { + std::lock_guard guard(functions_lock); + HashFunctions(); + UpdateHashToFunctionMap(); + } + void ReplaceFunctions() { std::lock_guard guard(functions_lock); diff --git a/Core/MIPS/MIPSAnalyst.h b/Core/MIPS/MIPSAnalyst.h index 4baebf39e8..1c1a679a78 100644 --- a/Core/MIPS/MIPSAnalyst.h +++ b/Core/MIPS/MIPSAnalyst.h @@ -115,6 +115,8 @@ namespace MIPSAnalyst { void StoreHashMap(Path filename = Path()); const char *LookupHash(u64 hash, u32 funcSize); + // Hashes the known functions again, from what memory holds now (after a savestate load.) + void RehashFunctions(); void ReplaceFunctions(); void UpdateHashMap();