Rust port of the official Windows Driver Samples on Github. Leverages windows-drivers-rs
Rust port of the official Windows Driver Samples on Github. Leverages windows-drivers-rs
This is a Rust port of the driver samples from the original Windows Driver Samples on Github.
The repository provides examples and best practices for Windows driver development in Rust using crates from windows-drivers-rs.
Set up EWDK Build Environment
c:\ewdk\LaunchBuildEnv.cmdInstall Clang
winget install LLVM.LLVMInstall Rust
Invoke-RestMethod -Uri "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" -OutFile "$env:USERPROFILE\Downloads\rustup-init.exe"
& "$env:USERPROFILE\Downloads\rustup-init.exe" -yRun the following commands after setting up Rust.
cargo install cargo-make --no-default-features --features tls-native
Note on arm64: ARM64 support for ring is not released yet, so TLS features must be disabled until arm64 is officially supported by ring (probably in 0.17.0 release)
These are not-required, but may make it easier to work in a rust environment:
cargo install cargo-expand cargo-edit cargo-workspaces
cargo doc --document-private-items --open
From an EWDK development command prompt, run:
cargo make
If build is successful, this will stamp the INF and create a CAT file placed with driver binary and INF in Package folder.
If Bitlocker is enabled, suspend Bitlocker
Example: manage-bde -protectors -disable C:
Turn off Secure Boot via your UEFI/BIOS Settings
Example: shutdown -r -o -t 0 then pick Advanced -> UEFI Settings
If Bitlocker is enabled, suspend Bitlocker again
Example: manage-bde -protectors -disable C:
Turn on test signing
bcdedit /set testsigning on
Reboot
shutdown -r -t 0
Copy the following to the DUT (Device Under Test: the computer you want to test the driver on):
package folder located in the Cargo Output Directory. The Cargo Output Directory changes based off of build profile, target architecture, etc.\target\x86_64-pc-windows-msvc\debug\package, \target\x86_64-pc-windows-msvc\release\package, \target\aarch64-pc-windows-msvc\debug\package, \target\aarch64-pc-windows-msvc\release\package,
\target\debug\package,
\target\release\packagedevgen.exe from the WDK Developer Tools that matches the archtecture of your DUTC:\ewdk\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exeInstall the Certificate on the DUT:
Install the driver from Admin Command Prompt:
pnputil.exe /add-driver echo_2.inf /installCreate a software device from Admin Command Prompt:
devgen.exe was copied to, run: devgen.exe /add /hardwareid "root\ECHO_2"Capture KernelEnable Verbose Kernel Outputed nt!Kd_DEFAULT_Mask 0xFFFFFFFFThe echo driver can be tested by using the included sample app.
cargo run --bin echoapp
cargo run --bin echoapp -- -Async
Exit the app anytime by pressing Ctrl-C
Take a look at the compilation of the new and changed driver-related content for Windows 11. Areas of improvement include camera, print, display, Near Field Communication (NFC), WLAN, Bluetooth, and more.
Find out what's new in the WDK
The Windows Driver Frameworks (WDF) are a set of libraries that make it simple to write high-quality device drivers.
Use the samples in this repo to guide your Windows driver development. Whether you're just getting started or porting an older driver to the newest version of Windows, code samples are valuable guides on how to write drivers.
For information about important changes that need to be made to the WDK sample drivers before releasing device drivers based on the sample code, see the following topic:
From Sample Code to Production Driver - What to Change in the Samples
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
No open issues yet, or sync has not completed.