msft-typelib 0.1.0

Allocation-free parser for MSFT-format type library (.tlb) files
Documentation
  • Coverage
  • 100%
    81 out of 81 items documented2 out of 2 items with examples
  • Size
  • Source code size: 326.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 17.5 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • BinFlip/msft-typelib
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • BinFlip

msft-typelib

Allocation-free parser for MSFT-format type library (.tlb) files.

MSFT is the binary format used by Microsoft COM type libraries since the late 1990s. A type library describes the interfaces, coclasses, enumerations, and constants exposed by a COM component so that tools and languages can use them at compile time or runtime.

Features

  • Zero-allocation -- record types borrow directly from the input &[u8]; parsing requires no heap allocations beyond loading the file
  • Full format coverage -- parses all 13 active segments (TypeInfo, functions, variables, parameters, GUIDs, names, strings, type descriptors, array descriptors, imports, custom data, and more)
  • Type resolution -- resolves VT_PTR, VT_SAFEARRAY, VT_USERDEFINED, and VT_CARRAY type descriptor chains
  • Import resolution -- resolves external type references through the import-info and import-files tables
  • Custom data -- walks per-library, per-type, per-function, and per-variable custom attribute chains
  • Constant decoding -- decodes inline and segment-stored constants for 20+ VARTYPE codes

Quick start

let data = std::fs::read("library.tlb").unwrap();
let lib = msft_typelib::TypeLib::parse(&data)?;

println!("Name: {}", lib.lib_name().unwrap_or("?"));
println!("GUID: {}", lib.lib_guid().unwrap());
println!("Types: {}", lib.typeinfo_count());

for result in lib.typeinfos() {
    let ti = result?;
    let name = lib.name(ti.name_offset()).unwrap_or("?");
    println!("  {} {name}", ti.typekind());
}

Example

The included dump example prints a complete listing of a type library:

cargo run --example dump -- path/to/library.tlb

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.