From 901d4992c0d702ae451fd12785563da448ed3d83 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Fri, 9 Jun 2017 18:10:02 +0200 Subject: [PATCH] Attempt fixing svcConnectToPortInitHook.s again --- patches/svcConnectToPortInitHook.s | 9 ++++++++- source/patches.c | 3 ++- .../rosalina/kernel_extension/source/svc/ConnectToPort.c | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/patches/svcConnectToPortInitHook.s b/patches/svcConnectToPortInitHook.s index 258794c..03a02b0 100644 --- a/patches/svcConnectToPortInitHook.s +++ b/patches/svcConnectToPortInitHook.s @@ -6,6 +6,7 @@ vars: orig: .word 0 SleepThread: .word 0 + UnmapProcessMemory: .word 0 skip_vars: push {r0-r4, lr} ldr r4, =0x1ff81108 @@ -16,12 +17,18 @@ skip_vars: bne loop_end ldr r12, [SleepThread] - ldr r0, =(10 * 1000 * 1000) + ldr r0, =(50 * 1000 * 1000) mov r1, #0 blx r12 b loop loop_end: + ; Attempt flushing caches + mov r0, #0 + mov r1, #0 + mov r2, #0 + ldr r12, [UnmapProcessMemory] + blx r12 pop {r0-r4, lr} mov r12, #0x40000000 add r12, #4 diff --git a/source/patches.c b/source/patches.c index 4abca77..21524a6 100644 --- a/source/patches.c +++ b/source/patches.c @@ -181,7 +181,7 @@ void installK11MainHook(u8 *pos, u32 size, bool isSafeMode, u32 baseK11VA, u32 * void installSvcConnectToPortInitHook(u32 *arm11SvcTable, u32 *arm11ExceptionsPage, u8 **freeK11Space) { u32 addr = 0xFFFF0000 + (u32)*freeK11Space - (u32)arm11ExceptionsPage; - u32 svcSleepThreadAddr = arm11SvcTable[0x0A], svcConnectToPortAddr = arm11SvcTable[0x2D]; + u32 svcSleepThreadAddr = arm11SvcTable[0x0A], svcConnectToPortAddr = arm11SvcTable[0x2D], svcUnmapProcessMemoryAddr = arm11SvcTable[0x72]; arm11SvcTable[0x2D] = addr; memcpy(*freeK11Space, svcConnectToPortInitHook_bin, svcConnectToPortInitHook_bin_size); @@ -189,6 +189,7 @@ void installSvcConnectToPortInitHook(u32 *arm11SvcTable, u32 *arm11ExceptionsPag u32 *off = (u32 *)(*freeK11Space); off[1] = svcConnectToPortAddr; off[2] = svcSleepThreadAddr; + off[3] = svcUnmapProcessMemoryAddr; (*freeK11Space) += svcConnectToPortInitHook_bin_size; } diff --git a/sysmodules/rosalina/kernel_extension/source/svc/ConnectToPort.c b/sysmodules/rosalina/kernel_extension/source/svc/ConnectToPort.c index 9575cf6..21de9e5 100644 --- a/sysmodules/rosalina/kernel_extension/source/svc/ConnectToPort.c +++ b/sysmodules/rosalina/kernel_extension/source/svc/ConnectToPort.c @@ -32,6 +32,7 @@ Result ConnectToPortHook(Handle *out, const char *name) { char portName[12] = {0}; Result res = 0; + if(name != NULL) { s32 nb = usrToKernelStrncpy(portName, name, 12);