Ever since mid-2023, Microsoft has been making a conscious effort to integrate Rust more and more into Windows. First Windows was able to boot with Rust in its kernel, and more recently, the company has been making moves to get driver developers to write using the language.
In July Microsoft shared some of the initial details about how the Surface team at the company was helping in this area with the creation of the new open-source windows-drivers-rs project which is essentially a platform meant to help with Windows driver development in Rust.
Following that, today, the company has released more details about the progress it is making. To help make Rust drivers easier, and like how it is on C, the company has introduced a new cargo-wdk crate as part of windows-drivers-rs. This Cargo extension generates empty driver projects with preconfigured linkage, build steps, and dependencies, and can invoke WDK tools such as InfVerif, similar to how it is when building a driver in C in Visual Studio.
For those wondering what the deal is about Rust, the language provides memory safety unlike traditional programming languages like C, such that memory-related security vulnerabilities can be shut out; plus it offers excellent C/C++ driver code interoperability as well, making the transition easier.
Microsoft says that the long-term aim is to provide Rust developers in a Cargo environment with the same build tools and configuration options available in Visual Studio, while medium-term plans include automatic WDK installation, NT_TARGET_VERSION support, full ARM64 support, and more.
Currently, Microsoft notes that windows-drivers-rs enables certain driver types in Rust but still requires significant use of unsafe code. The tech giant has also highlighted how the Windows Driver Framework (WDF) team is working with Rust experts to design safer abstractions for KMD (kernel mode drivers) and UMD (user mode drivers). Other Microsoft teams are developing safe structs and APIs beyond WDF for both core kernel and third-party driver development. Some of these are already shipping in the Windows kernel.
For those not familiar, abstraction essentially implies a safe way to switch from the user mode to the kernel mode. The latter is the most privileged while the former is the least privileged.
Finally, Microsoft says that over the coming months it will share more information regarding the best practices on driver development, one of which is using CodeQL for static analysis. If you recall, earlier in July, Microsoft had updated its guidance for third-party driver static analysis for Windows 11 version 25H2.
You can find the blog post here on Microsoft"s official Tech Community website.