mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
1. Replace `do_execveat_common` with `sys_execve` and `sys_execveat` 2. Replace `input_handle_event` with `input_event` and `input_inject_event` Tested on android12-5.10-2024-04, android13-5.15-2024-04. android14-6.1-2024-04
87 lines
2.7 KiB
C
87 lines
2.7 KiB
C
#ifndef __KSU_H_ARCH
|
|
#define __KSU_H_ARCH
|
|
|
|
#include "linux/version.h"
|
|
|
|
#if defined(__aarch64__)
|
|
|
|
#define __PT_PARM1_REG regs[0]
|
|
#define __PT_PARM2_REG regs[1]
|
|
#define __PT_PARM3_REG regs[2]
|
|
#define __PT_SYSCALL_PARM4_REG regs[3]
|
|
#define __PT_CCALL_PARM4_REG regs[3]
|
|
#define __PT_PARM5_REG regs[4]
|
|
#define __PT_PARM6_REG regs[5]
|
|
#define __PT_RET_REG regs[30]
|
|
#define __PT_FP_REG regs[29] /* Works only with CONFIG_FRAME_POINTER */
|
|
#define __PT_RC_REG regs[0]
|
|
#define __PT_SP_REG sp
|
|
#define __PT_IP_REG pc
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
|
|
#define PRCTL_SYMBOL "__arm64_sys_prctl"
|
|
#define SYS_READ_SYMBOL "__arm64_sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "__arm64_sys_newfstatat"
|
|
#define SYS_FACCESSAT_SYMBOL "__arm64_sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "__arm64_sys_execve"
|
|
#else
|
|
#define PRCTL_SYMBOL "sys_prctl"
|
|
#define SYS_READ_SYMBOL "sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "sys_newfstatat"
|
|
#define SYS_FACCESSAT_SYMBOL "sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "sys_execve"
|
|
#endif
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
#define __PT_PARM1_REG di
|
|
#define __PT_PARM2_REG si
|
|
#define __PT_PARM3_REG dx
|
|
/* syscall uses r10 for PARM4 */
|
|
#define __PT_SYSCALL_PARM4_REG r10
|
|
#define __PT_CCALL_PARM4_REG cx
|
|
#define __PT_PARM5_REG r8
|
|
#define __PT_PARM6_REG r9
|
|
#define __PT_RET_REG sp
|
|
#define __PT_FP_REG bp
|
|
#define __PT_RC_REG ax
|
|
#define __PT_SP_REG sp
|
|
#define __PT_IP_REG ip
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
|
|
#define PRCTL_SYMBOL "__x64_sys_prctl"
|
|
#define SYS_READ_SYMBOL "__x64_sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "__x64_sys_newfstatat"
|
|
#define SYS_FACCESSAT_SYMBOL "__x64_sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "__x64_sys_execve"
|
|
#else
|
|
#define PRCTL_SYMBOL "sys_prctl"
|
|
#define SYS_READ_SYMBOL "sys_read"
|
|
#define SYS_NEWFSTATAT_SYMBOL "sys_newfstatat"
|
|
#define SYS_FACCESSAT_SYMBOL "sys_faccessat"
|
|
#define SYS_EXECVE_SYMBOL "sys_execve"
|
|
#endif
|
|
|
|
#else
|
|
#error "Unsupported arch"
|
|
#endif
|
|
|
|
/* allow some architecutres to override `struct pt_regs` */
|
|
#ifndef __PT_REGS_CAST
|
|
#define __PT_REGS_CAST(x) (x)
|
|
#endif
|
|
|
|
#define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG)
|
|
#define PT_REGS_PARM2(x) (__PT_REGS_CAST(x)->__PT_PARM2_REG)
|
|
#define PT_REGS_PARM3(x) (__PT_REGS_CAST(x)->__PT_PARM3_REG)
|
|
#define PT_REGS_SYSCALL_PARM4(x) (__PT_REGS_CAST(x)->__PT_SYSCALL_PARM4_REG)
|
|
#define PT_REGS_CCALL_PARM4(x) (__PT_REGS_CAST(x)->__PT_CCALL_PARM4_REG)
|
|
#define PT_REGS_PARM5(x) (__PT_REGS_CAST(x)->__PT_PARM5_REG)
|
|
#define PT_REGS_PARM6(x) (__PT_REGS_CAST(x)->__PT_PARM6_REG)
|
|
#define PT_REGS_RET(x) (__PT_REGS_CAST(x)->__PT_RET_REG)
|
|
#define PT_REGS_FP(x) (__PT_REGS_CAST(x)->__PT_FP_REG)
|
|
#define PT_REGS_RC(x) (__PT_REGS_CAST(x)->__PT_RC_REG)
|
|
#define PT_REGS_SP(x) (__PT_REGS_CAST(x)->__PT_SP_REG)
|
|
#define PT_REGS_IP(x) (__PT_REGS_CAST(x)->__PT_IP_REG)
|
|
|
|
#endif
|