Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push:
pull_request:
merge_group:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: "0 11 * * *"

name: Typos

jobs:
typos:
name: Spell check
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

# We explicitly install typos instead the typos GitHub Action due to:
# https://github.com/crate-ci/typos/issues/1191
- name: Install typos (taiki-e/install-action)
uses: taiki-e/install-action@v2
with:
tool: typos

- name: Run typos (check)
run: typos
16 changes: 16 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[files]
extend-exclude = ["**/target/**", "**/Cargo.lock"]

# Allow specific identifiers in code derived from WDK
[default.extend-identifiers]
STATUS_FVE_MOR_FAILED = "STATUS_FVE_MOR_FAILED"
STATUS_MCA_OCCURED = "STATUS_MCA_OCCURED"
STATUS_ND_QUEUE_OVERFLOW = "STATUS_ND_QUEUE_OVERFLOW"
STATUS_TPM_DAA_INPUT_DATA0 = "STATUS_TPM_DAA_INPUT_DATA0"
STATUS_TPM_DAA_INPUT_DATA1 = "STATUS_TPM_DAA_INPUT_DATA1"
STATUS_TPM_DAA_ISSUER_SETTINGS = "STATUS_TPM_DAA_ISSUER_SETTINGS"
STATUS_TPM_DAA_ISSUER_VALIDITY = "STATUS_TPM_DAA_ISSUER_VALIDITY"
STATUS_TPM_DAA_RESOURCES = "STATUS_TPM_DAA_RESOURCES"
STATUS_TPM_DAA_STAGE = "STATUS_TPM_DAA_STAGE"
STATUS_TPM_DAA_TPM_SETTINGS = "STATUS_TPM_DAA_TPM_SETTINGS"
STATUS_TPM_DAA_WRONG_W = "STATUS_TPM_DAA_WRONG_W"
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The following tools should be installed as a part of the `windows-drivers-rs` de
* `cargo-audit`: `cargo install --locked cargo-audit`
* `cargo-machete`: `cargo install --locked cargo-machete`
* `taplo-cli`: `cargo install --locked taplo-cli`
* `typos-cli`: `cargo install --locked typos-cli`

**Note on arm64:** ARM64 support for ring is [not released yet](https://github.com/briansmith/ring/issues/1167), so TLS features must be disabled until arm64 is officially supported by ring (probably in 0.17.0 release)

Expand Down Expand Up @@ -140,6 +141,13 @@ To maintain the quality of code, tests and tools are required to pass before con
* Check for sorted sections and dependencies listed in the `Cargo.toml` files: `cargo sort -w -g -n --check`
* Running `cargo sort -w -g -n` resolves any formatting inconsistencies.

**_Spelling (typos-cli):_**

* Check spelling with typos-cli: `typos`
* Auto-fix locally before committing: `typos --write-changes`
* CI runs `typos` on every PR to `main` and will fail on finding any typos
* Configuration lives in `.typos.toml`; we allowlist specific Windows API identifiers flagged by typos to preserve upstream names and binding compatibility (no file-level excludes)

**_Dependency Analysis:_**

* Scan for security advisories in dependent crates: `cargo audit --deny warnings`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This project was built with support of WDM, KMDF, and UMDF drivers in mind, as w

* [crates](./crates): Contains all the main crates that are a part of the Cargo workspace.
* [examples](./examples): Contains workspace-level examples. These examples consist of different types of minimal Windows drivers (ie. WDM, KMDF, UMDF).
* [tests](./tests): Contains workspace-level tests, inlcuding tests for metadata-based wdk configuration in packages and workspaces.
* [tests](./tests): Contains workspace-level tests, including tests for metadata-based wdk configuration in packages and workspaces.

**Note:**: Since the workspace level examples and tests use different WDK configurations, and WDR only supports one WDK configuration per workspace, the workspace-level examples and tests folder are excluded from the [repository root's Cargo manifest](./Cargo.toml).

Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-wdk/src/actions/build/package_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct PackageTaskParams<'a> {
pub driver_model: DriverConfig,
}

/// Suports low level driver packaging operations
/// Supports low level driver packaging operations
pub struct PackageTask<'a> {
package_name: String,
verify_signature: bool,
Expand Down Expand Up @@ -394,7 +394,7 @@ impl<'a> PackageTask<'a> {
Ok(())
}

/// Signs the specified file using signtool command using cerificate from
/// Signs the specified file using signtool command using certificate from
/// certificate store.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-wdk/src/actions/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a> NewAction<'a> {
/// is used as the package name.
/// * `driver_type` - The type of the driver project to be created.
/// * `verbosity_level` - The verbosity level for logging.
/// * `command_exec` - The provider for command exection.
/// * `command_exec` - The provider for command execution.
/// * `fs` - The provider for file system operations.
///
/// # Returns
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod kernel_mode {
// SAFETY: This is safe because the Wdk allocator:
// 1. can never unwind since it can never panic
// 2. has implementations of alloc and dealloc that maintain layout
// constraints (FIXME: Alignment of the layout is currenty not
// constraints (FIXME: Alignment of the layout is currently not
// supported)
unsafe impl GlobalAlloc for WdkAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-build/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- resolve warnings in rust-script blocks and only fail warnings in CI ([#87](https://github/microsoft/windows-drivers-rs/pull/87))
- add missing cpu-arch macro defintions
- add missing cpu-arch macro definitions
- fix wdk path regkey detection

### Other
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-build/rust-driver-makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ wdk_build::cargo_make::forward_printed_env_vars(
'''

[tasks.setup-wdk-config-env-vars]
# This exists as a seperate task outside of `wdk-build-init` so that any wdk-metadata-detection errors can be a hard error, without failing every task flow that executes on non-driver crates in the workspace.
# This exists as a separate task outside of `wdk-build-init` so that any wdk-metadata-detection errors can be a hard error, without failing every task flow that executes on non-driver crates in the workspace.
private = true
install_crate = { crate_name = "rust-script", min_version = "0.30.0" }
plugin = "rust-env-update"
Expand Down
2 changes: 1 addition & 1 deletion crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ pub fn get_current_package_name() -> String {
///
/// # Errors
///
/// This function returns a [`ConfigError::IoError`] if the it encouters IO
/// This function returns a [`ConfigError::IoError`] if the it encounters IO
/// errors while copying the file or creating the directory
///
/// # Panics
Expand Down
4 changes: 2 additions & 2 deletions crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,12 +912,12 @@ impl Config {
/// where the issue was fixed. See
/// <https://github.com/llvm/llvm-project/issues/124869> for details.
fn should_include_ufxclient() -> bool {
const MINIMUM_CLANG_MAJOR_VERISON_WITH_INVALID_INLINE_FIX: u32 = 20;
const MINIMUM_CLANG_MAJOR_VERSION_WITH_INVALID_INLINE_FIX: u32 = 20;

let clang_version = ::bindgen::clang_version();
match clang_version.parsed {
Some((major, _minor))
if major >= MINIMUM_CLANG_MAJOR_VERISON_WITH_INVALID_INLINE_FIX =>
if major >= MINIMUM_CLANG_MAJOR_VERSION_WITH_INVALID_INLINE_FIX =>
{
true
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wdk-build/src/metadata/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::{
pub const KEY_NAME_SEPARATOR: char = '-';

/// Serialize a value into a [`Map`] where the keys represent a
/// `KEY_NAME_SEPARATOR`-seperated list of field names.
/// `KEY_NAME_SEPARATOR`-separated list of field names.
///
/// # Errors
///
Expand Down Expand Up @@ -63,7 +63,7 @@ where
}

/// Serialize a value into a [`Map`] where the keys represent a
/// `KEY_NAME_SEPARATOR`-seperated list of field names prepended with a
/// `KEY_NAME_SEPARATOR`-separated list of field names prepended with a
/// prefix.
///
/// # Errors
Expand Down
14 changes: 7 additions & 7 deletions crates/wdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct DerivedASTFragments {
struct IntermediateOutputASTFragments {
must_use_attribute: Option<Attribute>,
inline_wdf_fn_signature: Signature,
inline_wdf_fn_body_statments: Vec<Stmt>,
inline_wdf_fn_body_statements: Vec<Stmt>,
inline_wdf_fn_invocation: ExprCall,
}

Expand Down Expand Up @@ -299,7 +299,7 @@ impl DerivedASTFragments {
unsafe fn #inline_wdf_fn_name(#parameters) #return_type
};

let inline_wdf_fn_body_statments = parse_quote! {
let inline_wdf_fn_body_statements = parse_quote! {
// Get handle to WDF function from the function table
let wdf_function: wdk_sys::#function_pointer_type = Some(
// SAFETY: This `transmute` from a no-argument function pointer to a function pointer with the correct
Expand Down Expand Up @@ -353,7 +353,7 @@ impl DerivedASTFragments {
IntermediateOutputASTFragments {
must_use_attribute,
inline_wdf_fn_signature,
inline_wdf_fn_body_statments,
inline_wdf_fn_body_statements,
inline_wdf_fn_invocation,
}
}
Expand All @@ -364,7 +364,7 @@ impl IntermediateOutputASTFragments {
let Self {
must_use_attribute,
inline_wdf_fn_signature,
inline_wdf_fn_body_statments,
inline_wdf_fn_body_statements,
inline_wdf_fn_invocation,
} = self;

Expand All @@ -376,7 +376,7 @@ impl IntermediateOutputASTFragments {
// Use a private module to prevent leaking of glob import into inline_wdf_fn_invocation's parameters
mod private__ {
// Glob import types from wdk_sys. glob importing is done instead of blindly prepending the
// paramters types with wdk_sys:: because bindgen generates some paramters as native rust types
// parameters types with wdk_sys:: because bindgen generates some parameters as native rust types
use wdk_sys::*;

// If the function returns a value, add a `#[must_use]` attribute to the function
Expand All @@ -385,7 +385,7 @@ impl IntermediateOutputASTFragments {
// core::hint::must_use is not stable yet: https://github.com/rust-lang/rust/issues/94745
#[inline(always)]
pub #inline_wdf_fn_signature {
#(#inline_wdf_fn_body_statments)*
#(#inline_wdf_fn_body_statements)*
}
}

Expand Down Expand Up @@ -928,7 +928,7 @@ fn compute_fn_parameters(
.collect())
}

/// Compute the return type based on the function defintion
/// Compute the return type based on the function definition
///
/// # Examples
///
Expand Down
8 changes: 6 additions & 2 deletions crates/wdk/src/wdf/spinlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ impl SpinLock {
///
/// # Errors
///
/// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value)
/// This function will return an error if WDF fails to construct a spinlock.
/// The error variant will contain a [`NTSTATUS`] of the failure. Full error
/// documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value)
pub fn try_new(attributes: &mut WDF_OBJECT_ATTRIBUTES) -> Result<Self, NTSTATUS> {
let mut spin_lock = Self {
wdf_spin_lock: core::ptr::null_mut(),
Expand All @@ -51,7 +53,9 @@ impl SpinLock {
///
/// # Errors
///
/// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value)
/// This function will return an error if WDF fails to construct a spinlock.
/// The error variant will contain a [`NTSTATUS`] of the failure. Full error
/// documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value)
pub fn create(attributes: &mut WDF_OBJECT_ATTRIBUTES) -> Result<Self, NTSTATUS> {
Self::try_new(attributes)
}
Expand Down
8 changes: 6 additions & 2 deletions crates/wdk/src/wdf/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ impl Timer {
///
/// # Errors
///
/// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value)
/// This function will return an error if WDF fails to construct a timer.
/// The error variant will contain a [`NTSTATUS`] of the failure. Full error
/// documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value)
pub fn try_new(
timer_config: &mut WDF_TIMER_CONFIG,
attributes: &mut WDF_OBJECT_ATTRIBUTES,
Expand Down Expand Up @@ -48,7 +50,9 @@ impl Timer {
///
/// # Errors
///
/// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value)
/// This function will return an error if WDF fails to construct a timer.
/// The error variant will contain a [`NTSTATUS`] of the failure. Full error
/// documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value)
pub fn create(
timer_config: &mut WDF_TIMER_CONFIG,
attributes: &mut WDF_OBJECT_ATTRIBUTES,
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-kmdf-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Ex. `<REPO_ROOT>\target\x86_64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\x86_64-pc-windows-msvc\release\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\release\package`,
`<REPO_ROOT>\target\debug\package`,
`<REPO_ROOT>\target\release\package`
2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT
2. The version of `devgen.exe` from the WDK Developer Tools that matches the architecture of your DUT
* Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment
2. Install the Certificate on the DUT:
1. Double click the certificate
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-umdf-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Ex. `<REPO_ROOT>\target\x86_64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\x86_64-pc-windows-msvc\release\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\release\package`,
`<REPO_ROOT>\target\debug\package`,
`<REPO_ROOT>\target\release\package`
2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT
2. The version of `devgen.exe` from the WDK Developer Tools that matches the architecture of your DUT
* Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment
2. Install the Certificate on the DUT:
1. Double click the certificate
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-wdm-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Ex. `<REPO_ROOT>\target\x86_64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\x86_64-pc-windows-msvc\release\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\release\package`,
`<REPO_ROOT>\target\debug\package`,
`<REPO_ROOT>\target\release\package`
2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT
2. The version of `devgen.exe` from the WDK Developer Tools that matches the architecture of your DUT
* Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment
2. Install the Certificate on the DUT:
1. Double click the certificate
Expand Down
2 changes: 1 addition & 1 deletion tests/wdk-macros-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub static TRYBUILD_OUTPUT_FOLDER_PATH: LazyLock<PathBuf> =
/// reside in the `tests/inputs/macrotest` folder, and may be a path to
/// a file relative to the `tests/inputs/macrotest` folder. This macro is
/// designed to use one test file per generated test to fully take advantage of
/// parallization of tests in cargo.
/// parallelization of tests in cargo.
///
/// Note: Due to limitations in `trybuild`, a successful compilation
/// test will include output that looks similar to the following:
Expand Down
Loading