Closed daimoniuma closed 7 years ago
Looks like you have hooked critical methods like ClassLoader.loadClass(). Try if it also crashes without this hook.
Absolutely correct.
"java.lang.ClassLoader", lpparam.classLoader, "loadClass", String.class, new XC_MethodHook()
It was done to catch things from PathClassLoader and so on. Not all classes are hooked, it waits for defined class.
No errors if I dismiss this catcher. How can I bring it back? Where is mistake?
There's probably some error in your hook. The stack looks like you call getDeclaredMethods()
from your hook, which in turn calls loadClass()
again, so you probably have some infinite recursion. If you execute your logic before the class load, try to move it to afterwards. But if you always look up all methods of a class, and then look up all classes of their parameter types, and repeat that often enough, something like this will happen as you load and process lots of classes while your stack grows. There are ways to convert code from recursive to iterative, that might help. But seriously, I really recommend not to hook such critical methods.
You was right. Here is infinity loop.
findAndHookMethod("java.lang.ClassLoader", lpparam.classLoader, "loadClass", String.class, boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
String loadedClass = (String) param.args[0];
if(targetClasses.contains(loadedClass)){
XposedBridge.log(loadedClass);
onClassLoaded(lpparam, (Class<?>) param.getResult(), catcher);
}
}
});
private void onClassLoaded(final LoadPackageParam lpparam, Class<?> classToHook, XC_MethodHook catcher){
Method[] methods = classToHook.getDeclaredMethods();
For some reason return Class<?> is null. getDeclaredMethods tries to load class into loop. Why?
Solved. 😸
String loadedClass = (String) param.args[0];
if(inspectClasses.contains(loadedClass)){
Class<?> classToHook = (Class<?>) param.getResult();
if(classToHook == null)
return;
inspectClasses.remove(loadedClass);
onClassLoaded(lpparam, classToHook, catcher);
I tried to getDeclaredMethods from class and hook them all.
It works well with simple classes which nothing extends, but when I tried to hook classes which extends AppCompatActivity or Fragment...