Commit 43ada919 authored by swift_gan's avatar swift_gan Committed by swift_gan

tweak bridge exception

parent 5d50e0ba
......@@ -30,7 +30,7 @@ ext {
userOrg = 'ganyao114'
groupId = 'com.swift.sandhook'
repoName = 'SandHook'
publishVersion = '2.5.2'
publishVersion = '2.9.5'
desc = 'android art hook'
website = 'https://github.com/ganyao114/SandHook'
licences = ['Apache-2.0']
......
......@@ -9,6 +9,7 @@ import com.swift.sandhook.wrapper.HookErrorException;
import com.swift.sandhook.wrapper.HookWrapper;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
......@@ -149,9 +150,25 @@ public class SandHook {
public static Object callOriginMethod(Member originMethod, Method backupMethod, Object thiz, Object[] args) throws Throwable {
backupMethod.setAccessible(true);
if (Modifier.isStatic(originMethod.getModifiers())) {
return backupMethod.invoke(null, args);
try {
return backupMethod.invoke(null, args);
} catch (InvocationTargetException throwable) {
if (throwable.getCause() != null) {
throw throwable.getCause();
} else {
throw throwable;
}
}
} else {
return backupMethod.invoke(thiz, args);
try {
return backupMethod.invoke(thiz, args);
} catch (InvocationTargetException throwable) {
if (throwable.getCause() != null) {
throw throwable.getCause();
} else {
throw throwable;
}
}
}
}
......
......@@ -293,7 +293,7 @@ public class HookStubManager {
} else {
param.setResult(SandHook.callOriginMethod(originMethod, thiz, param.args));
}
} catch (Exception e) {
} catch (Throwable e) {
XposedBridge.log(e);
param.setThrowable(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment