AndroidQ : fix native hook & update sandhook
This commit is contained in:
parent
195a228514
commit
b9b10b510e
|
|
@ -3,6 +3,18 @@
|
||||||
|
|
||||||
#include <art/base/macros.h>
|
#include <art/base/macros.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#define __uintval(p) reinterpret_cast<uintptr_t>(p)
|
||||||
|
#define __ptr(p) reinterpret_cast<void *>(p)
|
||||||
|
#define __align_up(x, n) (((x) + ((n) - 1)) & ~((n) - 1))
|
||||||
|
#define __align_down(x, n) ((x) & -(n))
|
||||||
|
#define __page_size 4096
|
||||||
|
#define __page_align(n) __align_up(static_cast<uintptr_t>(n), __page_size)
|
||||||
|
#define __ptr_align(x) __ptr(__align_down(reinterpret_cast<uintptr_t>(x), __page_size))
|
||||||
|
#define __make_rwx(p, n) ::mprotect(__ptr_align(p), \
|
||||||
|
__page_align(__uintval(p) + n) != __page_align(__uintval(p)) ? __page_align(n) + __page_size : __page_align(n), \
|
||||||
|
PROT_READ | PROT_WRITE | PROT_EXEC)
|
||||||
|
|
||||||
typedef void (*HookFunType)(void *, void *, void **);
|
typedef void (*HookFunType)(void *, void *, void **);
|
||||||
|
|
||||||
|
|
@ -85,6 +97,7 @@ namespace edxp {
|
||||||
|
|
||||||
ALWAYS_INLINE inline static void HookFunction(HookFunType hook_fun, void *original,
|
ALWAYS_INLINE inline static void HookFunction(HookFunType hook_fun, void *original,
|
||||||
void *replace, void **backup) {
|
void *replace, void **backup) {
|
||||||
|
__make_rwx(original, __page_size);
|
||||||
hook_fun(original, replace, backup);
|
hook_fun(original, replace, backup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ dependencies {
|
||||||
compileOnly files("${hiddenApiStubJarFilePath}")
|
compileOnly files("${hiddenApiStubJarFilePath}")
|
||||||
implementation project(':edxp-common')
|
implementation project(':edxp-common')
|
||||||
implementation project(':xposed-bridge')
|
implementation project(':xposed-bridge')
|
||||||
implementation 'com.swift.sandhook:hooklib:3.5.8'
|
implementation 'com.swift.sandhook:hooklib:4.0.2'
|
||||||
compileOnly project(':dexmaker')
|
compileOnly project(':dexmaker')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import android.util.Log;
|
||||||
import com.swift.sandhook.SandHook;
|
import com.swift.sandhook.SandHook;
|
||||||
import com.swift.sandhook.SandHookMethodResolver;
|
import com.swift.sandhook.SandHookMethodResolver;
|
||||||
import com.swift.sandhook.utils.ParamWrapper;
|
import com.swift.sandhook.utils.ParamWrapper;
|
||||||
import com.swift.sandhook.wrapper.BackupMethodStubs;
|
import com.swift.sandhook.wrapper.StubMethodsFactory;
|
||||||
import com.swift.sandhook.xposedcompat.XposedCompat;
|
import com.swift.sandhook.xposedcompat.XposedCompat;
|
||||||
import com.swift.sandhook.xposedcompat.utils.DexLog;
|
import com.swift.sandhook.xposedcompat.utils.DexLog;
|
||||||
|
|
||||||
|
|
@ -167,13 +167,13 @@ public class HookStubManager {
|
||||||
try {
|
try {
|
||||||
if (is64Bit) {
|
if (is64Bit) {
|
||||||
Method hook = MethodHookerStubs64.class.getDeclaredMethod(getHookMethodName(curUseStubIndex), pars);
|
Method hook = MethodHookerStubs64.class.getDeclaredMethod(getHookMethodName(curUseStubIndex), pars);
|
||||||
Method backup = hasStubBackup ? MethodHookerStubs64.class.getDeclaredMethod(getBackupMethodName(curUseStubIndex), pars) : BackupMethodStubs.getStubMethod();
|
Method backup = hasStubBackup ? MethodHookerStubs64.class.getDeclaredMethod(getBackupMethodName(curUseStubIndex), pars) : StubMethodsFactory.getStubMethod();
|
||||||
if (hook == null || backup == null)
|
if (hook == null || backup == null)
|
||||||
return null;
|
return null;
|
||||||
return new StubMethodsInfo(stubArgs, curUseStubIndex, hook, backup);
|
return new StubMethodsInfo(stubArgs, curUseStubIndex, hook, backup);
|
||||||
} else {
|
} else {
|
||||||
Method hook = MethodHookerStubs32.class.getDeclaredMethod(getHookMethodName(curUseStubIndex), pars);
|
Method hook = MethodHookerStubs32.class.getDeclaredMethod(getHookMethodName(curUseStubIndex), pars);
|
||||||
Method backup = hasStubBackup ? MethodHookerStubs32.class.getDeclaredMethod(getBackupMethodName(curUseStubIndex), pars) : BackupMethodStubs.getStubMethod();
|
Method backup = hasStubBackup ? MethodHookerStubs32.class.getDeclaredMethod(getBackupMethodName(curUseStubIndex), pars) : StubMethodsFactory.getStubMethod();
|
||||||
if (hook == null || backup == null)
|
if (hook == null || backup == null)
|
||||||
return null;
|
return null;
|
||||||
return new StubMethodsInfo(stubArgs, curUseStubIndex, hook, backup);
|
return new StubMethodsInfo(stubArgs, curUseStubIndex, hook, backup);
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue