Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:WinRT metadata (WinMD)

From ReverseEngineering.wiki
Format
Developer Microsoft
Magic 42 53 4A 42 ('BSJB') metadata root inside a PE file
Extensions .winmd
Endianness little
On this wiki Facts · Code · Notes · Topics

A .winmd file is an ECMA-335 metadata image (no IL) that describes Windows Runtime types; the windowsruntime flag on types and assemblies, the Windows.* namespaces and the attributes that carry GUIDs, activation and factories tell a reader what a WinRT binary can call.

Identification

A .winmd is a PE file whose CLR header points to ECMA-335 metadata (Format:.NET metadata (ECMA-335)): the same BSJB root, #~ tables, #Strings, #GUID and #Blob heaps, with no IL bodies for interfaces. windows-rs's metadata reader checks the same signature constant, 0x424A5342, at the start of the metadata (crates/libs/metadata/src/reader/file.rs). Windows ships the platform metadata in C:\Windows\System32\WinMetadata\*.winmd (Windows.Foundation.winmd, Windows.UI.winmd, ...) (Unverified here); windows-rs checks Windows.winmd and Windows.Win32.winmd into crates/libs/default.

The windowsruntime flag

Two flags separate WinRT from plain .NET or Win32 metadata: TypeAttributes.WindowsRuntime = 0x4000 on a TypeDef row and AssemblyFlags.WindowsRuntime = 0x200 on the Assembly row (windows-rs crates/libs/metadata/src/attributes.rs lines 43 and 106). windows-rs's bindgen treats a type as WinRT only when the TypeDef has the 0x4000 flag, and then sorts it into class, delegate, enum or interface by category (crates/libs/bindgen/src/winmd/reader.rs, near line 79); other types are Win32 entries (see below).

What the metadata gives a reverser

  • Fully qualified type names (Windows.Foundation.Uri): these are exactly the strings passed as HSTRING to RoGetActivationFactory (see Platform:Windows Runtime).
  • Interface identity: each interface has a GuidAttribute custom attribute with its IID, so an IID found in .rdata maps back to a name.
  • Method order: the order of MethodDef rows of an interface is the vtable order after the three IInspectable slots (first method = slot 6).
  • Runtime classes list their default and other interfaces through InterfaceImpl rows; the attribute names Unverified for this page: ActivatableAttribute, StaticAttribute, ExclusiveToAttribute, ContractVersionAttribute and DefaultAttribute tell which factory interface creates the class.
  • Parameterized (generic) interfaces such as IVector<T> have a computed IID derived from the type signature, not a stored one. Unverified: the algorithm is a UUID v5 hash over the signature string; windows-rs RuntimeType SIGNATURE constants (e.g. cinterface(IInspectable)) are the input.

Win32 metadata

microsoft/win32metadata (MIT) produces Windows.Win32.winmd with the same container but Win32 semantics: DllImport for functions, [SupportedArchitecture] for per-architecture types, [In], [Out], [Optional], [ComOutPtr] and [Documentation] attributes (docs/projections.md). Its COM interfaces are TypeDefs with a GUID attribute too, so it is a machine-readable source of IIDs and vtable orders for classic COM (Direct3D, DXGI, shell). Projections: windows-rs (Rust), CsWin32 (C#), and community ones. A JSON translation exists in marlersoft/win32json (as linked from the same document; not read).

Parsing

Any ECMA-335 reader works (System.Reflection.Metadata, dnlib, windows-rs windows-metadata). For tables and heaps see Format:.NET metadata (ECMA-335)/Tables.

Related

Technique:Reading COM and WinRT code, Format:COM type library (TLB).

Code & repositories

  • https://github.com/microsoft/windows-rs @ 20f6de7473ebb2761a19a73dcc2c25ac9499db6e · license: MIT OR Apache-2.0 (declared by the contributor for the files used; GitHub reports Apache-2.0 for the repository)
    Rust bindings for Windows: crates/libs/metadata (winmd reader, WindowsRuntime flags), strings (HSTRING header), core (IInspectable, activation factory cache).
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-18
  • https://github.com/microsoft/win32metadata @ 8de8a7b9f47e1bb99550242690ca63c98dfb8fbf · license: MIT (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE; GitHub's detector did not classify it) for the repository)
    Win32 metadata: Windows.Win32.winmd and docs/projections.md (attributes such as SupportedArchitecture, ComOutPtr, DllImport conventions); machine-readable IIDs and vtable orders of classic COM.
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-18