winmd 6.1.0 copy "winmd: ^6.1.0" to clipboard
winmd: ^6.1.0 copied to clipboard

A Dart package for working with Windows Metadata (.winmd) files.

ci Package: winmd Publisher: halildurmus.dev Language: Dart License: BSD-3-Clause codecov

A package that provides a Dart language abstraction over Windows Metadata (WinMD) files, making it possible to load them and build Dart FFI interop libraries from the results.

It can be used to query Windows developer APIs, encompassing both unmanaged APIs like Win32 or COM, as well as modern APIs like Windows Runtime (WinRT) that include their own metadata.

Architecture #

Architecture diagram

Usage #

A simple example that loads the MessageBoxW function and prints out its parameters and return type:

import 'package:winmd/winmd.dart';

void main() async {
  // Load the Win32 metadata.
  final scope = await MetadataStore.loadWin32Scope();

  // Find a namespace.
  final namespace =
      scope.findTypeDef('Windows.Win32.UI.WindowsAndMessaging.Apis')!;

  // Sort the functions alphabetically.
  final sortedMethods =
      namespace.methods..sort((a, b) => a.name.compareTo(b.name));

  // Find a specific function.
  const funcName = 'MessageBoxW';
  final method = sortedMethods.firstWhere((m) => m.name == funcName);

  // Print out some information about it.
  print('Win32 function $funcName [token #${method.token}]');

  // Retrieve its parameters and project them into Dart FFI types.
  final params = method.parameters
      .map(
        (param) => '${param.typeIdentifier.name.split('.').last} ${param.name}',
      )
      .join(', ');
  print('The parameters are:\n  $params');

  final returnType = method.returnType.typeIdentifier.name.split('.').last;
  print('It returns type: $returnType.');

  MetadataStore.close();
}
copied to clipboard

More examples can be found in the example subdirectory.

Packages built on winmd #

  • win32: provides Dart FFI bindings to the Win32 API, allowing you to call unmanaged Windows APIs using Dart types.

Feature requests and bugs #

Please file feature requests and bugs at the issue tracker.

9
likes
160
points
538
downloads

Publisher

verified publisherhalildurmus.dev

Weekly Downloads

2024.09.16 - 2025.03.31

A Dart package for working with Windows Metadata (.winmd) files.

Repository (GitHub)
View/report issues
Contributing

Topics

#winmd #windows #metadata

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

archive, ffi, logging, nuget, path

More

Packages that depend on winmd