|
// 第一步:Hook方法ClassLoader#loadClass(String)
findAndHookMethod(ClassLoader.class, "loadClass", String.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (param.hasThrowable()) return;
Class<?> cls = (Class<?>) param.getResult();
String name = cls.getName();
if (classes.contains(name)) {
// 所有的类都是通过loadClass方法加载的
// 所以这里通过判断全限定类名,查找到目标类
// 第二步:Hook目标方法
findAndHookMethod(cls, "methodName", paramTypes, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// TODO
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// TODO
}
});
}
}
});
|
|