Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: expected a pointer while implementing Java code in frida script #2836

Open
deardaming opened this issue Apr 26, 2024 · 0 comments
Open

Comments

@deardaming
Copy link

I have just started using Frida and I am not very familiar with how to correctly convert or generate data types in scripts. Before submitting an issue, I searched a lot of documents and web pages and could not find more information to solve the problem. Therefore, I have to come here to ask questions. I apologize for any inconvenience caused

Java code :

`

    ArrayList<String> list = new ArrayList<>();
    list.add("a");
    list.add("b");
    list.add("c");
    list.add("d");
    String[] arr = list.toArray(new String[0]);
    System.out.println(Arrays.toString(arr)); // --> [Ljava.lang.String;@36d64342  This kind of data is what I need

`

frida script code:


`

    var ArrayList = Java.use('java.util.ArrayList');
    var String = Java.use('java.lang.String');
    var Objects = Java.use('java.lang.Object')
    var list = ArrayList.$new();
    list.add("a");
    list.add("b");
    list.add("c");
    list.add("d");

    // console.log(Objects.$new()); ---> java.lang.Object@7d60079 -> This kind of data is what I need
    // console.log(list.toArray(Objects.$new())); ---> Error: toArray(): argument types do not match any of: 
    // .overload('[Ljava.lang.Object;')
    // console.log(Java.cast(list.toArray(),Objects.$new())); ---> Error: expected a pointer
    // console.log(list.toArray(String.$new()));  --> TypeError: not a function
    // console.log(Java.cast(list.toArray(),String)); ---> Error: expected a pointer
    // console.log(Java.cast(list.toArray(),String.$new())); ---> expected a pointer

`

I have tried all the methods I know that may have implemented the Java code above in the frida script, but
they have all failed. If anyone knows and can tell me, I would greatly appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant