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: u32Row 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: TokenMetadata 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: usizeByte 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: u32Generation 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: u32Raw 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: u32Raw 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: u32Raw 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: u32Raw 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
impl ModuleRaw
pub fn to_owned(
&self,
strings: &Strings<'_>,
guids: &Guid<'_>,
) -> Result<ModuleRc>
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 nameguids- 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<()>
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<'a> RowDefinition<'a> for ModuleRaw
impl<'a> RowDefinition<'a> for ModuleRaw
§fn row_size(sizes: &TableInfoRef) -> u32
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>
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:
- Generation (2 bytes): Reserved field, always zero
- Name (2-4 bytes): Index into string heap containing module name
- Mvid (2-4 bytes): Index into GUID heap containing module version identifier
- EncId (2-4 bytes): Index into GUID heap for Edit and Continue
- EncBaseId (2-4 bytes): Index into GUID heap for ENC base
§Arguments
data- Binary data containing the tableoffset- 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§
impl Freeze for ModuleRaw
impl RefUnwindSafe for ModuleRaw
impl Send for ModuleRaw
impl Sync for ModuleRaw
impl Unpin for ModuleRaw
impl UnwindSafe for ModuleRaw
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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