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.05k stars 203 forks source link

C# typeof operator invocation #480

Closed commonuserlol closed 10 months ago

commonuserlol commented 10 months ago

There's method which consumes System.Type as argument, when in 'normal' C# it looks like

method(typeof(Klass));

Can i somehow invoke typeof operator? (Yes there's another overload with T method(); and i still remember how to work with it, but i'm interested in typeof)

Flechaa commented 10 months ago

For that case you need to somehow get the Il2Cpp.Class of the the type then inflate it, and invoke the method. If you have an Il2Cpp.Object then you can get the class that way or you could simply find the class in the assembly.

commonuserlol commented 10 months ago

wdym? I need get type of class, to pass to method (for example: UnityEngine.Component GetComponent(System.Type type);)

vfsfitvnm commented 10 months ago
const klass: Il2Cpp.Class = ...
const managedType: Il2Cpp.Object = klass.type.object; // a System.Type