From 9a9ece838de10ea573f424461fb75e02a02ebdda Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 26 Mar 2023 11:48:24 +0200 Subject: [PATCH] Preserve r2/r13 on kern_write --- source/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/main.cpp b/source/main.cpp index 0ddf758..e7d8abf 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -142,6 +142,9 @@ void KernelReadSRs(sr_table_t *table) { /* Write a 32-bit word with kernel permissions */ void __attribute__((noinline)) kern_write(void *addr, uint32_t value) { asm volatile( + "stwu 1, -0x10(1)\n" + "stw 2, 0x08(1)\n" + "stw 13, 0x0C(1)\n" "li 3,1\n" "li 4,0\n" "mr 5,%1\n" @@ -154,6 +157,9 @@ void __attribute__((noinline)) kern_write(void *addr, uint32_t value) { "sc\n" "nop\n" "mr 1,%1\n" + "lwz 2, 0x8(1)\n" + "lwz 13, 0xC(1)\n" + "addi 1, 1, 0x10\n" : : "r"(addr), "r"(value) : "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",