本篇文章,我们来说说 hooker 报错了,我想找到异常的详细信息!
Xpose 这个工具还是很强大的。可以在任何的地方进行植入自己的代码。对于异常的堆栈信息获取,我这里直接给出代码。
在 XC_MethodHook 的回调方法 afterHookedMethod 回调中,打印堆栈信息。
代码详细如下:
public static void exceptionHooker(final XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod("java.lang.Throwable", lpparam.classLoader, "getStackTrace", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { StackTraceElement[] result = (StackTraceElement[]) param.getResult(); boolean xposedDetected = false; for (StackTraceElement localStackTraceElement : result) { if (localStackTraceElement.getClassName().equals("de.robv.android.xposed.XposedBridge")) { //found xposed XposedBridge.log("Now, let's skip the Alipay hook checker, HOHO`` Anti Hook Starting.., skip method name: " + localStackTraceElement.getMethodName()); xposedDetected = true; break; } } if (xposedDetected) { //Replaces the returning value ListnewResult = new ArrayList<>(); for (StackTraceElement localStackTraceElement : result) { if (localStackTraceElement.getClassName().equals("de.robv.android.xposed.XposedBridge")) { //found xposed and skip... continue; } newResult.add(localStackTraceElement); } StackTraceElement[] retval = newResult.toArray(new StackTraceElement[newResult.size()]); XposedBridge.log("Anti Hook returning..."); param.setResult(retval); } } }); }
读者如果有什么疑问的话,随时可以联系我进行技术交流。