frida-java-bridge icon indicating copy to clipboard operation
frida-java-bridge copied to clipboard

Shouldn't be signature check with args be on instance instead of $className ?

Open PeroKetStory opened this issue 5 years ago • 0 comments

Hi, I've been working on trying to add graphical element to an Activity (yeah, I like challenges...). While I've been struggling with it, I get across a weird thing... Here are few lines of my js script:

var context = currentApplication.getApplicationContext();
var ccontext = Java.cast(context, Java.use("android.content.Context"))
console.log("Context C is type : " + JSON.stringify(ccontext))
let  image = Java.use("android.widget.ImageButton").$new(ccontext)

I got the following output:

Context C is type : "<instance: android.content.Context, $className: com.android.gallery3d.app.GalleryAppImpl>"
Error: ImageButton(): argument types do not match any of:
    .overload('android.content.Context')
    .overload('android.content.Context', 'android.util.AttributeSet')
    .overload('android.content.Context', 'android.util.AttributeSet', 'int')
        .overload('android.content.Context', 'android.util.AttributeSet', 'int', 'int')   

But I gave him the right instance type... So I checked into class-factory.js and found that: https://github.com/frida/frida-java-bridge/blob/master/lib/class-factory.js#L1307

The args are checked to know if the match the signature of the overloads implem by using the className instead of the instance. Shouldn't be the contrary ? Or the className should be changed while the cast is occuring maybe ?

Regards

PeroKetStory avatar Nov 03 '20 11:11 PeroKetStory