From aca81321bf3ae051b9b0fdd1eb43505da90c3ab3 Mon Sep 17 00:00:00 2001 From: June Date: Thu, 26 Dec 2024 15:33:48 +0900 Subject: [PATCH] smh --- AltStoreCore/ptrace.h | 14 ++++++++++++++ AltStoreCore/ptrace.m | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 AltStoreCore/ptrace.h create mode 100644 AltStoreCore/ptrace.m diff --git a/AltStoreCore/ptrace.h b/AltStoreCore/ptrace.h new file mode 100644 index 00000000..099cd5bf --- /dev/null +++ b/AltStoreCore/ptrace.h @@ -0,0 +1,14 @@ +// +// ptrace.h +// AltStore +// +// Created by June P on 12/26/24. +// Copyright © 2024 SideStore. All rights reserved. +// + +#ifndef ptrace_h +#define ptrace_h + +int ptrace(int request, pid_t pid, caddr_t addr, int data); + +#endif /* ptrace_h */ diff --git a/AltStoreCore/ptrace.m b/AltStoreCore/ptrace.m new file mode 100644 index 00000000..bb868081 --- /dev/null +++ b/AltStoreCore/ptrace.m @@ -0,0 +1,27 @@ +// +// ptrace.m +// AltStore +// +// Created by June P on 12/26/24. +// Copyright © 2024 SideStore. All rights reserved. +// + + +int ptrace(int request, pid_t pid, caddr_t addr, int data) { + int result = 0; + __asm__ ( + "MOV x16, #26 \n" // Syscall number for ptrace + "MOV x0, %[request] \n" // Pass request to x0 + "MOV x1, %[pid] \n" // Pass pid to x1 + "MOV x2, %[addr] \n" // Pass addr to x2 + "MOV x3, %[data] \n" // Pass data to x3 + "SVC 0 \n" // Make the syscall (0 for ARM64) + : [result] "=r" (result) // No output + : [request] "r" (request), // Input constraints + [pid] "r" (pid), + [addr] "r" (addr), + [data] "r" (data) + : "x0", "x1", "x2", "x3", "x16" // Clobber list + ); + return result; +}