From 93fb8f7d84ee4e5e6b3799dce15d82203c3d09e1 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 29 Apr 2022 00:35:14 +0200 Subject: [PATCH] Implement generic SR patching and generic sCheckDataRange replacement --- source/function_replacements.cpp | 2 +- source/memory_mapping.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/function_replacements.cpp b/source/function_replacements.cpp index 128a2f0..fdb767f 100644 --- a/source/function_replacements.cpp +++ b/source/function_replacements.cpp @@ -11,7 +11,7 @@ DECL_FUNCTION(uint32_t, KiEffectiveToPhysical, uint32_t addressSpace, uint32_t v } DECL_FUNCTION(int32_t, sCheckDataRange, uint32_t address, uint32_t maxDataSize) { - if ((address & 0xF0000000) == 0x80000000) { + if ((address & 0xF0000000) == (MEMORY_START_BASE & 0xF0000000)) { return 1; } diff --git a/source/memory_mapping.cpp b/source/memory_mapping.cpp index f7f3201..cae6572 100644 --- a/source/memory_mapping.cpp +++ b/source/memory_mapping.cpp @@ -26,10 +26,15 @@ void runOnAllCores(CThread::Callback callback, void *callbackArg, int32_t iAttr void writeKernelNOPs(CThread *thread, void *arg) { DEBUG_FUNCTION_LINE_VERBOSE("Writing kernel NOPs on core %d", OSGetThreadAffinity(OSGetCurrentThread()) / 2); - // Patch out any writes to SR8 - KernelNOPAtPhysicalAddress(0xFFF1D754); - KernelNOPAtPhysicalAddress(0xFFF1D64C); - KernelNOPAtPhysicalAddress(0xFFE00638); + // Patch out any writes to SR + int sr = MEMORY_START_BASE >> 28; + KernelNOPAtPhysicalAddress(0xfff1d734 + 0x4 * sr); + if (sr < 7) { + KernelNOPAtPhysicalAddress(0xfff1d604 + 0x4 * sr); + } else { + KernelNOPAtPhysicalAddress(0xfff1d648 + 0x4 * (sr - 7)); + } + KernelNOPAtPhysicalAddress(0xffe00618 + 0x4 * sr); // nop out branches to app panic 0x17 KernelNOPAtPhysicalAddress(0xfff01db0);