vfsfitvnm / frida-il2cpp-bridge

A Frida module to dump, trace or hijack any Il2Cpp application at runtime, without needing the global-metadata.dat file.
https://github.com/vfsfitvnm/frida-il2cpp-bridge/wiki
MIT License
974 stars 199 forks source link

Method overloading by return value #287

Closed commonuserlol closed 1 year ago

commonuserlol commented 1 year ago

hello again, I found that the frida-il2cpp-bridge bugs when the method has a return value overload (also overloaded method dont have offset)

    static Newtonsoft.Json.Linq.JObject ParseJson(System.String json); // 0x010110b8
    static T ParseJson(System.String json);

il2cpp inspector dump

    public static JObject ParseJson(this string json);
    public static T ParseJson<T>(this string json);

in ida (with the script from il2cpp dumper applied) the method is displayed as JsonExtensions__ParseJson and JsonExtensions__ParseJson_User_ but methods cannot be overloaded by return value... why is this happening then? game: https://stumble-guys.en.uptodown.com/android/download/3202957 (v0.22)

vfsfitvnm commented 1 year ago

but methods cannot be overloaded by return value... why is this happening then?

Exactly, this is why I don't take the return value into account. This is how you should retrieve it:

const ParseJson = JsonExtensions.methods.find(_ => _.name == "ParseJson" && _.isGeneric)!;
commonuserlol commented 1 year ago

i was able to get the method but now another error il2cpp: cannot implement method ParseJson: it has a NULL virtual address

vfsfitvnm commented 1 year ago

That method is generic and thus doesn't have an actual address. You have to call inflate on it to possibly get a real method instance.

commonuserlol commented 1 year ago

ok but now i can't invoke method... Error: expected a pointer

    const User = AssemblyCSharp.class("User");
    const ParseJson = AssemblyCSharp.class("JsonExtensions").methods.find(_ => _.name == "ParseJson" && _.isGeneric)!.inflate(User);
    ParseJson.implementation = function(json: Il2Cpp.Object) {
        console.log(json)
        ParseJson.invoke(json);
    }
vfsfitvnm commented 1 year ago

You forgot the return keyword (you are returning undefined but Frida expects a NativePointerValue, i.e. the object returned by ParseJson)

commonuserlol commented 1 year ago

stupid mistake, sorry. thanks for the help, i'm closing this issue