最近用Xposed hook QQ的一些class,总是hook不到。问题根源是ClassLoader不对,因为那几个class是动态加载进来的。
通过先ClassLoader.loadCLass则可以很轻松的拿到想要的classLoader对象
XposedBridge.hookAllMethods(ClassLoader.class, "loadClass", new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
if (param.hasThrowable()) return;
if (param.args.length != 1) return;
Class<?> cls = (Class<?>) param.getResult();
String name = cls.getName();
if ("com.tencent.mobileqq.utils.SecurityUtile".equals(name)) {
XposedBridge.hookAllMethods(cls,
"a",
new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
} catch (Exception e) {
Log.e(TAG, "beforeHookedMethod exception:" + e);
}
}
});
}
}
});