clrmeta 0.1.0

ECMA-335 CLI/.NET metadata parsing library with read/write support
Documentation
  • Coverage
  • 80%
    464 out of 580 items documented0 out of 118 items with examples
  • Size
  • Source code size: 226.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 28.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • coconutbird/clrmeta
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • coconutbird

clrmeta

ECMA-335 CLI/.NET metadata parsing library for Rust.

Crates.io Documentation License: MIT

Installation

Add to your Cargo.toml:

[dependencies]

clrmeta = "0.1"

Features

  • Parse BSJB metadata root and stream headers
  • Access heaps: #Strings, #US, #GUID, #Blob
  • Parse metadata tables: Module, TypeDef, TypeRef, MethodDef, Assembly, AssemblyRef, etc.
  • High-level API for common queries (assembly info, types, methods)
  • No PE dependency - works with raw metadata bytes

Usage

use clrmeta::Metadata;

// Parse metadata from raw bytes (e.g., from PE's CLR data directory)
let metadata = Metadata::parse(&metadata_bytes)?;

println!("Runtime version: {}", metadata.version());

if let Some(assembly) = metadata.assembly() {
    println!("Assembly: {} v{}.{}.{}.{}",
        assembly.name,
        assembly.version.0, assembly.version.1,
        assembly.version.2, assembly.version.3);
}

for type_def in metadata.types() {
    println!("Type: {}", type_def.full_name());
}

Integration with portex

This crate is designed to work with portex for parsing .NET assemblies from PE files:

use portex::PE;
use clrmeta::Metadata;

let pe = PE::from_file("example.exe")?;

if let Some(cli_header) = pe.cli_header()? {
    let metadata_bytes = pe.read_at_rva(
        cli_header.metadata_rva,
        cli_header.metadata_size as usize
    ).unwrap();
    
    let metadata = Metadata::parse(metadata_bytes)?;
    // ...
}

References

License

MIT