I'm currently trying to patch a sub routine like this one to pass it to my kernel plugin:
- Code: Select all
; ======================================================
; Subroutine sub_0041088C - Address 0x0041088C
sub_0041088C: ; Refs: 0x0040E6E0 0x00412868
0x0041088C: 0x27BDFF60 '`..'' - addiu $sp, $sp, -160
0x00410890: 0x8C860000 '....' - lw $a2, 0($a0)
What've done so far:
I've created my own stub and passing setting the 1st 2 instructions from the original function (as seen above). Than I do replace this 2 instructions with a syscall to my kernel mode function.
once my kernel mode function finished his stuff I do call the stub which will execute the 2 original instructions and than do a call to the position after the 2 original instruction..
The patching is done like this:
- Code: Select all
int interrupt = pspSdkDisableInterrupts();
//copy original to stub
patchStub[0] = originalFunc[0];
MAKE_JUMP((int)&patchStub[1], (int)(originalFunc)+8);
patchStub[2] = originalFunc[1];
//patching original
MAKE_SYSCALL((int)&originalFunc[0], sceKernelQuerySystemCall(patchFunc));
originalFunc[1] = 0x0; //nop
sceKernelDcacheWritebackInvalidateAll();
sceKernelIcacheInvalidateAll();
pspSdkEnableInterrupts(interrupt);
return patchStub;
My kernel mode function is well called - but only once and the PSP crashes once back in the original code. Does anyone has an idea what the issue might be ?
Thanks in advance for any hints...

