E235
E235

Reputation: 13420

How to overload function with "int" in Frida

I have the following function:

public final int getState(@NotNull String str, int i) {
    Intrinsics.checkParameterIsNotNull(str, "key");
    return PreferenceManager.getDefaultSharedPreferences(this).getInt(str, i);
}  

I don't know who to use the int argument when overloading. This is what I tried:

var myapp= Java.use('com.myapp.AppActivity');
myapp.cleanUi.overload().implementation = function () {
    console.log('! Intercepted cleanUi');
}

It throw an exception:

{'type': 'error', 'description': "Error: getState(): specified argument types do not match any of:
        .overload('java.lang.String', 'java.lang.String')
        .overload('java.lang.String', 'float')
        .overload('java.lang.String', 'int')", 'stack': "Error: getState(): specified argument types do not match any of:
        .overload('java.lang.String', 'java.lang.String')
        .overload('java.lang.String', 'float')
        .overload('java.lang.String', 'int')
    at throwOverloadError (frida/node_modules/frida-java/lib/class-factory.js:2233)
    at frida/node_modules/frida-java/lib/class-factory.js:1422
    at [anon] (/script1.js:25)
    at frida/node_modules/frida-java/lib/vm.js:42
    at M (frida/node_modules/frida-java/index.js:347)
    at frida/node_modules/frida-java/index.js:299
    at frida/node_modules/frida-java/lib/vm.js:42
    at frida/node_modules/frida-java/index.js:279
    at /script1.js:82", 'fileName': 'frida/node_modules/frida-java/lib/class-factory.js', 'lineNumber': 2233, 'columnNumber': 1}  

Upvotes: 1

Views: 12626

Answers (1)

E235
E235

Reputation: 13420

While writing the question I found what was the problem and I want to share it with you.

I just needed to add the arguments that I am using so just adding these str and myint:

myapp.getState.overload('java.lang.String', 'int').implementation = function (str, myint) {
    console.log('! Intercepted getState');
    return 100;
};  

Upvotes: 4

Related Questions