pub struct Metadata {Show 15 fields
pub version: u32,
pub images: Vec<ImageDefinition>,
pub assemblies: Vec<AssemblyDefinition>,
pub type_definitions: Vec<TypeDefinition>,
pub methods: Vec<MethodDefinition>,
pub fields: Vec<FieldDefinition>,
pub parameters: Vec<ParameterDefinition>,
pub properties: Vec<PropertyDefinition>,
pub events: Vec<EventDefinition>,
pub generic_containers: Vec<GenericContainer>,
pub generic_parameters: Vec<GenericParameter>,
pub nested_types: Vec<TypeDefinitionIndex>,
pub interfaces: Vec<TypeIndex>,
pub generic_parameter_constraints: Vec<TypeIndex>,
pub field_default_values: Vec<FieldDefaultValue>,
/* private fields */
}Expand description
A parsed global-metadata.dat: its tables, decoded, and its string and
data sections, read on demand.
The public tables are the raw records, in file order; indices stored in
one record (e.g. TypeDefinition::method_start) index into these
vectors.
Fields§
§version: u32The metadata version: 29, 31 or 39.
images: Vec<ImageDefinition>Every image (module), e.g. Assembly-CSharp.dll.
assemblies: Vec<AssemblyDefinition>Every assembly, one per image.
type_definitions: Vec<TypeDefinition>Every type definition in the game, grouped by image; a TypeDefinitionIndex indexes this.
methods: Vec<MethodDefinition>Every method definition, grouped by declaring type.
fields: Vec<FieldDefinition>Every field definition, grouped by declaring type.
parameters: Vec<ParameterDefinition>Every method parameter, grouped by method.
properties: Vec<PropertyDefinition>Every property, grouped by declaring type.
events: Vec<EventDefinition>Every event, grouped by declaring type.
generic_containers: Vec<GenericContainer>Generic parameter lists of generic types and methods.
generic_parameters: Vec<GenericParameter>Every generic parameter; TypeKind::Var and MVar index this.
nested_types: Vec<TypeDefinitionIndex>Nested type lists, sliced by each type’s nested_types_start and nested_type_count.
interfaces: Vec<TypeIndex>Implemented interface lists, sliced by each type’s interfaces_start and interfaces_count.
generic_parameter_constraints: Vec<TypeIndex>Constraint type lists, sliced by each generic parameter’s constraints_start and constraints_count.
field_default_values: Vec<FieldDefaultValue>Constant values of const fields and enum members.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self>
Reads and parses a global-metadata.dat file.
Sourcepub fn parse(data: Vec<u8>) -> Result<Self>
pub fn parse(data: Vec<u8>) -> Result<Self>
Parses global-metadata.dat from its bytes, decoding every table.
Fails with Error::BadSanity if it isn’t IL2CPP metadata,
Error::UnsupportedVersion for a version other than 29, 31 or 39,
and Error::BadSection if the header is inconsistent with the file.
Sourcepub fn type_name(&self, index: TypeDefinitionIndex) -> &str
pub fn type_name(&self, index: TypeDefinitionIndex) -> &str
A type definition’s own name, without namespace or declaring type.
Panics if index is out of range.
Sourcepub fn type_full_name(&self, index: TypeDefinitionIndex) -> String
pub fn type_full_name(&self, index: TypeDefinitionIndex) -> String
Namespace.Name, with / separating nested types.
Sourcepub fn find_type(&self, ty: impl TypeName) -> Option<TypeDefinitionIndex>
pub fn find_type(&self, ty: impl TypeName) -> Option<TypeDefinitionIndex>
The index of the top-level type definition named ty, e.g.
metadata.find_type(WellKnown::System(SystemType::String)) or
metadata.find_type(("System", "String")).
Sourcepub fn declaring_type_definition(
&self,
index: TypeDefinitionIndex,
) -> Option<TypeDefinitionIndex>
pub fn declaring_type_definition( &self, index: TypeDefinitionIndex, ) -> Option<TypeDefinitionIndex>
The enclosing type definition, found through the nested type lists.
Sourcepub fn image_name(&self, image: &ImageDefinition) -> &str
pub fn image_name(&self, image: &ImageDefinition) -> &str
An image’s file name, e.g. Assembly-CSharp.dll.
Sourcepub fn image_types(&self, image: &ImageDefinition) -> Range<TypeDefinitionIndex> ⓘ
pub fn image_types(&self, image: &ImageDefinition) -> Range<TypeDefinitionIndex> ⓘ
Type definition indices belonging to image.
Sourcepub fn type_methods(&self, t: &TypeDefinition) -> &[MethodDefinition]
pub fn type_methods(&self, t: &TypeDefinition) -> &[MethodDefinition]
The methods a type declares; empty if its range is out of bounds.
Sourcepub fn type_fields(&self, t: &TypeDefinition) -> &[FieldDefinition]
pub fn type_fields(&self, t: &TypeDefinition) -> &[FieldDefinition]
The fields a type declares; empty if its range is out of bounds.
Sourcepub fn default_value_data(&self, index: i32) -> &[u8] ⓘ
pub fn default_value_data(&self, index: i32) -> &[u8] ⓘ
Bytes of the default value data section from index on.
Sourcepub fn generic_container_parameters(
&self,
container: i32,
) -> &[GenericParameter]
pub fn generic_container_parameters( &self, container: i32, ) -> &[GenericParameter]
The generic parameters of a GenericContainer, by index into
Metadata::generic_containers (e.g. a type’s generic_container_index);
empty for -1.
Sourcepub fn method_parameters(&self, m: &MethodDefinition) -> &[ParameterDefinition]
pub fn method_parameters(&self, m: &MethodDefinition) -> &[ParameterDefinition]
A method’s parameters, in order; empty if its range is out of bounds.
Sourcepub fn attribute_data_ranges(&self) -> Vec<(u32, u32)>
pub fn attribute_data_ranges(&self) -> Vec<(u32, u32)>
The (token, start_offset) entries of the attribute_data_range section
(v29+). Each start_offset indexes into Metadata::attribute_data; a
range ends where the next entry begins, as the section is laid out in global
offset order (Il2CppCustomAttributeDataRange).
Sourcepub fn attribute_data(&self) -> &[u8] ⓘ
pub fn attribute_data(&self) -> &[u8] ⓘ
The raw attribute_data blob holding v29+ custom attribute values.