Skip to main content

Module metadata

Module metadata 

Source
Expand description

global-metadata.dat: names and the shape of every type, method and field.

Types of fields, parameters and return values are indices into the Il2CppType table, which lives in the game binary, not in this file.

Three metadata versions are supported:

  • v29 (Unity 2021.2 – 2023.x): header entries are (offset, size) pairs.
  • v31 (later Unity 2022.3 LTS / 2023.x): identical to v29 except the method record gained a returnParameterToken field (so each record is 4 bytes larger). The section list, header-entry size and all other record layouts match v29. Implemented from the Il2CppDumper/Il2CppInspector reference layouts; unverified against a real v31 game (none available).
  • v39 (Unity 6): each header entry also carries a record count, so the entries are 12 bytes. Several records shrank: type_definitions dropped element_type_index and narrowed generic_container_index; methods narrowed its middle index fields (moving parameter_start); images and assemblies were reordered; generic_parameters narrowed owner_index. The v39 layout was reverse-engineered and validated against real Unity 6 games (which ship Windows PE binaries, read via pewter’s PE support).
use hao_il2cpp::Metadata;

let metadata = Metadata::from_path("Game_Data/il2cpp_data/Metadata/global-metadata.dat")?;
println!("metadata v{}", metadata.version);
for image in &metadata.images {
    println!("{}:", metadata.image_name(image));
    for index in metadata.image_types(image) {
        let ty = &metadata.type_definitions[index as usize];
        println!("    {} ({} methods)", metadata.type_full_name(index), ty.method_count);
    }
}

Structs§

AssemblyDefinition
Il2CppAssemblyDefinition: an assembly’s identity and the image that holds it.
EventDefinition
Il2CppEventDefinition: an event and its accessors.
FieldDefaultValue
Il2CppFieldDefaultValue: a constant value for a field, stored in the default value data section.
FieldDefinition
Il2CppFieldDefinition: one field’s name and type.
GenericContainer
Il2CppGenericContainer: the generic parameter list of a generic type or method.
GenericParameter
Il2CppGenericParameter: one generic parameter, e.g. the T of List<T>.
ImageDefinition
Il2CppImageDefinition: one image (module) of the game, e.g. Assembly-CSharp.dll, and the range of type definitions it owns.
Metadata
A parsed global-metadata.dat: its tables, decoded, and its string and data sections, read on demand.
MethodDefinition
Il2CppMethodDefinition: one method’s name, signature and flags.
ParameterDefinition
Il2CppParameterDefinition: one method parameter’s name and type.
PropertyDefinition
Il2CppPropertyDefinition: a property and its accessors.
TypeDefinition
Il2CppTypeDefinition: one type’s name, flags, base type and the ranges of its members in the other tables.

Type Aliases§

TypeDefinitionIndex
An index into Metadata::type_definitions.
TypeIndex
An index into the binary’s Il2CppType table.