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

Il2Cpp.Thread::schedule error #276

Closed commonuserlol closed 1 year ago

commonuserlol commented 1 year ago

hello, i need the function to be executed in another thread (asynchronously), otherwise the game will freeze for 1-2 seconds. Il2Cpp.Thread::schedule throws an error il2cpp: couldn't find GetDisplayName in Runtime, did you mean .cctor? my code:

Il2Cpp.perform(() => {
        const AssemblyCSharp = Il2Cpp.Domain.assembly("Assembly-CSharp").image;
        AssemblyCSharp.class("Axlebolt.Standoff.Game.GameController").method("AGAADFEAHGCGFBH").implementation = function (event: Il2Cpp.Object, player: Il2Cpp.Object) {
            this.method("AGAADFEAHGCGFBH").invoke(event, player);
            Il2Cpp.currentThread?.schedule(() => {
                console.log("hello");
            }, 1000);
        }
    });

unity version: 2021.3.16f1 android: 12.1

vfsfitvnm commented 1 year ago

Thanks for reporting! In order to being able to schedule a callback into another thread, I need to choose a simple (static, no parameters) , unused-ish method to use as trampoline. I designated Mono.Runtime::GetDisplayName as such; however that game is also using Mono now (?), and it looks like that class is different. So, I'm just fallbacking to .cctor in case GetDisplayName isn't available.