Q:how to hook all classes of an app without source code

Search This thread

husterkang

New member
Nov 4, 2015
3
0
Hi, I am new in Xposed.. I have read the development tutorial, but still do not know how to finish my work.
I want to do the following three things(I do not have the source code):
1. Get all classes of an app when I use the app
2. Get all methods of every class I have found in step 1
3. Monitor the delay of every methods when I use the app.

In order to finish step 1, I use findAndHookMethod, and set the className argument to null, and method argument to null, but it could not work and throw an Exception. I supposed that the two argument can not be set to null!! :(
I did not find any other API to finish the step 1 :(, so is someone has any idea to help me? :)
 

WardellBagby

Senior Member
Nov 8, 2013
56
105
You're thinking about this wrong.

1: There's no automatic way to hook all methods of a class, so you shouldn't look for such a thing. There's no good reason you'd want to do that.
2: If the source for the app you want isn't available, you can decompile the app using a tool like APK to Java to decompile the app to Java/Smali. (If you can read or understand Smali, decompile to Smali as the APK to Smali decompilation is guaranteed to be faithful, while the Java decompilation can only give a general overview.)
 

husterkang

New member
Nov 4, 2015
3
0
You're thinking about this wrong.

1: There's no automatic way to hook all methods of a class, so you shouldn't look for such a thing. There's no good reason you'd want to do that.
2: If the source for the app you want isn't available, you can decompile the app using a tool like APK to Java to decompile the app to Java/Smali. (If you can read or understand Smali, decompile to Smali as the APK to Smali decompilation is guaranteed to be faithful, while the Java decompilation can only give a general overview.)

thanks, I have used DexFile to get all class list of an app. But when I used XposedHelpers.findClass to find the classes I have found, ClassNotFoundError happened for some Classes. Also, When I found some class, and use getdeclaredmethod to get all methods of these classes, NoClassDefError happened. Do you know how to deal with it?
 

WardellBagby

Senior Member
Nov 8, 2013
56
105
thanks, I have used DexFile to get all class list of an app. But when I used XposedHelpers.findClass to find the classes I have found, ClassNotFoundError happened for some Classes. Also, When I found some class, and use getdeclaredmethod to get all methods of these classes, NoClassDefError happened. Do you know how to deal with it?

Assuming you're using handleLoadPackage, make sure you're actually in the right package when you try to do the hooking. Also make sure you're using the classloader given to you in the LoadPackageParams. If you're trying to hook an internal class, make sure you're using the correct internal syntax. Ex., for a class that looks like this:

Code:
package com.example.test;
public class A {
    private class B {
    }
}

To hook class B, you'd have to use the format "com.example.test.A$B"
 

husterkang

New member
Nov 4, 2015
3
0
Assuming you're using handleLoadPackage, make sure you're actually in the right package when you try to do the hooking. Also make sure you're using the classloader given to you in the LoadPackageParams. If you're trying to hook an internal class, make sure you're using the correct internal syntax. Ex., for a class that looks like this:

Code:
package com.example.test;
public class A {
    private class B {
    }
}

To hook class B, you'd have to use the format "com.example.test.A$B"

thanks!In my module, I can hook the inner class. I doubt that it may be some Service Classes cause ClassNotFoundError, because Service lives in another progress. When I try to find a service class or some class extend from service class, the ClassNotFoundError happened. Do you know how to hook Service class in an app progress?