Struct ModuleRaw

pub struct ModuleRaw {
    pub rid: u32,
    pub token: Token,
    pub offset: usize,
    pub generation: u32,
    pub name: u32,
    pub mvid: u32,
    pub encid: u32,
    pub encbaseid: u32,
}
Expand description

Raw representation of a Module table entry with unresolved indexes.

This structure represents the unprocessed entry from the Module metadata table (ID 0x00), which provides information about the current module including its name, GUID (Mvid), and generation. It contains raw index values that require resolution to actual metadata objects.

§Purpose

The Module table serves as the foundational identity table for .NET assemblies:

  • Provides module name and unique identifier (Mvid)
  • Contains generation and Edit and Continue information
  • Always contains exactly one row per PE file
  • Serves as an anchor for other metadata references

§Raw vs Owned

This raw variant is used during initial metadata parsing and contains:

  • Unresolved heap indexes requiring lookup
  • Minimal memory footprint for storage
  • Direct representation of file format

Use Module for resolved references and runtime access.

§ECMA-335 Reference

Corresponds to ECMA-335 §II.22.30 Module table structure.

Fields§

§rid: u32

Row identifier within the Module table.

This is always 1 since the Module table contains exactly one row per PE file. Combined with table ID 0x00, forms the metadata token 0x00000001.

§token: Token

Metadata token for this Module entry.

Always 0x00000001 since this is the unique module entry. Used for cross-referencing this entry from other metadata structures.

§offset: usize

Byte offset of this entry in the original metadata stream.

Points to the start of this entry’s data in the metadata file. Used for debugging and low-level metadata inspection.

§generation: u32

Generation number for this module.

A 2-byte value that is reserved and shall always be zero according to ECMA-335 §II.22.30. Reserved for future versioning schemes.

§name: u32

Raw index into the string heap containing the module name.

This unresolved index identifies the module name string in the #Strings heap. Must be resolved using the string heap to get the actual module name. Index size depends on string heap size (2 or 4 bytes).

§mvid: u32

Raw index into the GUID heap containing the module version identifier.

This unresolved index identifies the Mvid GUID in the #GUID heap. The Mvid is used to distinguish between different versions of the same module. Must be resolved using the GUID heap to get the actual GUID. Index size depends on GUID heap size (2 or 4 bytes).

§encid: u32

Raw index into the GUID heap for Edit and Continue identifier.

This reserved field is typically 0 and points to the #GUID heap when present. Used for Edit and Continue scenarios during development. Index size depends on GUID heap size (2 or 4 bytes).

§encbaseid: u32

Raw index into the GUID heap for Edit and Continue base identifier.

This reserved field is typically 0 and points to the #GUID heap when present. Used for Edit and Continue base version tracking during development. Index size depends on GUID heap size (2 or 4 bytes).

Implementations§

§

impl ModuleRaw

pub fn to_owned( &self, strings: &Strings<'_>, guids: &Guid<'_>, ) -> Result<ModuleRc>

Converts this raw entry to an owned Module with resolved references.

This method resolves the raw heap indexes to actual string and GUID data, creating a fully usable Module instance for runtime access. The module serves as the fundamental identity anchor for the entire assembly.

§Arguments
  • strings - The string heap for resolving the module name
  • guids - The GUID heap for resolving module and ENC identifiers
§Returns

A reference-counted ModuleRc containing the resolved module entry.

§Errors
  • String heap entry cannot be resolved or is malformed
  • GUID heap entries cannot be resolved or are malformed
  • Heap indexes are out of bounds
  • Data corruption is detected

pub fn apply(&self) -> Result<()>

Applies a Module entry to update related metadata structures.

Module entries define the module information for the current assembly and are self-contained metadata descriptors. They don’t require cross-table updates during the dual variant resolution phase as they serve as identity anchors rather than references to other tables.

This method is provided for consistency with the metadata loading architecture but performs no operations since modules are identity tables.

§Returns

Always returns Ok(()) as Module entries don’t modify other tables.

Trait Implementations§

§

impl Clone for ModuleRaw

§

fn clone(&self) -> ModuleRaw

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ModuleRaw

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<'a> RowDefinition<'a> for ModuleRaw

§

fn row_size(sizes: &TableInfoRef) -> u32

Calculates the byte size of a Module table row.

The row size depends on the metadata heap sizes and is calculated as:

  • generation: 2 bytes (fixed)
  • name: 2 or 4 bytes (depends on string heap size)
  • mvid: 2 or 4 bytes (depends on GUID heap size)
  • encid: 2 or 4 bytes (depends on GUID heap size)
  • encbaseid: 2 or 4 bytes (depends on GUID heap size)
§Arguments
  • sizes - Table size information for calculating heap index widths
§Returns

Total byte size of one table row

§

fn read_row( data: &'a [u8], offset: &mut usize, rid: u32, sizes: &TableInfoRef, ) -> Result<Self>

Reads a single Module table row from binary data.

Parses the binary representation according to ECMA-335 §II.22.30:

  1. Generation (2 bytes): Reserved field, always zero
  2. Name (2-4 bytes): Index into string heap containing module name
  3. Mvid (2-4 bytes): Index into GUID heap containing module version identifier
  4. EncId (2-4 bytes): Index into GUID heap for Edit and Continue
  5. EncBaseId (2-4 bytes): Index into GUID heap for ENC base
§Arguments
  • data - Binary data containing the table
  • offset - Current read position (updated by this method)
  • rid - Row identifier for this entry (always 1 for Module table)
  • sizes - Table size information for proper index width calculation
§Returns

Parsed ModuleRaw instance with populated fields

§Errors
  • Insufficient data remaining at offset
  • Data corruption or malformed structure
  • Invalid heap index values

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.