百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

Windows-rust-driver-samples

> 编程语言
开源

Rust 上的官方 Windows 驱动示例的端口。利用 windows-drivers-rs

355 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Rust 上的官方 Windows 驱动示例的端口。利用 windows-drivers-rs

Rust Driver Samples

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.

Getting Started

Pre-requisites

Required

  • Set up EWDK Build Environment

    • Easy install option:
      • Install the latest version from link
      • Expand the ISO image to c:\ewdk
      • Start Environment by running in command prompt:
        • c:\ewdk\LaunchBuildEnv.cmd
  • Install Clang

    • Easy install option:
      • winget install LLVM.LLVM
  • Install Rust

    • Easy install option for x64 systems:
powershell
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" -y

Rust Setup

Run 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)

Optional

These are not-required, but may make it easier to work in a rust environment:

cargo install cargo-expand cargo-edit cargo-workspaces

Documentation

cargo doc --document-private-items --open

Build and Test

Build

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.

Install

One Time PC Setup

  1. If Bitlocker is enabled, suspend Bitlocker Example: manage-bde -protectors -disable C:

  2. Turn off Secure Boot via your UEFI/BIOS Settings Example: shutdown -r -o -t 0 then pick Advanced -> UEFI Settings

  3. If Bitlocker is enabled, suspend Bitlocker again Example: manage-bde -protectors -disable C:

  4. Turn on test signing bcdedit /set testsigning on

  5. Reboot shutdown -r -t 0

  6. Copy the following to the DUT (Device Under Test: the computer you want to test the driver on):

    1. The driver package folder located in the Cargo Output Directory. The Cargo Output Directory changes based off of build profile, target architecture, etc.
    • Ex. \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\package
    1. The version of devgen.exe from the WDK Developer Tools that matches the archtecture of your DUT
    • Ex. C:\ewdk\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe
  7. Install the Certificate on the DUT:

    1. Double click the certificate
    2. Click Install Certificate
    3. Store Location: Local Machine -> Next
    4. Place all certificates in the following Store -> Browse -> Trusted Root Certification Authorities -> Ok -> Next
    5. Repeat 2-4 for Store -> Browse -> Trusted Publishers -> Ok -> Next
    6. Finish
  8. Install the driver from Admin Command Prompt:

    1. In the package directory, run: pnputil.exe /add-driver echo_2.inf /install
  9. Create a software device from Admin Command Prompt:

    1. In the directory that devgen.exe was copied to, run: devgen.exe /add /hardwareid "root\ECHO_2"

Test

  • To capture prints:
    • Start DebugView
      1. Enable Capture Kernel
      2. Enable Enable Verbose Kernel Output
    • Alternatively, you can see prints in an active Windbg session.
      1. Attach WinDBG
      2. ed nt!Kd_DEFAULT_Mask 0xFFFFFFFF

Usage

The echo driver can be tested by using the included sample app.

  • cargo run --bin echoapp

    • Send single write and read request synchronously
  • cargo run --bin echoapp -- -Async

    • Send 100 reads and writes asynchronously

Exit the app anytime by pressing Ctrl-C

Windows driver development

Windows Driver Kit (WDK)

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

Windows Driver Frameworks

The Windows Driver Frameworks (WDF) are a set of libraries that make it simple to write high-quality device drivers.

WDF driver development guide

Samples

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

Trademarks

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustdriversrustsampleswindows

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言