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
946 stars 194 forks source link

question about static method #388

Closed m2k2v closed 11 months ago

m2k2v commented 11 months ago

hello everyone I am trying to run the following C# code using Frida. Thank you for your help, because I have an error somewhere in the process.

DialogBoxManager.Get<MessageBox>(null).Open("msg", "msg2", 9, MessageType.Info);

In this code, MessageType is an inamorator.

Also, the classes are entered in Farida's code as follows:

const AppNameCore = Il2Cpp.domain.assembly("AppName.Core").image const DialogBoxManager = AppNameCore.class("AppName.Core.Dialogs.DialogBoxManager") const MessageBox = AppNameCore.class("AppName.Core.Dialogs.MessageBox")

The codes I tried to run:

const tmp = DialogBoxManager.alloc() tmp.method(".ctor").invoke() tmp.method("Get").invoke() and const get = DialogBoxManager.new().method("Get") and Il2Cpp.gc.choose(DialogBoxManager)[0].method("Get").invoke()

The error I got every time: cannot access static method AppName.Core.Dialogs.DialogBoxManager::Get from an object, use a class instead

vfsfitvnm commented 11 months ago

What's DialogBoxManager? Can you print it?

m2k2v commented 11 months ago

What's DialogBoxManager? Can you print it?

No, It's a Class public class DialogBoxManager : MonoBehaviour

In fact, I want to use a piece of code from the older versions of the game that was easy to read by DnSpy, with the help of frida-il2cpp-bridge, to the new version where I need it.

vfsfitvnm commented 11 months ago

Would you run console.log(DialogBoxManager.toString())?

m2k2v commented 11 months ago

No need to call new for static method

const get = DialogBoxManager.method("Get");
get.invoke() 

I tried it firat as all

thinhbuzz commented 11 months ago

No need to call new for static method

const get = DialogBoxManager.method("Get");
get.invoke() 

I tried it firat as all

and have you done inflate with MessageBox? Generic method need to inflate before invoke

m2k2v commented 11 months ago

Would you run console.log(DialogBoxManager.toString())?

Sure!

class AppName.Core.Dialogs.DialogBoxManager : UnityEngine.MonoBehaviour { UnityEngine.Canvas canvas; // 0xc System.String defaultDialogName; // 0x10 AppName.Core.Dialogs.DialogBoxManager.DialogBoxDescriptor[] dialogs; // 0x14 System.Collections.Generic.Stack<AppName.Core.Dialogs.DialogBox> dialogBoxStack; // 0x18 static AppName.Core.Dialogs.DialogBoxManager <current>k__BackingField; // 0x0 static AppName.Core.Dialogs.DialogBoxManager get_current(); // 0x008d6e54 static System.Void set_current(AppName.Core.Dialogs.DialogBoxManager value); // 0x008d6ea8 static T Get(System.String name); static T HandleBackStackOnOpening(T dialog); System.Boolean EscapeCurrentDialogBox(); // 0x008d6f08 System.Void Awake(); // 0x008d7024 System.Void OnDestroy(); // 0x008d7084 System.Void .ctor(); // 0x008d70e4

m2k2v commented 11 months ago

No need to call new for static method

const get = DialogBoxManager.method("Get");
get.invoke() 

I tried it firat as all

and have you done inflate with MessageBox? Generic method need to inflate before invoke

No I didn't

m2k2v commented 11 months ago

How should I invoke/inflate Get\<MessageBox>? I mean what's different between Get and Get\<MessageBox> for invoke/inflate?

thinhbuzz commented 11 months ago
DialogBoxManager.Get<MessageBox>(null).Open("msg", "msg2", 9, MessageType.Info);

This is generic method and need inflate

const get = DialogBoxManager.method("Get").inflate(MessageBox) ;
get.invoke()
DialogBoxManager.Demo(MessageBox ).Open("msg", "msg2", 9, MessageType.Info);

For ex, this method isnt generic so just invoke

const get = DialogBoxManager.method("Demo");
get.invoke() 
vfsfitvnm commented 11 months ago

FYI: https://stackoverflow.com/questions/60871222/what-is-an-inflated-type

m2k2v commented 11 months ago

and how about MessageType ? how to call info from Enum ?

vfsfitvnm commented 11 months ago

Please use the "search" GitHub feature