I am using Frida to instrument Android applications. The methods I have to instruments are chosen from a trace obtained by the Android Tracer tool. I am having an issue with some overloads.
As an example, consider the writeTypedArray method from the android.os.Parcel class:
From the Android Tracer I get its parameters array as (['[Landroid.os.Parcelable;', 'int']), and a getDeclaredMethods confirms it is compatible, as it gives its signature as public final void android.os.Parcel.writeTypedArray(android.os.Parcelable[],int).
However if I try to re-implement it in my script with methodObject.overload.apply(this, parametersTypes).implementation = function () {...} (with parametersTypes equal to (['[Landroid.os.Parcelable;', 'int'])) it gives me the following error:
Error: writeTypedArray(): specified argument types do not match any of: .overload('java.lang.Object', 'int') at throwOverloadError (frida/node_modules/frida-java/lib/class-factory.js:1449) at frida/node_modules/frida-java/lib/class-factory.js:871 at apply (native) at OverloadTEST.js:13 at frida/node_modules/frida-java/lib/vm.js:33 at y (frida/node_modules/frida-java/index.js:322) at frida/node_modules/frida-java/index.js:296 at frida/node_modules/frida-java/lib/vm.js:33 at java.js:1369 at OverloadTEST.js:4 [...]
Just before posting I went to take a look at the documentation and source code of the android.os.Parcel class and found out that it uses a generics and its definition signature is:
public final <T extends Parcelable> void writeTypedArray(T[] val, int parcelableFlags)
Which may easily be the source of my problems, however I have no idea how to bypass it in an automated way, manually change my parameters to ('java.lang.Object', 'int') is not a good solution as I am instrumenting hundreds of different methods.
Is there an way to make it work with the actual class?
Is there a way to at least avoid the abort and crash of the instrumentation tool in case this happens? I would like to by able to recovery in my catch, but It is always stuck after the error.
Hi,
I am using Frida to instrument Android applications. The methods I have to instruments are chosen from a trace obtained by the Android Tracer tool. I am having an issue with some overloads. As an example, consider the
writeTypedArray
method from theandroid.os.Parcel
class:From the Android Tracer I get its parameters array as
(['[Landroid.os.Parcelable;', 'int'])
, and a getDeclaredMethods confirms it is compatible, as it gives its signature aspublic final void android.os.Parcel.writeTypedArray(android.os.Parcelable[],int)
. However if I try to re-implement it in my script withmethodObject.overload.apply(this, parametersTypes).implementation = function () {...}
(withparametersTypes
equal to(['[Landroid.os.Parcelable;', 'int'])
) it gives me the following error:Error: writeTypedArray(): specified argument types do not match any of: .overload('java.lang.Object', 'int') at throwOverloadError (frida/node_modules/frida-java/lib/class-factory.js:1449) at frida/node_modules/frida-java/lib/class-factory.js:871 at apply (native) at OverloadTEST.js:13 at frida/node_modules/frida-java/lib/vm.js:33 at y (frida/node_modules/frida-java/index.js:322) at frida/node_modules/frida-java/index.js:296 at frida/node_modules/frida-java/lib/vm.js:33 at java.js:1369 at OverloadTEST.js:4 [...]
Just before posting I went to take a look at the documentation and source code of the
android.os.Parcel
class and found out that it uses a generics and its definition signature is:public final <T extends Parcelable> void writeTypedArray(T[] val, int parcelableFlags)
Which may easily be the source of my problems, however I have no idea how to bypass it in an automated way, manually change my parameters to
('java.lang.Object', 'int')
is not a good solution as I am instrumenting hundreds of different methods.Is there an way to make it work with the actual class? Is there a way to at least avoid the abort and crash of the instrumentation tool in case this happens? I would like to by able to recovery in my catch, but It is always stuck after the error.
Here attached a minimal example to reproduce my issue: OverloadTEST.txt InstrumentTEST.txt