csu333 / Surrogate

This is the repository for the Surrogate Xposed module
25 stars 7 forks source link

Hooking into dynamic methods #8

Closed wimex closed 7 years ago

wimex commented 7 years ago

It's currently impossible to hook into a method with dynamic parameters (namely the implementation of AsyncTask doInBackground(Void... voids) method). Xposed is looking for an exact match, but I can't configure the method parameter types so it results in a java.lang.NoSuchMethodError.

csu333 commented 7 years ago

As far as I know, dynamic parameters are just a syntactic sugar on an array so AsyncTask doInBackgroup (Void... voids) is just the same as AsyncTask doInBackground(Void[] voids)

You should then be able to instrument those methods by considering arrays instead of dynamic parameters. Now using Surrogate this is a bit tricky because of the Reflection methods it uses. You should then use the standard Java notation. You'll find some more example here: http://stackoverflow.com/questions/5085889/l-array-notation-where-does-it-come-from

An array of Void should be represented as [Ljava/lang/Void;

wimex commented 7 years ago

Thanks for the quick reply. I didn't know the correct syntax but this seems to solve it.