Here is a demo plugin which contains the hook info.
Build the plugin and you'll get an APK file. Push the APK to /sdcard/demoPlugin-debug.apk
before running the demoApp.
To hook a method, please create a Class
which has the following fields:
- A static
String
field 3164 namedclassName
. This is the name of the class where the target method belongs to - A static
String
field namedmethodName
. This is the name of the target method - A static
String
field namedmethodSig
. This is the signature string of the target method
The above fields are used for finding target method. Besides, the class should have the following methods:
- A static method named
hook
. This is the hook method that would replace the target method. Please make sure that the arguments do match. For example, if you hook a virtual method, then the first argument of thehook()
should be thisObject
. - A static method named
backup
. This is the placeholder where the target method would be backed up before hooking. You can invokebackup()
inhook()
wherever you like. Sincebackup()
is a placeholder, how the method is implemented doesn't matter. Also,backup()
is optional, which means it's not necessary if the original method would not be called.
Now you have a class which contains all the information for hooking a method. We call this class hook item. You can create as many hook items as you like.
After creating all the hook items, put their names in the field hookItemNames
of class lab.galaxy.yahfa.HookInfo
. YAHFA would read this field for hook items when loading the plugin.