Rust in the Windows Kernel: Microsoft's 2026 Safety Push

RustifyRustifyThe Rustify team
Rust in Windows Kernel

By Rustify Team, updated March 2026

TL;DR: Microsoft has been shipping Rust code in Windows since 2023. The Windows kernel now contains Rust components, and Microsoft's engineers maintain first-class Rust toolchain support for Windows targets. The CrowdStrike incident (July 2024: 8.5 million Windows machines crashed from a faulty C++ kernel driver) accelerated Microsoft's push toward memory-safe kernel drivers.

  • Windows kernel Rust: Rust code in the Windows NT kernel as of Windows 11 (2023)
  • CrowdStrike impact: the 2024 incident raised kernel driver memory safety to boardroom-level priority
  • windows-rs crate: official Microsoft crate for Windows API access from Rust
  • WDK: Windows Driver Kit now supports Rust for kernel mode drivers (experimental)
  • Microsoft Rust team: dedicated team contributing to Rust compiler, maintaining Windows targets

Who Should Read This?

This article targets Windows platform engineers, driver developers, and systems architects evaluating Rust for Windows-native development in 2026. If you write kernel mode drivers, work on Windows security products, develop Windows-native applications that need low-level API access, or manage a team making decisions about the Windows development stack, this guide explains what Microsoft's Rust investment means practically. Windows kernel driver developers with Rust expertise are exceptionally rare. Senior roles at security software companies and hardware vendors command $190K–$240K in the US, with even higher total compensation at Microsoft itself.


What Is Microsoft's Rust Journey?

Microsoft has been public about memory safety since 2019. The progression from research to production:

2019: Microsoft Security Response Center publishes "We need a safer systems programming language": 70% of CVEs are memory safety issues

2020: Microsoft Research paper on Rust adoption for Windows components

2021: Official windows-rs crate released: idiomatic Rust bindings for the full Windows API

2022: Rust Insider (Jon Kalb, Ryan Levick) joins Rust Foundation. Microsoft joins as founding member.

2023: First Rust code merged into Windows NT kernel. Kernel mode Rust driver support announced (experimental).

2024 (July): CrowdStrike Falcon sensor: a kernel mode C++ driver that crashes 8.5 million Windows machines globally due to a NULL pointer dereference. Microsoft accelerates kernel driver safety initiatives.

2025–2026: Windows Driver Kit (WDK) Rust support advances toward stable. Microsoft encourages ISVs (Independent Software Vendors) to write new kernel drivers in Rust.

The trajectory is deliberate. Microsoft's security team identified memory safety as the dominant source of Windows vulnerabilities in 2019 and spent five years building the toolchain, documentation, and organizational knowledge needed to make Rust viable for Windows kernel work. Unlike some "we're evaluating Rust" announcements from large companies, Microsoft's investment is structural: dedicated headcount on the Rust team, founding membership in the Rust Foundation, and real kernel code shipped.


What Is in Rust in Windows?

Microsoft hasn't published a complete inventory, but confirmed Rust components include:

  • GDI+ rendering components: partial rewrite of graphics subsystem
  • WIN32K: portions of the kernel-mode window manager
  • DNS client: parts of the Windows DNS resolver
  • Safe Kernel Memory Allocator: safe memory allocation API used by kernel components
  • Windows Security Center: portions rewritten for memory safety

The pattern mirrors Android: security-sensitive, performance-critical code first.

The choice to start with the DNS client and memory allocator is strategic. These components handle external input (DNS responses can be maliciously crafted) and manage memory directly. These represent the two highest-risk categories for memory safety bugs. By rewriting these first, Microsoft reduces the attack surface in components most likely to be targeted by remote exploit chains. The Windows Security Center rewrite is notable because it sits in a privileged position that, if compromised, could disable the very security tooling meant to protect the system.

The counterintuitive reality about Microsoft's Rust rollout: The public narrative is ahead of the production reality. Microsoft's most significant Rust adoption is happening in internal build tooling, cloud infrastructure, and developer-facing services. These are different from the shipped Windows kernel components that get announced in blog posts. Engineers writing Rust kernel drivers still need deep C++ expertise, because the unsafe FFI boundary between Rust and existing Windows kernel internals is exactly where the subtle bugs live. Rust eliminates an entire class of memory safety errors, but it moves the risk rather than removes it to the boundary layer that every real driver must cross.

Microsoft's approach differs from Linux's in one key respect: Windows kernel code is proprietary. There is no public code review of the Rust kernel components. Microsoft validates them internally through its security review processes. This opacity means the Rust ecosystem cannot study Microsoft's patterns as directly as it can study AOSP's open-source Rust code. However, the security metrics Microsoft publishes do show improvement in the rewritten components.


What Happened with CrowdStrike and Why Does It Matter for Rust?

The CrowdStrike incident on July 19, 2024 changed the conversation about kernel driver safety:

What happened:

  • CrowdStrike Falcon deployed a content update to its kernel mode driver (csagent.sys)
  • The C++ driver had a NULL pointer dereference triggered by the new content
  • Windows doesn't recover from kernel mode faults: 8.5 million machines blue-screened (BSOD)
  • Global outage: airlines, hospitals, banks, emergency services

Why this matters for Rust:

  • Kernel mode C++ drivers can crash the entire OS on any memory safety violation
  • A Rust kernel driver with equivalent logic would fail to compile rather than crash at runtime
  • Microsoft's response included accelerating Rust kernel driver support
  • The incident became a reference case for "why memory-safe kernel code matters"

The CrowdStrike incident had an effect on the industry that years of security research could not: it made kernel driver memory safety a boardroom-level concern. CISOs and CTOs who previously viewed memory safety as an engineering concern suddenly had concrete evidence of business impact. A single NULL pointer dereference caused $10 billion in estimated economic damage. Microsoft capitalized on this moment by publishing its WDK Rust documentation and making public statements encouraging ISVs to evaluate Rust for their kernel drivers. The security software industry, which relies heavily on kernel mode drivers for endpoint protection products, is now actively evaluating Rust as a risk-reduction measure.

Bottom line: The CrowdStrike incident proved that a single NULL pointer dereference in a kernel mode driver can cost $10 billion. The case for writing new kernel drivers in Rust is no longer theoretical; it is a business continuity argument.


How Do You Use the windows-rs Crate?

Microsoft maintains windows-rs; the official Rust bindings for the entire Windows API surface:

[dependencies]
windows = { version = "0.57", features = [
    "Win32_Foundation",
    "Win32_Security",
    "Win32_System_Threading",
    "Win32_UI_WindowsAndMessaging",
    "Win32_Storage_FileSystem",
]}
use windows::{
    Win32::Foundation::*,
    Win32::System::Threading::*,
    Win32::UI::WindowsAndMessaging::*,
};
 
fn main() -> windows::core::Result<()> {
    // MessageBox: Win32 API call from Rust
    unsafe {
        MessageBoxA(
            None,
            windows::core::PCSTR::from_raw(b"Hello from Rust!\0".as_ptr()),
            windows::core::PCSTR::from_raw(b"Windows API\0".as_ptr()),
            MB_OK,
        );
    }
 
    // Process enumeration
    let snapshot = unsafe {
        CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)?
    };
 
    let mut entry = PROCESSENTRY32W {
        dwSize: std::mem::size_of::<PROCESSENTRY32W>() as u32,
        ..Default::default()
    };
 
    unsafe {
        if Process32FirstW(snapshot, &mut entry).is_ok() {
            loop {
                let name: String = entry.szExeFile
                    .iter()
                    .take_while(|&&c| c != 0)
                    .map(|&c| char::from(c as u8))
                    .collect();
                println!("PID {}: {}", entry.th32ProcessID, name);
 
                if Process32NextW(snapshot, &mut entry).is_err() { break; }
            }
        }
    }
 
    Ok(())
}

The windows-rs crate covers the full Win32 API surface. Over 10,000 functions and 5,000 types are available through a feature-flag system that keeps compile times manageable by only pulling in the API surface you actually use. The crate is generated directly from Microsoft's API metadata (the same metadata used to generate the C++ headers), which means it stays in sync with new Windows APIs automatically and has the same coverage as the official C SDK.


3 spots open this month → Check if you are eligible.

We help experienced developers transition into Rust roles at €80K–€150K+ in Europe or $130K–$200K+ in the US.

How Do You Write Rust Kernel Mode Drivers with the WDK?

Microsoft's Windows Driver Kit now has experimental Rust support for kernel mode drivers:

# Install WDK Rust support
cargo install wdk-build
 
# New kernel driver project
cargo new --lib my_kernel_driver
# Cargo.toml for a kernel mode driver
[lib]
crate-type = ["cdylib"]
 
[dependencies]
wdk = "0.3"
wdk-sys = "0.3"
 
[build-dependencies]
wdk-build = "0.3"
// Minimal kernel driver entry point in Rust
use wdk::println;
use wdk_sys::{
    ntddk::{DbgPrint, ExAllocatePool2, ExFreePoolWithTag, IoCreateDevice},
    DRIVER_OBJECT, NTSTATUS, PDRIVER_OBJECT, PUNICODE_STRING,
    STATUS_SUCCESS,
};
 
#[export_name = "DriverEntry"]
pub unsafe extern "system" fn driver_entry(
    driver: PDRIVER_OBJECT,
    _registry_path: PUNICODE_STRING,
) -> NTSTATUS {
    println!("Rust kernel driver loaded!");
 
    // Register unload routine
    (*driver).DriverUnload = Some(driver_unload);
 
    STATUS_SUCCESS
}
 
unsafe extern "C" fn driver_unload(_driver: PDRIVER_OBJECT) {
    println!("Rust kernel driver unloading");
}

Note: WDK Rust support is marked experimental as of 2026. It is not ready for production kernel drivers yet.

The wdk-sys crate provides raw bindings to Windows kernel APIs, analogous to how kernel::bindings works in the Linux Rust kernel. The wdk crate provides safe wrappers. The split mirrors the Linux approach intentionally. Microsoft's Rust team studied the Linux kernel Rust design before building WDK support. The goal is the same: minimize unsafe surface area in driver code by concentrating it in the well-reviewed WDK bindings.


What Is the Impact on the Windows Ecosystem?

Microsoft's Rust investment has cascading effects:

  1. Windows targets in Rust toolchain: Microsoft engineers maintain x86_64-pc-windows-msvc and aarch64-pc-windows-msvc targets. Windows is a first-class Rust platform.

  2. MSVC toolchain support: Rust on Windows can use MSVC (Microsoft Visual C++ compiler backend): important for Windows ABI compatibility and linking with Windows SDK libraries.

  3. Azure services in Rust: Azure networking (Virtual Network, Azure Firewall) components use Rust. Azure RTOS has Rust bindings.

  4. GitHub Copilot infrastructure: GitHub (Microsoft) uses Rust in backend infrastructure. Some of Copilot's serving infrastructure runs Rust.

  5. VS Code Rust tooling: VS Code's rust-analyzer extension team maintains one of Rust's best IDE experiences.

The MSVC toolchain support is particularly important for Windows adoption. Many Windows developers and teams cannot switch to the GNU toolchain due to ABI requirements, linking with existing C++ libraries, or Windows SDK dependencies. Rust's support for the MSVC ABI means that Rust code interoperates naturally with C++ code compiled by MSVC. Function calls, data structure layouts, and exception handling all work across the boundary. This removes a major practical barrier to adopting Rust incrementally in Windows codebases.


What Common Mistakes Do Windows Engineers Make When Adopting Rust?

Windows Rust development has specific pitfalls for engineers coming from C++ or C# backgrounds. Here are the most common issues and how to avoid them.

  • Not using the MSVC toolchain on Windows. Rust on Windows supports both the GNU and MSVC toolchains. For production Windows development, always use the MSVC toolchain (x86_64-pc-windows-msvc). The GNU toolchain works but produces binaries with different ABI characteristics and may not link correctly with Windows SDK libraries or existing C++ code. Install Visual Studio Build Tools and set the MSVC target as default.

  • Calling Win32 APIs without handling INVALID_HANDLE_VALUE. Many Win32 APIs signal errors by returning INVALID_HANDLE_VALUE rather than a null handle. The windows-rs crate wraps these in Result, but raw FFI calls still require manual checking. A common mistake is treating any non-null handle as valid: always check for INVALID_HANDLE_VALUE explicitly when working with handles from CreateFile, FindFirstFile, and similar APIs.

  • Ignoring COM initialization requirements. Many Windows APIs require COM to be initialized on the calling thread before use. In C++ this is enforced by ATL or the application framework. In Rust, you must call CoInitializeEx manually before using COM-based APIs and ensure CoUninitialize is called on thread exit. Forgetting this produces mysterious runtime failures that are difficult to diagnose without knowing to look for COM initialization.

  • Mishandling wide strings (LPCWSTR) in Win32 calls. The Windows API is predominantly UTF-16 (wide strings). The windows-rs crate provides HSTRING and PCWSTR types for this, but developers sometimes try to pass &str or String directly, requiring careful conversion. Use windows::core::HSTRING::from(your_string) for owned wide strings and be aware that the null terminator is required for many raw PCWSTR APIs.

  • Assuming process isolation prevents kernel driver bugs. A kernel mode driver bug crashes the entire machine, not just the process. Engineers with a userspace background sometimes apply userspace debugging intuitions to driver code. In kernel mode, any illegal memory access is immediately fatal. Test all kernel driver code in a virtual machine with a kernel debugger attached over a serial or network connection: never develop kernel drivers on a machine you cannot afford to crash.

  • Using std::thread::spawn in kernel mode. In WDK Rust drivers, the standard library's thread spawning is not available. Kernel threads must be created using kernel APIs (PsCreateSystemThread via wdk-sys). The same applies to timers, synchronization, and I/O: all must use kernel-provided mechanisms rather than standard library abstractions.


What Are the Most Common Misconceptions About Rust in the Windows Kernel?

Most developers hold at least one false belief about Microsoft's Rust kernel work. Here are the four that come up most in engineering discussions.

  1. "Rust will replace C++ in the Windows kernel entirely." False. Microsoft's strategy is incremental. New security-sensitive components and rewrites of high-risk subsystems use Rust, but the majority of the Windows kernel is C and C++ and will remain so indefinitely. Microsoft has never announced a goal of full replacement. The goal is eliminating memory safety bugs in the highest-risk components, not rewriting working code for its own sake.

  2. "You need kernel development experience before learning Rust for systems work." False. Rust's ownership model, type system, and tooling are learnable from a userspace background. Most Rust systems skills (memory management, unsafe code, FFI) transfer directly to kernel work once you add kernel-specific APIs. Engineers who learn Rust at the userspace level are well-positioned to move into WDK driver development. Kernel concepts (IRQLs, non-paged pool, DPC routines) are a separate learning curve, but Rust itself is not a prerequisite blocker.

  3. "Rust in the kernel means unsafe is banned." False. Kernel code inherently requires operations that Rust cannot statically verify: hardware register access, raw pointer manipulation, and interrupt-level synchronization. The WDK Rust bindings use unsafe extensively and intentionally. The goal is to concentrate unsafe in well-audited abstractions (the wdk-sys and wdk crates) so that driver authors write mostly safe code above a trusted unsafe layer. This mirrors the pattern used in the Linux kernel's Rust support.

  4. "Microsoft open-sourced their Rust kernel components." Partially true, but mostly false. The Windows kernel source is proprietary and Microsoft's internal Rust kernel code is not public. What Microsoft has open-sourced is the tooling: windows-rs (Windows API bindings, MIT licensed) and the wdk crates (driver development kit bindings). The kernel components themselves (the rewritten DNS client, WIN32K portions, memory allocator) remain closed source.

Bottom line: Microsoft's Rust investment is real and structural: founding Rust Foundation membership, first-class Windows toolchain targets, and shipped kernel components. However, the production story for third-party kernel drivers in Rust is still 1–2 years from widespread readiness as of 2026.


Frequently Asked Questions

Yes; use windows-rs or winapi crates for Windows API access. GUI applications can use windows-rs + Direct2D, or cross-platform frameworks like iced or egui that support Windows. Tauri builds Windows desktop apps using Rust with a web frontend. For console and service applications, Rust on Windows with windows-rs is production-ready and mature. The tooling (cargo, rust-analyzer in VS Code, and the MSVC linker) works seamlessly. Large Windows applications like parts of the 1Password desktop client are already built with Rust.

No; Windows source is proprietary. Microsoft announces Rust usage in Windows through blog posts and security papers. The windows-rs crate itself is open source (MIT licensed), as is the wdk crate for driver development. The blog posts from Microsoft's Security Response Center and the Azure engineering blog provide the clearest public signal of what has been rewritten and why. The security metrics; CVE counts by component, memory safety issue percentages; are the primary evidence of the Rust investment's effectiveness.

Microsoft targets stable WDK Rust support in a future Windows SDK release; no committed date as of March 2026. Early adopters can test with the experimental WDK Rust preview. Production ISV kernel drivers in Rust are likely 1–2 years away from widespread adoption. The security software industry (EDR and antivirus vendors) is watching closely given the CrowdStrike incident. Expect the first publicly announced production Rust kernel drivers from ISVs to appear in 2026–2027 as the WDK API stabilizes.

C++/CX (Component Extensions) is a Microsoft extension for Windows Runtime (WinRT) development, now largely superseded by C++/WinRT. For modern Windows development, the comparison is between Rust + windows-rs and C++/WinRT. Both provide access to WinRT APIs. Rust offers memory safety and a more expressive type system; C++/WinRT has a larger ecosystem, more tooling, and more available developers. For new projects where memory safety is a priority, Rust is increasingly competitive. For applications requiring deep WinRT UI integration (XAML, Windows UI Library), C++/WinRT or .NET remains the more practical choice in 2026.

Microsoft has confirmed Rust in Azure Virtual Network (the SDN layer handling billions of daily connections), Azure Firewall (the network security service), and portions of the Azure RTOS embedded runtime. GitHub Actions and GitHub's internal CI infrastructure also use Rust components. The Azure team has published engineering blog posts describing the performance and reliability improvements from Rust rewrites; consistent with the broader industry pattern of Rust being adopted first in high-throughput, reliability-sensitive network infrastructure. Senior engineers working on Azure Rust infrastructure in the Seattle area earn $200K–$270K total compensation.

Yes; the rust-analyzer extension for VS Code provides excellent Rust support on Windows, including type inference, auto-complete, go-to-definition, and inline error display. The windows-rs crate works with rust-analyzer for API completion. For debugging, both LLDB (via the CodeLLDB VS Code extension) and the native Windows debugger (WinDbg) support Rust debugging with source-level stepping. The cargo test workflow, cargo clippy linting, and cargo fmt formatting all work natively on Windows without special configuration. The MSVC toolchain integrates with Windows' application verifier and sanitizers for additional runtime validation.


Sources


  • Ownership: The fundamental mechanism behind Microsoft's safety rationale for adopting Rust
  • Borrow Checker: Eliminates use-after-free and buffer overflows at compile time. These are the CVEs Microsoft wants to prevent
  • Trait: Windows kernel abstractions like device drivers are defined as Rust traits
  • Lifetime: Ensures kernel references never outlive the objects they point to

Keep Reading


If you want a structured path from Rust fundamentals to Windows systems programming and driver development, Rustify's 9-week bootcamp covers unsafe Rust, FFI boundaries, and systems architecture with 1:1 coaching. These are the foundational skills needed before tackling WDK kernel driver work.

Ready to Land a $80-120k Rust Job?