Paul Krill
Editor at Large

Microsoft paves the way to Windows APIs

news
Jan 26, 20212 mins

Win32 Metadata project aims to enable automated projections of valid Windows API signatures for C#, C++, Rust, and other languages.

road to future forward idea cloud road
Credit: Thinkstock

Microsoft with its Win32 Metadata project is looking to make Windows APIs more accessible to more languages, by producing metadata for the APIs. Languages such as Rust, C#, and C++ are early beneficiaries of this project.

The Win32 Metadata project, with repos on GitHub, aims to provide a complete description of the WinAPI, allowing it to be projected to any language in an automated way, thus improving correctness and minimizing maintenance overload. The output of the project is an ECMA 335-compliant Windows metadata file published to Nuget.org. Accurately describing all of the Windows APIs will take time, however, so plans also call for developing tools to assist with the project.

One such project is C#/Win32, which parses metadata and generates P/Invoke wrappers required to call APIs. An early example of what can be done with dynamic projections of Win32 APIs, C#/Win32 offers IntelliSense capabilities as well as strong types for parameters. Similarly, Rust for Windows is a Rust language projection that lets Rust developers call any Windows API using code generated on the fly via metadata. APIs can be called as if they were just another Rust module. Also in development is a Modern C++ projection. A roadmap for the Win32 Metadata project has C#, C++, and Rust projects being published in 2022, after a preview this year.

Microsoft will work with the community to support other languages based on demand. The project has published a set of principles and goals including maximum API coverage. Microsoft said that while Win32 APIs are readily accessible to C and C++, other languages such as C# and Rust need wrappers or bindings to access them. Developers have been forced to handcraft these wrappers or bindings, a process that is both error-prone and scattershot.

While there have been projects such as Pinvoke for .NET and winapi-rs for Rust that offer more strongly typed and idiomatic representations of these bindings and wrappers, broad and sustained API coverage has been costly and difficult. With the Win32 Metadata project, Microsoft hopes to provide broad and sustainable API coverage across languages.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author