package com.example.xposedhook;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import java.lang.reflect.Method;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class Hook implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lppararm) throws Throwable {
if (lppararm.packageName.equals("xxx.xxxx.xxxx")) {
XposedBridge.log("start hook");
// Class clazz = lppararm.classLoader.loadClass("com.xxxx.xxx.xxx.xxx.xxx");
// XposedHelpers.findAndHookMethod(clazz, "invoke", new XC_MethodHook() {
//
// protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//
// super.beforeHookedMethod(param);
//
// Log.d("cxa"," has Hooked!");
//
// }
//
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// Object[] ars=(Object[])param.args[2];
// Log.d("cxa",ars.toString());
//
// }
//
// });
//hook 多dex
XposedHelpers.findAndHookMethod(Application.class, "attach",
Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ClassLoader cl = ((Context) param.args[0]).getClassLoader();
Class<?> hookclass = null;
try {
hookclass = cl.loadClass("com.kuaishou.android.security.kfree.a");
} catch (Exception e) {
Log.e("DEBUG", "load class error", e);
return;
}
Log.i("DEBUG", "load success");
XposedHelpers.findAndHookMethod(hookclass, "invoke", Object.class, Method.class, Object[].class,
new XC_MethodHook() {
//TODO: 相关hook操作
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
Log.d("cxa", " has Hooked!");
}
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Object[] ars = (Object[]) param.args[2];
Log.d("cxa", ars[0].toString());
}
});
}
});
}
}
}