SandHook: sync code from sandhook
This commit is contained in:
parent
047025b2a9
commit
85c00164bc
|
|
@ -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')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<Member, Method> 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;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue