hook webview的loadUrl方法
hook webview的loadUrl方法,打印webview加载的地址,修改参数将地址换成指定的url。
cpp
Class<?> clazz = lpparam.classLoader.loadClass("android.webkit.WebView");
if (clazz != null) {
XposedHelpers.findAndHookMethod(clazz, "loadUrl", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
Log.i(TAG, "beforeHookedMethod: url= " + param.args[0]); //打印参数
param.args[0] = "https://blog.csdn.net/u013170888"; //修改参数
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Log.i(TAG, "afterHookedMethod: url= " + param.args[0]); //打印修改后的参数
}
});
}