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
1.03k stars 202 forks source link

same function name different return type, how to specify which function call to make? #175

Closed qingpengchen2011 closed 2 years ago

qingpengchen2011 commented 2 years ago

Here are the functions: System.Collections.Generic.Dictionary.KeyCollection<System.Int32,RC.Game.ClassA> get_Keys(); // 0x00f16ae0 System.Collections.Generic.ICollection System.Collections.Generic.IDictionary<TKey,TValue>.get_Keys(); // 0x00f16b68

How can I make the call the function at 0x00f16b68(second function)

vfsfitvnm commented 2 years ago

My shot is the two functions are actually the same: 0x00f16ae0 calls 0x00f16b68 (in fact, System.Collections.Generic.Dictionary.KeyCollection implements System.Collections.Generic.ICollection). So it's irrelevant the one you pick.

Could you verify that?

qingpengchen2011 commented 2 years ago

Thanks for your reply. You're right. I've verified that. Would you please tell me how to iterate a System.Collections.Generic.Dictionary. Even thourgh I can do it by a very tricky way. Here is my code:

    const entries = upgradeInfoDict.field<Il2Cpp.Array<Il2Cpp.Object>>("entries").value;
    const count = upgradeInfoDict.method<number>("get_Count").invoke();
    for (var i = 0; i < count; i++) {
        const entry = entries.get(i);
        const key = entry.field<number>("key").value;
        const value = entry.field<Il2Cpp.Object>("value").value;
    }

The type of upgradeInfoDict is System.Collections.Generic.Dictionary<System.Int32,RC.Game.ClassA>

vfsfitvnm commented 2 years ago

Sure, you can look at here and here (see last snippet). These snippets use an old version, but you can easily adapt them to the newest one!