> module
std::re::dotnet::il2cpp
read Unity Il2Cpp games
std::re::dotnet::il2cpp reads the type metadata of a Unity game built with Il2Cpp: its global-metadata.dat and its GameAssembly binary. Game is the entry point; it gives every type, field and method by name, and can generate .NET declaration assemblies to compile mods against.
TypeView is a handle on one type of the game. FieldView and MethodView are snapshots of a field or method; printing one shows a C#-like declaration such as static string Concat(string str0, string str1). Type names are C#-like too, such as List<int>.
Backed by hao-il2cpp.
> functions
Read a game from the contents of those two files.
Open a game from the paths of its global-metadata.dat and GameAssembly binary.
> types
field_view.constant() -> Option<ConstantValue>The field's compile-time constant (enum members and const fields), if it has one.
field_view.is_static() -> boolWhether the field is static.
len bytes of the GameAssembly binary at virtual address vaddr, such as a method's code_address(); None if they aren't mapped.
The type with full name name, such as "UnityEngine.GameObject", "Outer/Nested" or "List`1".
The virtual address of the method's native code in the GameAssembly binary, if known. Read it with Game.bytes_at().
method_view.is_static() -> boolWhether the method is static.
The parameter type names, in order, such as ["string",\"int"].
The base type's name, such as "UnityEngine.MonoBehaviour", if it has one.
For an enum, each member's name and value; empty for other types.
type_view.find_method(name: str) -> Option<MethodView>The first method named name; use methods() to see every overload.
The type's TypeAttributes as an integer; see dotnet::type_attributes_names().
type_view.methods() -> list<MethodView>The type's methods, overloads included.
> examples
use std::io;
use std::re::dotnet::il2cpp;
fn main() -> Result<(), str> {
let game = il2cpp::open("path/to/game")?;
for ty in game.types() {
io::println("{}", ty.full_name());
for method in ty.methods() {
io::println(" {}", method);
}
}
game.write_assemblies("out")?;
Ok(())
}