Skip to main content

Metadata

Struct Metadata 

Source
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: u32

The 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

Source

pub fn from_path(path: impl AsRef<Path>) -> Result<Self>

Reads and parses a global-metadata.dat file.

Source

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.

Source

pub fn string(&self, index: u32) -> &str

A string from the #Strings-like string section.

Source

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.

Source

pub fn type_full_name(&self, index: TypeDefinitionIndex) -> String

Namespace.Name, with / separating nested types.

Source

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")).

Source

pub fn declaring_type_definition( &self, index: TypeDefinitionIndex, ) -> Option<TypeDefinitionIndex>

The enclosing type definition, found through the nested type lists.

Source

pub fn image_name(&self, image: &ImageDefinition) -> &str

An image’s file name, e.g. Assembly-CSharp.dll.

Source

pub fn image_types(&self, image: &ImageDefinition) -> Range<TypeDefinitionIndex> ⓘ

Type definition indices belonging to image.

Source

pub fn type_methods(&self, t: &TypeDefinition) -> &[MethodDefinition]

The methods a type declares; empty if its range is out of bounds.

Source

pub fn type_fields(&self, t: &TypeDefinition) -> &[FieldDefinition]

The fields a type declares; empty if its range is out of bounds.

Source

pub fn default_value_data(&self, index: i32) -> &[u8] ⓘ

Bytes of the default value data section from index on.

Source

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.

Source

pub fn method_parameters(&self, m: &MethodDefinition) -> &[ParameterDefinition]

A method’s parameters, in order; empty if its range is out of bounds.

Source

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).

Source

pub fn attribute_data(&self) -> &[u8] ⓘ

The raw attribute_data blob holding v29+ custom attribute values.

Trait Implementations§

Source§

impl<'ʄ> Facet<'ʄ> for Metadata

Available on crate feature reflect only.
Source§

const SHAPE: &'static Shape

The shape of this type, including: whether it’s a Struct, an Enum, something else? Read more

Auto Trait Implementations§

§

impl Forget for Metadata

§

impl Freeze for Metadata

§

impl Move for Metadata

§

impl RefUnwindSafe for Metadata

§

impl Send for Metadata
where RawVecInner: Send, RawTable<(&'static str, (usize, usize))>: Send,

§

impl Sync for Metadata
where RawVecInner: Sync, RawTable<(&'static str, (usize, usize))>: Sync,

§

impl Unpin for Metadata
where *const u8 is !null: Unpin, &'static str: Unpin,

§

impl UnsafeUnpin for Metadata

§

impl UnwindSafe for Metadata
where RawVecInner: UnwindSafe, HashMap<&'static str, (usize, usize)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.