From f9987bb3109647ce30bfdf591cdd9152a4ebfd46 Mon Sep 17 00:00:00 2001 From: Sergey Lisov Date: Thu, 24 Aug 2023 19:40:43 +0300 Subject: [PATCH] ps5-kstuff: add missing files --- ps5-kstuff/uelf/syscall_fixes.c | 27 +++++++++++++++++++++++++++ ps5-kstuff/uelf/syscall_fixes.h | 7 +++++++ 2 files changed, 34 insertions(+) create mode 100644 ps5-kstuff/uelf/syscall_fixes.c create mode 100644 ps5-kstuff/uelf/syscall_fixes.h diff --git a/ps5-kstuff/uelf/syscall_fixes.c b/ps5-kstuff/uelf/syscall_fixes.c new file mode 100644 index 0000000..07ac5af --- /dev/null +++ b/ps5-kstuff/uelf/syscall_fixes.c @@ -0,0 +1,27 @@ +#include "utils.h" +#include "syscall_fixes.h" + +extern char mprotect_fix_start[]; +extern char mprotect_fix_end[]; +extern char mdbg_call_fix[]; + +static uint64_t dbgregs_for_syscall_fix[6] = { + (uint64_t)mprotect_fix_start, (uint64_t)mdbg_call_fix, 0, 0, + 0, 0x405, +}; + +void handle_syscall_fix(uint64_t* regs) +{ + start_syscall_with_dbgregs(regs, dbgregs_for_syscall_fix); +} + +int try_handle_syscall_fix_trap(uint64_t* regs) +{ + if(regs[RIP] == (uint64_t)mprotect_fix_start) + regs[RIP] = (uint64_t)mprotect_fix_end; + else if(regs[RIP] == (uint64_t)mdbg_call_fix) + regs[RAX] = 1; + else + return 0; + return 1; +} diff --git a/ps5-kstuff/uelf/syscall_fixes.h b/ps5-kstuff/uelf/syscall_fixes.h new file mode 100644 index 0000000..8d632ea --- /dev/null +++ b/ps5-kstuff/uelf/syscall_fixes.h @@ -0,0 +1,7 @@ +#pragma once +#include + +#define SYS_mdbg_call 573 + +void handle_syscall_fix(uint64_t* regs); +int try_handle_syscall_fix_trap(uint64_t* regs);