diff --git a/edxp-core/src/main/cpp/main/include/base/object.h b/edxp-core/src/main/cpp/main/include/base/object.h index e4fd8d98..45806a08 100644 --- a/edxp-core/src/main/cpp/main/include/base/object.h +++ b/edxp-core/src/main/cpp/main/include/base/object.h @@ -3,6 +3,18 @@ #include #include +#include + +#define __uintval(p) reinterpret_cast(p) +#define __ptr(p) reinterpret_cast(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(n), __page_size) +#define __ptr_align(x) __ptr(__align_down(reinterpret_cast(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 **); @@ -85,6 +97,7 @@ namespace edxp { ALWAYS_INLINE inline static void HookFunction(HookFunType hook_fun, void *original, void *replace, void **backup) { + __make_rwx(original, __page_size); hook_fun(original, replace, backup); } diff --git a/edxp-sandhook/build.gradle b/edxp-sandhook/build.gradle index b377eddc..952c8f64 100644 --- a/edxp-sandhook/build.gradle +++ b/edxp-sandhook/build.gradle @@ -28,7 +28,7 @@ dependencies { compileOnly files("${hiddenApiStubJarFilePath}") implementation project(':edxp-common') implementation project(':xposed-bridge') - implementation 'com.swift.sandhook:hooklib:3.5.8' + implementation 'com.swift.sandhook:hooklib:4.0.2' compileOnly project(':dexmaker') } diff --git a/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java b/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java index c29e327d..2bdf3e99 100644 --- a/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java +++ b/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java @@ -5,7 +5,7 @@ import android.util.Log; import com.swift.sandhook.SandHook; import com.swift.sandhook.SandHookMethodResolver; 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.utils.DexLog; @@ -167,13 +167,13 @@ public class HookStubManager { try { if (is64Bit) { 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) return null; return new StubMethodsInfo(stubArgs, curUseStubIndex, hook, backup); } else { 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) return null; return new StubMethodsInfo(stubArgs, curUseStubIndex, hook, backup); diff --git a/edxp-sandhook/template_override/system/lib/libsandhook.edxp.so b/edxp-sandhook/template_override/system/lib/libsandhook.edxp.so old mode 100644 new mode 100755 index 01578925..6608f917 Binary files a/edxp-sandhook/template_override/system/lib/libsandhook.edxp.so and b/edxp-sandhook/template_override/system/lib/libsandhook.edxp.so differ diff --git a/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so b/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so old mode 100644 new mode 100755 index dcad9215..b0a53d8f Binary files a/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so and b/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so differ diff --git a/hiddenapi-stubs/libs/framework-stub.jar b/hiddenapi-stubs/libs/framework-stub.jar index 4d48c364..55e65898 100644 Binary files a/hiddenapi-stubs/libs/framework-stub.jar and b/hiddenapi-stubs/libs/framework-stub.jar differ