A minimal Windows Driver Model (WDM) project template that demonstrates how to configure a Rust crate to build a functional kernel-mode driver.
- Visual Studio with "Desktop development with C++" workload.
- Windows Driver Kit (WDK) 22H2 or newer.
- Clang (LLVM): Required for
bindgento generate Rust bindings from WDK headers. - Cargo-make: Task runner used for the build pipeline (
cargo install cargo-make). - Rust Toolchain: Nightly is often recommended for experimental features like
alloc_error_handler, though many WDK tasks now work on Stable.
-
.cargo/config.tomlSpecifies custom build flags, such as linking the C Runtime (CRT) statically and defining the target architecture. -
src/lib.rsThe main source file containing theDriverEntry(initialization) andDriverUnloadroutines. -
build.rsThe build script that uses thewdk-buildcrate to locate WDK headers and configure the linker for kernel mode. -
Cargo.tomlThe manifest file. For drivers, this typically sets the crate-type to["cdylib"]. -
Cargo.lockEnsures reproducible builds by locking the exact versions of all dependencies. -
Makefile.tomlConfiguration forcargo-make. It extends the defaultwdk-buildlogic to automate signing, inf-stamping, and package creation. -
wdm_driver_example_rs.inxThe architecture-independent template used to generate the final.inffile for driver installation.