This commit is contained in:
June
2024-12-26 15:33:48 +09:00
parent 01084039df
commit aca81321bf
2 changed files with 41 additions and 0 deletions

14
AltStoreCore/ptrace.h Normal file
View File

@@ -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 */

27
AltStoreCore/ptrace.m Normal file
View File

@@ -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;
}