diff --git a/edxp-sandhook/build.gradle b/edxp-sandhook/build.gradle index eaa7066c..74b9a3fb 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.4.2' + implementation 'com.swift.sandhook:hooklib:3.5.6' 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 a6d6b2d9..c29e327d 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 @@ -296,7 +296,7 @@ public class HookStubManager { long[] newArgs = entity.getArgsAddress(stubArgs, param.args); param.setResult(entity.getResult(callOrigin.call(newArgs))); } else { - param.setResult(SandHook.callOriginMethod(originMethod, thiz, param.args)); + param.setResult(SandHook.callOriginMethod(originMethod, entity.backup, thiz, param.args)); } } catch (Throwable e) { param.setThrowable(e); @@ -337,7 +337,7 @@ public class HookStubManager { Object[] snapshot = additionalHookInfo.callbacks.getSnapshot(); if (snapshot == null || snapshot.length == 0) { - return SandHook.callOriginMethod(origin, thiz, args); + return SandHook.callOriginMethod(origin, backup, thiz, args); } XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); 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 8b369478..a9135372 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,12 +1,11 @@ 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.blacklist.HookBlackList; import com.swift.sandhook.wrapper.HookWrapper; import com.swift.sandhook.xposedcompat.XposedCompat; import com.swift.sandhook.xposedcompat.hookstub.HookMethodEntity; @@ -28,7 +27,7 @@ import de.robv.android.xposed.XposedBridge; public final class SandHookXposedBridge { private static final Map hookedInfo = new ConcurrentHashMap<>(); - private static HookMaker hookMaker = XposedCompat.useNewCallBackup ? new HookerDexMakerNew() : new HookerDexMaker(); + private static HookMaker defaultHookMaker = XposedCompat.useNewCallBackup ? new HookerDexMakerNew() : new HookerDexMaker(); private static final AtomicBoolean dexPathInited = new AtomicBoolean(false); private static File dexDir; @@ -63,18 +62,24 @@ public final class SandHookXposedBridge { Trace.beginSection("SandXposed"); long timeStart = System.currentTimeMillis(); HookMethodEntity stub = null; - if (XposedCompat.useInternalStub) { + if (XposedCompat.useInternalStub && !HookBlackList.canNotHookByStub(hookMethod) && !HookBlackList.canNotHookByBridge(hookMethod)) { stub = HookStubManager.getHookMethodEntity(hookMethod, additionalHookInfo); } if (stub != null) { SandHook.hook(new HookWrapper.HookEntity(hookMethod, stub.hook, stub.backup, false)); entityMap.put(hookMethod, stub); } else { + HookMaker hookMaker; + if (HookBlackList.canNotHookByBridge(hookMethod)) { + hookMaker = new HookerDexMaker(); + } else { + hookMaker = defaultHookMaker; + } hookMaker.start(hookMethod, additionalHookInfo, hookMethod.getDeclaringClass().getClassLoader(), dexDir == null ? null : dexDir.getAbsolutePath()); hookedInfo.put(hookMethod, hookMaker.getCallBackupMethod()); } - DexLog.d("hook method <" + hookMethod.toString() + "> cost " + (System.currentTimeMillis() - timeStart) + " ms, by " + (stub != null ? "internal stub." : "dex maker")); + DexLog.d("hook method <" + hookMethod.toString() + "> cost " + (System.currentTimeMillis() - timeStart) + " ms, by " + (stub != null ? "internal stub" : "dex maker")); Trace.endSection(); } catch (Exception e) { DexLog.e("error occur when hook method <" + hookMethod.toString() + ">", e); @@ -126,9 +131,6 @@ 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 100755 new mode 100644 index e4f0a55e..01578925 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 100755 new mode 100644 index 1b9e9f52..dcad9215 Binary files a/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so and b/edxp-sandhook/template_override/system/lib64/libsandhook.edxp.so differ