diff --git a/edxp-sandhook/build.gradle b/edxp-sandhook/build.gradle index 642aeba3..67448739 100644 --- a/edxp-sandhook/build.gradle +++ b/edxp-sandhook/build.gradle @@ -24,7 +24,7 @@ dependencies { compileOnly files("libs/framework-stub.jar") implementation project(':edxp-common') implementation project(':xposed-bridge') - implementation 'com.swift.sandhook:hooklib:3.2.8' + implementation 'com.swift.sandhook:hooklib:3.3.4' compileOnly project(':dexmaker') } diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/Router.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/Router.java index c95016bf..1240845e 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/Router.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/entry/Router.java @@ -30,6 +30,7 @@ public class Router { private static volatile AtomicBoolean bootstrapHooked = new AtomicBoolean(false); + static boolean useSandHook = false; public static void prepare(boolean isSystem) { // this flag is needed when loadModules @@ -61,7 +62,7 @@ public class Router { } Router.startBootstrapHook(isSystem); XposedInit.initForZygote(isSystem); - SandHookConfig.compiler = !isSystem; + //SandHookConfig.compiler = !isSystem; } catch (Throwable t) { Utils.logE("error during Xposed initialization", t); XposedBridge.disableHooks = true; @@ -81,18 +82,46 @@ public class Router { Utils.logD("startBootstrapHook starts: isSystem = " + isSystem); ClassLoader classLoader = XposedBridge.BOOTCLASSLOADER; if (isSystem) { - XposedCompat.addHookers(classLoader, SysBootstrapHookInfo.hookItems); + if (useSandHook) { + XposedCompat.addHookers(classLoader, SysBootstrapHookInfo.hookItems); + } else { + HookMain.doHookDefault( + Router.class.getClassLoader(), + classLoader, + SysBootstrapHookInfo.class.getName()); + } } else { - XposedCompat.addHookers(classLoader, AppBootstrapHookInfo.hookItems); + if (useSandHook) { + XposedCompat.addHookers(classLoader, AppBootstrapHookInfo.hookItems); + } else { + HookMain.doHookDefault( + Router.class.getClassLoader(), + classLoader, + AppBootstrapHookInfo.class.getName()); + } } } public static void startSystemServerHook() { - XposedCompat.addHookers(SystemMainHooker.systemServerCL, SysInnerHookInfo.hookItems); + if (useSandHook) { + XposedCompat.addHookers(SystemMainHooker.systemServerCL, SysInnerHookInfo.hookItems); + } else { + HookMain.doHookDefault( + Router.class.getClassLoader(), + SystemMainHooker.systemServerCL, + SysInnerHookInfo.class.getName()); + } } public static void startWorkAroundHook() { - XposedCompat.addHookers(XposedBridge.BOOTCLASSLOADER, WorkAroundHookInfo.hookItems); + if (useSandHook) { + XposedCompat.addHookers(XposedBridge.BOOTCLASSLOADER, WorkAroundHookInfo.hookItems); + } else { + HookMain.doHookDefault( + Router.class.getClassLoader(), + XposedBridge.BOOTCLASSLOADER, + WorkAroundHookInfo.class.getName()); + } } public static void onEnterChildProcess() { 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 75773d47..571b8ba5 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 @@ -314,7 +314,6 @@ public class HookStubManager { try { ((XC_MethodHook) snapshot[afterIdx]).callAfterHookedMethod(param); } catch (Throwable t) { - XposedBridge.log(t); if (lastThrowable == null) param.setResult(lastResult); else @@ -384,7 +383,6 @@ public class HookStubManager { try { ((XC_MethodHook) snapshot[afterIdx]).callAfterHookedMethod(param); } catch (Throwable t) { - XposedBridge.log(t); if (lastThrowable == null) param.setResult(lastResult); else diff --git a/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/methodgen/SandHookXposedBridge.java b/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/methodgen/SandHookXposedBridge.java index 39eea87d..c79c6311 100644 --- a/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/methodgen/SandHookXposedBridge.java +++ b/edxp-sandhook/src/main/java/com/swift/sandhook/xposedcompat/methodgen/SandHookXposedBridge.java @@ -1,10 +1,12 @@ package com.swift.sandhook.xposedcompat.methodgen; +import android.os.Build; import android.os.Process; import android.os.Trace; import com.swift.sandhook.SandHook; import com.swift.sandhook.SandHookConfig; +import com.swift.sandhook.annotation.HookMode; import com.swift.sandhook.wrapper.HookWrapper; import com.swift.sandhook.xposedcompat.XposedCompat; import com.swift.sandhook.xposedcompat.hookstub.HookMethodEntity; @@ -124,6 +126,9 @@ public final class SandHookXposedBridge { @Override public void loadLib() { //do it in loadDexAndInit + if (SandHookConfig.SDK_INT >= Build.VERSION_CODES.O) { + SandHook.setHookMode(HookMode.REPLACE); + } } }; SandHookConfig.DEBUG = true; 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 a2a75892..e4f0a55e 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 02225e39..1b9e9f52 Binary files a/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so and b/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so differ