将代码改成try catch语句,尝试排除错误,代码如下:
[Java] 纯文本查看 复制代码 package com.example.unlock;
import android.util.Log;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
public class HookMain implements IXposedHookLoadPackage {
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if(!lpparam.packageName.equals("cn.soulapp.android")) //过滤包名
{
return;
}
XposedBridge.log("Loaded app: " + lpparam.packageName);
//Hook a方法
try {
Log.i("Tiger_test","hook进入程序");
XposedHelpers.findAndHookMethod("cn.soulapp.android.SoulNetworkSDK", lpparam.classLoader, "a", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
Log.i("Tiger_test","hook开始");
}
//方法执行后执行,改方法的返回值一定要在方法执行完毕后更改
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param)
throws Throwable {
//Log.i("Tiger_test","a方法的第一个参数为:"+param.args[0].toString());//param.args[0]为方法的第一个参数,同理param.args[1]为第二个参数
Log.i("Tiger_test","a方法的返回值为:"+param.getResult());//方法的返回值只能放在afterHookedMethod中获取
}
});
} catch (Throwable e){
XposedBridge.log("hook failed");
XposedBridge.log(e);
}
}
}
找到的报错如下:
|