diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 53b8de6d79..dd417d788e 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -2303,7 +2303,7 @@ void Replacement_Init() { } void Replacement_Shutdown() { - RestoreReplacedInstructions(0, 0xFFFFFFFF); + RemoveReplacements(0, 0xFFFFFFFF); replacementNameLookup.clear(); syphonFilterArrivals.clear(); syphonFilterFadeHolds.clear(); @@ -2353,7 +2353,7 @@ const ReplacementTableEntry *GetReplacementFunc(size_t i) { return &entries[i]; } -static bool WriteReplaceInstruction(u32 address, int index, u32 funcStart, u32 funcSize, u64 funcHash) { +static bool InstallReplacement(u32 address, int index, u32 funcStart, u32 funcSize, u64 funcHash) { if (!Memory::IsValid4AlignedAddress(address)) { return false; } @@ -2375,7 +2375,7 @@ static bool WriteReplaceInstruction(u32 address, int index, u32 funcStart, u32 f return true; } -void WriteReplaceInstructions(u32 address, u64 hash, int size) { +void InstallReplacements(u32 address, u64 hash, int size) { std::vector indexes = GetReplacementFuncIndexes(hash, size); const u64 funcHash = indexes.empty() ? 0 : HashReplacedFunc(address, size); for (int index : indexes) { @@ -2386,17 +2386,17 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) { for (u32 offset = 0; offset < (u32)size; offset += 4) { const u32 op = Memory::Read_Instruction(address + offset).encoding; if (op == MIPS_MAKE_JR_RA()) { - if (WriteReplaceInstruction(address + offset, index, address, size, funcHash)) { + if (InstallReplacement(address + offset, index, address, size, funcHash)) { didReplace = true; } } } } else if (entry->flags & REPFLAG_HOOK) { - if (WriteReplaceInstruction(address + entry->hookOffset, index, address, size, funcHash)) { + if (InstallReplacement(address + entry->hookOffset, index, address, size, funcHash)) { didReplace = true; } } else { - if (WriteReplaceInstruction(address, index, address, size, funcHash)) { + if (InstallReplacement(address, index, address, size, funcHash)) { didReplace = true; } } @@ -2407,7 +2407,7 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) { } } -void RestoreReplacedInstruction(u32 address) { +void RemoveReplacement(u32 address) { const u32 key = address & Memory::BLOCK_SHADOW_MASK; auto iter = installedReplacements.find(key); if (iter != installedReplacements.end()) { @@ -2450,7 +2450,7 @@ void Replacement_RepairStaleHookOps(const std::vector> &hook } } -void RestoreReplacedInstructions(u32 startAddr, u32 endAddr) { +void RemoveReplacements(u32 startAddr, u32 endAddr) { if (endAddr == startAddr) return; // Need to be in order, or we'll hang. @@ -2480,7 +2480,7 @@ void RestoreReplacedInstructions(u32 startAddr, u32 endAddr) { INFO_LOG(Log::HLE, "Restored %d replaced funcs between %08x-%08x", (int)restored.size(), startAddr, endAddr); } -void Replacement_CheckRange(u32 address, u32 length) { +void RemoveModifiedReplacementsInRange(u32 address, u32 length) { const u32 start = address & Memory::BLOCK_SHADOW_MASK; const u32 end = length >= Memory::BLOCK_SHADOW_MASK ? Memory::BLOCK_SHADOW_MASK : start + length; std::vector dropped; diff --git a/Core/HLE/ReplaceTables.h b/Core/HLE/ReplaceTables.h index 9c60a3a7c4..9afb2cbf37 100644 --- a/Core/HLE/ReplaceTables.h +++ b/Core/HLE/ReplaceTables.h @@ -79,9 +79,9 @@ const ReplacementTableEntry *GetReplacementFunc(size_t index); // entry: the JIT's block there, or the hook value if there's none. The CPU cores look up every // instruction with a nonzero entry when they run or compile it, and substitute the CallRepl // pseudo-op. -void WriteReplaceInstructions(u32 address, u64 hash, int size); -void RestoreReplacedInstruction(u32 address); -void RestoreReplacedInstructions(u32 startAddr, u32 endAddr); +void InstallReplacements(u32 address, u64 hash, int size); +void RemoveReplacement(u32 address); +void RemoveReplacements(u32 startAddr, u32 endAddr); // The address and original instruction of every installed hook. std::vector> Replacement_GetHookedOps(); // Some old savestates have hook ops in memory, which the CPU would now take as illegal and which @@ -89,7 +89,7 @@ std::vector> Replacement_GetHookedOps(); // session hooked at the same addresses (booting the game hooked the same module there). void Replacement_RepairStaleHookOps(const std::vector> &hookedOps); // Drops hooks in functions the game has changed. Called when the icache is invalidated over them. -void Replacement_CheckRange(u32 address, u32 length); +void RemoveModifiedReplacementsInRange(u32 address, u32 length); // The JIT's hook value, which its dispatcher sends to the compiler. Rewrites the hooks' entries. void Replacement_SetBlockShadowHook(u32 value); diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 05c319e1dc..781bc377da 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -552,7 +552,7 @@ void MIPSState::InvalidateICacheRangeImmediate(u32 address, u32 length) { me->InvalidateICacheRangeDeferred(address, length); } if (!IsMediaEngine()) { - Replacement_CheckRange(address, length); + RemoveModifiedReplacementsInRange(address, length); } if (!jit) { // Nothing to do. @@ -573,7 +573,7 @@ void MIPSState::ProcessPendingInvalidates() { pending.swap(pendingInvalidates_); for (const auto &p : pending) { if (!IsMediaEngine()) - Replacement_CheckRange(p.addr, p.size); + RemoveModifiedReplacementsInRange(p.addr, p.size); if (jit && !all) { jit->InvalidateCacheAt(p.addr, p.size); } diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index e4d75e0c3f..9304a931f7 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1309,7 +1309,7 @@ namespace MIPSAnalyst { functions.erase(prevMatch, functions.end()); } - RestoreReplacedInstructions(startAddr, endAddr); + RemoveReplacements(startAddr, endAddr); if (functions.empty()) { hashToFunction.clear(); @@ -1386,7 +1386,7 @@ namespace MIPSAnalyst { std::lock_guard guard(functions_lock); for (size_t i = 0; i < functions.size(); i++) { - WriteReplaceInstructions(functions[i].start, functions[i].hash, functions[i].size); + InstallReplacements(functions[i].start, functions[i].hash, functions[i].size); } } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 993ada0088..fb6bcbbacf 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -293,7 +293,7 @@ int g_screenshotFailures; if (p.mode == p.MODE_READ) { g_loadCount++; hookedOps = Replacement_GetHookedOps(); - RestoreReplacedInstructions(0, 0xFFFFFFFF); + RemoveReplacements(0, 0xFFFFFFFF); codeCompare.ranges = __KernelModuleCodeRanges(); } Memory::DoState(p, &codeCompare);