1

我有以下功能:

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

我不知道int重载时该使用谁的参数。这是我尝试过的:

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

它抛出一个异常:

{'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}  
4

1 回答 1

2

在写这个问题时,我发现了问题所在,我想与你分享。

我只需要添加我正在使用的参数,所以只需添加这些strmyint

myapp.getState.overload('java.lang.String', 'int').implementation = function (str, myint) {
    console.log('! Intercepted getState');
    return 100;
};  
于 2019-08-19T08:58:46.990 回答