Merge pull request #191 from ElderDrivers/sandhook

Sandhook
This commit is contained in:
solohsu 2019-03-25 17:09:47 +08:00 committed by GitHub
commit 8a37dae36a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 8 deletions

View File

@ -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.3'
compileOnly project(':dexmaker')
}

View File

@ -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() {

View File

@ -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

Binary file not shown.

Binary file not shown.