From cd23d2704872b26e268d7b1cd1bede93279c2215 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 6 Jan 2021 21:56:29 -0800 Subject: [PATCH] Fix remote_write implementation --- native/jni/inject/ptrace.cpp | 2 +- native/jni/magiskhide/proc_monitor.cpp | 4 ---- native/jni/utils/xwrap.hpp | 3 +++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/native/jni/inject/ptrace.cpp b/native/jni/inject/ptrace.cpp index 28cb99f63..4e57548c4 100644 --- a/native/jni/inject/ptrace.cpp +++ b/native/jni/inject/ptrace.cpp @@ -131,7 +131,7 @@ bool _remote_write(int pid, uintptr_t addr, const void *buf, size_t len) { for (size_t i = 0; i < len; i += sizeof(long)) { long data = 0; memcpy(&data, static_cast(buf) + i, std::min(len - i, sizeof(data))); - if (xptrace(PTRACE_POKETEXT, pid, reinterpret_cast(addr + i), &data) < 0) + if (xptrace(PTRACE_POKETEXT, pid, reinterpret_cast(addr + i), data) < 0) return false; } return true; diff --git a/native/jni/magiskhide/proc_monitor.cpp b/native/jni/magiskhide/proc_monitor.cpp index 437ae6b6a..d99b4df15 100644 --- a/native/jni/magiskhide/proc_monitor.cpp +++ b/native/jni/magiskhide/proc_monitor.cpp @@ -47,10 +47,6 @@ pid_set attaches; * Utils ********/ -static inline long xptrace(int request, pid_t pid, void *addr, uintptr_t data) { - return xptrace(request, pid, addr, reinterpret_cast(data)); -} - static inline int read_ns(const int pid, struct stat *st) { char path[32]; sprintf(path, "/proc/%d/ns/mnt", pid); diff --git a/native/jni/utils/xwrap.hpp b/native/jni/utils/xwrap.hpp index 6feb46a91..7cd888c83 100644 --- a/native/jni/utils/xwrap.hpp +++ b/native/jni/utils/xwrap.hpp @@ -61,3 +61,6 @@ int xinotify_init1(int flags); char *xrealpath(const char *path, char *resolved_path); int xmknod(const char *pathname, mode_t mode, dev_t dev); long xptrace(int request, pid_t pid, void *addr = nullptr, void *data = nullptr); +static inline long xptrace(int request, pid_t pid, void *addr, uintptr_t data) { + return xptrace(request, pid, addr, reinterpret_cast(data)); +}