diff --git a/packaging/windows/drivers/Cargo.lock b/packaging/windows/drivers/Cargo.lock index 962d48b..8dc5efd 100644 --- a/packaging/windows/drivers/Cargo.lock +++ b/packaging/windows/drivers/Cargo.lock @@ -716,8 +716,6 @@ dependencies = [ [[package]] name = "wdk-build" version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c150122a579af759770b354064cd2994d29e97525d904f65ff1412ad5122766" dependencies = [ "anyhow", "bindgen", @@ -767,8 +765,6 @@ dependencies = [ [[package]] name = "wdk-sys" version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e13e19ed97609bc1d1236806019309ca2d47aaad6d3217ab374e73c9ff3b8a9" dependencies = [ "anyhow", "bindgen", diff --git a/packaging/windows/drivers/Cargo.toml b/packaging/windows/drivers/Cargo.toml index cde8f16..f406a9b 100644 --- a/packaging/windows/drivers/Cargo.toml +++ b/packaging/windows/drivers/Cargo.toml @@ -21,6 +21,14 @@ wdk-sys = "0.5.1" wdk-build = "0.5.1" pf-vdisplay-proto = { path = "../../../crates/pf-vdisplay-proto" } +# Vendored windows-drivers-rs 0.5.1 (the published, self-contained crates) + an added `iddcx` +# ApiSubset (M1 — bindgens iddcx/1.10/IddCx.h reusing wdk_default for WDF type-identity). Redirect ALL +# wdk-sys/wdk-build refs (incl. wdk 0.4.1's transitive deps) to the patched copies so there is exactly +# one (iddcx-capable) wdk-sys in the graph. Pinned; do not chase upstream. +[patch.crates-io] +wdk-build = { path = "vendor/wdk-build" } +wdk-sys = { path = "vendor/wdk-sys" } + # wdk-sys's build script reads the WDK driver-model from the WORKSPACE metadata (a workspace build can't # know which member it's building for). All our drivers are UMDF 2.x (incl. pf-vdisplay's IddCx), so set # it once here; a member needing a different model would get its own [package.metadata.wdk.driver-model]. diff --git a/packaging/windows/drivers/vendor/wdk-build/CHANGELOG.md b/packaging/windows/drivers/vendor/wdk-build/CHANGELOG.md new file mode 100644 index 0000000..7877454 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/CHANGELOG.md @@ -0,0 +1,136 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [0.5.1](https://github.com/microsoft/windows-drivers-rs/compare/wdk-build-v0.5.0...wdk-build-v0.5.1) - 2025-11-13 + +### Fixed + +- fallback to detection logic when WDK env vars have invalid unicode ([#579](https://github.com/microsoft/windows-drivers-rs/pull/579)) +- path construction in `wdk-build` `get_wdk_tools_root` and `get_wdk_bin_root` ([#574](https://github.com/microsoft/windows-drivers-rs/pull/574)) + +### Other + +- fix wdk-build version in readme ([#568](https://github.com/microsoft/windows-drivers-rs/pull/568)) + +## [0.5.0](https://github.com/microsoft/windows-drivers-rs/compare/wdk-build-v0.4.0...wdk-build-v0.5.0) - 2025-11-06 + +### Added + +- enhance error handling with IoError and IoErrorMetadata for improved std::io::Error diagnostics for fs errors ([#480](https://github.com/microsoft/windows-drivers-rs/pull/480)) +- add color to cargo wdk and cargo make argument forwarding ([#519](https://github.com/microsoft/windows-drivers-rs/pull/519)) +- enhance debug tracing in bindgen and config modules ([#455](https://github.com/microsoft/windows-drivers-rs/pull/455)) +- enhance cargo metadata parsing to respect config.toml ([#451](https://github.com/microsoft/windows-drivers-rs/pull/451)) +- *(ci)* install and use `nuget` packages in CI workflows ([#406](https://github.com/microsoft/windows-drivers-rs/pull/406)) +- make `emit_check_cfg_settings` function public ([#352](https://github.com/microsoft/windows-drivers-rs/pull/352)) + +### Fixed + +- use latest version of ucx in the WDKContent as default ([#411](https://github.com/microsoft/windows-drivers-rs/pull/411)) +- improve error reporting when no wdk-build package is found ([#339](https://github.com/microsoft/windows-drivers-rs/pull/339)) + +### Other + +- Prepare cargo-wdk for release ([#560](https://github.com/microsoft/windows-drivers-rs/pull/560)) +- [**breaking**] bump to Rust 2024 Edition ([#430](https://github.com/microsoft/windows-drivers-rs/pull/430)) +- use `std::path::absolute` instead of canonicalize + strip_extended_path_prefix ([#462](https://github.com/microsoft/windows-drivers-rs/pull/462)) +- Bump tracing-subscriber from 0.3.19 to 0.3.20 ([#492](https://github.com/microsoft/windows-drivers-rs/pull/492)) +- enforce typo checking ([#452](https://github.com/microsoft/windows-drivers-rs/pull/452)) +- update crate references for consistency in documentation ([#440](https://github.com/microsoft/windows-drivers-rs/pull/440)) +- improve cargo-wdk tests ([#429](https://github.com/microsoft/windows-drivers-rs/pull/429)) + +## [0.4.0](https://github.com/microsoft/windows-drivers-rs/compare/wdk-build-v0.3.0...wdk-build-v0.4.0) - 2025-04-18 + +### Added + +- extend coverage in `wdk-sys` to include usb-related headers ([#296](https://github.com/microsoft/windows-drivers-rs/pull/296)) +- expand wdk-sys coverage to include gpio and parallel ports related headers ([#278](https://github.com/microsoft/windows-drivers-rs/pull/278)) +- add support for Storage API subset in `wdk-sys` ([#287](https://github.com/microsoft/windows-drivers-rs/pull/287)) +- expand `wdk-sys` coverage to include spb-related headers ([#263](https://github.com/microsoft/windows-drivers-rs/pull/263)) +- [**breaking**] expand `wdk-sys` coverage to include hid-related headers ([#260](https://github.com/microsoft/windows-drivers-rs/pull/260)) + +### Fixed + +- [**breaking**] specify rust version & edition to wdk-default bindgen::builder ([#314](https://github.com/microsoft/windows-drivers-rs/pull/314)) +- [**breaking**] explicitly mark `_KGDTENTRY64` and `_KIDTENTRY64` as opaque types in `bindgen` ([#277](https://github.com/microsoft/windows-drivers-rs/pull/277)) +- suppress linker warnings exposed by nightly rustc change ([#279](https://github.com/microsoft/windows-drivers-rs/pull/279)) +- add missing arm64rt library to linker flags for arm64 kernel-mode builds ([#261](https://github.com/microsoft/windows-drivers-rs/pull/261)) + +### Other + +- update README to clarify community engagement and contact methods ([#312](https://github.com/microsoft/windows-drivers-rs/pull/312)) +- remove noop `must_use` on trait impl ([#302](https://github.com/microsoft/windows-drivers-rs/pull/302)) +- [**breaking**] Remove lazy static instances ([#250](https://github.com/microsoft/windows-drivers-rs/pull/250)) +- fix panic condition docs for `package_driver_flow_condition_script` ([#264](https://github.com/microsoft/windows-drivers-rs/pull/264)) +- port certificate-generation condition script to Rust ([#259](https://github.com/microsoft/windows-drivers-rs/pull/259)) +- remove redundant code-path in `detect_wdk_content_root` ([#249](https://github.com/microsoft/windows-drivers-rs/pull/249)) +- use `next_back` instead of `last` on double-ended iterators (`clippy::double_ended_iterator_last`) ([#262](https://github.com/microsoft/windows-drivers-rs/pull/262)) +- use `is_none_or` for `clippy::nonminimal_bool` and resolve `clippy::needless_raw_string_hashes` ([#231](https://github.com/microsoft/windows-drivers-rs/pull/231)) +- fix `clippy::nonminimal_bool` and `clippy::ref_option` issues ([#230](https://github.com/microsoft/windows-drivers-rs/pull/230)) + +## [0.3.0](https://github.com/microsoft/windows-drivers-rs/compare/wdk-build-v0.2.0...wdk-build-v0.3.0) - 2024-09-27 + +### Added + +- add `skip_umdf_static_crt_check` unstable option to prevent static crt linkage check ([#217](https://github.com/microsoft/windows-drivers-rs/pull/217)) +- [**breaking**] add 'ExAllocatePool' to blocklist due to deprecation ([#190](https://github.com/microsoft/windows-drivers-rs/pull/190)) +- configure WDK configuration via parsing Cargo manifest metadata ([#186](https://github.com/microsoft/windows-drivers-rs/pull/186)) + +### Fixed + +- typos in Getting Started section of README.md ([#213](https://github.com/microsoft/windows-drivers-rs/pull/213)) +- skip infverif task for sample drivers built with certain GE WDK versions ([#143](https://github.com/microsoft/windows-drivers-rs/pull/143)) +- [**breaking**] prevent linking of wdk libraries in tests that depend on `wdk-sys` ([#118](https://github.com/microsoft/windows-drivers-rs/pull/118)) + +### Other + +- fix `clippy::empty-line-after-doc-comments` lint issues ([#221](https://github.com/microsoft/windows-drivers-rs/pull/221)) +- move infverif task's condition script logic to cargo_make.rs ([#216](https://github.com/microsoft/windows-drivers-rs/pull/216)) +- remove unstable `rustfmt` `version` setting (replaced by auto-detected `edition`) ([#220](https://github.com/microsoft/windows-drivers-rs/pull/220)) +- replace directory substitution plugin with condition_script_runner_args ([#208](https://github.com/microsoft/windows-drivers-rs/pull/208)) +- use cargo-make's built-in arg expansion instead of custom plugin support in `nested-cargo-workspace-in-cargo-make-emulated-workspace-support` ([#201](https://github.com/microsoft/windows-drivers-rs/pull/201)) +- Improve doc comments to comply with `too_long_first_doc_paragraph` clippy lint ([#202](https://github.com/microsoft/windows-drivers-rs/pull/202)) +- Update README.md ([#180](https://github.com/microsoft/windows-drivers-rs/pull/180)) +- update readme to call out bugged LLVM 18 versions ([#169](https://github.com/microsoft/windows-drivers-rs/pull/169)) +- Build perf: Make calls to bindgen run in parallel ([#159](https://github.com/microsoft/windows-drivers-rs/pull/159)) +- add support for rustc-check-cfg ([#150](https://github.com/microsoft/windows-drivers-rs/pull/150)) +- Bump windows from 0.52.0 to 0.56.0 ([#144](https://github.com/microsoft/windows-drivers-rs/pull/144)) +- Bump rustversion from 1.0.14 to 1.0.15 ([#145](https://github.com/microsoft/windows-drivers-rs/pull/145)) +- use a standardized workspace lint table ([#134](https://github.com/microsoft/windows-drivers-rs/pull/134)) +- Bump clap from 4.4.18 to 4.5.4 ([#130](https://github.com/microsoft/windows-drivers-rs/pull/130)) +- Bump thiserror from 1.0.56 to 1.0.59 ([#142](https://github.com/microsoft/windows-drivers-rs/pull/142)) +- fix `winget` llvm install command option ([#115](https://github.com/microsoft/windows-drivers-rs/pull/115)) +- fix various pipeline breakages (nightly rustfmt bug, new nightly clippy lints, upstream winget dependency issue) ([#117](https://github.com/microsoft/windows-drivers-rs/pull/117)) +- add lint exceptions for clippy::manual_c_str_literals and clippy::ref_as_ptr ([#108](https://github.com/microsoft/windows-drivers-rs/pull/108)) +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [0.2.0](https://github/microsoft/windows-drivers-rs/compare/wdk-build-v0.1.0...wdk-build-v0.2.0) - 2024-02-08 + +### Added +- package rust-driver-makefile.toml with wdk-build package ([#36](https://github/microsoft/windows-drivers-rs/pull/36)) +- support multiple drivers (of same type) in same cargo workspace +- cargo-make argument forwarding +- generate CStr for c string constants instead of &[u8] ([#72](https://github/microsoft/windows-drivers-rs/pull/72)) + +### 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 definitions +- fix wdk path regkey detection + +### Other +- update versions in readme and rust-driver-makefile.toml +- update dependencies +- allow multiple_crate_versions in wdk-build (build dependency) ([#98](https://github/microsoft/windows-drivers-rs/pull/98)) +- update cargo-make tasks with arch-specific tools +- Bump thiserror from 1.0.48 to 1.0.55 ([#59](https://github/microsoft/windows-drivers-rs/pull/59)) +- restrict to one unsafe operation per block ([#24](https://github/microsoft/windows-drivers-rs/pull/24)) +- [**breaking**] enable rustdoc lints and resolve errors +- initial open-source check in diff --git a/packaging/windows/drivers/vendor/wdk-build/Cargo.lock b/packaging/windows/drivers/vendor/wdk-build/Cargo.lock new file mode 100644 index 0000000..97eca7d --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/Cargo.lock @@ -0,0 +1,918 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" + +[[package]] +name = "assert_fs" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652f6cb1f516886fcfee5e7a5c078b9ade62cfcb889524efe5a64d682dd27a9" +dependencies = [ + "anstyle", + "doc-comment", + "globwalk", + "predicates", + "predicates-core", + "predicates-tree", + "tempfile", +] + +[[package]] +name = "bindgen" +version = "0.71.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "itertools", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", +] + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "bstr" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap-cargo" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d546f0e84ff2bfa4da1ce9b54be42285767ba39c688572ca32412a09a73851e5" +dependencies = [ + "anstyle", + "clap", +] + +[[package]] +name = "clap_builder" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "errno" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi", + "windows-targets", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "globset" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "globwalk" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "ignore" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "libc" +version = "0.2.172" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "libloading" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "predicates" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +dependencies = [ + "anstyle", + "difflib", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" + +[[package]] +name = "predicates-tree" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "termtree" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wdk-build" +version = "0.5.1" +dependencies = [ + "anyhow", + "assert_fs", + "bindgen", + "camino", + "cargo_metadata", + "cfg-if", + "clap", + "clap-cargo", + "paste", + "regex", + "rustversion", + "semver", + "serde", + "serde_json", + "thiserror", + "tracing", + "windows", +] + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] diff --git a/packaging/windows/drivers/vendor/wdk-build/Cargo.toml b/packaging/windows/drivers/vendor/wdk-build/Cargo.toml new file mode 100644 index 0000000..7ca7134 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/Cargo.toml @@ -0,0 +1,142 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2024" +rust-version = "1.85.0" +name = "wdk-build" +version = "0.5.1" +build = "build.rs" +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "A library to configure a Cargo build script for binding generation and downstream linking of the WDK (Windows Driver Kit)" +readme = "README.md" +keywords = [ + "wdk", + "windows", + "build-dependencies", +] +categories = [ + "development-tools::build-utils", + "development-tools::ffi", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/microsoft/windows-drivers-rs" + +[package.metadata.cargo-machete] +ignored = ["regex"] + +[features] +nightly = [] + +[lib] +name = "wdk_build" +path = "src/lib.rs" + +[dependencies.anyhow] +version = "1.0.97" + +[dependencies.bindgen] +version = "0.71.0" + +[dependencies.camino] +version = "1.1.9" + +[dependencies.cargo_metadata] +version = "0.19.2" + +[dependencies.cfg-if] +version = "1.0.3" + +[dependencies.clap] +version = "4.5.40" +features = ["derive"] + +[dependencies.clap-cargo] +version = "0.15.2" + +[dependencies.paste] +version = "1.0.15" + +[dependencies.regex] +version = "1.11.1" +features = ["unicode-case"] + +[dependencies.rustversion] +version = "1.0.20" + +[dependencies.semver] +version = "1.0.26" + +[dependencies.serde] +version = "1.0" +features = ["derive"] + +[dependencies.serde_json] +version = "1.0" + +[dependencies.thiserror] +version = "2.0.12" + +[dependencies.tracing] +version = "0.1.40" + +[dependencies.windows] +version = "0.58.0" +features = [ + "Win32_Foundation", + "Win32_System_Registry", +] + +[dev-dependencies.assert_fs] +version = "1.1.3" + +[dev-dependencies.windows] +version = "0.58.0" +features = ["Win32_UI_Shell"] + +[build-dependencies.rustversion] +version = "1.0.20" + +[lints.clippy] +all = "deny" +cargo = "warn" +multiple_unsafe_ops_per_block = "deny" +nursery = "warn" +pedantic = "warn" +undocumented_unsafe_blocks = "deny" +unnecessary_safety_doc = "deny" + +[lints.rust] +missing_docs = "warn" +unsafe_op_in_unsafe_fn = "forbid" + +[lints.rust.unexpected_cfgs] +level = "warn" +priority = 0 +check-cfg = [ + "cfg(wdk_build_unstable)", + "cfg(skip_umdf_static_crt_check)", +] + +[lints.rustdoc] +bare_urls = "warn" +broken_intra_doc_links = "warn" +invalid_codeblock_attributes = "warn" +invalid_html_tags = "warn" +invalid_rust_codeblocks = "warn" +missing_crate_level_docs = "warn" +private_intra_doc_links = "warn" +redundant_explicit_links = "warn" +unescaped_backticks = "warn" diff --git a/packaging/windows/drivers/vendor/wdk-build/README.md b/packaging/windows/drivers/vendor/wdk-build/README.md new file mode 100644 index 0000000..4df726a --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/README.md @@ -0,0 +1,237 @@ +# windows-drivers-rs + +This repo is a collection of Rust crates that enable developers to develop Windows Drivers in Rust. It is the intention to support both WDM and WDF driver development models. This repo contains the following crates: + +* [wdk-build](./crates/wdk-build): A library to configure a Cargo build script for binding generation and downstream linking of the WDK (Windows Driver Kit). While this crate is written to be flexible with different WDK releases and different WDF version, it is currently only tested for NI eWDK, KMDF 1.33, UMDF 2.33, and WDM Drivers. There may be missing linker options for older DDKs. +* [wdk-sys](./crates/wdk-sys): Direct FFI bindings to APIs available in the Windows Development Kit (WDK). This includes both autogenerated ffi bindings from `bindgen`, and also manual re-implementations of macros that bindgen fails to generate. +* [wdk](./crates/wdk): Safe idiomatic bindings to APIs available in the Windows Development Kit (WDK) +* [wdk-panic](./crates/wdk-panic/): Default panic handler implementations for programs built with WDK +* [wdk-alloc](./crates/wdk-alloc): alloc support for binaries compiled with the Windows Development Kit (WDK) +* [wdk-macros](./crates/wdk-macros): A collection of macros that help make it easier to interact with wdk-sys's direct bindings. This crate is re-exported via `wdk-sys` and crates should typically never need to directly depend on `wdk-macros` + +To see an example of this repo used to create drivers, see [Windows-rust-driver-samples](https://github.com/microsoft/Windows-rust-driver-samples). + +Note: This project is still in early stages of development and is not yet recommended for production use. We encourage community experimentation and collaboration through our [GitHub Discussions forum](https://github.com/microsoft/windows-drivers-rs/discussions)! + +## Supported Configurations + +This project was built with support of WDM, KMDF, and UMDF drivers in mind, as well as Win32 Services. This includes support for all versions of WDF included in WDK 22H2 and newer. Currently, the crates available on [`crates.io`](https://crates.io) only support KMDF v1.33, but bindings can be generated for everything else by cloning `windows-drivers-rs` and modifying the config specified in [`build.rs` of `wdk-sys`](./crates/wdk-sys/build.rs). Crates.io support for other WDK configurations is planned in the near future. + +## Repo Layout + +* [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, 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). + +## Getting Started + +### Build Requirements + +* Binding generation via `bindgen` requires `libclang`. The easiest way to acquire this is via `winget` + * `winget install -i LLVM.LLVM --version 17.0.6 --force` + * Ensure you select the GUI option to add LLVM to the PATH + * LLVM 18 has a bug that causes bindings to fail to generate for ARM64. Continue using LLVM 17 until LLVM 19 comes out with [the fix](https://github.com/llvm/llvm-project/pull/93235). See [this](https://github.com/rust-lang/rust-bindgen/issues/2842) for more details. +* To execute post-build tasks (ie. `inf2cat`, `infverif`, etc.), `cargo make` is used + * `cargo install --locked cargo-make --no-default-features --features tls-native` + +* Building programs with the WDK also requires being in a valid WDK environment. The recommended way to do this is to [enter an eWDK developer prompt](https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk#getting-started) + +### Adding windows-drivers-rs to Your Driver Package + +The crates in this repository are available from [`crates.io`](https://crates.io), but take into account the current limitations outlined in [Supported Configurations](#supported-configs). If you need to support a different config, try cloning this repo and using [path dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies) + +1. Create a new Cargo package with a lib crate: + + ```pwsh + cargo new --lib + ``` + +1. Add dependencies on `windows-drivers-rs` crates: + + ```pwsh + cd + cargo add --build wdk-build + cargo add wdk wdk-sys wdk-alloc wdk-panic + ``` + +1. Set the crate type to `cdylib` by adding the following snippet to `Cargo.toml`: + + ```toml + [lib] + crate-type = ["cdylib"] + ``` + +1. Add a wdk metadata section and configure the wdk for your use case. This also lets the cargo-make tasks know that the package is a driver and that the driver packaging steps need to run. + + UMDF Example: + ```toml + [package.metadata.wdk.driver-model] + driver-type = "UMDF" + umdf-version-major = 1 + target-umdf-version-minor = 33 + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Set crate panic strategy to `abort` in `Cargo.toml`: + + ```toml + [profile.dev] + panic = "abort" + + [profile.release] + panic = "abort" + ``` + +1. Create a `build.rs` and add the following snippet: + + ```rust + fn main() -> Result<(), wdk_build::ConfigError> { + wdk_build::configure_wdk_binary_build() + } + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Mark your driver crate as `no_std` in `lib.rs`: + + ```rust + #![no_std] + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Add a panic handler in `lib.rs`: + + ```rust + #[cfg(not(test))] + extern crate wdk_panic; + + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Add an optional global allocator in `lib.rs`: + + ```rust + #[cfg(not(test))] + use wdk_alloc::WdkAllocator; + + #[cfg(not(test))] + #[global_allocator] + static GLOBAL_ALLOCATOR: WdkAllocator = WdkAllocator; + ``` + + This is only required if you want to be able to use the [`alloc` modules](https://doc.rust-lang.org/alloc/) in the rust standard library. + +1. Add a DriverEntry in `lib.rs`: + + ```rust + use wdk_sys::{ + PDRIVER_OBJECT, + NTSTATUS, + PCUNICODE_STRING, + }; + + // SAFETY: "DriverEntry" is the required symbol name for Windows driver entry points. + // No other function in this compilation unit exports this name, preventing symbol conflicts. + #[unsafe(export_name = "DriverEntry")] // WDF expects a symbol with the name DriverEntry + pub unsafe extern "system" fn driver_entry( + driver: PDRIVER_OBJECT, + registry_path: PCUNICODE_STRING, + ) -> NTSTATUS { + 0 + } + ``` + + Note: In Kernel Mode crates, you can use `driver: &mut DRIVER_OBJECT` instead of `driver: PDRIVER_OBJECT`. + +1. Add a `Makefile.toml`: + ```toml + extend = "target/rust-driver-makefile.toml" + + [config] + load_script = ''' + #!@rust + //! ```cargo + //! [dependencies] + //! wdk-build = "0.5.1" + //! ``` + #![allow(unused_doc_comments)] + + wdk_build::cargo_make::load_rust_driver_makefile()? + ''' + ``` + +1. Add an inx file that matches the name of your `cdylib` crate. + +1. Enable static crt linkage. One approach is to add this to your `.cargo/config.toml`: + + ```toml + [build] + rustflags = ["-C", "target-feature=+crt-static"] + ``` + +1. Build the driver: + + ```pwsh + cargo make + ``` + +A signed driver package, including a `WDRLocalTestCert.cer` file, will be generated at `target//package`. If a specific target architecture was specified, the driver package will be generated at `target///package` + +Minimal examples of `WDM`, `KMDF`, and `UMDF` drivers can be found in the [examples directory](./examples). + +## Cargo Make + +[`cargo-make`](https://github.com/sagiegurari/cargo-make) is used to facilitate builds using `windows-drivers-rs`, including for executing post-build driver packaging steps. + +To execute the default action (build and package driver): + +`cargo make default` + +When executing the default task, just `cargo make` make also works since the `default` task is implied. + +### Argument Forwarding + +`windows-drivers-rs` extends `cargo make` to forward specific arguments to the underlying `cargo` commands. In order to specify arguments to forward, they must be provided **after explicitly specifying the `cargo-make` task name** (ie. omitting the name for the `default` task is not supported). + +#### Examples + +For a specific target: + +`cargo make default --target ` + +For release builds: + +`cargo make default --release` or `cargo make default --profile release` + +To specify specific features: + +`cargo make default --features ` + +To specify a specific rust toolchain: + +`cargo make default +` + +To display help and see the full list of supported CLI args to forward to Cargo: + +`cargo make help` + +### Driver Package Signature Verification + +The `WDK_BUILD_ENABLE_SIGNTOOL_VERIFY` [cargo-make environment variable](https://github.com/sagiegurari/cargo-make?tab=readme-ov-file#environment-variables) can be set to `true` to enable tasks that handle signature verification of the generated `.sys` and `.cat` files. `signtool verify` requires the certificate to be installed as in the `Trusted Root Certification Authorities` for this verification to function. These tasks are not enabled by default as the default behavior of `WDR` is to sign with a generated test certificate. These test certificates are typically only installed into `Trusted Root Certification Authorities` on computers dedicated to testing drivers, and not personal development machines, given the security implications of installing your own root certificates. + +If you understand these implications, and have installed the test certificate, then you may validate the signatures as follows: + +``` +cargo make --env WDK_BUILD_ENABLE_SIGNTOOL_VERIFY=true +``` + +## Contact + +* For bug reports, feature requests, and other actionable items, please use [GitHub Issues](https://github.com/microsoft/windows-drivers-rs/issues) +* For broader questions, architectural discussions, and community engagement, please use [GitHub Discussions](https://github.com/microsoft/windows-drivers-rs/discussions) +* For inquiries not suitable for public forums, email us at + +## Crates.io Release Policy + +Releases to crates.io are not made after every change merged to main. Releases will only be made when requested by the community, or when the `windows-drivers-rs` team believes there is sufficient value in pushing a release. + +## Trademark Notice + +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. diff --git a/packaging/windows/drivers/vendor/wdk-build/build.rs b/packaging/windows/drivers/vendor/wdk-build/build.rs new file mode 100644 index 0000000..c375368 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/build.rs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Build script for the `wdk-build` crate +//! +//! This provides a `nightly_toolchain` feature to the `wdk-build` crate, so +//! that it can conditionally enable unstable features. + +fn main() { + println!("cargo::rustc-check-cfg=cfg(nightly_toolchain)"); + setup_nightly_cfgs(); +} + +// Custom attributes cannot be applied to expressions yet, so separate functions are required for nightly/non-nightly: https://github.com/rust-lang/rust/issues/15701 +#[rustversion::nightly] +fn setup_nightly_cfgs() { + println!("cargo::rustc-cfg=nightly_toolchain"); +} + +#[rustversion::not(nightly)] +const fn setup_nightly_cfgs() {} diff --git a/packaging/windows/drivers/vendor/wdk-build/rust-driver-makefile.toml b/packaging/windows/drivers/vendor/wdk-build/rust-driver-makefile.toml new file mode 100644 index 0000000..06a52c8 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/rust-driver-makefile.toml @@ -0,0 +1,567 @@ +# This file is leveraged to build downstream drivers. See examples at https://github.com/microsoft/Windows-rust-drivers-samples + +[config] +min_version = "0.37.16" +init_task = "wdk-build-init" +reduce_output = false + +[env] +# This allows all workspace members to access this makefile +CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true + +# CARGO_MAKE_CARGO_BUILD_TEST_FLAGS is set to "--all-features" by default in cargo-make: https://github.com/sagiegurari/cargo-make/blob/c0abc4d0ae1bcc03adde22b63fa0accc4af2b3bc/src/lib/descriptor/makefiles/stable.toml#L31 +# This is set to "" here to match the default behavior of Cargo. +CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = { unset = true } + +# rust-script condition_script's return `Err` to signal that the task should not be run. Hide Err backtraces by default to keep output cleaner. +RUST_LIB_BACKTRACE = 0 + +WDK_BUILD_BASE_INFVERIF_FLAGS = "/v" + +[plugins.impl.rust-env-update] +script = ''' +assert ${task.has_script} "script is required for rust-env-update plugin" +assert_eq ${task.script_runner} @rust "script_runner must be set to @rust for rust-env-update plugin" + +cargo_make_rust_script_provider = get_env CARGO_MAKE_RUST_SCRIPT_PROVIDER +assert_eq ${cargo_make_rust_script_provider} rust-script "rust-env-update plugin is only compatible with rust-script" + +taskjson = json_parse ${task.as_json} + +# Install dependency crate +out = exec --fail-on-error cargo install ${taskjson.install_crate.crate_name} --version ${taskjson.install_crate.min_version} +assert_eq ${out.code} 0 "[tasks.${task.name}]'s install_crate failed with exit code: ${out.code}\nstdout:\n${out.stdout}\nstderr:\n${out.stderr}" + +# Enable rust-env-update's rust-script cache (Note: when developing locally on WDR itself, rust-script.exe --clear-cache can be used to force a rebuild of the script's wdk-build dependency) +filepath = set "${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/cargo-make-script/${task.name}/rust-env-update.rs" +# If a file already exists, only overwrite it if the script has changed (so that rust-script caching can be leveraged) +if is_file ${filepath} + old_hash = digest --algo sha256 --file ${filepath} + new_hash = digest --algo sha256 ${taskjson.script} + if not eq ${old_hash} ${new_hash} + writefile ${filepath} ${taskjson.script} + end +else + writefile ${filepath} ${taskjson.script} +end + +# Append cli args to task args +task_args = array_join ${task.args} " " +cli_args = array_join ${flow.cli.args} " " +combined_args = concat ${cli_args} " " ${task_args} +combined_args = trim ${combined_args} + +# Execute rust-script +out = exec --fail-on-error rust-script --base-path ${taskjson.env.CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY} ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/cargo-make-script/${task.name}/rust-env-update.rs %{combined_args} +assert_eq ${out.code} 0 "[tasks.${task.name}]'s script failed with exit code: ${out.code}\nstdout:\n${out.stdout}\nstderr:\n${out.stderr}\nThe temporary rust-script file is located at ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/cargo-make-script/${task.name}/rust-env-update.rs" + +if contains ${combined_args} "--help" + println ${out.stdout} + + # If help was triggered, exit with code 1 to prevent the rest of the makefile from running + exit 1 +end + +# Set cargo-make env vars based on output of rust-script +script_output = trim ${out.stdout} +if not is_empty ${script_output} + script_output_array = split ${script_output} \n + + # Search the stdout output of the script, with the following behaviours for each line: + # 1. If the line is between the "FORWARDING ARGS TO CARGO-MAKE:" start delimited and the "END OF FORWARDING ARGS TO CARGO-MAKE" end delimiter, update the cargo-make process' environment variables based on the key-value pairs in the line. + # 2. If the line is not between the start and end delimiters, print the line normally. + looking_for_start_delimiter = set true + for line in ${script_output_array} + if ${looking_for_start_delimiter} + if eq ${line} "FORWARDING ARGS TO CARGO-MAKE:" + looking_for_start_delimiter = set false + else + # Any output not surrounded by the start and end delimiter lines should be printed normally + println ${line} + end + else + if eq ${line} "END OF FORWARDING ARGS TO CARGO-MAKE" + looking_for_start_delimiter = set true + else + # Set cargo-make env_var based on line output + parts = split ${line} = + key = array_get ${parts} 0 + value = array_get ${parts} 1 + set_env ${key} ${value} + end + end + end + assert ${looking_for_start_delimiter} "A matching \"END OF FORWARDING ARGS TO CARGO-MAKE\" for a \"FORWARDING ARGS TO CARGO-MAKE:\" was not found in script output." +end +''' + +# This plugin adds support for cargo-make's emulated workspace feature to work on emulated workspace members which are Cargo workspaces themselves. +# Since Cargo workspaces are not detected in cargo-make emulated workspace members, the task is rerun in a forked subprocess with the CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER env var unset to allow cargo-make's workspace detection to run. +[plugins.impl.nested-cargo-workspace-in-cargo-make-emulated-workspace-support] +script = ''' +# If current flow is executing in a Cargo workspace, which is a member of a cargo-make emulated workspace +if ${CARGO_MAKE_WORKSPACE_EMULATION} and ${CARGO_MAKE_CRATE_IS_WORKSPACE} + + # Re-run the task in a forked subprocess, allowing cargo-make to run in a workspace context (i.e. running on each of the members of the Cargo workspace) + echo Executing \"${task.name}\" Task in a forked subprocess to run on Cargo workspace: ${CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER} + + # Unset the CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER env var to allow cargo-make's workspace detection to run + unset_env CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER + + cm_plugin_run_custom_task "{\"run_task\":{\"name\":\"${task.name}\",\"fork\":true}}" +else + cm_plugin_run_task +end +''' + +[tasks.wdk-build-init] +private = true +install_crate = { crate_name = "rust-script", min_version = "0.30.0" } +plugin = "rust-env-update" +script_runner = "@rust" +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +let cli_env_vars = wdk_build::cargo_make::validate_command_line_args(); +let path_env_vars = wdk_build::cargo_make::setup_path()?; +let wdk_version_env_vars = wdk_build::cargo_make::setup_wdk_version()?; + +wdk_build::cargo_make::forward_printed_env_vars( + cli_env_vars.into_iter().chain(path_env_vars).chain(wdk_version_env_vars), +); +''' + +[tasks.setup-wdk-config-env-vars] +# 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" +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +let serialized_wdk_metadata_map = wdk_build::metadata::to_map_with_prefix::>( + "WDK_BUILD_METADATA", + &wdk_build::metadata::Wdk::try_from(&wdk_build::cargo_make::get_cargo_metadata()?)?, +)?; + +#[cfg(not(target_os = "windows"))] +compile_error!( + "windows-drivers-rs is designed to be run on a Windows host machine in a WDK \ + environment. Please build using a Windows target." +); + +for (key, value) in &serialized_wdk_metadata_map { + // SAFETY: this function is only conditionally compiled for windows targets, and + // env::set_var is always safe for windows targets + unsafe { + std::env::set_var(key, value); + } +} + +wdk_build::cargo_make::forward_printed_env_vars( + serialized_wdk_metadata_map + .into_iter() + .map(|(key, _)| key), +); +''' + +[tasks.copy-inx-to-output] +private = true +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +// Create build output directory if it doesn't exist +let output_folder_path = wdk_build::cargo_make::get_wdk_build_output_directory(); +if !output_folder_path.exists() { + std::fs::create_dir_all(&output_folder_path).expect(&format!("creation of '{}' folder should succeed", output_folder_path.display())); +} + +let cargo_make_working_directory = std::env::var("CARGO_MAKE_WORKING_DIRECTORY").expect( + "CARGO_MAKE_WORKING_DIRECTORY should be set by cargo-make via the env section of \ + rust-driver-makefile.toml", +); + +let source_file = [ + cargo_make_working_directory, + format!("{}.inx", wdk_build::cargo_make::get_current_package_name()), +] +.iter() +.collect::(); + +let destination_file = wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "{}.inf", + wdk_build::cargo_make::get_current_package_name() +)); + +std::fs::copy(&source_file, &destination_file).expect(&format!( + "copy of '{}' file to '{}' file should succeed", + source_file.display(), + destination_file.display() +)); +''' + +[tasks.generate-driver-binary-file] +private = true +dependencies = ["setup-wdk-config-env-vars", "build"] +condition_script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +condition_script = ''' +#!@rust + +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +wdk_build::cargo_make::condition_script(|| { + let driver_type = std::env::var("WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE") + .expect("WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE should be set by setup-wdk-config-env-vars cargo-make task"); + + match driver_type.as_str() { + "WDM" | "KMDF" => Ok(()), + _ => Err("Non-Kernel Mode Driver detected. Skipping generate-driver-binary-file task."), + } +})? +''' +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +#!@rust + +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +let source_file = wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "{}.dll", + wdk_build::cargo_make::get_current_package_name() +)); + +let destination_file = wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "{}.sys", + wdk_build::cargo_make::get_current_package_name() +)); + +std::fs::copy(&source_file, &destination_file).expect(&format!( + "copy of '{}' file to '{}' file should succeed", + source_file.display(), + destination_file.display() +)); +''' + +[tasks.stampinf] +private = true +dependencies = ["setup-wdk-config-env-vars", "copy-inx-to-output"] +env = { "WDK_BUILD_STAMPINF_WDF_FLAGS" = { source = "${WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE}", default_value = "", mapping = { "KMDF" = "-k ${WDK_BUILD_METADATA-DRIVER_MODEL-KMDF_VERSION_MAJOR}.${WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR}", "UMDF" = "-u ${WDK_BUILD_METADATA-DRIVER_MODEL-UMDF_VERSION_MAJOR}.${WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_UMDF_VERSION_MINOR}.0" } }, "WDK_BUILD_STAMPINF_ARCH" = { source = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", default_value = "UNKNOWN", mapping = { "x86_64-pc-windows-msvc" = "amd64", "aarch64-pc-windows-msvc" = "arm64" } } } +command = "stampinf" +args = [ + "-f", + "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}.inf", + "-d", + "*", + "-a", + "${WDK_BUILD_STAMPINF_ARCH}", + "-c", + "${CARGO_MAKE_CRATE_FS_NAME}.cat", + "-v", + "*", + "@@split(WDK_BUILD_STAMPINF_WDF_FLAGS, ,remove-empty)", +] + +[tasks.infverif] +private = true +dependencies = ["setup-wdk-config-env-vars", "stampinf"] +# TODO: This should be if WDK <= GE && DRIVER_MODEL == UMDF +env = { "WDK_BUILD_BASE_INFVERIF_FLAGS" = { source = "${WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE}", default_value = "${WDK_BUILD_BASE_INFVERIF_FLAGS} /w", mapping = { "UMDF" = "${WDK_BUILD_BASE_INFVERIF_FLAGS} /u" } } } +command = "infverif" +args = [ + "@@split(WDK_BUILD_BASE_INFVERIF_FLAGS, ,remove-empty)", + "@@split(WDK_BUILD_ADDITIONAL_INFVERIF_FLAGS, ,remove-empty)", + "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}.inf", +] + +[tasks.copy-driver-binary-to-package] +private = true +dependencies = ["setup-wdk-config-env-vars", "generate-driver-binary-file"] +env = { "WDK_BUILD_DRIVER_EXTENSION" = { source = "${WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE}", default_value = "UNKNOWN_EXTENSION", mapping = { "WDM" = "sys", "KMDF" = "sys", "UMDF" = "dll" } } } +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +let driver_binary_extension = std::env::var("WDK_BUILD_DRIVER_EXTENSION").expect("WDK_BUILD_DRIVER_EXTENSION should be set by cargo-make"); +wdk_build::cargo_make::copy_to_driver_package_folder( + wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "{}.{driver_binary_extension}", + wdk_build::cargo_make::get_current_package_name() + )), +)? +''' + +[tasks.copy-pdb-to-package] +private = true +dependencies = ["build"] +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +wdk_build::cargo_make::copy_to_driver_package_folder( + wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "{}.pdb", + wdk_build::cargo_make::get_current_package_name() + )), +)? +''' + +[tasks.copy-inf-to-package] +private = true +dependencies = ["stampinf"] +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +wdk_build::cargo_make::copy_to_driver_package_folder( + wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "{}.inf", + wdk_build::cargo_make::get_current_package_name() + )), +)? +''' + +[tasks.copy-map-to-package] +private = true +dependencies = ["build"] +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +wdk_build::cargo_make::copy_to_driver_package_folder( + wdk_build::cargo_make::get_wdk_build_output_directory().join(format!( + "deps/{}.map", + wdk_build::cargo_make::get_current_package_name() + )), +)? +''' + +[tasks.inf2cat] +private = true +dependencies = ["copy-driver-binary-to-package", "copy-inf-to-package"] +env = { "WDK_BUILD_INF2CAT_OS" = { source = "${CARGO_MAKE_CRATE_TARGET_TRIPLE}", default_value = "UNKNOWN", mapping = { "x86_64-pc-windows-msvc" = "10_x64", "aarch64-pc-windows-msvc" = "Server10_arm64" } } } +command = "inf2cat" +args = [ + "/driver:${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package", + "/os:${WDK_BUILD_INF2CAT_OS}", + "/uselocaltime", +] + +[tasks.generate-certificate] +private = true +condition_script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +condition_script = ''' +#!@rust + +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! anyhow = "1" +//! ``` +#![allow(unused_doc_comments)] + +fn main() -> anyhow::Result<()> { + wdk_build::cargo_make::generate_certificate_condition_script() +} +''' +command = "makecert" +args = [ + "-r", + "-pe", + "-a", + "SHA256", + "-eku", + "1.3.6.1.5.5.7.3.3", + "-ss", + "WDRTestCertStore", # FIXME: this should be a parameter + "-n", + "CN=WDRLocalTestCert", # FIXME: this should be a parameter + "${WDK_BUILD_OUTPUT_DIRECTORY}/WDRLocalTestCert.cer", +] + +[tasks.copy-certificate-to-package] +private = true +dependencies = ["generate-certificate"] +script_runner = "@rust" +script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +wdk_build::cargo_make::copy_to_driver_package_folder( + wdk_build::cargo_make::get_wdk_build_output_directory().join("WDRLocalTestCert.cer"), +)? +''' + +[tasks.signtool-sign] +private = true +dependencies = ["generate-certificate"] +command = "signtool" +args = [ + "sign", + "/v", + "/s", + "WDRTestCertStore", # FIXME: this should be a parameter + "/n", + "WDRLocalTestCert", # FIXME: this should be a parameter + "/t", + "http://timestamp.digicert.com", + "/fd", + "SHA256", + "${WDK_BUILD_SIGNTOOL_SIGN_INPUT_FILE}", +] + +[tasks.sign-driver-binary] +private = true +dependencies = ["setup-wdk-config-env-vars", "copy-driver-binary-to-package"] +env = { "WDK_BUILD_SIGNTOOL_SIGN_INPUT_FILE" = "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package/${CARGO_MAKE_CRATE_FS_NAME}.${WDK_BUILD_DRIVER_EXTENSION}" } +run_task = "signtool-sign" + +[tasks.sign-cat] +private = true +dependencies = ["inf2cat", "sign-driver-binary"] +env = { "WDK_BUILD_SIGNTOOL_SIGN_INPUT_FILE" = "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package/${CARGO_MAKE_CRATE_FS_NAME}.cat" } +run_task = "signtool-sign" + +[tasks.signtool-verify] +private = true +condition = { env_true = ["WDK_BUILD_ENABLE_SIGNTOOL_VERIFY"] } +command = "signtool" +args = ["verify", "/v", "/pa", "${WDK_BUILD_SIGNTOOL_VERIFY_INPUT_FILE}"] + +[tasks.verify-signature-driver-binary] +private = true +dependencies = ["setup-wdk-config-env-vars", "sign-driver-binary"] +env = { "WDK_BUILD_SIGNTOOL_VERIFY_INPUT_FILE" = "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package/${CARGO_MAKE_CRATE_FS_NAME}.${WDK_BUILD_DRIVER_EXTENSION}" } +run_task = "signtool-verify" + +[tasks.verify-signature-cat] +private = true +dependencies = ["sign-cat"] +env = { "WDK_BUILD_SIGNTOOL_VERIFY_INPUT_FILE" = "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package/${CARGO_MAKE_CRATE_FS_NAME}.cat" } +run_task = "signtool-verify" + +[tasks.package-driver] +private = true +dependencies = [ + "copy-driver-binary-to-package", + "copy-pdb-to-package", + "copy-inf-to-package", + "copy-map-to-package", + "copy-certificate-to-package", + "sign-driver-binary", + "verify-signature-driver-binary", + "sign-cat", + "verify-signature-cat", + "infverif", +] + +[tasks.package-driver-flow] +# Note: Dependencies are always run, regardless of the condition_script result. This allows `cargo make` in mixed driver/non-driver workspaces +dependencies = ["build"] +# Only run package-driver flow if the current package is marked as a driver +plugin = "nested-cargo-workspace-in-cargo-make-emulated-workspace-support" +condition_script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +condition_script = ''' +#!@rust + +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! anyhow = "1" +//! ``` +#![allow(unused_doc_comments)] + +fn main() -> anyhow::Result<()> { + wdk_build::cargo_make::package_driver_flow_condition_script() +} +''' +run_task = "package-driver" + +[tasks.help] +extend = "wdk-build-init" +private = false +workspace = false +args = ["--help"] + +[tasks.default] +alias = "package-driver-flow" diff --git a/packaging/windows/drivers/vendor/wdk-build/rust-driver-sample-makefile.toml b/packaging/windows/drivers/vendor/wdk-build/rust-driver-sample-makefile.toml new file mode 100644 index 0000000..90dfdd6 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/rust-driver-sample-makefile.toml @@ -0,0 +1,48 @@ +# This file is used to extend the standard rust-driver-makefile to build official sample drivers. See examples at https://github.com/microsoft/Windows-rust-drivers-samples +# Using this file requires extending both the standard makefile and this makefile in order, as follows: +# extend = [ { path = "target/rust-driver-makefile.toml" }, { path = "target/rust-driver-sample-makefile.toml" } ] + +[tasks.wdk-samples-setup] +private = true +install_crate = { crate_name = "rust-script", min_version = "0.30.0" } +plugin = "rust-env-update" +script_runner = "@rust" +script = ''' +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! ``` +#![allow(unused_doc_comments)] + +let env_string = std::env::var_os(wdk_build::cargo_make::WDK_VERSION_ENV_VAR) + .map_or_else( + || panic!("Couldn't read WDK build version that should have been set in init"), + |os_env_string| os_env_string.to_string_lossy().into_owned(), + ); +let samples_infverif_env_vars = wdk_build::cargo_make::setup_infverif_for_samples(&env_string)?; + +wdk_build::cargo_make::forward_printed_env_vars( + samples_infverif_env_vars, +); +''' + +[tasks.infverif] +dependencies = ["wdk-samples-setup", "stampinf"] +condition_script_runner_args = [ + "--base-path", + "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}", +] +condition_script = ''' +#!@rust + +//! ```cargo +//! [dependencies] +//! wdk-build = { path = ".", version = "0.5.1" } +//! anyhow = "1" +//! ``` +#![allow(unused_doc_comments)] + +fn main() -> anyhow::Result<()> { + wdk_build::cargo_make::driver_sample_infverif_condition_script() +} +''' diff --git a/packaging/windows/drivers/vendor/wdk-build/src/bindgen.rs b/packaging/windows/drivers/vendor/wdk-build/src/bindgen.rs new file mode 100644 index 0000000..ecae67e --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/bindgen.rs @@ -0,0 +1,273 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +use std::{borrow::Borrow, fmt}; + +use bindgen::{ + Builder, + callbacks::{ItemInfo, ItemKind, ParseCallbacks}, +}; +use cargo_metadata::MetadataCommand; +use tracing::debug; + +use crate::{Config, ConfigError, DriverConfig, find_top_level_cargo_manifest}; + +/// An extension trait that provides a way to create a [`bindgen::Builder`] +/// configured for generating bindings to the wdk +pub trait BuilderExt { + /// Returns a `bindgen::Builder` with the default configuration for + /// generation of bindings to the WDK + /// + /// # Errors + /// + /// Implementation may return `wdk_build::ConfigError` if it fails to create + /// a builder + fn wdk_default(config: impl Borrow + fmt::Debug) -> Result; +} + +#[derive(Debug)] +struct WdkCallbacks { + wdf_function_table_symbol_name: Option, +} + +struct BindgenRustEditionWrapper(bindgen::RustEdition); + +impl TryFrom for BindgenRustEditionWrapper { + type Error = ConfigError; + + fn try_from(edition: cargo_metadata::Edition) -> Result { + match edition { + cargo_metadata::Edition::E2015 => Err(ConfigError::UnsupportedRustEdition { + edition: "2015".to_string(), + }), + cargo_metadata::Edition::E2018 => Ok(Self(bindgen::RustEdition::Edition2018)), + cargo_metadata::Edition::E2021 => Ok(Self(bindgen::RustEdition::Edition2021)), + cargo_metadata::Edition::E2024 => Ok(Self(bindgen::RustEdition::Edition2024)), + cargo_metadata::Edition::_E2027 => Err(ConfigError::UnsupportedRustEdition { + edition: "2027".to_string(), + }), + cargo_metadata::Edition::_E2030 => Err(ConfigError::UnsupportedRustEdition { + edition: "2030".to_string(), + }), + _ => Err(ConfigError::UnsupportedRustEdition { + edition: "unknown".to_string(), + }), + } + } +} + +impl BuilderExt for Builder { + /// Returns a `bindgen::Builder` with the default configuration for + /// generation of bindings to the WDK + /// + /// # Errors + /// + /// Will return `wdk_build::ConfigError` if any of the resolved include or + /// library paths do not exist + #[tracing::instrument(level = "debug")] + fn wdk_default(config: impl Borrow + fmt::Debug) -> Result { + let config = config.borrow(); + + let mut builder = Self::default() + .use_core() // Can't use std for kernel code + .derive_default(true) // allows for default initializing structs + // CStr types are safer and easier to work with when interacting with string constants + // from C + .generate_cstr(true) + // Building in eWDK can pollute system search path when clang-sys tries to detect + // c_search_paths + .detect_include_paths(false) + .clang_args(config.include_paths()?.map(|include_path| { + format!( + "--include-directory={}", + include_path + .to_str() + .expect("Non Unicode paths are not supported") + ) + })) + .clang_args( + config + .preprocessor_definitions() + .map(|(key, value)| { + format!( + "--define-macro={key}{}", + value.map(|v| format!("={v}")).unwrap_or_default() + ) + }) + .chain(Config::wdk_bindgen_compiler_flags()), + ) + .blocklist_item("ExAllocatePoolWithTag") // Deprecated + .blocklist_item("ExAllocatePoolWithQuotaTag") // Deprecated + .blocklist_item("ExAllocatePoolWithTagPriority") // Deprecated + .blocklist_item("ExAllocatePool") // Deprecated + .blocklist_item("USBD_CalculateUsbBandwidth") // Deprecated + .blocklist_item("USBD_CreateConfigurationRequest") // Deprecated + .blocklist_item("USBD_Debug_LogEntry") // Deprecated + .blocklist_item("USBD_GetUSBDIVersion") // Deprecated + .blocklist_item("USBD_ParseConfigurationDescriptor") // Deprecated + .blocklist_item("USBD_QueryBusTime") // Deprecated + .blocklist_item("USBD_RegisterHcFilter") // Deprecated + .blocklist_item("IOCTL_USB_DIAG_IGNORE_HUBS_OFF") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_DIAG_IGNORE_HUBS_ON") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_DIAGNOSTIC_MODE_OFF") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_DIAGNOSTIC_MODE_ON") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_GET_HUB_CAPABILITIES") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_HCD_DISABLE_PORT") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_HCD_ENABLE_PORT") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_HCD_GET_STATS_1") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_HCD_GET_STATS_2") // Deprecated/Internal-Use-Only + .blocklist_item("IOCTL_USB_RESET_HUB") // Deprecated/Internal-Use-Only + .opaque_type("_KGDTENTRY64") // No definition in WDK + .opaque_type("_KIDTENTRY64") // No definition in WDK + // FIXME: bitfield generated with non-1byte alignment in _MCG_CAP + .blocklist_item(".*MCG_CAP(?:__bindgen.*)?") + .blocklist_item(".*WHEA_XPF_MCA_SECTION") + .blocklist_item(".*WHEA_ARM_BUS_ERROR(?:__bindgen.*)?") + .blocklist_item(".*WHEA_ARM_PROCESSOR_ERROR") + .blocklist_item(".*WHEA_ARM_CACHE_ERROR") + // FIXME: bindgen unable to generate for anonymous structs + // https://github.com/rust-lang/rust-bindgen/issues/3177 + .blocklist_item(".*ADDRESS0_OWNERSHIP_ACQUIRE") + .blocklist_item(".*USBDEVICE_ABORTIO") + .blocklist_item(".*USBDEVICE_STARTIO") + .blocklist_item(".*USBDEVICE_TREE_PURGEIO") + // FIXME: arrays with more than 32 entries currently fail to generate a `Default`` impl: https://github.com/rust-lang/rust-bindgen/issues/2803 + .no_default(".*tagMONITORINFOEXA") + .must_use_type("NTSTATUS") + .must_use_type("HRESULT") + // Defaults enums to generate as a set of constants contained in a module (default value + // is EnumVariation::Consts which generates enums as global constants) + .default_enum_style(bindgen::EnumVariation::ModuleConsts) + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + .parse_callbacks(Box::new(WdkCallbacks::new(config))) + .formatter(bindgen::Formatter::Prettyplease) + .rust_target(get_rust_target()?) + .rust_edition(get_rust_edition()?); + + // The `_USBPM_CLIENT_CONFIG_EXTRA_INFO` struct only has members when + // _KERNEL_MODE flag is defined. We need to mark this type as opaque to avoid + // generating an empty struct, since they are not currently supported by + // bindgen: https://github.com/rust-lang/rust-bindgen/issues/1683 + if let DriverConfig::Umdf(_) = config.driver_config { + builder = builder.opaque_type("_USBPM_CLIENT_CONFIG_EXTRA_INFO"); + } + + Ok(builder) + } +} + +impl ParseCallbacks for WdkCallbacks { + fn generated_name_override(&self, item_info: ItemInfo) -> Option { + // Override the generated name for the WDF function table symbol, since bindgen is unable to currently translate the #define automatically: https://github.com/rust-lang/rust-bindgen/issues/2544 + if let Some(wdf_function_table_symbol_name) = &self.wdf_function_table_symbol_name { + if let ItemInfo { + name: item_name, + kind: ItemKind::Var, + .. + } = item_info + { + if item_name == wdf_function_table_symbol_name { + return Some("WdfFunctions".to_string()); + } + } + } + None + } +} + +impl WdkCallbacks { + #[tracing::instrument(level = "trace")] + fn new(config: &Config) -> Self { + Self { + wdf_function_table_symbol_name: config.compute_wdffunctions_symbol_name(), + } + } +} + +// Retrieves the Rust version as a `bindgen::RustTarget` for the current build +// configuration. +// +// If the `nightly` feature is enabled and the current toolchain is `nightly`, +// returns a value allowing `bindgen` to generate code with supported `nightly` +// features. Otherwise, queries the MSRV from the `CARGO_PKG_RUST_VERSION` +// environment variable and uses it to create a `bindgen::RustTarget::stable` +// value. +// +// # Errors +// +// Returns `ConfigError::MsrvNotSupportedByBindgen` if the MSRV is not supported +// by bindgen, or `ConfigError::SemverError` if the MSRV cannot be parsed as a +// semver version. +#[tracing::instrument(level = "trace")] +fn get_rust_target() -> Result { + let nightly_feature = cfg!(feature = "nightly"); + let nightly_toolchain = rustversion::cfg!(nightly); + + match (nightly_feature, nightly_toolchain) { + (true, true) => Ok(bindgen::RustTarget::nightly()), + (false, false) => get_stable_rust_target(), + (true, false) => { + tracing::warn!( + "A non-nightly toolchain has been detected. Nightly bindgen features are only \ + enabled with both nightly feature enablement and nightly toolchain use. " + ); + get_stable_rust_target() + } + (false, true) => { + tracing::warn!( + "The nightly feature for wdk-build is disabled. Nightly bindgen features are only \ + enabled with both nightly feature enablement and nightly toolchain use. " + ); + get_stable_rust_target() + } + } +} + +// Retrieves the stable Rust target for the current build configuration. +// Queries the MSRV from the `CARGO_PKG_RUST_VERSION` environment variable and +// uses it to create a `bindgen::RustTarget::stable` value. +#[tracing::instrument(level = "trace")] +fn get_stable_rust_target() -> Result { + let package_msrv = semver::Version::parse(env!("CARGO_PKG_RUST_VERSION")) + .map_err(|e| ConfigError::RustVersionParseError { error_source: e })?; + + let bindgen_msrv = bindgen::RustTarget::stable(package_msrv.minor, package_msrv.patch) + .map_err(|e| ConfigError::MsrvNotSupportedByBindgen { + msrv: package_msrv.to_string(), + reason: e.to_string(), + })?; + Ok(bindgen_msrv) +} + +// Retrieves the Rust edition from `cargo metadata` and returns the appropriate +// `bindgen::RustEdition` value. +// +// # Errors +// +// Returns `ConfigError::CargoMetadataPackageNotFound` if the `wdk-build` +// package is not found, or `ConfigError::UnsupportedRustEdition` if the edition +// is not supported. +#[tracing::instrument(level = "trace")] +fn get_rust_edition() -> Result { + const WDK_BUILD_PACKAGE_NAME: &str = "wdk-build"; + // Run `cargo_metadata` in the same working directory as the top level manifest + // in order to respect `config.toml` overrides + let top_level_cargo_manifest_path = find_top_level_cargo_manifest(); + debug!( + "Top level Cargo manifest path: {:?}", + top_level_cargo_manifest_path + ); + let cwd = top_level_cargo_manifest_path + .parent() + .expect("Cargo manifest should have a valid parent directory"); + let wdk_sys_cargo_metadata = MetadataCommand::new().current_dir(cwd).exec()?; + + let wdk_sys_package_metadata = wdk_sys_cargo_metadata + .packages + .iter() + .find(|package| package.name == WDK_BUILD_PACKAGE_NAME) + .ok_or_else(|| ConfigError::WdkBuildPackageNotFoundInCargoMetadata)?; + + let rust_edition: BindgenRustEditionWrapper = wdk_sys_package_metadata.edition.try_into()?; + Ok(rust_edition.0) +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/cargo_make.rs b/packaging/windows/drivers/vendor/wdk-build/src/cargo_make.rs new file mode 100644 index 0000000..0b8c5a3 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/cargo_make.rs @@ -0,0 +1,1273 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Utilities for `cargo-make` tasks used to package binaries dependent on the +//! `WDK`. +//! +//! This module provides functions used in the rust scripts in +//! `rust-driver-makefile.toml`. This includes argument parsing functionality +//! used by `rust-driver-makefile.toml` to validate and forward arguments common +//! to cargo commands. It uses a combination of `clap` and `clap_cargo` to +//! provide a CLI very close to cargo's own, but only exposes the arguments +//! supported by `rust-driver-makefile.toml`. + +use core::{fmt, ops::RangeFrom}; +use std::{ + env, + panic::UnwindSafe, + path::{Path, PathBuf, absolute}, + process::Command, +}; + +use anyhow::Context; +use cargo_metadata::{Metadata, MetadataCommand, camino::Utf8Path}; +use clap::{Args, ColorChoice, CommandFactory, FromArgMatches, Parser}; +use tracing::{instrument, trace}; + +use crate::{ + ConfigError, + CpuArchitecture, + IoError, + metadata, + utils::{detect_wdk_content_root, detect_windows_sdk_version, get_wdk_version_number, set_var}, +}; + +/// The filename of the main makefile for Rust Windows drivers. +pub const RUST_DRIVER_MAKEFILE_NAME: &str = "rust-driver-makefile.toml"; +/// The filename of the samples makefile for Rust Windows drivers. +pub const RUST_DRIVER_SAMPLE_MAKEFILE_NAME: &str = "rust-driver-sample-makefile.toml"; + +const PATH_ENV_VAR: &str = "Path"; +/// The environment variable that [`setup_wdk_version`] stores the WDK version +/// in. +pub const WDK_VERSION_ENV_VAR: &str = "WDK_BUILD_DETECTED_VERSION"; +/// The first WDK version with the new `InfVerif` behavior. +const MINIMUM_SAMPLES_FLAG_WDK_VERSION: i32 = 25798; +const WDK_INF_ADDITIONAL_FLAGS_ENV_VAR: &str = "WDK_BUILD_ADDITIONAL_INFVERIF_FLAGS"; +const WDK_BUILD_OUTPUT_DIRECTORY_ENV_VAR: &str = "WDK_BUILD_OUTPUT_DIRECTORY"; + +/// The name of the environment variable that cargo-make uses during `cargo +/// build` and `cargo test` commands +const CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR: &str = "CARGO_MAKE_CARGO_BUILD_TEST_FLAGS"; + +const CARGO_MAKE_DISABLE_COLOR_ENV_VAR: &str = "CARGO_MAKE_DISABLE_COLOR"; +const CARGO_MAKE_PROFILE_ENV_VAR: &str = "CARGO_MAKE_PROFILE"; +const CARGO_MAKE_CARGO_PROFILE_ENV_VAR: &str = "CARGO_MAKE_CARGO_PROFILE"; +const CARGO_MAKE_CRATE_TARGET_TRIPLE_ENV_VAR: &str = "CARGO_MAKE_CRATE_TARGET_TRIPLE"; +const CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY_ENV_VAR: &str = + "CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY"; +const CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN_ENV_VAR: &str = "CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN"; +const CARGO_MAKE_CRATE_NAME_ENV_VAR: &str = "CARGO_MAKE_CRATE_NAME"; +const CARGO_MAKE_CRATE_FS_NAME_ENV_VAR: &str = "CARGO_MAKE_CRATE_FS_NAME"; +const CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY_ENV_VAR: &str = + "CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY"; +const CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR: &str = "CARGO_MAKE_CURRENT_TASK_NAME"; + +/// `clap` uses an exit code of 2 for usage errors: +const CLAP_USAGE_EXIT_CODE: i32 = 2; + +// This range is inclusive of 25798. FIXME: update with range end after /sample +// flag is added to InfVerif CLI +const MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE: RangeFrom = 25798..; + +trait ParseCargoArgs { + fn parse_cargo_args(&self); +} + +#[derive(Parser, Debug)] +#[command(styles = clap_cargo::style::CLAP_STYLING)] +struct CommandLineInterface { + #[command(flatten)] + base: BaseOptions, + + #[command(flatten)] + #[command(next_help_heading = "Package Selection")] + workspace: clap_cargo::Workspace, + + #[command(flatten)] + #[command(next_help_heading = "Feature Selection")] + features: clap_cargo::Features, + + #[command(flatten)] + compilation_options: CompilationOptions, + + #[command(flatten)] + manifest_options: ManifestOptions, +} + +#[derive(Args, Debug)] +struct BaseOptions { + #[arg(long, help = "Do not print cargo log messages")] + quiet: bool, + + #[arg(short, long, action = clap::ArgAction::Count, help = "Use verbose output (-vv very verbose/build.rs output)")] + verbose: u8, +} + +#[derive(Args, Debug)] +#[command(next_help_heading = "Compilation Options")] +struct CompilationOptions { + #[arg( + short, + long, + help = "Build artifacts in release mode, with optimizations" + )] + release: bool, + + #[arg( + long, + value_name = "PROFILE-NAME", + help = "Build artifacts with the specified profile" + )] + profile: Option, + + #[arg( + short, + long, + value_name = "N", + allow_negative_numbers = true, + help = "Number of parallel jobs, defaults to # of CPUs." + )] + jobs: Option, + + // FIXME: support building multiple targets at once + #[arg(long, value_name = "TRIPLE", help = "Build for a target triple")] + target: Option, + + #[allow(clippy::option_option)] // This is how clap_derive expects "optional value for optional argument" args + #[arg( + long, + value_name = "FMTS", + require_equals = true, + help = "Timing output formats (unstable) (comma separated): html, json" + )] + timings: Option>, +} + +#[derive(Args, Debug)] +#[command(next_help_heading = "Manifest Options")] +struct ManifestOptions { + #[arg(long, help = "Require Cargo.lock and cache are up to date")] + frozen: bool, + + #[arg(long, help = "Require Cargo.lock is up to date")] + locked: bool, + + #[arg(long, help = "Run without accessing the network")] + offline: bool, +} + +impl ParseCargoArgs for CommandLineInterface { + fn parse_cargo_args(&self) { + let Self { + base, + workspace, + features, + compilation_options, + manifest_options, + } = self; + + base.parse_cargo_args(); + workspace.parse_cargo_args(); + features.parse_cargo_args(); + compilation_options.parse_cargo_args(); + manifest_options.parse_cargo_args(); + } +} + +impl ParseCargoArgs for BaseOptions { + fn parse_cargo_args(&self) { + let Self { quiet, verbose } = self; + + if *quiet && *verbose > 0 { + eprintln!("Cannot specify both --quiet and --verbose"); + std::process::exit(CLAP_USAGE_EXIT_CODE); + } + + if *quiet { + append_to_space_delimited_env_var(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, "--quiet"); + } + + if *verbose > 0 { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + format!("-{}", "v".repeat((*verbose).into())).as_str(), + ); + } + } +} + +impl ParseCargoArgs for clap_cargo::Workspace { + fn parse_cargo_args(&self) { + let Self { + package, + workspace, + all, + exclude, + .. + } = self; + + if !package.is_empty() { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + package + .iter() + .fold( + String::with_capacity({ + const MINIMUM_PACKAGE_SPEC_LENGTH: usize = 1; + const MINIMUM_PACKAGE_ARG_LENGTH: usize = + "--package ".len() + MINIMUM_PACKAGE_SPEC_LENGTH + " ".len(); + package.len() * MINIMUM_PACKAGE_ARG_LENGTH + }), + |mut package_args, package_spec| { + package_args.push_str("--package "); + package_args.push_str(package_spec); + package_args.push(' '); + package_args + }, + ) + .trim_end(), + ); + } + + if *workspace { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--workspace", + ); + } + + if !exclude.is_empty() { + if !*workspace { + eprintln!("--exclude can only be used together with --workspace"); + std::process::exit(CLAP_USAGE_EXIT_CODE); + } + + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + exclude + .iter() + .fold( + String::with_capacity({ + const MINIMUM_PACKAGE_SPEC_LENGTH: usize = 1; + const MINIMUM_EXCLUDE_ARG_LENGTH: usize = + "--exclude ".len() + MINIMUM_PACKAGE_SPEC_LENGTH + " ".len(); + package.len() * MINIMUM_EXCLUDE_ARG_LENGTH + }), + |mut exclude_args, package_spec| { + exclude_args.push_str("--exclude "); + exclude_args.push_str(package_spec); + exclude_args.push(' '); + exclude_args + }, + ) + .trim_end(), + ); + } + + if *all { + append_to_space_delimited_env_var(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, "--all"); + } + } +} + +impl ParseCargoArgs for clap_cargo::Features { + fn parse_cargo_args(&self) { + let Self { + all_features, + no_default_features, + features, + .. + } = self; + if *all_features { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--all-features", + ); + } + + if *no_default_features { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--no-default-features", + ); + } + + if !features.is_empty() { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + features + .iter() + .fold( + String::with_capacity({ + const MINIMUM_FEATURE_NAME_LENGTH: usize = 1; + const MINIMUM_FEATURE_ARG_LENGTH: usize = + "--features ".len() + MINIMUM_FEATURE_NAME_LENGTH + " ".len(); + features.len() * MINIMUM_FEATURE_ARG_LENGTH + }), + |mut feature_args: String, feature| { + feature_args.push_str("--features "); + feature_args.push_str(feature); + feature_args.push(' '); + feature_args + }, + ) + .trim_end(), + ); + } + } +} + +impl ParseCargoArgs for CompilationOptions { + fn parse_cargo_args(&self) { + let Self { + release, + profile, + jobs, + target, + timings, + } = self; + if *release && profile.is_some() { + eprintln!("the `--release` flag should not be specified with the `--profile` flag"); + std::process::exit(CLAP_USAGE_EXIT_CODE); + } + let cargo_make_cargo_profile = match env::var(CARGO_MAKE_PROFILE_ENV_VAR) + .unwrap_or_else(|_| panic!("{CARGO_MAKE_PROFILE_ENV_VAR} should be set by cargo-make")) + .as_str() + { + "release" => { + // cargo-make release profile sets the `--profile release` flag + if let Some(profile) = &profile { + if profile != "release" { + eprintln!( + "Specifying `--profile release` for cargo-make conflicts with the \ + setting `--profile {profile}` to forward to tasks" + ); + std::process::exit(CLAP_USAGE_EXIT_CODE); + } + } + + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--profile release", + ); + "release".to_string() + } + _ => { + // All other cargo-make profiles do not set a specific cargo profile. Cargo + // profiles set by --release, --profile , or -p (after + // the cargo-make task name) are forwarded to cargo + // commands + if *release { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--release", + ); + "release".to_string() + } else if let Some(profile) = &profile { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + format!("--profile {profile}").as_str(), + ); + profile.into() + } else { + env::var(CARGO_MAKE_CARGO_PROFILE_ENV_VAR).unwrap_or_else(|_| { + panic!("{CARGO_MAKE_CARGO_PROFILE_ENV_VAR} should be set by cargo-make") + }) + } + } + }; + + set_var(CARGO_MAKE_CARGO_PROFILE_ENV_VAR, &cargo_make_cargo_profile); + + if let Some(jobs) = &jobs { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + format!("--jobs {jobs}").as_str(), + ); + } + + if let Some(target) = &target { + set_var(CARGO_MAKE_CRATE_TARGET_TRIPLE_ENV_VAR, target); + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + format!("--target {target}").as_str(), + ); + } + + configure_wdf_build_output_dir(target.as_ref(), &cargo_make_cargo_profile); + + if let Some(timings_option) = &timings { + timings_option.as_ref().map_or_else( + || { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--timings", + ); + }, + |timings_value| { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + format!("--timings {timings_value}").as_str(), + ); + }, + ); + } + } +} + +impl ParseCargoArgs for ManifestOptions { + fn parse_cargo_args(&self) { + let Self { + frozen, + locked, + offline, + } = self; + + if *frozen { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--frozen", + ); + } + + if *locked { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--locked", + ); + } + + if *offline { + append_to_space_delimited_env_var( + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + "--offline", + ); + } + } +} + +/// Parses the command line arguments, validates that they are supported by +/// `rust-driver-makefile.toml`, and then returns a list of environment variable +/// names that were updated. +/// +/// These environment variable names should be passed to +/// [`forward_printed_env_vars`] to forward values to cargo-make. +/// +/// # Panics +/// +/// This function will panic if there's an internal error (i.e. bug) in its +/// argument processing. +#[must_use] +pub fn validate_command_line_args() -> impl IntoIterator { + const TOOLCHAIN_ARG_POSITION: usize = 1; + + let mut env_args = env::args_os().collect::>(); + + // + is a special argument that can't currently be handled by clap parsing: https://github.com/clap-rs/clap/issues/2468 + let toolchain_arg = if env_args + .get(TOOLCHAIN_ARG_POSITION) + .is_some_and(|arg| arg.to_string_lossy().starts_with('+')) + { + Some( + env_args + .remove(TOOLCHAIN_ARG_POSITION) + .to_string_lossy() + .strip_prefix('+') + .expect("Toolchain arg should have a + prefix") + .to_string(), + ) + } else { + None + }; + + if let Some(toolchain) = toolchain_arg { + set_var(CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN_ENV_VAR, toolchain); + } + + CommandLineInterface::from_arg_matches_mut( + &mut CommandLineInterface::command() + .color(if is_cargo_make_color_disabled() { + ColorChoice::Never + } else { + // `ColorChoice::Always` is used instead of `ColorChoice::Auto` to force color. + // This function is always executed from rust-script invoked by cargo-make, + // whose piping of stdout/stderr disables color by default. + ColorChoice::Always + }) + .get_matches_from(env_args), + ) + .unwrap_or_else(|err| err.exit()) + .parse_cargo_args(); + + [ + CARGO_MAKE_CARGO_BUILD_TEST_FLAGS_ENV_VAR, + CARGO_MAKE_CARGO_PROFILE_ENV_VAR, + CARGO_MAKE_CRATE_TARGET_TRIPLE_ENV_VAR, + CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN_ENV_VAR, + WDK_BUILD_OUTPUT_DIRECTORY_ENV_VAR, + ] + .into_iter() + .filter(|env_var_name| env::var_os(env_var_name).is_some()) + .map(ToString::to_string) +} + +fn is_cargo_make_color_disabled() -> bool { + env::var(CARGO_MAKE_DISABLE_COLOR_ENV_VAR) + .map(|value| { + !matches!( + value.trim().to_ascii_lowercase().as_str(), + // when color is enabled in cargo-make, the env var is guaranteed to be set to one + // of the below values, or not be set at all + "0" | "false" | "no" | "" + ) + }) + .unwrap_or(false) +} + +/// Prepends the path variable with the necessary paths to access WDK(+SDK) +/// tools. +/// +/// # Errors +/// +/// This function returns a [`ConfigError::WdkContentRootDetectionError`] if the +/// WDK content root directory could not be found. +/// +/// # Panics +/// +/// This function will panic if the CPU architecture cannot be determined from +/// [`env::consts::ARCH`] or if the PATH variable contains non-UTF8 +/// characters. +pub fn setup_path() -> Result, ConfigError> { + let wdk_content_root = + detect_wdk_content_root().ok_or(ConfigError::WdkContentRootDetectionError)?; + + let sdk_version = detect_windows_sdk_version(&wdk_content_root)?; + + let host_arch = CpuArchitecture::try_from_cargo_str(env::consts::ARCH) + .expect("The rust standard library should always set env::consts::ARCH"); + + let wdk_bin_root = get_wdk_bin_root(&wdk_content_root, &sdk_version); + + let host_windows_sdk_ver_bin_path = { + let path = wdk_bin_root.join(host_arch.as_windows_str()); + absolute(&path).map_err(|source| IoError::with_path(path, source))? + } + .to_str() + .expect("WDK bin path should be valid UTF-8") + .to_string(); + + let x86_windows_sdk_ver_bin_path = { + let path = wdk_bin_root.join("x86"); + absolute(&path).map_err(|source| IoError::with_path(path, source))? + } + .to_str() + .expect("WDK x86 bin path should be valid UTF-8") + .to_string(); + + if let Ok(sdk_bin_path) = env::var("WindowsSdkBinPath") { + let sdk_bin_path = { + let path = PathBuf::from(sdk_bin_path) + .join(&sdk_version) + .join(host_arch.as_windows_str()); + absolute(&path).map_err(|source| IoError::with_path(path, source))? + } + .to_str() + .expect("WindowsSdkBinPath should be valid UTF-8") + .to_string(); + prepend_to_semicolon_delimited_env_var(PATH_ENV_VAR, sdk_bin_path); + } + + prepend_to_semicolon_delimited_env_var( + PATH_ENV_VAR, + format!("{host_windows_sdk_ver_bin_path};{x86_windows_sdk_ver_bin_path}",), + ); + + let wdk_tool_root = get_wdk_tools_root(&wdk_content_root, &sdk_version); + let host_windows_sdk_version_tool_path = { + let path = wdk_tool_root.join(host_arch.as_windows_str()); + absolute(&path).map_err(|source| IoError::with_path(path, source))? + } + .to_str() + .expect("WDK tool path should be valid UTF-8") + .to_string(); + prepend_to_semicolon_delimited_env_var(PATH_ENV_VAR, host_windows_sdk_version_tool_path); + + Ok([PATH_ENV_VAR].map(ToString::to_string)) +} + +fn get_wdk_tools_root(wdk_content_root: &Path, sdk_version: &str) -> PathBuf { + get_path_from_env("WDKToolRoot", wdk_content_root, "tools", sdk_version) +} + +fn get_wdk_bin_root(wdk_content_root: &Path, sdk_version: &str) -> PathBuf { + get_path_from_env("WDKBinRoot", wdk_content_root, "bin", sdk_version) +} + +/// Reads path from the given env variable or falls back to +/// constructing it from WDK content root. +/// +/// The path in `env_var` is already the full path because eWDK +/// and Nuget CLI set it that way. In the fallback however we +/// have to append `sub_folder` and `sdk_version` manually. +fn get_path_from_env( + env_var: &str, + wdk_content_root: &Path, + sub_folder: &str, + sdk_version: &str, +) -> PathBuf { + env::var(env_var).map_or_else( + |e| { + trace!( + "Could not read env var '{env_var}': {e:?}. Constructing path from WDK content \ + root" + ); + wdk_content_root.join(sub_folder).join(sdk_version) + }, + PathBuf::from, + ) +} + +/// Forwards the specified environment variables in this process to the parent +/// cargo-make. This is facilitated by printing to `stdout`, and having the +/// `rust-env-update` plugin parse the printed output. +/// +/// # Panics +/// +/// Panics if any of the `env_vars` do not exist or contain a non-UTF8 value. +pub fn forward_printed_env_vars(env_vars: impl IntoIterator>) { + // This print signifies the start of the forwarding and signals to the + // `rust-env-update` plugin that it should forward args + println!("FORWARDING ARGS TO CARGO-MAKE:"); + + for env_var_name in env_vars { + let env_var_name = env_var_name.as_ref(); + + // Since this executes in a child process to cargo-make, we need to forward the + // values we want to change to duckscript, in order to get it to modify the + // parent process (ie. cargo-make) + println!( + "{env_var_name}={}", + env::var(env_var_name).unwrap_or_else(|_| panic!( + "{env_var_name} should be the name of an environment variable that is set and \ + contains a valid UTF-8 value" + )) + ); + } + + // This print signifies the end of the forwarding and signals to the + // `rust-env-update` plugin that it should stop forwarding args + println!("END OF FORWARDING ARGS TO CARGO-MAKE"); +} + +/// Adds the WDK version to the environment in the full string form of +/// 10.xxx.yyy.zzz, where x, y, and z are numerical values. +/// +/// # Errors +/// +/// This function returns a [`ConfigError::WdkContentRootDetectionError`] if the +/// WDK content root directory could not be found, or if the WDK version is +/// ill-formed. +pub fn setup_wdk_version() -> Result, ConfigError> { + let Some(wdk_content_root) = detect_wdk_content_root() else { + return Err(ConfigError::WdkContentRootDetectionError); + }; + + let detected_sdk_version = detect_windows_sdk_version(&wdk_content_root)?; + + if let Ok(existing_version) = std::env::var(WDK_VERSION_ENV_VAR) { + if detected_sdk_version == existing_version { + // Skip updating. This can happen in certain recursive + // cargo-make cases. + return Ok([WDK_VERSION_ENV_VAR].map(ToString::to_string)); + } + // We have a bad version string set somehow. Return an error. + return Err(ConfigError::WdkContentRootDetectionError); + } + + if !crate::utils::validate_wdk_version_format(&detected_sdk_version) { + return Err(ConfigError::WdkVersionStringFormatError { + version: detected_sdk_version, + }); + } + + set_var(WDK_VERSION_ENV_VAR, detected_sdk_version); + Ok([WDK_VERSION_ENV_VAR].map(ToString::to_string)) +} + +/// Sets the `WDK_INFVERIF_SAMPLE_FLAG` environment variable to contain the +/// appropriate flag for building samples. +/// +/// # Errors +/// +/// This function returns a [`ConfigError::WdkContentRootDetectionError`] if +/// an invalid WDK version is provided. +/// +/// # Panics +/// +/// This function will panic if the function for validating a WDK version string +/// is ever changed to no longer validate that each part of the version string +/// is an i32. +pub fn setup_infverif_for_samples + ToString + ?Sized>( + version: &S, +) -> Result, ConfigError> { + let validated_version_string = crate::utils::get_wdk_version_number(version)?; + + // Safe to unwrap as we called .parse::().is_ok() in our call to + // validate_wdk_version_format above. + let version = validated_version_string + .parse::() + .expect("Unable to parse the build number of the WDK version string as an int!"); + let sample_flag = if version > MINIMUM_SAMPLES_FLAG_WDK_VERSION { + // Note: Not currently implemented, so in samples TOML we currently skip + // infverif + "/samples" + } else { + "/msft" + }; + append_to_space_delimited_env_var(WDK_INF_ADDITIONAL_FLAGS_ENV_VAR, sample_flag); + + Ok([WDK_INF_ADDITIONAL_FLAGS_ENV_VAR].map(ToString::to_string)) +} + +/// Returns the path to the WDK build output directory for the current +/// cargo-make flow +/// +/// # Panics +/// +/// This function will panic if the `WDK_BUILD_OUTPUT_DIRECTORY` environment +/// variable is not set +#[must_use] +pub fn get_wdk_build_output_directory() -> PathBuf { + PathBuf::from( + env::var("WDK_BUILD_OUTPUT_DIRECTORY") + .expect("WDK_BUILD_OUTPUT_DIRECTORY should have been set by the wdk-build-init task"), + ) +} + +/// Returns the name of the current cargo package cargo-make is processing +/// +/// # Panics +/// +/// This function will panic if the `CARGO_MAKE_CRATE_FS_NAME` environment +/// variable is not set +#[must_use] +pub fn get_current_package_name() -> String { + env::var(CARGO_MAKE_CRATE_FS_NAME_ENV_VAR).unwrap_or_else(|_| { + panic!( + "{} should be set by cargo-make", + &CARGO_MAKE_CRATE_FS_NAME_ENV_VAR + ) + }) +} + +/// Copies the file or directory at `path_to_copy` to the Driver Package folder +/// +/// # Errors +/// +/// This function returns a [`ConfigError::IoError`] if the it encounters IO +/// errors while copying the file or creating the directory +/// +/// # Panics +/// +/// This function will panic if `path_to_copy` does end with a valid file or +/// directory name +pub fn copy_to_driver_package_folder>(path_to_copy: P) -> Result<(), ConfigError> { + let path_to_copy = path_to_copy.as_ref(); + + let package_folder_path: PathBuf = + get_wdk_build_output_directory().join(format!("{}_package", get_current_package_name())); + if !package_folder_path.exists() { + std::fs::create_dir(&package_folder_path) + .map_err(|source| IoError::with_path(&package_folder_path, source))?; + } + + let destination_path = package_folder_path.join( + path_to_copy + .file_name() + .expect("path_to_copy should always end with a valid file or directory name"), + ); + std::fs::copy(path_to_copy, &destination_path) + .map_err(|source| IoError::with_src_dest_paths(path_to_copy, destination_path, source))?; + + Ok(()) +} + +/// Symlinks `rust-driver-makefile.toml` to the `target` folder where it can be +/// extended from a `Makefile.toml`. +/// +/// This is necessary so that paths in the `rust-driver-makefile.toml` can to be +/// relative to `CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY` +/// +/// # Errors +/// +/// This function returns: +/// - [`ConfigError::CargoMetadataError`] if there is an error executing or +/// parsing `cargo_metadata` +/// - [`ConfigError::MultipleWdkBuildCratesDetected`] if there are multiple +/// versions of the WDK build crate detected +/// - [`ConfigError::IoError`] if there is an error creating or updating the +/// symlink to `rust-driver-makefile.toml` +/// +/// # Panics +/// +/// This function will panic if the `CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY` +/// environment variable is not set +pub fn load_rust_driver_makefile() -> Result<(), ConfigError> { + load_wdk_build_makefile(RUST_DRIVER_MAKEFILE_NAME) +} + +/// Symlinks `rust-driver-sample-makefile.toml` to the `target` folder where it +/// can be extended from a `Makefile.toml`. +/// +/// This is necessary so that paths in the `rust-driver-sample-makefile.toml` +/// can to be relative to `CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY` +/// +/// # Errors +/// +/// This function returns: +/// - [`ConfigError::CargoMetadataError`] if there is an error executing or +/// parsing `cargo_metadata` +/// - [`ConfigError::MultipleWdkBuildCratesDetected`] if there are multiple +/// versions of the WDK build crate detected +/// - [`ConfigError::IoError`] if there is an error creating or updating the +/// symlink to `rust-driver-sample-makefile.toml` +/// +/// # Panics +/// +/// This function will panic if the `CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY` +/// environment variable is not set +pub fn load_rust_driver_sample_makefile() -> Result<(), ConfigError> { + load_wdk_build_makefile(RUST_DRIVER_SAMPLE_MAKEFILE_NAME) +} + +/// Symlinks a [`wdk_build`] `cargo-make` makefile to the `target` folder where +/// it can be extended from a downstream `Makefile.toml`. +/// +/// This is necessary so that paths in the [`wdk_build`] makefile can be +/// relative to `CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY`. The +/// version of `wdk-build` from which the file being symlinked to comes from is +/// determined by the working directory of the process that invokes this +/// function. For example, if this function is ultimately executing in a +/// `cargo_make` `load_script`, the files will be symlinked from the `wdk-build` +/// version that is in the `.Cargo.lock` file, and not the `wdk-build` version +/// specified in the `load_script`. +/// +/// # Errors +/// +/// This function returns: +/// - [`ConfigError::CargoMetadataError`] if there is an error executing or +/// parsing `cargo_metadata` +/// - [`ConfigError::MultipleWdkBuildCratesDetected`] if there are multiple +/// versions of the WDK build crate detected +/// - [`ConfigError::IoError`] if there is an error creating or updating the +/// symlink to the makefile. +/// +/// # Panics +/// +/// This function will panic if the `CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY` +/// environment variable is not set +#[instrument(level = "trace")] +fn load_wdk_build_makefile + AsRef + AsRef + fmt::Debug>( + makefile_name: S, +) -> Result<(), ConfigError> { + let cargo_metadata = MetadataCommand::new().exec()?; + trace!(cargo_metadata_output = ?cargo_metadata); + + let wdk_build_package_matches = cargo_metadata + .packages + .into_iter() + .filter(|package| package.name == "wdk-build") + .collect::>(); + + match wdk_build_package_matches.len() { + 0 => { + return Err(ConfigError::NoWdkBuildCrateDetected); + } + 1 => {} + _ => { + return Err(ConfigError::MultipleWdkBuildCratesDetected { + package_ids: wdk_build_package_matches + .iter() + .map(|package_info| package_info.id.clone()) + .collect(), + }); + } + } + + let rust_driver_makefile_toml_path = wdk_build_package_matches[0] + .manifest_path + .parent() + .expect("The parsed manifest_path should have a valid parent directory") + .join(&makefile_name) + .into_std_path_buf(); + + let cargo_make_workspace_working_directory = + env::var(CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY_ENV_VAR).unwrap_or_else(|_| { + panic!("{CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY_ENV_VAR} should be set by cargo-make") + }); + + let destination_path = Path::new(&cargo_make_workspace_working_directory) + .join("target") + .join(&makefile_name); + + // Only create a new symlink if the existing one is not already pointing to the + // correct file + if !destination_path.exists() { + std::os::windows::fs::symlink_file(&rust_driver_makefile_toml_path, &destination_path) + .map_err(|source| { + IoError::with_src_dest_paths( + rust_driver_makefile_toml_path, + destination_path, + source, + ) + })?; + } else if !destination_path.is_symlink() + || std::fs::read_link(&destination_path) + .map_err(|source| IoError::with_path(&destination_path, source))? + != rust_driver_makefile_toml_path + { + std::fs::remove_file(&destination_path) + .map_err(|source| IoError::with_path(&destination_path, source))?; + std::os::windows::fs::symlink_file(&rust_driver_makefile_toml_path, &destination_path) + .map_err(|source| { + IoError::with_src_dest_paths( + rust_driver_makefile_toml_path, + destination_path, + source, + ) + })?; + } + + // Symlink is already up to date + Ok(()) +} + +/// Get [`cargo_metadata::Metadata`] based off of manifest in +/// `CARGO_MAKE_WORKING_DIRECTORY` +/// +/// # Errors +/// +/// This function will return a [`cargo_metadata::Error`] if `cargo_metadata` +/// fails +/// +/// # Panics +/// +/// This function will panic if executed outside of a `cargo-make` task +pub fn get_cargo_metadata() -> cargo_metadata::Result { + let manifest_path = { + let mut p: PathBuf = std::path::PathBuf::from( + std::env::var("CARGO_MAKE_WORKING_DIRECTORY") + .expect("CARGO_MAKE_WORKING_DIRECTORY should be set by cargo-make"), + ); + p.push("Cargo.toml"); + p + }; + + cargo_metadata::MetadataCommand::new() + .manifest_path(manifest_path) + .exec() +} + +/// Execute a `FnOnce` closure, and handle its contents in a way compatible with +/// `cargo-make`'s `condition_script`: +/// 1. If the closure panics, the panic is caught and it returns an `Ok(())`. +/// This ensures that panics encountered in `condition_script_closure` will +/// not default to skipping the task. +/// 2. If the closure executes without panicking, forward the result to +/// `cargo-make`. `Ok` types will result in the task being run, and `Err` +/// types will print the `Err` contents and then skip the task. +/// +/// If you want your task to be skipped, return an `Err` from +/// `condition_script_closure`. If you want the task to execute, return an +/// `Ok(())` from `condition_script_closure` +/// +/// # Errors +/// +/// This function returns an error whenever `condition_script_closure` returns +/// an error +/// +/// # Panics +/// +/// Panics if `CARGO_MAKE_CURRENT_TASK_NAME` is not set in the environment +pub fn condition_script(condition_script_closure: F) -> anyhow::Result<(), E> +where + F: FnOnce() -> anyhow::Result<(), E> + UnwindSafe, +{ + std::panic::catch_unwind(condition_script_closure).unwrap_or_else(|_| { + // Note: Any panic messages has already been printed by this point + + let cargo_make_task_name = env::var(CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR) + .expect("CARGO_MAKE_CURRENT_TASK_NAME should be set by cargo-make"); + + eprintln!( + r#"`condition_script` for "{cargo_make_task_name}" task panicked while executing. \ + Defaulting to running "{cargo_make_task_name}" task."# + ); + Ok(()) + }) +} + +/// `cargo-make` condition script for `package-driver-flow` task in +/// [`rust-driver-makefile.toml`](../rust-driver-makefile.toml) +/// +/// # Errors +/// +/// This function returns an error whenever it determines that the +/// `package-driver-flow` `cargo-make` task should be skipped (i.e. when the +/// current package isn't a cdylib depending on the WDK, or when no valid WDK +/// configurations are detected) +/// +/// # Panics +/// +/// Panics if `CARGO_MAKE_CURRENT_TASK_NAME` is not set in the environment +pub fn package_driver_flow_condition_script() -> anyhow::Result<()> { + condition_script(|| { + // Get the current package name via `CARGO_MAKE_CRATE_NAME_ENV_VAR` instead of + // `CARGO_MAKE_CRATE_FS_NAME_ENV_VAR`, since `cargo_metadata` output uses the + // non-preprocessed name (ie. - instead of _) + let current_package_name = env::var(CARGO_MAKE_CRATE_NAME_ENV_VAR).unwrap_or_else(|_| { + panic!( + "{} should be set by cargo-make", + &CARGO_MAKE_CRATE_NAME_ENV_VAR + ) + }); + let cargo_metadata = get_cargo_metadata()?; + + // Skip task if the current crate is not a driver (i.e. a cdylib with a + // `package.metadata.wdk` section) + let current_package = cargo_metadata + .packages + .iter() + .find(|package| package.name == current_package_name) + .expect("The current package should be present in the cargo metadata output"); + if current_package.metadata["wdk"].is_null() { + return Err::<(), anyhow::Error>( + metadata::TryFromCargoMetadataError::NoWdkConfigurationsDetected.into(), + ) + .with_context(|| { + "Skipping package-driver-flow cargo-make task because the current crate does not \ + have a package.metadata.wdk section" + }); + } + if !current_package + .targets + .iter() + .any(|target| target.kind.contains(&cargo_metadata::TargetKind::CDyLib)) + { + return Err::<(), anyhow::Error>( + metadata::TryFromCargoMetadataError::NoWdkConfigurationsDetected.into(), + ) + .with_context(|| { + "Skipping package-driver-flow cargo-make task because the current crate does not \ + contain a cdylib target" + }); + } + + match metadata::Wdk::try_from(&cargo_metadata) { + Err(e @ metadata::TryFromCargoMetadataError::NoWdkConfigurationsDetected) => { + // Skip task only if no WDK configurations are detected + Err::<(), anyhow::Error>(e.into()).with_context(|| { + "Skipping package-driver-flow cargo-make task because the current crate is not \ + a driver" + }) + } + + Ok(_) => Ok(()), + + Err(unexpected_error) => { + eprintln!("Unexpected error: {unexpected_error:#?}"); + // Do not silently skip task if unexpected error in parsing WDK Metadata occurs + Ok(()) + } + } + }) +} + +/// `cargo-make` condition script for `generate-certificate` task in +/// [`rust-driver-makefile.toml`](../rust-driver-makefile.toml) +/// +/// # Errors +/// +/// This functions returns an error whenever it determines that the +/// `generate-certificate` `cargo-make` task should be skipped. This only +/// occurs when `WdrLocalTestCert` already exists in `WDRTestCertStore`. +/// +/// # Panics +/// +/// Panics if `CARGO_MAKE_CURRENT_TASK_NAME` is not set in the environment. +pub fn generate_certificate_condition_script() -> anyhow::Result<()> { + condition_script(|| { + let mut command = Command::new("certmgr"); + + command.args([ + "-put".as_ref(), + "-s".as_ref(), + "WDRTestCertStore".as_ref(), + "-c".as_ref(), + "-n".as_ref(), + "WdrLocalTestCert".as_ref(), + get_wdk_build_output_directory() + .join("WDRLocalTestCert.cer") + .as_os_str(), + ]); + + let output = command.output().unwrap_or_else(|err| { + panic!( + "Failed to run certmgr.exe {} due to error: {}", + command + .get_args() + .map(|arg| arg.to_string_lossy()) + .collect::>() + .join(" "), + err + ) + }); + + match output.status.code() { + Some(0) => Err(anyhow::anyhow!( + "WDRLocalTestCert found in WDRTestCertStore. Skipping certificate generation." + )), + Some(1) => { + eprintln!( + "WDRLocalTestCert not found in WDRTestCertStore. Generating new certificate." + ); + Ok(()) + } + Some(_) => { + eprintln!("Unknown status code found from certmgr. Generating new certificate."); + Ok(()) + } + None => { + unreachable!("Unreachable, no status code found from certmgr."); + } + } + }) +} + +fn configure_wdf_build_output_dir(target_arg: Option<&String>, cargo_make_cargo_profile: &str) { + let cargo_make_crate_custom_triple_target_directory = + env::var(CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY_ENV_VAR).unwrap_or_else(|_| { + panic!( + "{CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY_ENV_VAR} should be set by \ + cargo-make." + ) + }); + + let wdk_build_output_directory = { + let mut output_dir = cargo_make_crate_custom_triple_target_directory; + + // Providing the "--target" flag causes the build output to go into a subdirectory: https://doc.rust-lang.org/cargo/guide/build-cache.html#build-cache + if let Some(target) = target_arg { + output_dir += "/"; + output_dir += target; + } + + if cargo_make_cargo_profile == "dev" { + // Cargo puts "dev" profile builds in the "debug" target folder: https://doc.rust-lang.org/cargo/guide/build-cache.html#build-cache. + // This also supports cargo-make profile of "development" since cargo-make maps + // CARGO_MAKE_PROFILE value of "development" to CARGO_MAKE_CARGO_PROFILE of + // "dev". + output_dir += "/debug"; + } else { + output_dir += "/"; + output_dir += cargo_make_cargo_profile; + } + + output_dir + }; + set_var( + WDK_BUILD_OUTPUT_DIRECTORY_ENV_VAR, + wdk_build_output_directory, + ); +} + +fn append_to_space_delimited_env_var(env_var_name: S, string_to_append: T) +where + S: AsRef, + T: AsRef, +{ + let env_var_name: &str = env_var_name.as_ref(); + let string_to_append: &str = string_to_append.as_ref(); + + let mut env_var_value: String = env::var(env_var_name).unwrap_or_default(); + env_var_value.push(' '); + env_var_value.push_str(string_to_append); + set_var(env_var_name, env_var_value.trim()); +} + +fn prepend_to_semicolon_delimited_env_var(env_var_name: S, string_to_prepend: T) +where + S: AsRef, + T: AsRef, +{ + let env_var_name = env_var_name.as_ref(); + let string_to_prepend = string_to_prepend.as_ref(); + + let mut env_var_value = string_to_prepend.to_string(); + env_var_value.push(';'); + env_var_value.push_str(env::var(env_var_name).unwrap_or_default().as_str()); + set_var(env_var_name, env_var_value); +} + +/// `cargo-make` condition script for `infverif` task in +/// [`rust-driver-sample-makefile.toml`](../rust-driver-sample-makefile.toml) +/// +/// # Errors +/// +/// This function returns an error whenever it determines that the +/// `infverif` `cargo-make` task should be skipped (i.e. when the WDK Version is +/// bugged and does not contain /samples flag) +/// +/// # Panics +/// Panics if `CARGO_MAKE_CURRENT_TASK_NAME` is not set in the environment +pub fn driver_sample_infverif_condition_script() -> anyhow::Result<()> { + condition_script(|| { + let wdk_version = env::var(WDK_VERSION_ENV_VAR).expect( + "WDK_BUILD_DETECTED_VERSION should always be set by wdk-build-init cargo make task", + ); + let wdk_build_number = str::parse::( + &get_wdk_version_number(&wdk_version).expect("Failed to get WDK version number"), + ) + .unwrap_or_else(|_| { + panic!("Couldn't parse WDK version number! Version number: {wdk_version}") + }); + if MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.contains(&wdk_build_number) { + // cargo_make will interpret returning an error from the rust-script + // condition_script as skipping the task + return Err::<(), anyhow::Error>(anyhow::Error::msg(format!( + "Skipping InfVerif. InfVerif in WDK Build {wdk_build_number} is bugged and does \ + not contain the /samples flag.", + ))); + } + Ok(()) + }) +} + +#[cfg(test)] +mod tests { + use crate::ConfigError; + + const WDK_TEST_OLD_INF_VERSION: &str = "10.0.22061.0"; + const WDK_TEST_NEW_INF_VERSION: &str = "10.0.26100.0"; + + #[test] + fn check_env_passing() -> Result<(), ConfigError> { + crate::cargo_make::setup_infverif_for_samples(WDK_TEST_OLD_INF_VERSION)?; + let env_string = std::env::var_os(crate::cargo_make::WDK_INF_ADDITIONAL_FLAGS_ENV_VAR) + .map_or_else( + || panic!("Couldn't get OS string"), + |os_env_string| os_env_string.to_string_lossy().into_owned(), + ); + assert_eq!(env_string.split(' ').next_back(), Some("/msft")); + + crate::cargo_make::setup_infverif_for_samples(WDK_TEST_NEW_INF_VERSION)?; + let env_string = std::env::var_os(crate::cargo_make::WDK_INF_ADDITIONAL_FLAGS_ENV_VAR) + .map_or_else( + || panic!("Couldn't get OS string"), + |os_env_string| os_env_string.to_string_lossy().into_owned(), + ); + assert_eq!(env_string.split(' ').next_back(), Some("/samples")); + Ok(()) + } +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/lib.rs b/packaging/windows/drivers/vendor/wdk-build/src/lib.rs new file mode 100644 index 0000000..6dc4946 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/lib.rs @@ -0,0 +1,2232 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! The [`wdk-build`][crate] crate is a library that is used within Cargo build +//! scripts to configure any build that depends on the WDK (Windows Driver Kit). +//! This is especially useful for crates that generate FFI bindings to the WDK, +//! WDK-dependent libraries, and programs built on top of the WDK (ex. Drivers). +//! This library is built to be able to accommodate different WDK releases, as +//! well strives to allow for all the configuration the WDK allows. This +//! includes being ables to select different WDF versions and different driver +//! models (WDM, KMDF, UMDF). + +#![cfg_attr(nightly_toolchain, feature(assert_matches))] +use std::{ + env, + fmt, + path::{Path, PathBuf, absolute}, + str::FromStr, + sync::LazyLock, +}; + +pub use bindgen::BuilderExt; +use metadata::TryFromCargoMetadataError; +use tracing::debug; + +pub mod cargo_make; +pub mod metadata; + +mod utils; + +mod bindgen; + +use cargo_metadata::MetadataCommand; +use serde::{Deserialize, Serialize}; +use thiserror::Error; + +use crate::utils::detect_windows_sdk_version; + +/// Configuration parameters for a build dependent on the WDK +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct Config { + /// Path to root of WDK. Corresponds with `WDKContentRoot` environment + /// variable in eWDK + wdk_content_root: PathBuf, + /// CPU architecture to target + cpu_architecture: CpuArchitecture, + /// Build configuration of driver + pub driver_config: DriverConfig, +} + +/// The driver type with its associated configuration parameters +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[serde( + tag = "DRIVER_TYPE", + deny_unknown_fields, + rename_all = "UPPERCASE", + from = "DeserializableDriverConfig" +)] +pub enum DriverConfig { + /// Windows Driver Model + Wdm, + /// Kernel Mode Driver Framework + Kmdf(KmdfConfig), + /// User Mode Driver Framework + Umdf(UmdfConfig), +} + +/// Private enum identical to [`DriverConfig`] but with different tag name to +/// deserialize from. +/// +/// [`serde_derive`] doesn't support different tag names for serialization vs. +/// deserialization, and also doesn't support aliases for tag names, so the +/// `from` attribute is used in conjunction with this type to facilitate a +/// different tag name for deserialization. +/// +/// Relevant Github Issues: +/// * +/// * +#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Hash)] +#[serde(tag = "driver-type", deny_unknown_fields, rename_all = "UPPERCASE")] +enum DeserializableDriverConfig { + Wdm, + Kmdf(KmdfConfig), + Umdf(UmdfConfig), +} + +/// The CPU architecture that's configured to be compiled for +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] +pub enum CpuArchitecture { + /// AMD64 CPU architecture. Also known as x64 or x86-64. + Amd64, + /// ARM64 CPU architecture. Also known as aarch64. + Arm64, +} + +impl FromStr for CpuArchitecture { + type Err = String; + + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "amd64" => Ok(Self::Amd64), + "arm64" => Ok(Self::Arm64), + _ => Err(format!("'{s}' is not a valid target architecture")), + } + } +} + +impl fmt::Display for CpuArchitecture { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s = match self { + Self::Amd64 => "amd64", + Self::Arm64 => "arm64", + }; + write!(f, "{s}") + } +} + +/// The configuration parameters for KMDF drivers +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[serde( + deny_unknown_fields, + rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case") +)] +pub struct KmdfConfig { + /// Major KMDF Version + pub kmdf_version_major: u8, + /// Minor KMDF Version (Target Version) + pub target_kmdf_version_minor: u8, + /// Minor KMDF Version (Minimum Required) + pub minimum_kmdf_version_minor: Option, +} + +/// The configuration parameters for UMDF drivers +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[serde( + deny_unknown_fields, + rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case") +)] +pub struct UmdfConfig { + /// Major UMDF Version + pub umdf_version_major: u8, + /// Minor UMDF Version (Target Version) + pub target_umdf_version_minor: u8, + /// Minor UMDF Version (Minimum Required) + pub minimum_umdf_version_minor: Option, +} + +/// Metadata providing additional context for [`std::io::Error`] failures +/// +/// This enum provides structured information about the file system paths +/// or operations that led to an I/O error. It can represent either single +/// path operations or operations involving both source and destination paths. +#[non_exhaustive] +#[derive(Debug, Error)] +pub enum IoErrorMetadata { + /// Path related to [`std::io::Error`] failure + #[error(r#"failed to perform an IO operation on "{path}""#)] + Path { + /// The file system path where the I/O error occurred + path: PathBuf, + }, + /// Source and destination paths related to [`std::io::Error`] failure. + /// + /// This can be provided for APIs like [`std::fs::copy`] which have both a + /// `from` and `to` path. + #[error(r#"failed to perform an IO operation from "{from_path}" to "{to_path}""#)] + SrcDestPaths { + /// The source path in a copy or move operation that failed + from_path: PathBuf, + /// The destination path in a copy or move operation that failed + to_path: PathBuf, + }, +} + +/// Dedicated error type for I/O operations with extra metadata context +/// +/// This error type wraps [`std::io::Error`] with additional [`IoErrorMetadata`] +/// to provide better context about which file system paths or operations +/// failed. It can be used directly by functions that only perform I/O +/// operations, and automatically converts to [`ConfigError`] when needed. +#[derive(Debug, Error)] +#[error("{metadata}")] +pub struct IoError { + /// Extra metadata related to the error + metadata: IoErrorMetadata, + /// [`std::io::Error`] that caused the operation to fail + #[source] + source: std::io::Error, +} + +impl IoError { + /// Creates a new `IoError` with a single path and source error. + pub fn with_path(path: impl Into, source: std::io::Error) -> Self { + Self { + metadata: IoErrorMetadata::Path { path: path.into() }, + source, + } + } + + /// Creates a new `IoError` for operations involving a source and + /// destination path. + pub fn with_src_dest_paths( + from_path: impl Into, + to_path: impl Into, + source: std::io::Error, + ) -> Self { + Self { + metadata: IoErrorMetadata::SrcDestPaths { + from_path: from_path.into(), + to_path: to_path.into(), + }, + source, + } + } +} + +/// Errors that could result from configuring a build via [`wdk_build`][crate] +#[derive(Debug, Error)] +pub enum ConfigError { + /// Error returned when an [`std::io`] operation fails + #[error(transparent)] + IoError(#[from] IoError), + + /// Error returned when an expected directory does not exist + #[error("cannot find directory: {directory}")] + DirectoryNotFound { + /// Path of directory that was not found + directory: String, + }, + + /// Error returned when a package is not found in Cargo metadata + #[error("cannot find wdk-build package in Cargo metadata")] + WdkBuildPackageNotFoundInCargoMetadata, + + /// Error returned Cargo manifest contains an unsupported edition + #[error("Cargo manifest contains unsupported Rust edition: {edition}")] + UnsupportedRustEdition { + /// Edition of the Cargo manifest that was not supported + edition: String, + }, + + /// Error returned when `bindgen` does not support `rust-version` in Cargo + /// manifest + #[error("Rust version {msrv} not supported by Bindgen: {reason}")] + MsrvNotSupportedByBindgen { + /// MSRV that was not supported by Bindgen + msrv: String, + /// Reason why the MSRV was not supported + reason: String, + }, + + /// Error returned when `semver` parsing of the Rust version fails + #[error("failed to parse rust-version in manifest")] + RustVersionParseError { + /// [`semver::Error`] that caused parsing the Rust version to fail + #[source] + error_source: semver::Error, + }, + + /// Error returned when a [`metadata::Wdk`] fails to be parsed from a Cargo + /// Manifest + #[error(transparent)] + TryFromCargoMetadataError(#[from] metadata::TryFromCargoMetadataError), + + /// Error returned when a [`Config`] fails to be serialized + #[error( + "WDKContentRoot should be able to be detected. Ensure that the WDK is installed, or that \ + the environment setup scripts in the eWDK have been run." + )] + WdkContentRootDetectionError, + + /// Error returned when the WDK version string does not match the expected + /// format + #[error("the WDK version string provided ({version}) was not in a valid format")] + WdkVersionStringFormatError { + /// The incorrect WDK version string. + version: String, + }, + + /// Error returned when `cargo_metadata` execution or parsing fails + #[error(transparent)] + CargoMetadataError(#[from] cargo_metadata::Error), + + /// Error returned when no wdk-build package is detected + #[error("no wdk-build package is detected")] + NoWdkBuildCrateDetected, + + /// Error returned when multiple versions of the wdk-build package are + /// detected + #[error( + "multiple versions of the wdk-build package are detected, but only one version is \ + allowed: {package_ids:#?}" + )] + MultipleWdkBuildCratesDetected { + /// package ids of the wdk-build crates detected + package_ids: Vec, + }, + + /// Error returned when the c runtime is not configured to be statically + /// linked + #[error( + "the C runtime is not properly configured to be statically linked. This is required for building WDK drivers. The recommended solution is to add the following snippet to a \ + `.cargo/config.toml` file: +[build] +rustflags = [\"-C\", \"target-feature=+crt-static\"] + +\ + See https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes for more ways \ + to enable static crt linkage" + )] + StaticCrtNotEnabled, + + /// Error returned when [`metadata::ser::Serializer`] fails to serialize the + /// [`metadata::Wdk`] + #[error(transparent)] + SerdeError(#[from] metadata::Error), +} + +/// Subset of APIs in the Windows Driver Kit +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum ApiSubset { + /// API subset typically required for all Windows drivers + Base, + /// API subset required for WDF (Windows Driver Framework) drivers: + Wdf, + /// API subset for GPIO (General Purpose Input/Output) drivers: + Gpio, + /// API subset for HID (Human Interface Device) drivers: + Hid, + /// API subset for Parallel Ports drivers: + ParallelPorts, + /// API subset for SPB (Serial Peripheral Bus) drivers: + Spb, + /// API subset for Storage drivers: + Storage, + /// API subset for USB (Universal Serial Bus) drivers: + Usb, + /// API subset for IddCx (Indirect Display, UMDF-only) drivers: + Iddcx, +} + +#[derive(Debug, Error, PartialEq, Eq)] +/// Error when parsing a [`TwoPartVersion`]. +pub enum TwoPartVersionError { + /// Supplied string didn't match MAJOR.MINOR format. + #[error("Invalid version: {0}. Expected format is 'major.minor'")] + InvalidFormat(String), + /// A numeric component failed to parse (component name, original string). + #[error("Error parsing {0} version to 'u32'. Version string: {1}")] + ParseError(String, String), +} + +/// Version of the form MAJOR.MINOR (both u32). Accepts leading zeros. +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] +pub struct TwoPartVersion(pub u32, pub u32); + +/// Parses a string of the form `MAJOR.MINOR` into a [`TwoPartVersion`]. +/// +/// # Expected format +/// - The input string must contain exactly one dot (`.`) separating two +/// non-empty components. +/// - Both components must be valid unsigned 32-bit integers (`u32`). Leading +/// zeros are accepted. +/// +/// # Errors +/// - Returns [`TwoPartVersionError::InvalidFormat`] if the string does not +/// contain exactly one dot or has empty components. +/// - Returns [`TwoPartVersionError::ParseError`] if either component cannot be +/// parsed as a `u32`. +impl FromStr for TwoPartVersion { + type Err = TwoPartVersionError; + + fn from_str(s: &str) -> Result { + let dot_count = s.matches('.').count(); + if dot_count != 1 { + return Err(TwoPartVersionError::InvalidFormat(s.to_string())); + } + let (major_str, minor_str) = s + .split_once('.') + .ok_or_else(|| TwoPartVersionError::InvalidFormat(s.to_string()))?; + if major_str.is_empty() || minor_str.is_empty() { + return Err(TwoPartVersionError::InvalidFormat(s.to_string())); + } + let major = major_str + .parse::() + .map_err(|_| TwoPartVersionError::ParseError("major".to_string(), s.to_string()))?; + let minor = minor_str + .parse::() + .map_err(|_| TwoPartVersionError::ParseError("minor".to_string(), s.to_string()))?; + Ok(Self(major, minor)) + } +} + +impl Default for Config { + fn default() -> Self { + Self { + wdk_content_root: utils::detect_wdk_content_root().expect( + "WDKContentRoot should be able to be detected. Ensure that the WDK is installed, \ + or that the environment setup scripts in the eWDK have been run.", + ), + driver_config: DriverConfig::Wdm, + cpu_architecture: utils::detect_cpu_architecture_in_build_script(), + } + } +} + +impl Config { + /// Create a new [`Config`] with default values + #[must_use] + #[tracing::instrument(level = "debug")] + pub fn new() -> Self { + Self::default() + } + + /// Create a [`Config`] from parsing the top-level Cargo manifest into a + /// [`metadata::Wdk`], and using it to populate the [`Config`]. It also + /// emits `cargo::rerun-if-changed` directives for any files that are + /// used to create the [`Config`]. + /// + /// # Errors + /// + /// This function will return an error if: + /// * the execution of `cargo metadata` fails + /// * the parsing of [`metadata::Wdk`] from any of the Cargo manifests fail + /// * multiple conflicting [`metadata::Wdk`] configurations are detected + /// * no [`metadata::Wdk`] configurations are detected + /// + /// # Panics + /// + /// Panics if the resolved top-level Cargo manifest path is not valid UTF-8 + #[tracing::instrument(level = "debug")] + pub fn from_env_auto() -> Result { + let top_level_cargo_manifest_path = find_top_level_cargo_manifest(); + debug!( + "Top level Cargo manifest path: {:?}", + top_level_cargo_manifest_path + ); + + let cwd = top_level_cargo_manifest_path + .parent() + .expect("Cargo manifest should have a valid parent directory"); + + let cargo_metadata = MetadataCommand::new() + // Run `cargo_metadata` in the same working directory as the top level manifest in order + // to respect `config.toml` overrides + .current_dir(cwd) + // top-level manifest path must be used in order for metadata from the top-level crates + // to be discovered + .manifest_path(&top_level_cargo_manifest_path) + .exec()?; + let wdk_metadata = metadata::Wdk::try_from(&cargo_metadata)?; + + // Force rebuilds if any of the manifest files change (ex. if wdk metadata + // section is modified) + for manifest_path in metadata::iter_manifest_paths(cargo_metadata) + .into_iter() + .chain(std::iter::once( + top_level_cargo_manifest_path + .try_into() + .expect("Path to Cargo manifests should always be valid UTF8"), + )) + { + println!("cargo:rerun-if-changed={manifest_path}"); + } + + Ok(Self { + driver_config: wdk_metadata.driver_model, + ..Default::default() + }) + } + + /// Emit `cargo::rustc-check-cfg` directives corresponding to all the + /// possible `rustc-cfg` settings `wdk_build` could emit + /// + /// This is useful in situations where a library may not have a valid WDK + /// config available during build. This function is not needed if the build + /// was already configured via [`configure_wdk_binary_build`], + /// [`configure_wdk_library_build`], or + /// [`configure_wdk_library_build_and_then`] + #[tracing::instrument(level = "debug")] + pub fn emit_check_cfg_settings() { + for (cfg_key, allowed_values) in EXPORTED_CFG_SETTINGS.iter() { + let allowed_cfg_value_string = + allowed_values.iter().fold(String::new(), |mut acc, value| { + const OPENING_QUOTE: char = '"'; + const CLOSING_QUOTE_AND_COMMA: &str = r#"","#; + + acc.reserve( + value.len() + OPENING_QUOTE.len_utf8() + CLOSING_QUOTE_AND_COMMA.len(), + ); + acc.push(OPENING_QUOTE); + acc.push_str(value); + acc.push_str(CLOSING_QUOTE_AND_COMMA); + acc + }); + + let cfg_key = { + // Replace `metadata::ser::KEY_NAME_SEPARATOR` with `__` so that `cfg_key` is a + // valid rust identifier name + let mut k = cfg_key.replace(metadata::ser::KEY_NAME_SEPARATOR, "__"); + // convention is that cfg keys are lowercase + k.make_ascii_lowercase(); + k + }; + + // Emit allowed cfg values + println!("cargo::rustc-check-cfg=cfg({cfg_key}, values({allowed_cfg_value_string}))"); + } + } + + /// Expose `cfg` settings based on this [`Config`] to enable conditional + /// compilation. This emits specially formatted prints to Cargo based on + /// this [`Config`]. + #[tracing::instrument(level = "trace")] + fn emit_cfg_settings(&self) -> Result<(), ConfigError> { + Self::emit_check_cfg_settings(); + + let serialized_wdk_metadata_map = + metadata::to_map::>(&metadata::Wdk { + driver_model: self.driver_config.clone(), + })?; + + for cfg_key in EXPORTED_CFG_SETTINGS.iter().map(|(key, _)| *key) { + let cfg_value = &serialized_wdk_metadata_map[cfg_key]; + + let cfg_key = { + // Replace `metadata::ser::KEY_NAME_SEPARATOR` with `__` so that `cfg_key` is a + // valid rust identifier name + let mut k = cfg_key.replace(metadata::ser::KEY_NAME_SEPARATOR, "__"); + // convention is that cfg keys are lowercase + k.make_ascii_lowercase(); + k + }; + + // Emit cfg + println!(r#"cargo::rustc-cfg={cfg_key}="{cfg_value}""#); + } + + Ok(()) + } + + /// Return header include paths required to build and link based off of the + /// configuration of `Config` + /// + /// # Errors + /// + /// This function will return an error if any of the required paths do not + /// exist. + #[tracing::instrument(level = "debug")] + pub fn include_paths(&self) -> Result, ConfigError> { + let mut include_paths = vec![]; + let sdk_version = detect_windows_sdk_version(&self.wdk_content_root)?; + let include_directory = self.wdk_content_root.join("Include"); + + // Add windows sdk include paths + // Based off of logic from WindowsDriver.KernelMode.props & + // WindowsDriver.UserMode.props in NI(22H2) WDK + let windows_sdk_include_path = include_directory.join(sdk_version); + + let crt_include_path = windows_sdk_include_path.join("km/crt"); + Self::validate_and_add_folder_path(&mut include_paths, &crt_include_path)?; + + let km_or_um_include_path = windows_sdk_include_path.join(match self.driver_config { + DriverConfig::Wdm | DriverConfig::Kmdf(_) => "km", + DriverConfig::Umdf(_) => "um", + }); + Self::validate_and_add_folder_path(&mut include_paths, &km_or_um_include_path)?; + + let kit_shared_include_path = windows_sdk_include_path.join("shared"); + Self::validate_and_add_folder_path(&mut include_paths, &kit_shared_include_path)?; + + // Add other driver type-specific include paths + match &self.driver_config { + DriverConfig::Wdm => {} + DriverConfig::Kmdf(kmdf_config) => { + let kmdf_include_path = include_directory.join(format!( + "wdf/kmdf/{}.{}", + kmdf_config.kmdf_version_major, kmdf_config.target_kmdf_version_minor + )); + Self::validate_and_add_folder_path(&mut include_paths, &kmdf_include_path)?; + + // `ufxclient.h` relies on `ufxbase.h` being on the headers search path. The WDK + // normally does not automatically include this search path, but it is required + // here so that the headers can be processed successfully. + let ufx_include_path = km_or_um_include_path.join("ufx/1.1"); + Self::validate_and_add_folder_path(&mut include_paths, &ufx_include_path)?; + } + DriverConfig::Umdf(umdf_config) => { + let umdf_include_path = include_directory.join(format!( + "wdf/umdf/{}.{}", + umdf_config.umdf_version_major, umdf_config.target_umdf_version_minor + )); + Self::validate_and_add_folder_path(&mut include_paths, &umdf_include_path)?; + } + } + + Ok(include_paths.into_iter()) + } + + /// Validate that a path refers to an existing directory and push its + /// canonical absolute form into the provided collection. + /// + /// This helper is used for both header include directories and library + /// directories. It normalizes paths before insertion. + fn validate_and_add_folder_path( + include_paths: &mut Vec, + path: &Path, + ) -> Result<(), ConfigError> { + // Include paths should be directories + if !path.is_dir() { + return Err(ConfigError::DirectoryNotFound { + directory: path.to_string_lossy().into(), + }); + } + + let absolute_path = absolute(path).map_err(|source| IoError::with_path(path, source))?; + + include_paths.push(absolute_path); + Ok(()) + } + + /// Return library include paths required to build and link based off of + /// the configuration of [`Config`]. + /// + /// For UMDF drivers, this assumes a "Windows-Driver" Target Platform. + /// + /// # Errors + /// + /// This function will return an error if any of the required paths do not + /// exist. + #[tracing::instrument(level = "debug")] + pub fn library_paths(&self) -> Result, ConfigError> { + let mut library_paths = vec![]; + let sdk_version = detect_windows_sdk_version(&self.wdk_content_root)?; + + // Add windows sdk library paths + // Based off of logic from WindowsDriver.KernelMode.props & + // WindowsDriver.UserMode.props in NI(22H2) WDK + let windows_sdk_library_path = self.sdk_library_path(sdk_version)?; + Self::validate_and_add_folder_path(&mut library_paths, &windows_sdk_library_path)?; + + // Add other driver type-specific library paths + let library_directory = self.wdk_content_root.join("Lib"); + match &self.driver_config { + DriverConfig::Wdm => (), + DriverConfig::Kmdf(kmdf_config) => { + let kmdf_library_path = library_directory.join(format!( + "wdf/kmdf/{}/{}.{}", + self.cpu_architecture.as_windows_str(), + kmdf_config.kmdf_version_major, + kmdf_config.target_kmdf_version_minor + )); + Self::validate_and_add_folder_path(&mut library_paths, &kmdf_library_path)?; + } + DriverConfig::Umdf(umdf_config) => { + let umdf_library_path = library_directory.join(format!( + "wdf/umdf/{}/{}.{}", + self.cpu_architecture.as_windows_str(), + umdf_config.umdf_version_major, + umdf_config.target_umdf_version_minor, + )); + Self::validate_and_add_folder_path(&mut library_paths, &umdf_library_path)?; + } + } + + // Reverse order of library paths so that paths pushed later into the vec take + // precedence + library_paths.reverse(); + Ok(library_paths.into_iter()) + } + + /// Return an iterator of strings that represent compiler definitions + /// derived from the `Config` + #[tracing::instrument(level = "debug")] + pub fn preprocessor_definitions(&self) -> impl Iterator)> { + // _WIN32_WINNT=$(WIN32_WINNT_VERSION); + // WINVER=$(WINVER_VERSION); + // WINNT=1; + // NTDDI_VERSION=$(NTDDI_VERSION); + + // Definition sourced from: Program Files\Windows + // Kits\10\build\10.0.26040.0\WindowsDriver.Shared.Props + // vec![ //from driver.os.props //D:\EWDK\rsprerelease\content\Program + // Files\Windows Kits\10\build\10.0.26040.0\WindowsDriver.OS.Props + // ("_WIN32_WINNT", Some()),CURRENT_WIN32_WINNT_VERSION + // ("WINVER", Some()), = CURRENT_WIN32_WINNT_VERSION + // ("WINNT", Some(1)),1 + // ("NTDDI_VERSION", Some()),CURRENT_NTDDI_VERSION + // ] + // .into_iter() + // .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))) + match self.cpu_architecture { + // Definitions sourced from `Program Files\Windows + // Kits\10\build\10.0.22621.0\WindowsDriver.x64.props` + CpuArchitecture::Amd64 => { + vec![("_WIN64", None), ("_AMD64_", None), ("AMD64", None)] + } + // Definitions sourced from `Program Files\Windows + // Kits\10\build\10.0.22621.0\WindowsDriver.arm64.props` + CpuArchitecture::Arm64 => { + vec![ + ("_ARM64_", None), + ("ARM64", None), + ("_USE_DECLSPECS_FOR_SAL", Some(1)), + ("STD_CALL", None), + ] + } + } + .into_iter() + .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))) + .chain( + match self.driver_config { + DriverConfig::Wdm => { + vec![ + ("_KERNEL_MODE", None), // Normally defined by msvc via /kernel flag + ] + } + DriverConfig::Kmdf(kmdf_config) => { + let mut kmdf_definitions = vec![ + ("_KERNEL_MODE", None), // Normally defined by msvc via /kernel flag + ("KMDF_VERSION_MAJOR", Some(kmdf_config.kmdf_version_major)), + ( + "KMDF_VERSION_MINOR", + Some(kmdf_config.target_kmdf_version_minor), + ), + ]; + + if let Some(minimum_minor_version) = kmdf_config.minimum_kmdf_version_minor { + kmdf_definitions + .push(("KMDF_MINIMUM_VERSION_REQUIRED", Some(minimum_minor_version))); + } + kmdf_definitions + } + DriverConfig::Umdf(umdf_config) => { + let mut umdf_definitions = vec![ + ("UMDF_VERSION_MAJOR", Some(umdf_config.umdf_version_major)), + ( + "UMDF_VERSION_MINOR", + Some(umdf_config.target_umdf_version_minor), + ), + // Definition sourced from: Program Files\Windows + // Kits\10\build\10.0.26040.0\Windows.UserMode.props + ("_ATL_NO_WIN_SUPPORT", None), + // Definition sourced from: Program Files\Windows + // Kits\10\build\10.0.26040.0\WindowsDriver.Shared.Props + ("WIN32_LEAN_AND_MEAN", Some(1)), + ]; + + if let Some(minimum_minor_version) = umdf_config.minimum_umdf_version_minor { + umdf_definitions + .push(("UMDF_MINIMUM_VERSION_REQUIRED", Some(minimum_minor_version))); + } + + if umdf_config.umdf_version_major >= 2 { + umdf_definitions.push(("UMDF_USING_NTSTATUS", None)); + umdf_definitions.push(("_UNICODE", None)); + umdf_definitions.push(("UNICODE", None)); + } + + umdf_definitions + } + } + .into_iter() + .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))), + ) + } + + /// Return an iterator of strings that represent compiler flags (i.e. + /// warnings, settings, etc.) used by bindgen to parse WDK headers + #[tracing::instrument(level = "debug")] + pub fn wdk_bindgen_compiler_flags() -> impl Iterator { + vec![ + // Enable Microsoft C/C++ extensions and compatibility options (https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions) + "-fms-compatibility", + "-fms-extensions", + "-fdelayed-template-parsing", + // Windows SDK & DDK have non-portable paths (ex. #include "DriverSpecs.h" but the + // file is actually driverspecs.h) + "--warn-=no-nonportable-include-path", + // Windows SDK & DDK use pshpack and poppack headers to change packing + "--warn-=no-pragma-pack", + "--warn-=no-ignored-attributes", + "--warn-=no-ignored-pragma-intrinsic", + "--warn-=no-visibility", + "--warn-=no-switch", + "--warn-=no-comment", + // Don't warn for deprecated declarations. Deprecated items should be explicitly + // blocklisted (i.e. by the bindgen invocation). Any non-blocklisted function + // definitions will trigger a -WDeprecated warning + "--warn-=no-deprecated-declarations", + // Windows SDK & DDK contain unnecessary token pasting (ex. &##_variable: `&` and + // `_variable` are separate tokens already, and don't need `##` to concatenate + // them) + "--warn-=no-invalid-token-paste", + // Windows SDK & DDK headers rely on Microsoft extensions to C/C++ + "--warn-=no-microsoft", + ] + .into_iter() + .map(ToString::to_string) + } + + /// Returns a [`String`] iterator over all the headers for a given + /// [`ApiSubset`] + /// + /// The iterator considers both the [`ApiSubset`] and the [`Config`] to + /// determine which headers to yield + /// + /// # Errors + /// [`ConfigError`] - if the headers for the given [`ApiSubset`] could not + /// be determined + #[tracing::instrument(level = "debug")] + pub fn headers( + &self, + api_subset: ApiSubset, + ) -> Result, ConfigError> { + let headers = match api_subset { + ApiSubset::Base => self.base_headers(), + ApiSubset::Wdf => self.wdf_headers(), + ApiSubset::Gpio => self.gpio_headers(), + ApiSubset::Hid => self.hid_headers(), + ApiSubset::ParallelPorts => self.parallel_ports_headers(), + ApiSubset::Spb => self.spb_headers(), + ApiSubset::Storage => self.storage_headers(), + ApiSubset::Usb => return self.usb_headers().map(std::iter::IntoIterator::into_iter), + ApiSubset::Iddcx => self.iddcx_headers(), + }; + Ok(headers + .into_iter() + .map(String::from) + .collect::>() + .into_iter()) + } + + #[tracing::instrument(level = "trace")] + fn iddcx_headers(&self) -> Vec<&'static str> { + // IddCx (Indirect Display) is UMDF-only. Versioned subpath like spb/1.1 and HidSpiCx/1.0. + if matches!(self.driver_config, DriverConfig::Umdf(_)) { + vec!["iddcx/1.10/IddCx.h"] + } else { + vec![] + } + } + + #[tracing::instrument(level = "trace")] + fn base_headers(&self) -> Vec<&'static str> { + match &self.driver_config { + DriverConfig::Wdm | DriverConfig::Kmdf(_) => { + vec!["ntifs.h", "ntddk.h", "ntstrsafe.h"] + } + DriverConfig::Umdf(_) => { + vec!["windows.h"] + } + } + } + + #[tracing::instrument(level = "trace")] + fn wdf_headers(&self) -> Vec<&'static str> { + if matches!( + self.driver_config, + DriverConfig::Kmdf(_) | DriverConfig::Umdf(_) + ) { + vec!["wdf.h"] + } else { + vec![] + } + } + + #[tracing::instrument(level = "trace")] + fn gpio_headers(&self) -> Vec<&'static str> { + let mut headers = vec!["gpio.h"]; + if matches!(self.driver_config, DriverConfig::Kmdf(_)) { + headers.extend(["gpioclx.h"]); + } + headers + } + + #[tracing::instrument(level = "trace")] + fn hid_headers(&self) -> Vec<&'static str> { + let mut headers = vec!["hidclass.h", "hidsdi.h", "hidpi.h", "vhf.h"]; + if matches!( + self.driver_config, + DriverConfig::Wdm | DriverConfig::Kmdf(_) + ) { + headers.extend(["hidpddi.h", "hidport.h", "kbdmou.h", "ntdd8042.h"]); + } + + if matches!(self.driver_config, DriverConfig::Kmdf(_)) { + headers.extend(["HidSpiCx/1.0/hidspicx.h"]); + } + headers + } + + #[tracing::instrument(level = "trace")] + fn parallel_ports_headers(&self) -> Vec<&'static str> { + let mut headers = vec!["ntddpar.h", "ntddser.h"]; + if matches!( + self.driver_config, + DriverConfig::Wdm | DriverConfig::Kmdf(_) + ) { + headers.extend(["parallel.h"]); + } + headers + } + + #[tracing::instrument(level = "trace")] + fn spb_headers(&self) -> Vec<&'static str> { + let mut headers = vec!["spb.h", "reshub.h"]; + if matches!( + self.driver_config, + DriverConfig::Wdm | DriverConfig::Kmdf(_) + ) { + headers.extend(["pwmutil.h"]); + } + if matches!(self.driver_config, DriverConfig::Kmdf(_)) { + headers.extend(["spb/1.1/spbcx.h"]); + } + headers + } + + #[tracing::instrument(level = "trace")] + fn storage_headers(&self) -> Vec<&'static str> { + let mut headers = vec![ + "ehstorioctl.h", + "ntddcdrm.h", + "ntddcdvd.h", + "ntdddisk.h", + "ntddmmc.h", + "ntddscsi.h", + "ntddstor.h", + "ntddtape.h", + "ntddvol.h", + "ufs.h", + ]; + if matches!( + self.driver_config, + DriverConfig::Wdm | DriverConfig::Kmdf(_) + ) { + headers.extend([ + "mountdev.h", + "mountmgr.h", + "ntddchgr.h", + "ntdddump.h", + "storduid.h", + "storport.h", + ]); + } + if matches!(self.driver_config, DriverConfig::Kmdf(_)) { + headers.extend(["ehstorbandmgmt.h"]); + } + headers + } + + #[tracing::instrument(level = "trace")] + fn usb_headers(&self) -> Result, ConfigError> { + let mut headers = Vec::new(); + headers.extend( + [ + "usb.h", + "usbfnbase.h", + "usbioctl.h", + "usbspec.h", + "Usbpmapi.h", + ] + .iter() + .map(ToString::to_string), + ); + if matches!( + self.driver_config, + DriverConfig::Wdm | DriverConfig::Kmdf(_) + ) { + headers.extend( + ["usbbusif.h", "usbdlib.h", "usbfnattach.h", "usbfnioctl.h"] + .iter() + .map(ToString::to_string), + ); + } + + if matches!( + self.driver_config, + DriverConfig::Kmdf(_) | DriverConfig::Umdf(_) + ) { + headers.extend(["wdfusb.h".to_string()]); + } + + if matches!(self.driver_config, DriverConfig::Kmdf(_)) { + headers.extend( + [ + "ucm/1.0/UcmCx.h", + "UcmTcpci/1.0/UcmTcpciCx.h", + "UcmUcsi/1.0/UcmucsiCx.h", + "ude/1.1/UdeCx.h", + "ufx/1.1/ufxbase.h", + "ufxproprietarycharger.h", + "urs/1.0/UrsCx.h", + ] + .iter() + .map(ToString::to_string), + ); + + let latest_ucx_header_path = self.ucx_header()?; + headers.push(latest_ucx_header_path); + + if Self::should_include_ufxclient() { + headers.push("ufx/1.1/ufxclient.h".to_string()); + } + } + Ok(headers) + } + + /// Determines whether to include the ufxclient.h header based on the Clang + /// version used by bindgen. + /// + /// The ufxclient.h header contains FORCEINLINE annotations that are invalid + /// according to the C standard. While MSVC silently ignores these in C + /// mode, older versions of Clang (pre-20.0) will error, even with MSVC + /// compatibility enabled. + /// + /// This function checks if the current Clang version is 20.0 or newer, + /// where the issue was fixed. See + /// for details. + #[tracing::instrument(level = "trace")] + fn should_include_ufxclient() -> bool { + 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_VERSION_WITH_INVALID_INLINE_FIX => + { + true + } + Some(_) => { + tracing::info!( + "Skipping ufxclient.h due to FORCEINLINE bug in {}", + clang_version.full + ); + false + } + None => { + tracing::warn!( + "Failed to parse semver Major and Minor components from full Clang version \ + string: {}", + clang_version.full + ); + false + } + } + } + + /// Returns a [`String`] containing the contents of a header file designed + /// for [`bindgen`](https://docs.rs/bindgen) to process + /// + /// The contents contain `#include`'ed headers based off the [`ApiSubset`] + /// and [`Config`], as well as any additional definitions required for the + /// headers to be processed successfully. + /// + /// # Errors + /// [`ConfigError`] - if the headers for a [`ApiSubset`] could not be + /// determined + #[tracing::instrument(level = "debug")] + pub fn bindgen_header_contents( + &self, + api_subsets: impl IntoIterator + fmt::Debug, + ) -> Result { + Ok(api_subsets + .into_iter() + .map(|api_subset| self.headers(api_subset)) + .collect::, _>>()? + .into_iter() + .flat_map(|iter| iter.map(|header| format!("#include \"{header}\"\n"))) + .collect()) + } + + /// Configure a Cargo build of a library that depends on the WDK. This + /// emits specially formatted prints to Cargo based on this [`Config`]. + /// + /// # Errors + /// + /// This function will return an error if the [`Config`] fails to be + /// serialized + #[tracing::instrument(level = "debug")] + pub fn configure_library_build(&self) -> Result<(), ConfigError> { + self.emit_cfg_settings() + } + + /// Compute the name of the `WdfFunctions` symbol used for WDF function + /// dispatching based off of the [`Config`]. Returns `None` if the driver + /// model is [`DriverConfig::Wdm`] + #[must_use] + #[tracing::instrument(level = "debug")] + pub fn compute_wdffunctions_symbol_name(&self) -> Option { + let (wdf_major_version, wdf_minor_version) = match self.driver_config { + DriverConfig::Kmdf(config) => { + (config.kmdf_version_major, config.target_kmdf_version_minor) + } + DriverConfig::Umdf(config) => { + (config.umdf_version_major, config.target_umdf_version_minor) + } + DriverConfig::Wdm => return None, + }; + + Some(format!( + "WdfFunctions_{wdf_major_version:02}0{wdf_minor_version:02}" + )) + } + + /// Configure a Cargo build of a binary that depends on the WDK. This + /// emits specially formatted prints to Cargo based on this [`Config`]. + /// + /// This consists mainly of linker setting configuration. This must be + /// called from a Cargo build script of the binary being built + /// + /// # Errors + /// + /// This function will return an error if: + /// * any of the required WDK paths do not exist + /// * the C runtime is not configured to be statically linked for a + /// kernel-mode driver + /// + /// # Panics + /// + /// Panics if the invoked from outside a Cargo build environment + #[tracing::instrument(level = "debug")] + pub fn configure_binary_build(&self) -> Result<(), ConfigError> { + if !Self::is_crt_static_linked() { + cfg_if::cfg_if! { + if #[cfg(all(wdk_build_unstable, skip_umdf_static_crt_check))] { + if !matches!(self.driver_config, DriverConfig::Umdf(_)) { + return Err(ConfigError::StaticCrtNotEnabled); + } + } else { + return Err(ConfigError::StaticCrtNotEnabled); + } + }; + } + + // Emit linker search paths + for path in self.library_paths()? { + println!("cargo::rustc-link-search={}", path.display()); + } + + match &self.driver_config { + DriverConfig::Wdm => { + // Emit WDM-specific libraries to link to + println!("cargo::rustc-link-lib=static=BufferOverflowFastFailK"); + println!("cargo::rustc-link-lib=static=ntoskrnl"); + println!("cargo::rustc-link-lib=static=hal"); + println!("cargo::rustc-link-lib=static=wmilib"); + + // Emit ARM64-specific libraries to link to derived from + // WindowsDriver.arm64.props + if self.cpu_architecture == CpuArchitecture::Arm64 { + println!("cargo::rustc-link-lib=static=arm64rt"); + } + + // Linker arguments derived from WindowsDriver.KernelMode.props in Ni(22H2) WDK + println!("cargo::rustc-cdylib-link-arg=/DRIVER"); + println!("cargo::rustc-cdylib-link-arg=/NODEFAULTLIB"); + println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:NATIVE"); + println!("cargo::rustc-cdylib-link-arg=/KERNEL"); + + // Linker arguments derived from WindowsDriver.KernelMode.WDM.props in Ni(22H2) + // WDK + println!("cargo::rustc-cdylib-link-arg=/ENTRY:DriverEntry"); + + // Ignore `LNK4257: object file was not compiled for kernel mode; the image + // might not run` since `rustc` has no support for `/KERNEL` + println!("cargo::rustc-cdylib-link-arg=/IGNORE:4257"); + + // Ignore `LNK4216: Exported entry point DriverEntry` since Rust currently + // provides no way to set a symbol's name without also exporting the symbol: + // https://github.com/rust-lang/rust/issues/67399 + println!("cargo::rustc-cdylib-link-arg=/IGNORE:4216"); + } + DriverConfig::Kmdf(_) => { + // Emit KMDF-specific libraries to link to + println!("cargo::rustc-link-lib=static=BufferOverflowFastFailK"); + println!("cargo::rustc-link-lib=static=ntoskrnl"); + println!("cargo::rustc-link-lib=static=hal"); + println!("cargo::rustc-link-lib=static=wmilib"); + println!("cargo::rustc-link-lib=static=WdfLdr"); + println!("cargo::rustc-link-lib=static=WdfDriverEntry"); + + // Emit ARM64-specific libraries to link to derived from + // WindowsDriver.arm64.props + if self.cpu_architecture == CpuArchitecture::Arm64 { + println!("cargo::rustc-link-lib=static=arm64rt"); + } + + // Linker arguments derived from WindowsDriver.KernelMode.props in Ni(22H2) WDK + println!("cargo::rustc-cdylib-link-arg=/DRIVER"); + println!("cargo::rustc-cdylib-link-arg=/NODEFAULTLIB"); + println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:NATIVE"); + println!("cargo::rustc-cdylib-link-arg=/KERNEL"); + + // Linker arguments derived from WindowsDriver.KernelMode.KMDF.props in + // Ni(22H2) WDK + println!("cargo::rustc-cdylib-link-arg=/ENTRY:FxDriverEntry"); + + // Ignore `LNK4257: object file was not compiled for kernel mode; the image + // might not run` since `rustc` has no support for `/KERNEL` + println!("cargo::rustc-cdylib-link-arg=/IGNORE:4257"); + } + DriverConfig::Umdf(umdf_config) => { + // Emit UMDF-specific libraries to link to + if umdf_config.umdf_version_major >= 2 { + println!("cargo::rustc-link-lib=static=WdfDriverStubUm"); + println!("cargo::rustc-link-lib=static=ntdll"); + } + + println!("cargo::rustc-cdylib-link-arg=/NODEFAULTLIB:kernel32.lib"); + println!("cargo::rustc-cdylib-link-arg=/NODEFAULTLIB:user32.lib"); + println!("cargo::rustc-link-lib=static=OneCoreUAP"); + + // Linker arguments derived from WindowsDriver.UserMode.props in Ni(22H2) WDK + println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:WINDOWS"); + } + } + + // Emit linker arguments common to all configs + { + // Linker arguments derived from Microsoft.Link.Common.props in Ni(22H2) WDK + println!("cargo::rustc-cdylib-link-arg=/NXCOMPAT"); + println!("cargo::rustc-cdylib-link-arg=/DYNAMICBASE"); + + // Always generate Map file with Exports + println!("cargo::rustc-cdylib-link-arg=/MAP"); + println!("cargo::rustc-cdylib-link-arg=/MAPINFO:EXPORTS"); + + // Force Linker Optimizations + println!("cargo::rustc-cdylib-link-arg=/OPT:REF,ICF"); + + // Enable "Forced Integrity Checking" to prevent non-signed binaries from + // loading + println!("cargo::rustc-cdylib-link-arg=/INTEGRITYCHECK"); + + // Disable Manifest File Generation + println!("cargo::rustc-cdylib-link-arg=/MANIFEST:NO"); + } + + self.emit_cfg_settings() + } + + #[tracing::instrument(level = "trace")] + fn is_crt_static_linked() -> bool { + const STATICALLY_LINKED_C_RUNTIME_FEATURE_NAME: &str = "crt-static"; + + let enabled_cpu_target_features = env::var("CARGO_CFG_TARGET_FEATURE") + .expect("CARGO_CFG_TARGET_FEATURE should be set by Cargo"); + + enabled_cpu_target_features.contains(STATICALLY_LINKED_C_RUNTIME_FEATURE_NAME) + } + + /// Constructs the architecture-specific Windows SDK library path using the + /// provided SDK Version and the driver configuration. + /// + /// Builds the library path following the Windows SDK convention: + /// `{library_directory}/{sdk_version}/{km|um}/{architecture}/` + /// + /// # Arguments + /// + /// * `sdk_version` - Windows SDK version string (e.g., "10.0.22621.0") + /// + /// # Returns + /// + /// The constructed library path if it exists, otherwise + /// `ConfigError::DirectoryNotFound`. + /// + /// # Examples + /// + /// KMDF/AMD64: `C:\...\Lib\10.0.22621.0\km\x64` + /// UMDF/ARM64: `C:\...\Lib\10.0.22621.0\um\arm64` + #[tracing::instrument(level = "trace")] + fn sdk_library_path(&self, sdk_version: String) -> Result { + let windows_sdk_library_path = + self.wdk_content_root + .join("Lib") + .join(sdk_version) + .join(match self.driver_config { + DriverConfig::Wdm | DriverConfig::Kmdf(_) => { + format!("km/{}", self.cpu_architecture.as_windows_str(),) + } + DriverConfig::Umdf(_) => { + format!("um/{}", self.cpu_architecture.as_windows_str(),) + } + }); + if !windows_sdk_library_path.is_dir() { + return Err(ConfigError::DirectoryNotFound { + directory: windows_sdk_library_path.to_string_lossy().into(), + }); + } + Ok(windows_sdk_library_path) + } + + /// Returns the path to the latest available UCX header file present in the + /// Lib folder of the WDK content root + #[tracing::instrument(level = "trace")] + fn ucx_header(&self) -> Result { + let sdk_version = utils::detect_windows_sdk_version(&self.wdk_content_root)?; + let ucx_header_root_dir = self.sdk_library_path(sdk_version)?.join("ucx"); + let max_version = utils::find_max_version_in_directory(&ucx_header_root_dir)?; + let path = format!("ucx/{}.{}/ucxclass.h", max_version.0, max_version.1); + Ok(path) + } +} + +impl From for DriverConfig { + fn from(config: DeserializableDriverConfig) -> Self { + match config { + DeserializableDriverConfig::Wdm => Self::Wdm, + DeserializableDriverConfig::Kmdf(kmdf_config) => Self::Kmdf(kmdf_config), + DeserializableDriverConfig::Umdf(umdf_config) => Self::Umdf(umdf_config), + } + } +} + +impl Default for KmdfConfig { + fn default() -> Self { + // FIXME: determine default values from TargetVersion and _NT_TARGET_VERSION + Self { + kmdf_version_major: 1, + target_kmdf_version_minor: 33, + minimum_kmdf_version_minor: None, + } + } +} + +impl KmdfConfig { + /// Creates a new [`KmdfConfig`] with default values + #[must_use] + pub fn new() -> Self { + Self::default() + } +} + +impl Default for UmdfConfig { + fn default() -> Self { + // FIXME: determine default values from TargetVersion and _NT_TARGET_VERSION + Self { + umdf_version_major: 2, + target_umdf_version_minor: 33, + minimum_umdf_version_minor: None, + } + } +} + +impl UmdfConfig { + /// Creates a new [`UmdfConfig`] with default values + #[must_use] + pub fn new() -> Self { + Self::default() + } +} + +impl CpuArchitecture { + /// Converts [`CpuArchitecture`] to the string corresponding to what the + /// architecture is typically referred to in Windows + #[must_use] + pub const fn as_windows_str(&self) -> &str { + match self { + Self::Amd64 => "x64", + Self::Arm64 => "ARM64", + } + } + + /// Converts from a cargo-provided [`std::str`] to a [`CpuArchitecture`]. + #[must_use] + pub fn try_from_cargo_str>(cargo_str: S) -> Option { + // Specifically not using the [`std::convert::TryFrom`] trait to be more + // explicit in function name, since only arch strings from cargo are handled. + match cargo_str.as_ref() { + "x86_64" => Some(Self::Amd64), + "aarch64" => Some(Self::Arm64), + _ => None, + } + } +} + +/// Find the path of the toplevel Cargo manifest of the currently executing +/// Cargo subcommand. This should resolve to either: +/// 1. the `Cargo.toml` of the package where the Cargo subcommand (build, check, +/// etc.) was run +/// 2. the `Cargo.toml` provided to the `--manifest-path` argument to the Cargo +/// subcommand +/// 3. the `Cargo.toml` of the workspace that contains the package pointed to by +/// 1 or 2 +/// +/// The returned path should be a manifest in the same directory of the +/// lockfile. This does not support invocations that use non-default target +/// directories (ex. via `--target-dir`). This function only works when called +/// from a `build.rs` file +/// +/// # Panics +/// +/// Panics if a `Cargo.lock` file cannot be found in any of the ancestors of +/// `OUT_DIR` or if this function was called outside of a `build.rs` file +#[must_use] +#[tracing::instrument(level = "debug")] +pub fn find_top_level_cargo_manifest() -> PathBuf { + let out_dir = + PathBuf::from(env::var("OUT_DIR").expect( + "Cargo should have set the OUT_DIR environment variable when executing build.rs", + )); + + out_dir + .ancestors() + .find(|path| path.join("Cargo.lock").exists()) + .expect("a Cargo.lock file should exist in the same directory as the top-level Cargo.toml") + .join("Cargo.toml") +} + +/// Configure a Cargo build of a library that depends on the WDK. +/// +/// This emits specially formatted prints to Cargo based on the [`Config`] +/// derived from `metadata.wdk` sections of `Cargo.toml`s. +/// +/// Cargo build graphs that have no valid WDK configurations will emit a +/// warning, but will still return [`Ok`]. This allows libraries +/// designed for multiple configurations to successfully compile when built in +/// isolation. +/// +/// # Errors +/// +/// This function will return an error if the [`Config`] fails to be +/// serialized +#[tracing::instrument(level = "debug")] +pub fn configure_wdk_library_build() -> Result<(), ConfigError> { + match Config::from_env_auto() { + Ok(config) => { + config.configure_library_build()?; + Ok(()) + } + Err(ConfigError::TryFromCargoMetadataError( + TryFromCargoMetadataError::NoWdkConfigurationsDetected, + )) => { + // No WDK configurations will be detected if the crate is not being used in a + // driver. Since this is usually the case when libraries are being built + // standalone, this scenario is treated as a warning. + tracing::warn!("No WDK configurations detected."); + // check_cfg must be emitted even if no WDK configurations are detected, so that + // cfg options are still checked + Config::emit_check_cfg_settings(); + Ok(()) + } + + Err(error) => Err(error), + } +} + +/// Configure a Cargo build of a library that depends on the WDK, then execute a +/// function or closure with the [`Config`] derived from `metadata.wdk` sections +/// of `Cargo.toml`s. +/// +/// This emits specially formatted prints to Cargo based on the [`Config`] +/// derived from `metadata.wdk` sections of `Cargo.toml`s. +/// +/// Cargo build graphs that have no valid WDK configurations will emit a +/// warning, but will still return [`Ok`]. This allows libraries +/// designed for multiple configurations to successfully compile when built in +/// isolation. +/// +/// # Errors +/// +/// This function will return an error if the [`Config`] fails to be +/// serialized +#[tracing::instrument(level = "debug", skip(f))] +pub fn configure_wdk_library_build_and_then(mut f: F) -> Result<(), E> +where + F: FnMut(Config) -> Result<(), E>, + E: std::convert::From, +{ + match Config::from_env_auto() { + Ok(config) => { + config.configure_library_build()?; + debug!("Calling closure with {config:#?}"); + Ok(f(config)?) + } + Err(ConfigError::TryFromCargoMetadataError( + TryFromCargoMetadataError::NoWdkConfigurationsDetected, + )) => { + // No WDK configurations will be detected if the crate is not being used in a + // driver. Since this is usually the case when libraries are being built + // standalone, this scenario is treated as a warning. + tracing::warn!("No WDK configurations detected."); + // check_cfg must be emitted even if no WDK configurations are detected, so that + // cfg options are still checked + Config::emit_check_cfg_settings(); + Ok(()) + } + + Err(error) => Err(error.into()), + } +} + +/// Configure a Cargo build of a binary that depends on the WDK using a +/// [`Config`] derived from `metadata.wdk` sections of `Cargo.toml`s. +/// +/// # Errors +/// +/// This function will return an error if: +/// * any of the required WDK paths do not exist +/// * the C runtime is not configured to be statically linked +/// +/// # Panics +/// +/// Panics if the invoked from outside a Cargo build environment +#[tracing::instrument(level = "debug")] +pub fn configure_wdk_binary_build() -> Result<(), ConfigError> { + Config::from_env_auto()?.configure_binary_build() +} + +/// This currently only exports the driver type, but may export more metadata in +/// the future. `EXPORTED_CFG_SETTINGS` is a mapping of cfg key to allowed cfg +/// values +static EXPORTED_CFG_SETTINGS: LazyLock)>> = + LazyLock::new(|| vec![("DRIVER_MODEL-DRIVER_TYPE", vec!["WDM", "KMDF", "UMDF"])]); + +/// Detects the WDK build number. +/// +/// Detects the Windows Driver Kit (WDK) build number by locating +/// the WDK content root, retrieving the latest Windows SDK version, validating +/// the version format, and extracting the build number. +/// +/// # Returns +/// +/// Returns a `Result`, which contains the WDK +/// build number on success or a `ConfigError` on failure. +/// +/// # Errors +/// +/// Returns an error if: +/// * The WDK content root cannot be detected. +/// * The latest Windows SDK version cannot be retrieved. +/// * The WDK version string format is invalid. +/// * The WDK version number cannot be parsed. +/// +/// # Panics +/// +/// Panics if the WDK version number cannot be extracted from +/// the version string. +#[tracing::instrument(level = "debug")] +pub fn detect_wdk_build_number() -> Result { + let wdk_content_root = + utils::detect_wdk_content_root().ok_or(ConfigError::WdkContentRootDetectionError)?; + let detected_sdk_version = detect_windows_sdk_version(&wdk_content_root)?; + + if !utils::validate_wdk_version_format(&detected_sdk_version) { + return Err(ConfigError::WdkVersionStringFormatError { + version: detected_sdk_version, + }); + } + + let wdk_build_number = + str::parse::(&utils::get_wdk_version_number(&detected_sdk_version)?).unwrap_or_else( + |_| panic!("Couldn't parse WDK version number! Version number: {detected_sdk_version}"), + ); + + Ok(wdk_build_number) +} + +#[cfg(test)] +mod tests { + #[cfg(nightly_toolchain)] + use std::assert_matches::assert_matches; + use std::{collections::HashMap, ffi::OsStr, sync::Mutex}; + + use super::*; + use crate::utils::{remove_var, set_var}; + + mod two_part_version { + use super::*; + + #[test] + fn valid_versions() { + assert_eq!("1.2".parse(), Ok(TwoPartVersion(1, 2))); + assert_eq!("0.0".parse(), Ok(TwoPartVersion(0, 0))); + assert_eq!("10.15".parse(), Ok(TwoPartVersion(10, 15))); + assert_eq!("999.1".parse(), Ok(TwoPartVersion(999, 1))); + assert_eq!("1.999".parse(), Ok(TwoPartVersion(1, 999))); + assert_eq!("01.02".parse(), Ok(TwoPartVersion(1, 2))); + assert_eq!("1.02".parse(), Ok(TwoPartVersion(1, 2))); + assert_eq!("01.2".parse(), Ok(TwoPartVersion(1, 2))); + } + + #[test] + fn invalid_format_versions() { + assert_eq!( + String::new().parse::(), + Err(TwoPartVersionError::InvalidFormat(String::new())) + ); + assert_eq!( + "1".parse::(), + Err(TwoPartVersionError::InvalidFormat("1".to_string())) + ); + assert_eq!( + "123".parse::(), + Err(TwoPartVersionError::InvalidFormat("123".to_string())) + ); + assert_eq!( + "1.2.3.4".parse::(), + Err(TwoPartVersionError::InvalidFormat("1.2.3.4".to_string())) + ); + assert_eq!( + ".".parse::(), + Err(TwoPartVersionError::InvalidFormat(".".to_string())) + ); + assert_eq!( + ".2".parse::(), + Err(TwoPartVersionError::InvalidFormat(".2".to_string())) + ); + assert_eq!( + "1.".parse::(), + Err(TwoPartVersionError::InvalidFormat("1.".to_string())) + ); + assert_eq!( + "myfolder".parse::(), + Err(TwoPartVersionError::InvalidFormat("myfolder".to_string())) + ); + } + + #[test] + fn parse_error_versions() { + assert_eq!( + "a.b".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "a.b".to_string() + )) + ); + assert_eq!( + "1.b".parse::(), + Err(TwoPartVersionError::ParseError( + "minor".to_string(), + "1.b".to_string() + )) + ); + assert_eq!( + "a.2".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "a.2".to_string() + )) + ); + assert_eq!( + "1.2a".parse::(), + Err(TwoPartVersionError::ParseError( + "minor".to_string(), + "1.2a".to_string() + )) + ); + assert_eq!( + "1a.2".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "1a.2".to_string() + )) + ); + assert_eq!( + " 1.2".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + " 1.2".to_string() + )) + ); + assert_eq!( + "1.2 ".parse::(), + Err(TwoPartVersionError::ParseError( + "minor".to_string(), + "1.2 ".to_string() + )) + ); + assert_eq!( + "1 .2".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "1 .2".to_string() + )) + ); + assert_eq!( + "1. 2".parse::(), + Err(TwoPartVersionError::ParseError( + "minor".to_string(), + "1. 2".to_string() + )) + ); + } + + #[test] + fn version_ordering() { + let v1_0 = TwoPartVersion(1, 0); + let v1_1 = TwoPartVersion(1, 1); + let v1_999 = TwoPartVersion(1, 999); + let v2_0 = TwoPartVersion(2, 0); + let v2_1 = TwoPartVersion(2, 1); + + assert!(v1_0 < v1_1); + assert!(v1_1 < v1_999); + assert!(v1_999 < v2_0); + assert!(v2_0 < v2_1); + } + + #[test] + fn equality() { + let v1 = TwoPartVersion(1, 2); + let v2 = TwoPartVersion(1, 2); + let v3 = TwoPartVersion(1, 3); + assert_eq!(v1, v2); + assert_ne!(v1, v3); + } + + #[test] + fn debug_formatting() { + let version = TwoPartVersion(1, 2); + let debug_str = format!("{version:?}"); + assert_eq!(debug_str, "TwoPartVersion(1, 2)"); + } + + #[test] + fn max_selection() { + let versions = [ + TwoPartVersion(1, 2), + TwoPartVersion(1, 10), + TwoPartVersion(2, 0), + TwoPartVersion(1, 5), + TwoPartVersion(2, 1), + TwoPartVersion(1, 999), + ]; + + let max_version = versions.iter().max().unwrap(); + assert_eq!(*max_version, TwoPartVersion(2, 1)); + } + + #[test] + fn u32_max_and_overflow() { + assert_eq!( + "4294967295.4294967295".parse::(), + Ok(TwoPartVersion(4_294_967_295, 4_294_967_295)) + ); + assert_eq!( + "4294967296.0".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "4294967296.0".to_string() + )) + ); + assert_eq!( + "99999999999999999999.0".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "99999999999999999999.0".to_string() + )) + ); + assert_eq!( + "0.4294967296".parse::(), + Err(TwoPartVersionError::ParseError( + "minor".to_string(), + "0.4294967296".to_string() + )) + ); + assert_eq!( + "1.99999999999999999999".parse::(), + Err(TwoPartVersionError::ParseError( + "minor".to_string(), + "1.99999999999999999999".to_string() + )) + ); + assert_eq!( + "4294967296.4294967296".parse::(), + Err(TwoPartVersionError::ParseError( + "major".to_string(), + "4294967296.4294967296".to_string() + )) + ); + } + } + + /// Runs function after modifying environment variables, and returns the + /// function's return value. + /// + /// The environment is guaranteed to be not modified during the execution + /// of the function, and the environment is reset to its original state + /// after execution of the function. No testing asserts should be called in + /// the function, since a failing test will poison the mutex, and cause all + /// remaining tests to fail. + /// + /// # Panics + /// + /// Panics if called with duplicate environment variable keys. + pub fn with_env(env_vars_key_value_pairs: &[(K, V)], f: F) -> R + where + K: AsRef + std::cmp::Eq + std::hash::Hash, + V: AsRef, + F: FnOnce() -> R, + { + // Tests can execute in multiple threads in the same process, so mutex must be + // used to guard access to the environment variables + static ENV_MUTEX: Mutex<()> = Mutex::new(()); + + let _mutex_guard = ENV_MUTEX.lock().unwrap(); + let mut original_env_vars = HashMap::new(); + + // set requested environment variables + for (key, value) in env_vars_key_value_pairs { + if let Ok(original_value) = env::var(key) { + let insert_result = original_env_vars.insert(key, original_value); + assert!( + insert_result.is_none(), + "Duplicate environment variable keys were provided" + ); + } + set_var(key, value); + } + + let f_return_value = f(); + + // reset all set environment variables + for (key, _) in env_vars_key_value_pairs { + original_env_vars.get(key).map_or_else( + || { + remove_var(key); + }, + |value| { + set_var(key, value); + }, + ); + } + + f_return_value + } + + #[test] + fn default_config() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], Config::new); + + #[cfg(nightly_toolchain)] + assert_matches!(config.driver_config, DriverConfig::Wdm); + assert_eq!(config.cpu_architecture, CpuArchitecture::Amd64); + } + + #[test] + fn wdm_config() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Wdm, + ..Config::default() + }); + + #[cfg(nightly_toolchain)] + assert_matches!(config.driver_config, DriverConfig::Wdm); + assert_eq!(config.cpu_architecture, CpuArchitecture::Amd64); + } + + #[test] + fn default_kmdf_config() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Kmdf(KmdfConfig::new()), + ..Config::default() + }); + + #[cfg(nightly_toolchain)] + assert_matches!( + config.driver_config, + DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 33, + minimum_kmdf_version_minor: None + }) + ); + assert_eq!(config.cpu_architecture, CpuArchitecture::Amd64); + } + + #[test] + fn kmdf_config() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 15, + minimum_kmdf_version_minor: None, + }), + ..Config::default() + }); + + #[cfg(nightly_toolchain)] + assert_matches!( + config.driver_config, + DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 15, + minimum_kmdf_version_minor: None + }) + ); + assert_eq!(config.cpu_architecture, CpuArchitecture::Amd64); + } + + #[test] + fn default_umdf_config() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Umdf(UmdfConfig::new()), + ..Config::default() + }); + + #[cfg(nightly_toolchain)] + assert_matches!( + config.driver_config, + DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 2, + target_umdf_version_minor: 33, + minimum_umdf_version_minor: None + }) + ); + assert_eq!(config.cpu_architecture, CpuArchitecture::Amd64); + } + + #[test] + fn umdf_config() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "aarch64")], || Config { + driver_config: DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 2, + target_umdf_version_minor: 15, + minimum_umdf_version_minor: None, + }), + ..Config::default() + }); + + #[cfg(nightly_toolchain)] + assert_matches!( + config.driver_config, + DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 2, + target_umdf_version_minor: 15, + minimum_umdf_version_minor: None + }) + ); + assert_eq!(config.cpu_architecture, CpuArchitecture::Arm64); + } + + #[test] + fn test_try_from_cargo_str() { + assert_eq!( + CpuArchitecture::try_from_cargo_str("x86_64"), + Some(CpuArchitecture::Amd64) + ); + assert_eq!( + CpuArchitecture::try_from_cargo_str("aarch64"), + Some(CpuArchitecture::Arm64) + ); + assert_eq!(CpuArchitecture::try_from_cargo_str("arm"), None); + } + + mod bindgen_header_contents { + use super::*; + use crate::{KmdfConfig, UmdfConfig}; + + #[test] + fn wdm() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Wdm, + ..Default::default() + }); + + assert_eq!( + config.bindgen_header_contents([ApiSubset::Base]).unwrap(), + r#"#include "ntifs.h" +#include "ntddk.h" +#include "ntstrsafe.h" +"#, + ); + } + + #[test] + fn kmdf() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 33, + minimum_kmdf_version_minor: None, + }), + ..Default::default() + }); + + assert_eq!( + config + .bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf]) + .unwrap(), + r#"#include "ntifs.h" +#include "ntddk.h" +#include "ntstrsafe.h" +#include "wdf.h" +"#, + ); + } + + #[test] + fn umdf() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "aarch64")], || Config { + driver_config: DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 2, + target_umdf_version_minor: 15, + minimum_umdf_version_minor: None, + }), + ..Default::default() + }); + + assert_eq!( + config + .bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf]) + .unwrap(), + r#"#include "windows.h" +#include "wdf.h" +"#, + ); + } + } + mod compute_wdffunctions_symbol_name { + use super::*; + use crate::{KmdfConfig, UmdfConfig}; + + #[test] + fn kmdf() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 15, + minimum_kmdf_version_minor: None, + }), + ..Default::default() + }); + + let result = config.compute_wdffunctions_symbol_name(); + + assert_eq!(result, Some("WdfFunctions_01015".to_string())); + } + + #[test] + fn umdf() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "aarch64")], || Config { + driver_config: DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 2, + target_umdf_version_minor: 33, + minimum_umdf_version_minor: None, + }), + ..Default::default() + }); + + let result = config.compute_wdffunctions_symbol_name(); + + assert_eq!(result, Some("WdfFunctions_02033".to_string())); + } + + #[test] + fn wdm() { + let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config { + driver_config: DriverConfig::Wdm, + ..Default::default() + }); + + let result = config.compute_wdffunctions_symbol_name(); + + assert_eq!(result, None); + } + } + + mod validate_and_add_folder_path { + use assert_fs::prelude::*; + + use super::*; + + #[test] + fn valid_directory_is_added_successfully() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let mut include_paths = Vec::new(); + + let result = Config::validate_and_add_folder_path(&mut include_paths, temp_dir.path()); + + assert!(result.is_ok()); + assert_eq!(include_paths.len(), 1); + assert!(include_paths[0].exists()); + assert!(include_paths[0].is_dir()); + + // Verify the exact canonicalized path was added + let expected_path = absolute(temp_dir.path()).unwrap(); + assert_eq!(include_paths[0], expected_path); + } + + #[test] + fn non_existent_path_returns_directory_not_found_error() { + let non_existent_path = std::path::Path::new("/this/path/does/not/exist"); + let mut include_paths = Vec::new(); + + let result = + Config::validate_and_add_folder_path(&mut include_paths, non_existent_path); + + assert!(result.is_err()); + #[cfg(nightly_toolchain)] + assert_matches!( + result.unwrap_err(), + ConfigError::DirectoryNotFound { directory } if directory == non_existent_path.to_string_lossy() + ); + assert_eq!(include_paths.len(), 0); + } + + #[test] + fn file_path_returns_directory_not_found_error() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let file = temp_dir.child("test_file.txt"); + file.write_str("test content").unwrap(); + let mut include_paths = Vec::new(); + + let result = Config::validate_and_add_folder_path(&mut include_paths, file.path()); + + assert!(result.is_err()); + #[cfg(nightly_toolchain)] + assert_matches!( + result.unwrap_err(), + ConfigError::DirectoryNotFound { directory } if directory == file.path().to_string_lossy() + ); + assert_eq!(include_paths.len(), 0); + } + + #[test] + fn path_is_canonicalized_before_adding() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let sub_dir = temp_dir.child("subdir"); + sub_dir.create_dir_all().unwrap(); + + // Create a path with ".." to test canonicalization + let complex_path = sub_dir.path().join("..").join("subdir"); + let mut include_paths = Vec::new(); + + let result = Config::validate_and_add_folder_path(&mut include_paths, &complex_path); + + assert!(result.is_ok()); + assert_eq!(include_paths.len(), 1); + + // The canonicalized path should not contain ".." + assert!(!include_paths[0].to_string_lossy().contains("..")); + assert!(include_paths[0].is_absolute()); + + // Verify the path resolves to the actual subdir path + let expected_path = absolute(sub_dir.path()).unwrap(); + assert_eq!(include_paths[0], expected_path); + } + + #[test] + fn multiple_paths_are_added_correctly() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let dir1 = temp_dir.child("dir1"); + let dir2 = temp_dir.child("dir2"); + dir1.create_dir_all().unwrap(); + dir2.create_dir_all().unwrap(); + + let mut include_paths = Vec::new(); + + let result1 = Config::validate_and_add_folder_path(&mut include_paths, dir1.path()); + let result2 = Config::validate_and_add_folder_path(&mut include_paths, dir2.path()); + + assert!(result1.is_ok()); + assert!(result2.is_ok()); + assert_eq!(include_paths.len(), 2); + + // Both paths should be present and different + assert_ne!(include_paths[0], include_paths[1]); + assert!(include_paths[0].exists()); + assert!(include_paths[1].exists()); + + // Verify both paths match their expected canonicalized values + let expected_path1 = absolute(dir1.path()).unwrap(); + let expected_path2 = absolute(dir2.path()).unwrap(); + assert_eq!(include_paths[0], expected_path1); + assert_eq!(include_paths[1], expected_path2); + } + + #[test] + fn nested_directory_is_handled_correctly() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let nested_dir = temp_dir.child("level1").child("level2").child("level3"); + nested_dir.create_dir_all().unwrap(); + let mut include_paths = Vec::new(); + + let result = + Config::validate_and_add_folder_path(&mut include_paths, nested_dir.path()); + + assert!(result.is_ok()); + assert_eq!(include_paths.len(), 1); + assert!(include_paths[0].exists()); + assert!(include_paths[0].is_dir()); + + // Verify the nested path matches the expected canonicalized value + let expected_path = absolute(nested_dir.path()).unwrap(); + assert_eq!(include_paths[0], expected_path); + } + + #[test] + fn same_directory_can_be_added_multiple_times() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let mut include_paths = Vec::new(); + + let result1 = Config::validate_and_add_folder_path(&mut include_paths, temp_dir.path()); + let result2 = Config::validate_and_add_folder_path(&mut include_paths, temp_dir.path()); + + assert!(result1.is_ok()); + assert!(result2.is_ok()); + assert_eq!(include_paths.len(), 2); + assert_eq!(include_paths[0], include_paths[1]); + + // Verify both entries match the expected canonicalized path + let expected_path = absolute(temp_dir.path()).unwrap(); + assert_eq!(include_paths[0], expected_path); + assert_eq!(include_paths[1], expected_path); + } + + #[cfg(windows)] + #[test] + fn windows_extended_length_paths_are_stripped() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let mut include_paths = Vec::new(); + + let result = Config::validate_and_add_folder_path(&mut include_paths, temp_dir.path()); + + assert!(result.is_ok()); + assert_eq!(include_paths.len(), 1); + + // `validate_and_add_folder_path` should always ensure that the path should not + // start with \\?\ on Windows + let path_str = include_paths[0].to_string_lossy(); + assert!(!path_str.starts_with(r"\\?\")); + + // Verify the path matches expected value + let expected_path = absolute(temp_dir.path()).unwrap(); + assert_eq!(include_paths[0], expected_path); + } + } +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/metadata/error.rs b/packaging/windows/drivers/vendor/wdk-build/src/metadata/error.rs new file mode 100644 index 0000000..954ae87 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/metadata/error.rs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +use serde::ser::{self}; +use thiserror::Error; + +/// A specialized [`Result`] type for [`metadata`](crate::metadata) +/// serialization and deserialization operations. +pub type Result = std::result::Result; + +/// This type represents all possible errors that can occur when serializing +/// or deserializing [`metadata::Wdk`](crate::metadata::Wdk). +#[derive(Debug, Error)] +pub enum Error { + /// catch-all error emitted during serialization, when a more specific + /// error type is not available. This type of error is commonly + /// generated from [`serde`]'s `derive` feature's generated `Serialize` + /// impls. + #[error("custom serialization error: {message}")] + CustomSerialization { + /// Message describing the error + message: String, + }, + + /// error emitted when an empty key name is encountered during + /// serialization. Serialization of values always requires a non-empty + /// key name + #[error("empty key name encountered during serialization of value: {value_being_serialized}")] + EmptySerializationKeyName { + /// Value being serialized + value_being_serialized: String, + }, + + /// error emitted when duplicate key names are found during + /// serialization. Serializing into a + /// [`metadata::Map`](crate::metadata::Map) requires unique key names + #[error( + "duplicate keys found during serialization:\nkey: {key}\nvalue 1: {value_1}\nvalue 2: \ + {value_2}" + )] + DuplicateSerializationKeys { + /// Key name + key: String, + /// One of the conflicting values + value_1: String, + /// One of the conflicting values + value_2: String, + }, +} + +impl ser::Error for Error { + fn custom(msg: T) -> Self { + Self::CustomSerialization { + message: msg.to_string(), + } + } +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/metadata/map.rs b/packaging/windows/drivers/vendor/wdk-build/src/metadata/map.rs new file mode 100644 index 0000000..35d88ae --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/metadata/map.rs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +use std::{ + collections::{BTreeMap, HashMap, btree_map, hash_map}, + hash::{BuildHasher, Hash}, +}; + +/// Trait for map-like type that is returned by +/// [`metadata::to_map`](crate::metadata::to_map) +/// and [`metadata::to_map_with_prefix`](crate::metadata::to_map_with_prefix). +pub trait Map: Default { + /// Creates a new, empty map + #[must_use] + fn new() -> Self { + Self::default() + } + + /// Inserts a new key-value pair into the map, or calls a function/closure + /// if the key already exists. + /// + /// The function/closure is called with the existing key, the existing + /// value, and the new value it tried to insert. The closure can decide + /// whether the function will return an `Err` or if it will still return a + /// `Ok` despite not inserting the value. + /// + /// # Errors + /// This function returns an error if the key already exists and `f` returns + /// an `Err` value + fn insert_or_else(&mut self, key: K, value: V, f: F) -> Result<(), E> + where + F: FnMut(&K, &V, V) -> Result<(), E>; +} + +impl Map for HashMap { + fn insert_or_else(&mut self, key: K, value: V, mut f: F) -> Result<(), E> + where + F: FnMut(&K, &V, V) -> Result<(), E>, + { + match self.entry(key) { + hash_map::Entry::Occupied(entry) => f(entry.key(), entry.get(), value), + hash_map::Entry::Vacant(entry) => { + entry.insert(value); + Ok(()) + } + } + } +} + +impl Map for BTreeMap { + fn insert_or_else(&mut self, key: K, value: V, mut f: F) -> Result<(), E> + where + F: FnMut(&K, &V, V) -> Result<(), E>, + { + match self.entry(key) { + btree_map::Entry::Occupied(entry) => f(entry.key(), entry.get(), value), + btree_map::Entry::Vacant(entry) => { + entry.insert(value); + Ok(()) + } + } + } +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/metadata/mod.rs b/packaging/windows/drivers/vendor/wdk-build/src/metadata/mod.rs new file mode 100644 index 0000000..262810d --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/metadata/mod.rs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Parsing and serializing metadata about WDK projects +//! +//! This module provides a [`Wdk`] struct that represents the cargo metadata +//! specified in the `metadata.wdk` section any `Cargo.toml`. This corresponds +//! with the settings in the `Driver Settings` property pages for WDK projects +//! in Visual Studio. This module also also provides [`serde`]-compatible +//! serialization and deserialization for the metadata. + +pub use error::{Error, Result}; +pub use map::Map; +pub use ser::{Serializer, to_map, to_map_with_prefix}; + +pub(crate) mod ser; + +mod error; +mod map; + +use std::collections::HashSet; + +use camino::Utf8PathBuf; +use cargo_metadata::Metadata; +use serde::{Deserialize, Serialize}; +use thiserror::Error; + +use crate::DriverConfig; + +/// Metadata specified in the `metadata.wdk` section of the `Cargo.toml` +/// of a crate that depends on the WDK, or in a cargo workspace. +/// +/// This corresponds with the settings in the `Driver Settings` property pages +/// for WDK projects in Visual Studio +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[serde( + deny_unknown_fields, + rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case") +)] +pub struct Wdk { + /// Metadata corresponding to the `Driver Model` property page in the WDK + pub driver_model: DriverConfig, +} + +/// Errors that could result from trying to construct a +/// [`metadata::Wdk`](crate::metadata::Wdk) from information parsed by `cargo +/// metadata` +#[derive(Debug, Error)] +pub enum TryFromCargoMetadataError { + /// Error returned when no WDK configuration metadata is detected in the + /// dependency graph + #[error( + "no WDK configuration metadata is detected in the dependency graph. This could happen \ + when building WDR itself, or building library crates that depend on the WDK but defer \ + WDK configuration to their consumers" + )] + NoWdkConfigurationsDetected, + + /// Error returned when multiple configurations of the WDK are detected + /// across the dependency graph + #[error( + "multiple configurations of the WDK are detected across the dependency graph, but only \ + one configuration is allowed: {wdk_metadata_configurations:#?}" + )] + MultipleWdkConfigurationsDetected { + /// [`HashSet`] of unique [`metadata::Wdk`](crate::metadata::Wdk) + /// derived from detected WDK metadata + wdk_metadata_configurations: HashSet, + }, + + /// Error returned when [`crate::metadata::Wdk`] fails to be deserialized + /// from [`cargo_metadata::Metadata`] output + #[error("failed to deserialize metadata::Wdk from {metadata_source}")] + WdkMetadataDeserialization { + /// `String` that describes what part of + /// `cargo_metadata::Metadata` was used as the source for + /// deserialization + metadata_source: String, + /// [`serde_json::Error`] that caused the deserialization to fail + #[source] + error_source: serde_json::Error, + }, +} + +impl TryFrom<&Metadata> for Wdk { + type Error = TryFromCargoMetadataError; + + fn try_from(metadata: &Metadata) -> std::result::Result { + let wdk_metadata_configurations = { + // Parse WDK metadata from workspace and all packages + let mut configs = parse_packages_wdk_metadata(&metadata.packages)?; + if let Some(workspace_metadata) = + parse_workspace_wdk_metadata(&metadata.workspace_metadata)? + { + configs.insert(workspace_metadata); + } + configs + }; + + // Ensure that only one configuration of WDK is allowed per dependency graph + match wdk_metadata_configurations.len() { + 1 => Ok(wdk_metadata_configurations.into_iter().next().expect( + "wdk_metadata_configurations should have exactly one element because of the \ + .len() check above", + )), + + 0 => Err(TryFromCargoMetadataError::NoWdkConfigurationsDetected), + + _ => Err( + TryFromCargoMetadataError::MultipleWdkConfigurationsDetected { + wdk_metadata_configurations, + }, + ), + } + } +} + +fn parse_packages_wdk_metadata( + packages: &[cargo_metadata::Package], +) -> std::result::Result, TryFromCargoMetadataError> { + let wdk_metadata_configurations = packages + .iter() + .filter_map(|package| match &package.metadata["wdk"] { + serde_json::Value::Null => None, + // When wdk section is empty, treat it as if it wasn't there. This is to allow for using + // empty wdk metadata sections to mark the package as a driver (ex. for detection in + // `package_driver_flow_condition_script`) + serde_json::Value::Object(map) if map.is_empty() => None, + wdk_metadata => Some(Wdk::deserialize(wdk_metadata).map_err(|err| { + TryFromCargoMetadataError::WdkMetadataDeserialization { + metadata_source: format!( + "{} for {} package", + stringify!(package.metadata["wdk"]), + package.name + ), + error_source: err, + } + })), + }) + .collect::, _>>()?; + Ok(wdk_metadata_configurations) +} + +fn parse_workspace_wdk_metadata( + workspace_metadata: &serde_json::Value, +) -> std::result::Result, TryFromCargoMetadataError> { + Ok(match &workspace_metadata["wdk"] { + serde_json::Value::Null => None, + wdk_metadata => Some(Wdk::deserialize(wdk_metadata).map_err(|err| { + TryFromCargoMetadataError::WdkMetadataDeserialization { + metadata_source: stringify!(workspace_metadata["wdk"]).to_string(), + error_source: err, + } + })?), + }) +} + +pub(crate) fn iter_manifest_paths(metadata: Metadata) -> impl IntoIterator { + let mut cargo_manifest_paths = HashSet::new(); + + // Add all package manifest paths + for package in metadata.packages { + cargo_manifest_paths.insert(package.manifest_path); + } + + // Add workspace manifest path + let workspace_manifest_path: Utf8PathBuf = { + let mut path = metadata.workspace_root; + path.push("Cargo.toml"); + path + }; + cargo_manifest_paths.insert(workspace_manifest_path); + + cargo_manifest_paths +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/metadata/ser.rs b/packaging/windows/drivers/vendor/wdk-build/src/metadata/ser.rs new file mode 100644 index 0000000..1e00d8a --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/metadata/ser.rs @@ -0,0 +1,746 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +use serde::{ + Serialize, + ser::{self, Impossible}, +}; + +use super::{ + error::{Error, Result}, + map::Map, +}; + +/// delimiter used to separate the names of the different nodes encoded into a +/// key name. Since `-` is not valid in Rust identifiers, it is used +/// as a separator between different node names. +pub const KEY_NAME_SEPARATOR: char = '-'; + +/// Serialize a value into a [`Map`] where the keys represent a +/// `KEY_NAME_SEPARATOR`-separated list of field names. +/// +/// # Errors +/// +/// This function will return an error if the type being serialized: +/// * results in duplicate key names +/// * results in an empty key name +/// * otherwise fails to be parsed and correctly serialized into a [`Map`] +/// +/// # Example +/// ```rust +/// use std::collections::BTreeMap; +/// +/// use wdk_build::{ +/// DriverConfig, +/// KmdfConfig, +/// metadata::{self, to_map}, +/// }; +/// +/// let wdk_metadata = metadata::Wdk { +/// driver_model: DriverConfig::Kmdf(KmdfConfig { +/// kmdf_version_major: 1, +/// target_kmdf_version_minor: 23, +/// minimum_kmdf_version_minor: None, +/// }), +/// }; +/// +/// let output = to_map::>(&wdk_metadata).unwrap(); +/// +/// assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "KMDF"); +/// assert_eq!(output["DRIVER_MODEL-KMDF_VERSION_MAJOR"], "1"); +/// assert_eq!(output["DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR"], "23"); +/// +/// // `None` values are not serialized +/// assert_eq!(output.get("DRIVER_MODEL-MINIMUM_KMDF_VERSION_MINOR"), None); +/// ``` +pub fn to_map(value: &impl Serialize) -> Result +where + M: Map, +{ + let mut serialization_buffer: Vec<(String, String)> = Vec::new(); + value.serialize(&mut Serializer::new(&mut serialization_buffer))?; + convert_serialized_output_to_map(serialization_buffer) +} + +/// Serialize a value into a [`Map`] where the keys represent a +/// `KEY_NAME_SEPARATOR`-separated list of field names prepended with a +/// prefix. +/// +/// # Errors +/// +/// This function will return an error if the type being serialized: +/// * results in duplicate key names +/// * results in an empty key name +/// * otherwise fails to be parsed and correctly serialized into a [`Map`] +/// +/// # Example +/// ```rust +/// use std::collections::BTreeMap; +/// +/// use wdk_build::{ +/// DriverConfig, +/// KmdfConfig, +/// metadata::{self, to_map_with_prefix}, +/// }; +/// +/// let wdk_metadata = metadata::Wdk { +/// driver_model: DriverConfig::Kmdf(KmdfConfig { +/// kmdf_version_major: 1, +/// target_kmdf_version_minor: 33, +/// minimum_kmdf_version_minor: Some(31), +/// }), +/// }; +/// +/// let output = to_map_with_prefix::>("WDK_BUILD_METADATA", &wdk_metadata).unwrap(); +/// +/// assert_eq!( +/// output["WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE"], +/// "KMDF" +/// ); +/// assert_eq!( +/// output["WDK_BUILD_METADATA-DRIVER_MODEL-KMDF_VERSION_MAJOR"], +/// "1" +/// ); +/// assert_eq!( +/// output["WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR"], +/// "33" +/// ); +/// assert_eq!( +/// output["WDK_BUILD_METADATA-DRIVER_MODEL-MINIMUM_KMDF_VERSION_MINOR"], +/// "31" +/// ); +/// ``` +pub fn to_map_with_prefix(prefix: impl Into, value: &impl Serialize) -> Result +where + M: Map, +{ + let mut serialization_buffer: Vec<(String, String)> = Vec::new(); + value.serialize(&mut Serializer::with_prefix( + prefix.into(), + &mut serialization_buffer, + ))?; + convert_serialized_output_to_map(serialization_buffer) +} + +fn convert_serialized_output_to_map(serialization_buffer: Vec<(String, String)>) -> Result +where + M: Map, +{ + let mut output_map = M::new(); + for (key, value) in serialization_buffer { + output_map.insert_or_else(key, value, |key, existing_value, new_value| { + Err(Error::DuplicateSerializationKeys { + key: key.clone(), + value_1: existing_value.clone(), + value_2: new_value, + }) + })?; + } + + Ok(output_map) +} + +/// [`serde`] serializer that serializes values into a [`Vec`] of key-value +/// pairs. +/// +/// This serializer is useful when you want to have more granular control of the +/// output of the serializer. Most usecases should already be covered by the +/// [`to_map`] and [`to_map_with_prefix`] functions. +pub struct Serializer<'a> { + root_key_name: Option, + dst: &'a mut Vec<(String, String)>, +} + +impl<'a> ser::Serializer for &'a mut Serializer<'a> { + type Error = Error; + type Ok = (); + type SerializeMap = Impossible; + type SerializeSeq = Impossible; + type SerializeStruct = Self; + type SerializeStructVariant = Impossible; + type SerializeTuple = Impossible; + type SerializeTupleStruct = Impossible; + type SerializeTupleVariant = Impossible; + + unsupported_serde_serialize_method! { + // simple types + bytes newtype_struct newtype_variant unit_struct unit_variant + // complex types (returns SerializeXYZ types) + map seq struct_variant tuple tuple_struct tuple_variant + } + + fn serialize_str(self, value: &str) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_bool(self, value: bool) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_char(self, value: char) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_i8(self, value: i8) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_i16(self, value: i16) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_i32(self, value: i32) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_i64(self, value: i64) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_f32(self, value: f32) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_f64(self, value: f64) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_none(self) -> Result { + self.serialize_unit() + } + + fn serialize_some(self, value: &T) -> Result + where + T: ?Sized + Serialize, + { + value.serialize(self) + } + + fn serialize_unit(self) -> Result { + Ok(()) + } + + fn serialize_u8(self, value: u8) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_u16(self, value: u16) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_u32(self, value: u32) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_u64(self, value: u64) -> Result { + self.dst.push(( + self.root_key_name + .clone() + .ok_or_else(|| Error::EmptySerializationKeyName { + value_being_serialized: value.to_string(), + })?, + value.to_string(), + )); + Ok(()) + } + + fn serialize_struct(self, _name: &'static str, _len: usize) -> Result { + Ok(self) + } +} + +impl<'a> ser::SerializeStruct for &'a mut Serializer<'a> { + type Error = Error; + type Ok = (); + + fn serialize_field(&mut self, key: &'static str, value: &T) -> Result + where + T: ?Sized + Serialize, + { + value.serialize(&mut Serializer::with_prefix( + self.root_key_name.as_ref().map_or_else( + || key.to_string(), + |root_key_name| format!("{root_key_name}{KEY_NAME_SEPARATOR}{key}"), + ), + self.dst, + ))?; + Ok(()) + } + + fn end(self) -> Result { + Ok(()) + } +} + +impl<'a> Serializer<'a> { + /// Create a new instance of the `Serializer` struct + pub const fn new(dst: &'a mut Vec<(String, String)>) -> Self { + Self { + root_key_name: None, + dst, + } + } + + /// Create a new instance of the `Serializer` struct with a prefix used as + /// the root for all keys + pub const fn with_prefix(prefix: String, dst: &'a mut Vec<(String, String)>) -> Self { + Self { + root_key_name: Some(prefix), + dst, + } + } +} + +#[doc(hidden)] +/// Helper macro when implementing the `Serializer` part of a new data +/// format for Serde. +/// +/// Generates [`serde::ser::Serializer`] trait methods for serde data model +/// types that aren't supported by this serializer. This generates a +/// method that calls [`unimplemented!`]. +macro_rules! unsupported_serde_serialize_method { + ($($method_type:ident)*) => { + $(unsupported_serde_serialize_method_helper! {$method_type})* + }; +} +#[doc(hidden)] +pub(crate) use unsupported_serde_serialize_method; + +#[doc(hidden)] +macro_rules! unsupported_serde_serialize_method_helper { + // methods for simple types (returns Ok) + (bytes) => { + unsupported_serde_serialize_method_definition! { + serialize_bytes(_v: &[u8]) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (newtype_struct) => { + unsupported_serde_serialize_method_definition! { + serialize_newtype_struct(_name: &'static str, _value: &T) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (newtype_variant) => { + unsupported_serde_serialize_method_definition! { + serialize_newtype_variant(_name: &'static str, _variant_index: u32, _variant: &'static str, _value: &T) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (none) => { + unsupported_serde_serialize_method_definition! { + serialize_none() -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (some) => { + unsupported_serde_serialize_method_definition! { + serialize_some(_value: &T) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (str) => { + unsupported_serde_serialize_method_definition! { + serialize_str(_v: &str) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (unit) => { + unsupported_serde_serialize_method_definition! { + serialize_unit() -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (unit_struct) => { + unsupported_serde_serialize_method_definition! { + serialize_unit_struct(_name: &'static str) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + (unit_variant) => { + unsupported_serde_serialize_method_definition! { + serialize_unit_variant(_name: &'static str, _variant_index: u32, _variant: &'static str) -> std::result::Result< + ::Ok, + ::Error, + > + } + }; + // methods for complex types (returns SerializeXYZ types) + (map) => { + unsupported_serde_serialize_method_definition! { + serialize_map(_len: Option) -> std::result::Result< + ::SerializeMap, + ::Error, + > + } + }; + (struct) => { + unsupported_serde_serialize_method_definition! { + serialize_struct(_name: &'static str, _len: usize) -> std::result::Result< + ::SerializeStruct, + ::Error, + > + } + }; + (struct_variant) => { + unsupported_serde_serialize_method_definition! { + serialize_struct_variant(_name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize) -> std::result::Result< + ::SerializeStructVariant, + ::Error, + > + } + }; + (seq) => { + unsupported_serde_serialize_method_definition! { + serialize_seq(_len: Option) -> std::result::Result< + ::SerializeSeq, + ::Error, + > + } + }; + (tuple) => { + unsupported_serde_serialize_method_definition! { + serialize_tuple(_len: usize) -> std::result::Result< + ::SerializeTuple, + ::Error, + > + } + }; + (tuple_struct) => { + unsupported_serde_serialize_method_definition! { + serialize_tuple_struct(_name: &'static str, _len: usize) -> std::result::Result< + ::SerializeTupleStruct, + ::Error, + > + } + }; + (tuple_variant) => { + unsupported_serde_serialize_method_definition! { + serialize_tuple_variant(_name: &'static str, _variant_index: u32, _variant: &'static str, _len: usize) -> std::result::Result< + ::SerializeTupleVariant, + ::Error, + > + } + }; + // every other method has no extra arguments and is for simple types + ($method_type:ident) => { + paste::paste! { + unsupported_serde_serialize_method_definition! { + [](_v: $method_type) -> std::result::Result< + ::Ok, + ::Error, + > + } + } + }; +} +#[doc(hidden)] +pub(crate) use unsupported_serde_serialize_method_helper; + +#[doc(hidden)] +macro_rules! unsupported_serde_serialize_method_definition { + // methods with generic argument + ($func:ident <$generic_arg:ident> ($($arg:ident : $ty:ty),*) -> std::result::Result<$ok:ty, $err:ty$(,)?>) => { + #[inline] + fn $func <$generic_arg> (self, $($arg: $ty,)*) -> std::result::Result<$ok, $err> + where + $generic_arg: ?Sized + Serialize { + unimplemented!( + "{} is not implemented for {} since it is currently not needed to serialize the metadata::Wdk struct", + stringify!($func), + std::any::type_name::(), + ) + } + }; + // methods without generic argument + ($func:ident ($($arg:ident : $ty:ty),*) -> std::result::Result<$ok:ty, $err:ty$(,)?>) => { + #[inline] + fn $func (self, $($arg: $ty,)*) -> std::result::Result<$ok, $err> { + unimplemented!( + "{} is not implemented for {} since it is currently not needed to serialize the metadata::Wdk struct", + stringify!($func), + std::any::type_name::(), + ) + } + }; +} +#[doc(hidden)] +pub(crate) use unsupported_serde_serialize_method_definition; + +#[cfg(test)] +mod tests { + use std::{ + collections::{BTreeMap, HashMap}, + vec, + }; + + use super::*; + use crate::{DriverConfig, KmdfConfig, UmdfConfig, metadata}; + + #[test] + fn test_kmdf() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 23, + minimum_kmdf_version_minor: Some(21), + }), + }; + + let output = to_map::>(&wdk_metadata).unwrap(); + + assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "KMDF"); + assert_eq!(output["DRIVER_MODEL-KMDF_VERSION_MAJOR"], "1"); + assert_eq!(output["DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR"], "23"); + assert_eq!(output["DRIVER_MODEL-MINIMUM_KMDF_VERSION_MINOR"], "21"); + } + + #[test] + fn test_kmdf_no_minimum() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 23, + minimum_kmdf_version_minor: None, + }), + }; + + let output = to_map::>(&wdk_metadata).unwrap(); + + assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "KMDF"); + assert_eq!(output["DRIVER_MODEL-KMDF_VERSION_MAJOR"], "1"); + assert_eq!(output["DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR"], "23"); + + // `None` values are not serialized + assert_eq!(output.get("DRIVER_MODEL-MINIMUM_KMDF_VERSION_MINOR"), None); + } + + #[test] + fn test_kmdf_with_prefix() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 33, + minimum_kmdf_version_minor: Some(31), + }), + }; + + let output = + to_map_with_prefix::>("WDK_BUILD_METADATA", &wdk_metadata).unwrap(); + + assert_eq!( + output["WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE"], + "KMDF" + ); + assert_eq!( + output["WDK_BUILD_METADATA-DRIVER_MODEL-KMDF_VERSION_MAJOR"], + "1" + ); + assert_eq!( + output["WDK_BUILD_METADATA-DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR"], + "33" + ); + assert_eq!( + output["WDK_BUILD_METADATA-DRIVER_MODEL-MINIMUM_KMDF_VERSION_MINOR"], + "31" + ); + } + + #[test] + fn test_kmdf_with_hashmap() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major: 1, + target_kmdf_version_minor: 33, + minimum_kmdf_version_minor: Some(31), + }), + }; + + let output = to_map::>(&wdk_metadata).unwrap(); + + assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "KMDF"); + assert_eq!(output["DRIVER_MODEL-KMDF_VERSION_MAJOR"], "1"); + assert_eq!(output["DRIVER_MODEL-TARGET_KMDF_VERSION_MINOR"], "33"); + assert_eq!(output["DRIVER_MODEL-MINIMUM_KMDF_VERSION_MINOR"], "31"); + } + + #[test] + fn test_umdf() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 1, + target_umdf_version_minor: 23, + minimum_umdf_version_minor: Some(21), + }), + }; + + let output = to_map::>(&wdk_metadata).unwrap(); + + assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "UMDF"); + assert_eq!(output["DRIVER_MODEL-UMDF_VERSION_MAJOR"], "1"); + assert_eq!(output["DRIVER_MODEL-TARGET_UMDF_VERSION_MINOR"], "23"); + assert_eq!(output["DRIVER_MODEL-MINIMUM_UMDF_VERSION_MINOR"], "21"); + } + + #[test] + fn test_umdf_no_minimum() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Umdf(UmdfConfig { + umdf_version_major: 1, + target_umdf_version_minor: 23, + minimum_umdf_version_minor: None, + }), + }; + + let output = to_map::>(&wdk_metadata).unwrap(); + + assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "UMDF"); + assert_eq!(output["DRIVER_MODEL-UMDF_VERSION_MAJOR"], "1"); + assert_eq!(output["DRIVER_MODEL-TARGET_UMDF_VERSION_MINOR"], "23"); + + // `None` values are not serialized + assert_eq!(output.get("DRIVER_MODEL-MINIMUM_UMDF_VERSION_MINOR"), None); + } + + #[test] + fn test_wdm() { + let wdk_metadata = metadata::Wdk { + driver_model: DriverConfig::Wdm, + }; + + let output = to_map::>(&wdk_metadata).unwrap(); + + assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM"); + } + + #[test] + fn test_conflicting_keys_in_convert_serialized_output_to_map() { + let input = vec![("KEY_NAME", "VALUE_1"), ("KEY_NAME", "VALUE_2")] + .into_iter() + .map(|(k, v)| (k.to_string(), v.to_string())) + .collect(); + + let err = convert_serialized_output_to_map::>(input).unwrap_err(); + + assert!(matches!( + err, + Error::DuplicateSerializationKeys { + key, + value_1, + value_2, + } if key == "KEY_NAME" && value_1 == "VALUE_1" && value_2 == "VALUE_2" + )); + } +} diff --git a/packaging/windows/drivers/vendor/wdk-build/src/utils.rs b/packaging/windows/drivers/vendor/wdk-build/src/utils.rs new file mode 100644 index 0000000..7b35714 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-build/src/utils.rs @@ -0,0 +1,713 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Private module for utility code related to the cargo-make experience for +//! building drivers. + +use std::{ + env, + ffi::{CStr, OsStr}, + io, + path::{Path, PathBuf}, +}; + +use windows::{ + Win32::System::Registry::{ + HKEY, + HKEY_LOCAL_MACHINE, + KEY_READ, + RRF_RT_REG_SZ, + RegCloseKey, + RegGetValueA, + RegOpenKeyExA, + }, + core::{PCSTR, s}, +}; + +use crate::{ConfigError, CpuArchitecture, IoError, TwoPartVersion}; + +/// Detect `WDKContentRoot` Directory. Logic is based off of Toolset.props in +/// NI(22H2) WDK +#[must_use] +pub fn detect_wdk_content_root() -> Option { + // If WDKContentRoot is present in environment(ex. running in an eWDK prompt), + // use it + if let Ok(wdk_content_root) = env::var("WDKContentRoot") { + let path = Path::new(wdk_content_root.as_str()); + if path.is_dir() { + return Some(path.to_path_buf()); + } + eprintln!( + "WDKContentRoot was detected to be {}, but does not exist or is not a valid directory.", + path.display() + ); + } + + // If MicrosoftKitRoot environment variable is set, use it to set WDKContentRoot + if let Ok(microsoft_kit_root) = env::var("MicrosoftKitRoot") { + let path = Path::new(microsoft_kit_root.as_str()); + + if !path.is_absolute() { + eprintln!( + "MicrosoftKitRoot({}) was found in environment, but is not an absolute path.", + path.display() + ); + } else if !path.is_dir() { + eprintln!( + "MicrosoftKitRoot({}) was found in environment, but does not exist or is not a \ + valid directory.", + path.display() + ); + } else { + let wdk_kit_version = env::var("WDKKitVersion").unwrap_or_else(|_| "10.0".to_string()); + let path = path.join("Windows Kits").join(wdk_kit_version); + if path.is_dir() { + return Some(path); + } + eprintln!( + "WDKContentRoot was detected to be {}, but does not exist or is not a valid \ + directory.", + path.display() + ); + } + } + + // Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed + // Roots@KitsRoot10 registry key + if let Some(path) = read_registry_key_string_value( + HKEY_LOCAL_MACHINE, + s!(r"SOFTWARE\Microsoft\Windows Kits\Installed Roots"), + s!(r"KitsRoot10"), + ) { + return Some(Path::new(path.as_str()).to_path_buf()); + } + + // Check HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows + // Kits\Installed Roots@KitsRoot10 registry key + if let Some(path) = read_registry_key_string_value( + HKEY_LOCAL_MACHINE, + s!(r"SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots"), + s!(r"KitsRoot10"), + ) { + return Some(Path::new(path.as_str()).to_path_buf()); + } + + None +} + +/// Searches a directory and determines the latest windows SDK version in that +/// directory +/// +/// # Errors +/// +/// Returns a `ConfigError::DirectoryNotFound` error if the directory provided +/// does not exist. +/// +/// # Panics +/// +/// Panics if the path provided is not valid Unicode. +pub fn get_latest_windows_sdk_version(path_to_search: &Path) -> Result { + Ok(path_to_search + .read_dir() + .map_err(|source| IoError::with_path(path_to_search, source))? + .filter_map(std::result::Result::ok) + .map(|valid_directory_entry| valid_directory_entry.path()) + .filter(|path| { + path.is_dir() + && path.file_name().is_some_and(|directory_name| { + directory_name + .to_str() + .is_some_and(|directory_name| directory_name.starts_with("10.")) + }) + }) + .max() // Get the latest SDK folder in case there are multiple installed + .ok_or(ConfigError::DirectoryNotFound { + directory: format!( + "Windows SDK Directory in {}", + path_to_search.to_string_lossy() + ), + })? + .file_name() + .expect("path should never terminate in ..") + .to_str() + .expect("directory name should always be valid Unicode") + .to_string()) +} + +/// Detect architecture based on cargo TARGET variable. +/// +/// # Panics +/// +/// Panics if the `CARGO_CFG_TARGET_ARCH` environment variable is not set, +/// or if the cargo architecture is unsupported. +#[must_use] +pub fn detect_cpu_architecture_in_build_script() -> CpuArchitecture { + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect( + "Cargo should have set the CARGO_CFG_TARGET_ARCH environment variable when executing \ + build.rs", + ); + + CpuArchitecture::try_from_cargo_str(&target_arch).unwrap_or_else(|| { + panic!("The target architecture, {target_arch}, is currently not supported.") + }) +} + +/// Validates that a given string matches the WDK version format (10.xxx.yyy.zzz +/// where xxx, yyy, and zzz are numeric and not necessarily 3 digits long). +#[rustversion::attr( + nightly, + allow( + clippy::nonminimal_bool, + reason = "is_some_or is not stable until 1.82.0 is released on 10/17/24" + ) +)] +pub fn validate_wdk_version_format>(version_string: S) -> bool { + let version = version_string.as_ref(); + let version_parts: Vec<&str> = version.split('.').collect(); + + // First, check if we have "10" as our first value + if version_parts.first().is_none_or(|first| *first != "10") { + return false; + } + + // Now check that we have four entries. + if version_parts.len() != 4 { + return false; + } + + // Finally, confirm each part is numeric. + if !version_parts + .iter() + .all(|version_part| version_part.parse::().is_ok()) + { + return false; + } + + true +} + +/// Returns the version number from a full WDK version string. +/// +/// # Errors +/// +/// This function returns a [`ConfigError::WdkVersionStringFormatError`] if the +/// version string provided is ill-formed. +/// +/// # Panics +/// +/// If the WDK version format validation function is ever changed not to +/// validate that there are 4 substrings in the WDK version string, this +/// function will panic. +pub fn get_wdk_version_number + ToString + ?Sized>( + version_string: &S, +) -> Result { + if !validate_wdk_version_format(version_string) { + return Err(ConfigError::WdkVersionStringFormatError { + version: version_string.to_string(), + }); + } + + let version_substrings = version_string.as_ref().split('.').collect::>(); + let version_substring = version_substrings.get(2).expect( + "WDK version string was validated to be well-formatted, but we couldn't get the \ + appropriate substring!", + ); + Ok((*version_substring).to_string()) +} + +/// Read a string value from a registry key +/// +/// # Arguments +/// +/// * `key_handle` - a [`windows::Win32::System::Registry::HKEY`] to the base +/// key +/// * `sub_key` - a [`windows::core::PCSTR`] that is the path of a registry key +/// relative to the `key_handle` argument +/// * `value` - a [`windows::core::PCSTR`] that is the name of the string +/// registry value to read +/// +/// # Panics +/// +/// Panics if read value isn't valid UTF-8 or if the opened regkey could not be +/// closed +fn read_registry_key_string_value( + key_handle: HKEY, + sub_key: PCSTR, + value: PCSTR, +) -> Option { + let mut opened_key_handle = HKEY::default(); + let mut len = 0; + if + // SAFETY: `&mut opened_key_handle` is coerced to a &raw mut, so the address passed as the + // argument is always valid. `&mut opened_key_handle` is coerced to a pointer of the correct + // type. + unsafe { RegOpenKeyExA(key_handle, sub_key, 0, KEY_READ, &raw mut opened_key_handle) } + .is_ok() + { + if + // SAFETY: `opened_key_handle` is valid key opened with the `KEY_QUERY_VALUE` access right + // (included in `KEY_READ`). `&mut len` is coerced to a &raw mut, so the address passed as + // the argument is always valid. `&mut len` is coerced to a pointer of the correct + // type. + unsafe { + RegGetValueA( + opened_key_handle, + None, + value, + RRF_RT_REG_SZ, + None, + None, + Some(&raw mut len), + ) + } + .is_ok() + { + let mut buffer = vec![0u8; len as usize]; + if + // SAFETY: `opened_key_handle` is valid key opened with the `KEY_QUERY_VALUE` access + // right (included in `KEY_READ`). `&mut buffer` is coerced to a &raw mut, + // so the address passed as the argument is always valid. `&mut buffer` is + // coerced to a pointer of the correct type. `&mut len` is coerced to a &raw + // mut, so the address passed as the argument is always valid. `&mut len` is + // coerced to a pointer of the correct type. + unsafe { + RegGetValueA( + opened_key_handle, + None, + value, + RRF_RT_REG_SZ, + None, + Some(buffer.as_mut_ptr().cast()), + Some(&raw mut len), + ) + } + .is_ok() + { + // SAFETY: `opened_key_handle` is valid opened key that was opened by + // `RegOpenKeyExA` + unsafe { RegCloseKey(opened_key_handle) } + .ok() + .expect("opened_key_handle should be successfully closed"); + return Some( + CStr::from_bytes_with_nul(&buffer[..len as usize]) + .expect( + "RegGetValueA should always return a null-terminated string. The read \ + string (REG_SZ) from the registry should not contain any interior \ + nulls.", + ) + .to_str() + .expect("Registry value should be parseable as UTF8") + .to_string(), + ); + } + } + + // SAFETY: `opened_key_handle` is valid opened key that was opened by + // `RegOpenKeyExA` + unsafe { RegCloseKey(opened_key_handle) } + .ok() + .expect("opened_key_handle should be successfully closed"); + } + None +} + +/// Detects the Windows SDK version from the `Version_Number` env var or from +/// the WDK content's `Lib` directory. +/// +/// # Arguments +/// * `wdk_content_root` - A reference to the path where the WDK content root is +/// located. +/// +/// # Errors +/// +/// Returns a `ConfigError::DirectoryNotFound` error if the directory provided +/// does not exist. +pub fn detect_windows_sdk_version(wdk_content_root: &Path) -> Result { + env::var("Version_Number") + .or_else(|_| get_latest_windows_sdk_version(&wdk_content_root.join("Lib"))) +} + +/// Finds the maximum version in a directory where subdirectories are named with +/// version format "x.y" +pub fn find_max_version_in_directory>( + directory_path: P, +) -> Result { + let directory_path = directory_path.as_ref(); + std::fs::read_dir(directory_path) + .map_err(|source| IoError::with_path(directory_path, source))? + .flatten() + .filter(|entry| entry.file_type().is_ok_and(|ft| ft.is_dir())) + .filter_map(|entry| entry.file_name().to_str()?.parse().ok()) + .max() + .ok_or_else(|| { + IoError::with_path( + directory_path, + io::Error::new( + io::ErrorKind::NotFound, + format!("Maximum version in {} not found", directory_path.display()), + ), + ) + }) +} + +/// Safely sets an environment variable. Will not compile if crate is not +/// targeted for Windows. +/// +/// This function provides a safe wrapper around [`std::env::set_var`] that +/// became unsafe in Rust 2024 edition. +/// +/// # Panics +/// +/// This function may panic if key is empty, contains an ASCII equals sign '=' +/// or the NUL character '\0', or when value contains the NUL character. +#[cfg(target_os = "windows")] +pub fn set_var(key: K, value: V) +where + K: AsRef, + V: AsRef, +{ + // SAFETY: this function is only conditionally compiled for windows targets, and + // env::set_var is always safe for windows targets + unsafe { + env::set_var(key, value); + } +} + +#[cfg(not(target_os = "windows"))] +pub fn set_var(_key: K, _value: V) +where + K: AsRef, + V: AsRef, +{ + compile_error!( + "windows-drivers-rs is designed to be run on a Windows host machine in a WDK environment. \ + Please build using a Windows target." + ); +} + +/// Safely removes an environment variable. Will not compile if crate is not +/// targeted for Windows. +/// +/// This function provides a safe wrapper around [`std::env::remove_var`] that +/// became unsafe in Rust 2024 edition. +/// +/// # Panics +/// +/// This function may panic if key is empty, contains an ASCII equals sign '=' +/// or the NUL character '\0', or when value contains the NUL character. +#[allow(dead_code)] +#[cfg(target_os = "windows")] +pub fn remove_var(key: K) +where + K: AsRef, +{ + // SAFETY: this function is only conditionally compiled for windows targets, and + // env::remove_var is always safe for windows targets + unsafe { + env::remove_var(key); + } +} + +#[allow(dead_code)] +#[cfg(not(target_os = "windows"))] +pub fn remove_var(_key: K) +where + K: AsRef, +{ + compile_error!( + "windows-drivers-rs is designed to be run on a Windows host machine in a WDK environment. \ + Please build using a Windows target." + ); +} + +#[cfg(test)] +mod tests { + use assert_fs::prelude::*; + + use super::*; + + // Function with_clean_env clears the inputted environment variable and runs the + // closure + fn with_clean_env(key: &str, f: F) + where + F: FnOnce(), + { + let original = env::var(key).ok(); + + // SAFETY: We have verified that this is built for a Windows host due to no + // compile errors from building `set_var`. + unsafe { + env::remove_var(key); + } + + f(); + + if let Some(val) = &original { + // SAFETY: We have verified that this is built for a Windows host due to no + // compile errors from building `set_var`. + unsafe { + env::set_var(key, val); + } + } else { + // SAFETY: We have verified that this is built for a Windows host due to no + // compile errors from building `set_var`. + unsafe { + env::remove_var(key); + } + } + + assert!(env::var(key).ok() == original); + } + + mod read_registry_key_string_value { + use windows::Win32::UI::Shell::{ + FOLDERID_ProgramFiles, + KF_FLAG_DEFAULT, + SHGetKnownFolderPath, + }; + + use super::*; + + #[test] + fn read_reg_key_programfilesdir() { + let program_files_dir = + // SAFETY: FOLDERID_ProgramFiles is a constant from the windows crate, so the pointer (resulting from its reference being coerced) is always valid to be dereferenced + unsafe { SHGetKnownFolderPath(&FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, None) } + .expect("Program Files Folder should always resolve via SHGetKnownFolderPath."); + + assert_eq!( + read_registry_key_string_value( + HKEY_LOCAL_MACHINE, + s!(r"SOFTWARE\Microsoft\Windows\CurrentVersion"), + s!("ProgramFilesDir") + ), + Some( + // SAFETY: program_files_dir pointer stays valid for reads up until and + // including its terminating null + unsafe { program_files_dir.to_string() } + .expect("Path resolved from FOLDERID_ProgramFiles should be valid UTF16.") + ) + ); + } + } + + #[test] + fn validate_wdk_strings() { + let test_string = "10.0.12345.0"; + assert_eq!( + get_wdk_version_number(test_string).ok(), + Some("12345".to_string()) + ); + let test_string = "10.0.5.0"; + assert_eq!( + get_wdk_version_number(test_string).ok(), + Some("5".to_string()) + ); + let test_string = "10.0.0.0"; + assert_eq!( + get_wdk_version_number(test_string).ok(), + Some("0".to_string()) + ); + let test_string = "11.0.0.0"; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + let test_string = "10.0.12345.0.0"; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + let test_string = "10.0.12345.a"; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + let test_string = "10.0.12345"; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + let test_string = "10.0.1234!5.0"; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + let test_string = "Not a real version!"; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + let test_string = ""; + assert_eq!( + format!("{}", get_wdk_version_number(test_string).err().unwrap()), + format!( + "the WDK version string provided ({}) was not in a valid format", + test_string + ) + ); + } + + mod find_max_version_in_directory { + use super::*; + + #[test] + fn empty_directory() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + let result = find_max_version_in_directory(temp_dir.path()); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().source.kind(), + std::io::ErrorKind::NotFound + ); + } + + #[test] + fn nonexistent_directory() { + let nonexistent_path = std::path::Path::new("/this/path/does/not/exist"); + let result = find_max_version_in_directory(nonexistent_path); + assert!(result.is_err()); + } + + #[test] + fn valid_version_directories() { + // Single valid version directory + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("3.14").create_dir_all().unwrap(); + temp_dir.child("folder1").create_dir_all().unwrap(); + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(3, 14) + ); + // Multiple valid version directories + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("1.2").create_dir_all().unwrap(); + temp_dir.child("1.10").create_dir_all().unwrap(); + temp_dir.child("2.0").create_dir_all().unwrap(); + temp_dir.child("not_a_version").create_dir_all().unwrap(); + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(2, 0) + ); + } + + #[test] + fn invalid_version_directories() { + // Single invalid directory + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("folder1").create_dir_all().unwrap(); + let result = find_max_version_in_directory(temp_dir.path()); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().source.kind(), + std::io::ErrorKind::NotFound + ); + + // Multiple invalid directories + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("folder1").create_dir_all().unwrap(); + temp_dir.child("1.2.3").create_dir_all().unwrap(); // Too many dots + temp_dir.child("a.b").create_dir_all().unwrap(); // Non-numeric + temp_dir.child("1").create_dir_all().unwrap(); // No dot + temp_dir.child("1.").create_dir_all().unwrap(); // Missing minor + temp_dir.child(".5").create_dir_all().unwrap(); // Missing major + let result = find_max_version_in_directory(temp_dir.path()); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().source.kind(), + std::io::ErrorKind::NotFound + ); + } + + #[test] + fn major_version_priority() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("1.999").create_dir_all().unwrap(); + temp_dir.child("2.0").create_dir_all().unwrap(); + temp_dir.child("1.1000").create_dir_all().unwrap(); + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(2, 0) + ); + } + + #[test] + fn minor_version_comparison() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("1.5").create_dir_all().unwrap(); + temp_dir.child("1.10").create_dir_all().unwrap(); + temp_dir.child("1.2").create_dir_all().unwrap(); + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(1, 10) + ); + } + + #[test] + fn zero_versions() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("0.0").create_dir_all().unwrap(); + temp_dir.child("0.1").create_dir_all().unwrap(); + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(0, 1) + ); + temp_dir.child("1.0").create_dir_all().unwrap(); + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(1, 0) + ); + } + + #[test] + fn mixed_valid_and_invalid_entries() { + let temp_dir = assert_fs::TempDir::new().unwrap(); + temp_dir.child("1.5").create_dir_all().unwrap(); + temp_dir.child("2.0").create_dir_all().unwrap(); + temp_dir.child("invalid").create_dir_all().unwrap(); + temp_dir.child("1.2.3").create_dir_all().unwrap(); // Invalid: too many dots + temp_dir.child("a.b").create_dir_all().unwrap(); // Invalid: non-numeric + temp_dir.child("not_version").touch().unwrap(); // File: ignored + temp_dir.child("3.0").touch().unwrap(); // File: ignored + // Should find the maximum among valid version directories only + assert_eq!( + find_max_version_in_directory(temp_dir.path()).unwrap(), + TwoPartVersion(2, 0) + ); + } + } + + #[cfg(target_os = "windows")] + mod safe_env_vars { + use super::*; + + #[test] + fn set_var_and_remove_var() { + let key = "WDK_BUILD_TEST_VAR"; + with_clean_env(key, || { + set_var(key, "test_value"); + assert_eq!(env::var(key).unwrap(), "test_value"); + remove_var(key); + assert!(env::var(key).is_err()); + }); + } + } +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/CHANGELOG.md b/packaging/windows/drivers/vendor/wdk-sys/CHANGELOG.md new file mode 100644 index 0000000..b5e3882 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/CHANGELOG.md @@ -0,0 +1,106 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [0.5.1](https://github.com/microsoft/windows-drivers-rs/compare/wdk-sys-v0.5.0...wdk-sys-v0.5.1) - 2025-11-13 + +### Other + +- fix wdk-build version in readme ([#568](https://github.com/microsoft/windows-drivers-rs/pull/568)) + +## [0.5.0](https://github.com/microsoft/windows-drivers-rs/compare/wdk-sys-v0.4.0...wdk-sys-v0.5.0) - 2025-11-06 + +### Added + +- enhance error handling with IoError and IoErrorMetadata for improved std::io::Error diagnostics for fs errors ([#480](https://github.com/microsoft/windows-drivers-rs/pull/480)) + +### Fixed + +- use latest version of ucx in the WDKContent as default ([#411](https://github.com/microsoft/windows-drivers-rs/pull/411)) +- allow unnecessary_transmutes lint for bindgen-generated types.rs ([#350](https://github.com/microsoft/windows-drivers-rs/pull/350)) + +### Other + +- [**breaking**] bump to Rust 2024 Edition ([#430](https://github.com/microsoft/windows-drivers-rs/pull/430)) +- improve logging for build action ([#495](https://github.com/microsoft/windows-drivers-rs/pull/495)) +- enforce typo checking ([#452](https://github.com/microsoft/windows-drivers-rs/pull/452)) +- Add stubs for __CxxFrameHandler4 and __GSHandlerCheck_EH4 ([#438](https://github.com/microsoft/windows-drivers-rs/pull/438)) + +## [0.4.0](https://github.com/microsoft/windows-drivers-rs/compare/wdk-sys-v0.3.0...wdk-sys-v0.4.0) - 2025-04-18 + +### Added + +- extend coverage in `wdk-sys` to include usb-related headers ([#296](https://github.com/microsoft/windows-drivers-rs/pull/296)) +- expand wdk-sys coverage to include gpio and parallel ports related headers ([#278](https://github.com/microsoft/windows-drivers-rs/pull/278)) +- add support for Storage API subset in `wdk-sys` ([#287](https://github.com/microsoft/windows-drivers-rs/pull/287)) +- expand `wdk-sys` coverage to include spb-related headers ([#263](https://github.com/microsoft/windows-drivers-rs/pull/263)) +- [**breaking**] expand `wdk-sys` coverage to include hid-related headers ([#260](https://github.com/microsoft/windows-drivers-rs/pull/260)) +- Use stack-based formatter for debug-printing. ([#233](https://github.com/microsoft/windows-drivers-rs/pull/233)) + +### Fixed + +- passing cache tests when WDK config is enabled ([#332](https://github.com/microsoft/windows-drivers-rs/pull/332)) +- [**breaking**] specify rust version & edition to wdk-default bindgen::builder ([#314](https://github.com/microsoft/windows-drivers-rs/pull/314)) +- use absolute paths for items used in PAGED_CODE macro ([#297](https://github.com/microsoft/windows-drivers-rs/pull/297)) + +### Other + +- update README to clarify community engagement and contact methods ([#312](https://github.com/microsoft/windows-drivers-rs/pull/312)) +- [**breaking**] Remove lazy static instances ([#250](https://github.com/microsoft/windows-drivers-rs/pull/250)) +- use `is_none_or` for `clippy::nonminimal_bool` and resolve `clippy::needless_raw_string_hashes` ([#231](https://github.com/microsoft/windows-drivers-rs/pull/231)) + +## [0.3.0](https://github.com/microsoft/windows-drivers-rs/compare/wdk-sys-v0.2.0...wdk-sys-v0.3.0) - 2024-09-27 + +### Added + +- add more precise NTSTATUS const fns ([#183](https://github.com/microsoft/windows-drivers-rs/pull/183)) +- configure WDK configuration via parsing Cargo manifest metadata ([#186](https://github.com/microsoft/windows-drivers-rs/pull/186)) + +### Fixed + +- typos in Getting Started section of README.md ([#213](https://github.com/microsoft/windows-drivers-rs/pull/213)) +- [**breaking**] prevent linking of wdk libraries in tests that depend on `wdk-sys` ([#118](https://github.com/microsoft/windows-drivers-rs/pull/118)) + +### Other + +- Improve doc comments to comply with `too_long_first_doc_paragraph` clippy lint ([#202](https://github.com/microsoft/windows-drivers-rs/pull/202)) +- Update README.md ([#180](https://github.com/microsoft/windows-drivers-rs/pull/180)) +- update readme to call out bugged LLVM 18 versions ([#169](https://github.com/microsoft/windows-drivers-rs/pull/169)) +- Build perf: Make calls to bindgen run in parallel ([#159](https://github.com/microsoft/windows-drivers-rs/pull/159)) +- Bump rustversion from 1.0.14 to 1.0.15 ([#145](https://github.com/microsoft/windows-drivers-rs/pull/145)) +- use a standardized workspace lint table ([#134](https://github.com/microsoft/windows-drivers-rs/pull/134)) +- Bump anyhow from 1.0.79 to 1.0.82 ([#140](https://github.com/microsoft/windows-drivers-rs/pull/140)) +- Bump thiserror from 1.0.56 to 1.0.59 ([#142](https://github.com/microsoft/windows-drivers-rs/pull/142)) +- change version bounds for `manual_c_str_literals` and `ref_as_ptr` clippy lints ([#127](https://github.com/microsoft/windows-drivers-rs/pull/127)) +- fix `winget` llvm install command option ([#115](https://github.com/microsoft/windows-drivers-rs/pull/115)) +- fix various pipeline breakages (nightly rustfmt bug, new nightly clippy lints, upstream winget dependency issue) ([#117](https://github.com/microsoft/windows-drivers-rs/pull/117)) +- add lint exceptions for clippy::manual_c_str_literals and clippy::ref_as_ptr ([#108](https://github.com/microsoft/windows-drivers-rs/pull/108)) +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [0.2.0](https://github/microsoft/windows-drivers-rs/compare/wdk-sys-v0.1.0...wdk-sys-v0.2.0) - 2024-02-08 + +### Added +- generate CStr for c string constants instead of &[u8] ([#72](https://github/microsoft/windows-drivers-rs/pull/72)) + +### Fixed +- resolve warnings in rust-script blocks and only fail warnings in CI ([#87](https://github/microsoft/windows-drivers-rs/pull/87)) + +### Other +- update dependencies +- allow multiple_crate_versions in wdk-build (build dependency) ([#98](https://github/microsoft/windows-drivers-rs/pull/98)) +- allow exception for clippy::pub_underscore_fields in generated code ([#77](https://github/microsoft/windows-drivers-rs/pull/77)) +- Bump thiserror from 1.0.48 to 1.0.55 ([#59](https://github/microsoft/windows-drivers-rs/pull/59)) +- reduce noise from bindgen warnings +- fix clippy errors missed due to buggy ci stage +- restrict to one unsafe operation per block ([#24](https://github/microsoft/windows-drivers-rs/pull/24)) +- [**breaking**] enable rustdoc lints and resolve errors +- remove extra keywords in cargo manifests +- initial open-source check in diff --git a/packaging/windows/drivers/vendor/wdk-sys/Cargo.lock b/packaging/windows/drivers/vendor/wdk-sys/Cargo.lock new file mode 100644 index 0000000..a8579b3 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/Cargo.lock @@ -0,0 +1,859 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" + +[[package]] +name = "bindgen" +version = "0.71.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "itertools", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", +] + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.2.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap-cargo" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d546f0e84ff2bfa4da1ce9b54be42285767ba39c688572ca32412a09a73851e5" +dependencies = [ + "anstyle", + "clap", +] + +[[package]] +name = "clap_builder" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "errno" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" + +[[package]] +name = "fs4" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4" +dependencies = [ + "rustix", + "windows-sys", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.172" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "libloading" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scratch" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f6280af86e5f559536da57a45ebc84948833b3bee313a7dd25232e09c878a52" + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "wdk-build" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c150122a579af759770b354064cd2994d29e97525d904f65ff1412ad5122766" +dependencies = [ + "anyhow", + "bindgen", + "camino", + "cargo_metadata", + "cfg-if", + "clap", + "clap-cargo", + "paste", + "regex", + "rustversion", + "semver", + "serde", + "serde_json", + "thiserror", + "tracing", + "windows", +] + +[[package]] +name = "wdk-macros" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b288d5ef6b276345d197fe0b82ef274dcb5a1f658a2294c67ff85b775f63ee26" +dependencies = [ + "cfg-if", + "fs4", + "itertools", + "proc-macro2", + "quote", + "scratch", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "wdk-sys" +version = "0.5.1" +dependencies = [ + "anyhow", + "bindgen", + "cargo_metadata", + "cc", + "cfg-if", + "rustversion", + "serde_json", + "thiserror", + "tracing", + "tracing-subscriber", + "wdk-build", + "wdk-macros", +] + +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/packaging/windows/drivers/vendor/wdk-sys/Cargo.toml b/packaging/windows/drivers/vendor/wdk-sys/Cargo.toml new file mode 100644 index 0000000..505b4ea --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/Cargo.toml @@ -0,0 +1,119 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2024" +name = "wdk-sys" +version = "0.5.1" +build = "build.rs" +links = "wdk" +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Direct bindings to APIs available in the Windows Development Kit (WDK)" +readme = "README.md" +keywords = [ + "wdk", + "windows", + "wdf", + "wdm", + "ffi", +] +categories = [ + "external-ffi-bindings", + "development-tools::ffi", + "os::windows-apis", + "os", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/microsoft/windows-drivers-rs" + +[features] +default = [] +gpio = [] +hid = [] +nightly = [ + "wdk-macros/nightly", + "wdk-build/nightly", +] +parallel-ports = ["gpio"] +spb = [] +storage = [] +test-stubs = [] +usb = [] +iddcx = [] + +[lib] +name = "wdk_sys" +path = "src/lib.rs" + +[dependencies.rustversion] +version = "1.0.20" + +[dependencies.wdk-macros] +version = "=0.5.1" + +[build-dependencies.anyhow] +version = "1.0.97" + +[build-dependencies.bindgen] +version = "0.71.0" + +[build-dependencies.cargo_metadata] +version = "0.19.2" + +[build-dependencies.cc] +version = "1.2.39" + +[build-dependencies.cfg-if] +version = "1.0.3" + +[build-dependencies.serde_json] +version = "1.0" + +[build-dependencies.thiserror] +version = "2.0.12" + +[build-dependencies.tracing] +version = "0.1.40" + +[build-dependencies.tracing-subscriber] +version = "0.3.20" +features = ["env-filter"] + +[build-dependencies.wdk-build] +version = "0.5.1" + +[lints.clippy] +all = "deny" +cargo = "warn" +multiple_unsafe_ops_per_block = "deny" +nursery = "warn" +pedantic = "warn" +undocumented_unsafe_blocks = "deny" +unnecessary_safety_doc = "forbid" + +[lints.rust] +missing_docs = "warn" +unsafe_op_in_unsafe_fn = "deny" + +[lints.rustdoc] +bare_urls = "warn" +broken_intra_doc_links = "warn" +invalid_codeblock_attributes = "warn" +invalid_html_tags = "warn" +invalid_rust_codeblocks = "warn" +missing_crate_level_docs = "warn" +private_intra_doc_links = "warn" +redundant_explicit_links = "warn" +unescaped_backticks = "warn" diff --git a/packaging/windows/drivers/vendor/wdk-sys/README.md b/packaging/windows/drivers/vendor/wdk-sys/README.md new file mode 100644 index 0000000..4df726a --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/README.md @@ -0,0 +1,237 @@ +# windows-drivers-rs + +This repo is a collection of Rust crates that enable developers to develop Windows Drivers in Rust. It is the intention to support both WDM and WDF driver development models. This repo contains the following crates: + +* [wdk-build](./crates/wdk-build): A library to configure a Cargo build script for binding generation and downstream linking of the WDK (Windows Driver Kit). While this crate is written to be flexible with different WDK releases and different WDF version, it is currently only tested for NI eWDK, KMDF 1.33, UMDF 2.33, and WDM Drivers. There may be missing linker options for older DDKs. +* [wdk-sys](./crates/wdk-sys): Direct FFI bindings to APIs available in the Windows Development Kit (WDK). This includes both autogenerated ffi bindings from `bindgen`, and also manual re-implementations of macros that bindgen fails to generate. +* [wdk](./crates/wdk): Safe idiomatic bindings to APIs available in the Windows Development Kit (WDK) +* [wdk-panic](./crates/wdk-panic/): Default panic handler implementations for programs built with WDK +* [wdk-alloc](./crates/wdk-alloc): alloc support for binaries compiled with the Windows Development Kit (WDK) +* [wdk-macros](./crates/wdk-macros): A collection of macros that help make it easier to interact with wdk-sys's direct bindings. This crate is re-exported via `wdk-sys` and crates should typically never need to directly depend on `wdk-macros` + +To see an example of this repo used to create drivers, see [Windows-rust-driver-samples](https://github.com/microsoft/Windows-rust-driver-samples). + +Note: This project is still in early stages of development and is not yet recommended for production use. We encourage community experimentation and collaboration through our [GitHub Discussions forum](https://github.com/microsoft/windows-drivers-rs/discussions)! + +## Supported Configurations + +This project was built with support of WDM, KMDF, and UMDF drivers in mind, as well as Win32 Services. This includes support for all versions of WDF included in WDK 22H2 and newer. Currently, the crates available on [`crates.io`](https://crates.io) only support KMDF v1.33, but bindings can be generated for everything else by cloning `windows-drivers-rs` and modifying the config specified in [`build.rs` of `wdk-sys`](./crates/wdk-sys/build.rs). Crates.io support for other WDK configurations is planned in the near future. + +## Repo Layout + +* [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, 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). + +## Getting Started + +### Build Requirements + +* Binding generation via `bindgen` requires `libclang`. The easiest way to acquire this is via `winget` + * `winget install -i LLVM.LLVM --version 17.0.6 --force` + * Ensure you select the GUI option to add LLVM to the PATH + * LLVM 18 has a bug that causes bindings to fail to generate for ARM64. Continue using LLVM 17 until LLVM 19 comes out with [the fix](https://github.com/llvm/llvm-project/pull/93235). See [this](https://github.com/rust-lang/rust-bindgen/issues/2842) for more details. +* To execute post-build tasks (ie. `inf2cat`, `infverif`, etc.), `cargo make` is used + * `cargo install --locked cargo-make --no-default-features --features tls-native` + +* Building programs with the WDK also requires being in a valid WDK environment. The recommended way to do this is to [enter an eWDK developer prompt](https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk#getting-started) + +### Adding windows-drivers-rs to Your Driver Package + +The crates in this repository are available from [`crates.io`](https://crates.io), but take into account the current limitations outlined in [Supported Configurations](#supported-configs). If you need to support a different config, try cloning this repo and using [path dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies) + +1. Create a new Cargo package with a lib crate: + + ```pwsh + cargo new --lib + ``` + +1. Add dependencies on `windows-drivers-rs` crates: + + ```pwsh + cd + cargo add --build wdk-build + cargo add wdk wdk-sys wdk-alloc wdk-panic + ``` + +1. Set the crate type to `cdylib` by adding the following snippet to `Cargo.toml`: + + ```toml + [lib] + crate-type = ["cdylib"] + ``` + +1. Add a wdk metadata section and configure the wdk for your use case. This also lets the cargo-make tasks know that the package is a driver and that the driver packaging steps need to run. + + UMDF Example: + ```toml + [package.metadata.wdk.driver-model] + driver-type = "UMDF" + umdf-version-major = 1 + target-umdf-version-minor = 33 + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Set crate panic strategy to `abort` in `Cargo.toml`: + + ```toml + [profile.dev] + panic = "abort" + + [profile.release] + panic = "abort" + ``` + +1. Create a `build.rs` and add the following snippet: + + ```rust + fn main() -> Result<(), wdk_build::ConfigError> { + wdk_build::configure_wdk_binary_build() + } + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Mark your driver crate as `no_std` in `lib.rs`: + + ```rust + #![no_std] + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Add a panic handler in `lib.rs`: + + ```rust + #[cfg(not(test))] + extern crate wdk_panic; + + ``` + +1. **For Kernel Mode crates** (ex. `KMDF` drivers, `WDM` drivers): Add an optional global allocator in `lib.rs`: + + ```rust + #[cfg(not(test))] + use wdk_alloc::WdkAllocator; + + #[cfg(not(test))] + #[global_allocator] + static GLOBAL_ALLOCATOR: WdkAllocator = WdkAllocator; + ``` + + This is only required if you want to be able to use the [`alloc` modules](https://doc.rust-lang.org/alloc/) in the rust standard library. + +1. Add a DriverEntry in `lib.rs`: + + ```rust + use wdk_sys::{ + PDRIVER_OBJECT, + NTSTATUS, + PCUNICODE_STRING, + }; + + // SAFETY: "DriverEntry" is the required symbol name for Windows driver entry points. + // No other function in this compilation unit exports this name, preventing symbol conflicts. + #[unsafe(export_name = "DriverEntry")] // WDF expects a symbol with the name DriverEntry + pub unsafe extern "system" fn driver_entry( + driver: PDRIVER_OBJECT, + registry_path: PCUNICODE_STRING, + ) -> NTSTATUS { + 0 + } + ``` + + Note: In Kernel Mode crates, you can use `driver: &mut DRIVER_OBJECT` instead of `driver: PDRIVER_OBJECT`. + +1. Add a `Makefile.toml`: + ```toml + extend = "target/rust-driver-makefile.toml" + + [config] + load_script = ''' + #!@rust + //! ```cargo + //! [dependencies] + //! wdk-build = "0.5.1" + //! ``` + #![allow(unused_doc_comments)] + + wdk_build::cargo_make::load_rust_driver_makefile()? + ''' + ``` + +1. Add an inx file that matches the name of your `cdylib` crate. + +1. Enable static crt linkage. One approach is to add this to your `.cargo/config.toml`: + + ```toml + [build] + rustflags = ["-C", "target-feature=+crt-static"] + ``` + +1. Build the driver: + + ```pwsh + cargo make + ``` + +A signed driver package, including a `WDRLocalTestCert.cer` file, will be generated at `target//package`. If a specific target architecture was specified, the driver package will be generated at `target///package` + +Minimal examples of `WDM`, `KMDF`, and `UMDF` drivers can be found in the [examples directory](./examples). + +## Cargo Make + +[`cargo-make`](https://github.com/sagiegurari/cargo-make) is used to facilitate builds using `windows-drivers-rs`, including for executing post-build driver packaging steps. + +To execute the default action (build and package driver): + +`cargo make default` + +When executing the default task, just `cargo make` make also works since the `default` task is implied. + +### Argument Forwarding + +`windows-drivers-rs` extends `cargo make` to forward specific arguments to the underlying `cargo` commands. In order to specify arguments to forward, they must be provided **after explicitly specifying the `cargo-make` task name** (ie. omitting the name for the `default` task is not supported). + +#### Examples + +For a specific target: + +`cargo make default --target ` + +For release builds: + +`cargo make default --release` or `cargo make default --profile release` + +To specify specific features: + +`cargo make default --features ` + +To specify a specific rust toolchain: + +`cargo make default +` + +To display help and see the full list of supported CLI args to forward to Cargo: + +`cargo make help` + +### Driver Package Signature Verification + +The `WDK_BUILD_ENABLE_SIGNTOOL_VERIFY` [cargo-make environment variable](https://github.com/sagiegurari/cargo-make?tab=readme-ov-file#environment-variables) can be set to `true` to enable tasks that handle signature verification of the generated `.sys` and `.cat` files. `signtool verify` requires the certificate to be installed as in the `Trusted Root Certification Authorities` for this verification to function. These tasks are not enabled by default as the default behavior of `WDR` is to sign with a generated test certificate. These test certificates are typically only installed into `Trusted Root Certification Authorities` on computers dedicated to testing drivers, and not personal development machines, given the security implications of installing your own root certificates. + +If you understand these implications, and have installed the test certificate, then you may validate the signatures as follows: + +``` +cargo make --env WDK_BUILD_ENABLE_SIGNTOOL_VERIFY=true +``` + +## Contact + +* For bug reports, feature requests, and other actionable items, please use [GitHub Issues](https://github.com/microsoft/windows-drivers-rs/issues) +* For broader questions, architectural discussions, and community engagement, please use [GitHub Discussions](https://github.com/microsoft/windows-drivers-rs/discussions) +* For inquiries not suitable for public forums, email us at + +## Crates.io Release Policy + +Releases to crates.io are not made after every change merged to main. Releases will only be made when requested by the community, or when the `windows-drivers-rs` team believes there is sufficient value in pushing a release. + +## Trademark Notice + +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. diff --git a/packaging/windows/drivers/vendor/wdk-sys/build.rs b/packaging/windows/drivers/vendor/wdk-sys/build.rs new file mode 100644 index 0000000..f7b1625 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/build.rs @@ -0,0 +1,799 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Build script for the `wdk-sys` crate. +//! +//! This parses the WDK configuration from metadata provided in the build tree, +//! and generates the relevant bindings to WDK APIs. + +use std::{ + env, + fs::File, + io::Write, + panic, + path::{Path, PathBuf}, + sync::LazyLock, + thread, +}; + +use anyhow::Context; +use bindgen::CodegenConfig; +use tracing::{Span, info, info_span, trace}; +use tracing_subscriber::{ + EnvFilter, + filter::{LevelFilter, ParseError}, +}; +use wdk_build::{ + ApiSubset, + BuilderExt, + Config, + ConfigError, + DriverConfig, + IoError, + KmdfConfig, + UmdfConfig, + configure_wdk_library_build_and_then, +}; + +const OUT_DIR_PLACEHOLDER: &str = + ""; +const WDFFUNCTIONS_SYMBOL_NAME_PLACEHOLDER: &str = + ""; +const WDF_FUNCTION_COUNT_PLACEHOLDER: &str = + " = LazyLock::new(|| { + format!( + r"#[allow(clippy::must_use_candidate)] +/// Returns the number of functions available in the WDF function table. +/// Should not be used in public API. +pub fn get_wdf_function_count() -> usize {{ + {WDF_FUNCTION_COUNT_PLACEHOLDER} +}}" + ) +}); + +static CALL_UNSAFE_WDF_BINDING_TEMPLATE: LazyLock = LazyLock::new(|| { + format!( + r#" +/// A procedural macro that allows WDF functions to be called by name. +/// +/// This function parses the name of the WDF function, finds it function +/// pointer from the WDF function table, and then calls it with the +/// arguments passed to it +/// +/// # Safety +/// Function arguments must abide by any rules outlined in the WDF +/// documentation. This macro does not perform any validation of the +/// arguments passed to it., beyond type validation. +/// +/// # Examples +/// +/// ```rust, no_run +/// use wdk_sys::*; +/// +/// pub unsafe extern "system" fn driver_entry( +/// driver: &mut DRIVER_OBJECT, +/// registry_path: PCUNICODE_STRING, +/// ) -> NTSTATUS {{ +/// +/// let mut driver_config = WDF_DRIVER_CONFIG {{ +/// Size: core::mem::size_of::() as ULONG, +/// ..WDF_DRIVER_CONFIG::default() +/// }}; +/// let driver_handle_output = WDF_NO_HANDLE as *mut WDFDRIVER; +/// +/// unsafe {{ +/// call_unsafe_wdf_function_binding!( +/// WdfDriverCreate, +/// driver as PDRIVER_OBJECT, +/// registry_path, +/// WDF_NO_OBJECT_ATTRIBUTES, +/// &mut driver_config, +/// driver_handle_output, +/// ) +/// }} +/// }} +/// ``` +#[macro_export] +macro_rules! call_unsafe_wdf_function_binding {{ + ( $($tt:tt)* ) => {{ + $crate::__proc_macros::call_unsafe_wdf_function_binding! ( + r"{OUT_DIR_PLACEHOLDER}", + $($tt)* + ) + }} +}}"# + ) +}); + +static TEST_STUBS_TEMPLATE: LazyLock = LazyLock::new(|| { + format!( + r" +use crate::WDFFUNC; + +/// Stubbed version of the symbol that `WdfFunctions` links to so that test targets will compile +// SAFETY: Generated WDF symbol name is required for test compilation and is unique per build. +// No other symbols in this crate export this name, preventing linker conflicts. +#[unsafe(no_mangle)] +pub static mut {WDFFUNCTIONS_SYMBOL_NAME_PLACEHOLDER}: *const WDFFUNC = core::ptr::null(); +", + ) +}); + +/// Enabled API subsets based off of cargo-features +const ENABLED_API_SUBSETS: &[ApiSubset] = &[ + ApiSubset::Base, + ApiSubset::Wdf, + #[cfg(feature = "gpio")] + ApiSubset::Gpio, + #[cfg(feature = "hid")] + ApiSubset::Hid, + #[cfg(feature = "parallel-ports")] + ApiSubset::ParallelPorts, + #[cfg(feature = "spb")] + ApiSubset::Spb, + #[cfg(feature = "storage")] + ApiSubset::Storage, + #[cfg(feature = "usb")] + ApiSubset::Usb, + #[cfg(feature = "iddcx")] + ApiSubset::Iddcx, +]; + +type GenerateFn = fn(&Path, &Config) -> Result<(), ConfigError>; +const BINDGEN_FILE_GENERATORS_TUPLES: &[(&str, GenerateFn)] = &[ + ("constants.rs", generate_constants), + ("types.rs", generate_types), + ("base.rs", generate_base), + ("wdf.rs", generate_wdf), + #[cfg(feature = "gpio")] + ("gpio.rs", generate_gpio), + #[cfg(feature = "hid")] + ("hid.rs", generate_hid), + #[cfg(feature = "parallel-ports")] + ("parallel_ports.rs", generate_parallel_ports), + #[cfg(feature = "spb")] + ("spb.rs", generate_spb), + #[cfg(feature = "storage")] + ("storage.rs", generate_storage), + #[cfg(feature = "usb")] + ("usb.rs", generate_usb), + #[cfg(feature = "iddcx")] + ("iddcx.rs", generate_iddcx), +]; + +fn initialize_tracing() -> Result<(), ParseError> { + let tracing_filter = EnvFilter::default() + // Show up to INFO level by default + .add_directive(LevelFilter::INFO.into()) + // Silence various warnings originating from bindgen that are not currently actionable + // FIXME: this currently sets the minimum log level to error for the listed modules. It + // should actually be turning off logging (level=off) for specific warnings in these + // modules, but a bug in the tracing crate's filtering is preventing this from working as expected. See https://github.com/tokio-rs/tracing/issues/2843. + .add_directive("bindgen::codegen::helpers[{message}]=error".parse()?) + .add_directive("bindgen::codegen::struct_layout[{message}]=error".parse()?) + .add_directive("bindgen::ir::comp[{message}]=error".parse()?) + .add_directive("bindgen::ir::context[{message}]=error".parse()?) + .add_directive("bindgen::ir::ty[{message}]=error".parse()?) + .add_directive("bindgen::ir::var[{message}]=error".parse()?); + + // Allow overriding tracing behaviour via `EnvFilter::DEFAULT_ENV` env var + let tracing_filter = + if let Ok(filter_directives_from_env_var) = env::var(EnvFilter::DEFAULT_ENV) { + // Append each directive from the env var to the filter + filter_directives_from_env_var.split(',').fold( + tracing_filter, + |tracing_filter, filter_directive| { + match filter_directive.parse() { + Ok(parsed_filter_directive) => { + tracing_filter.add_directive(parsed_filter_directive) + } + Err(parsing_error) => { + // Must use eprintln!() here as tracing is not yet initialized + eprintln!( + "Skipping filter directive, {}, which failed to be parsed from {} \ + obtained from {} with the following error: {}", + filter_directive, + filter_directives_from_env_var, + EnvFilter::DEFAULT_ENV, + parsing_error + ); + tracing_filter + } + } + }, + ) + } else { + tracing_filter + }; + + tracing_subscriber::fmt() + .pretty() + .with_env_filter(tracing_filter) + .with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE) + .init(); + + Ok(()) +} + +fn generate_constants(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: constants.rs"); + + let header_contents = config.bindgen_header_contents(ENABLED_API_SUBSETS.iter().copied())?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config(CodegenConfig::VARS) + .header_contents("constants-input.h", &header_contents); + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("constants.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +fn generate_types(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: types.rs"); + + let header_contents = config.bindgen_header_contents(ENABLED_API_SUBSETS.iter().copied())?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config(CodegenConfig::TYPES) + .header_contents("types-input.h", &header_contents); + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("types.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +fn generate_base(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + let outfile_name = match &config.driver_config { + DriverConfig::Wdm | DriverConfig::Kmdf(_) => "ntddk", + DriverConfig::Umdf(_) => "windows", + }; + info!("Generating bindings to WDK: {outfile_name}.rs"); + + let header_contents = config.bindgen_header_contents([ApiSubset::Base])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents(&format!("{outfile_name}-input.h"), &header_contents); + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join(format!("{outfile_name}.rs")); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +fn generate_wdf(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + if let DriverConfig::Kmdf(_) | DriverConfig::Umdf(_) = config.driver_config { + info!("Generating bindings to WDK: wdf.rs"); + + let header_contents = config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("wdf-input.h", &header_contents) + // Only generate for files that are prefixed with (case-insensitive) wdf (ie. + // /some/path/WdfSomeHeader.h), to prevent duplication of code in ntddk.rs + .allowlist_file("(?i).*wdf.*"); + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("wdf.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) + } else { + info!( + "Skipping wdf.rs generation since driver_config is {:#?}", + config.driver_config + ); + Ok(()) + } +} + +#[cfg(feature = "gpio")] +fn generate_gpio(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: gpio.rs"); + + let header_contents = + config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf, ApiSubset::Gpio])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + let mut builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("gpio-input.h", &header_contents); + + // Only allowlist files in the gpio-specific files to avoid + // duplicate definitions + for header_file in config.headers(ApiSubset::Gpio)? { + builder = builder.allowlist_file(format!("(?i).*{header_file}.*")); + } + builder + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("gpio.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +#[cfg(feature = "iddcx")] +fn generate_iddcx(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: iddcx.rs"); + + let header_contents = + config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf, ApiSubset::Iddcx])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("iddcx-input.h", &header_contents) + // Allowlist by the "iddcx" path component (separator-agnostic) so ONLY IddCx items are + // emitted; the WDF/Win/DXGI types they reference RESOLVE to the shared base/wdf bindings + // instead of being redefined. + .allowlist_file("(?i).*iddcx.*") + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("iddcx.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +#[cfg(feature = "hid")] +fn generate_hid(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: hid.rs"); + + let header_contents = + config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf, ApiSubset::Hid])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + let mut builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("hid-input.h", &header_contents); + + // Only allowlist files in the hid-specific files to avoid + // duplicate definitions + for header_file in config.headers(ApiSubset::Hid)? { + builder = builder.allowlist_file(format!("(?i).*{header_file}.*")); + } + builder + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("hid.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +#[cfg(feature = "parallel-ports")] +fn generate_parallel_ports(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: parallel_ports.rs"); + + let header_contents = config.bindgen_header_contents([ + ApiSubset::Base, + ApiSubset::Wdf, + ApiSubset::ParallelPorts, + ])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + let mut builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("parallel-ports-input.h", &header_contents); + + // Only allowlist files in the parallel-ports-specific files to + // avoid duplicate definitions + for header_file in config.headers(ApiSubset::ParallelPorts)? { + builder = builder.allowlist_file(format!("(?i).*{header_file}.*")); + } + builder + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("parallel_ports.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +#[cfg(feature = "spb")] +fn generate_spb(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: spb.rs"); + + let header_contents = + config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf, ApiSubset::Spb])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + let mut builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("spb-input.h", &header_contents); + + // Only allowlist files in the spb-specific files to avoid + // duplicate definitions + for header_file in config.headers(ApiSubset::Spb)? { + builder = builder.allowlist_file(format!("(?i).*{header_file}.*")); + } + builder + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("spb.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +#[cfg(feature = "storage")] +fn generate_storage(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: storage.rs"); + + let header_contents = + config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf, ApiSubset::Storage])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + let mut builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("storage-input.h", &header_contents); + + // Only allowlist files in the storage-specific files to avoid + // duplicate definitions + for header_file in config.headers(ApiSubset::Storage)? { + builder = builder.allowlist_file(format!("(?i).*{header_file}.*")); + } + builder + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("storage.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +#[cfg(feature = "usb")] +fn generate_usb(out_path: &Path, config: &Config) -> Result<(), ConfigError> { + info!("Generating bindings to WDK: usb.rs"); + + let header_contents = + config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf, ApiSubset::Usb])?; + trace!(header_contents = ?header_contents); + + let bindgen_builder = { + let mut builder = bindgen::Builder::wdk_default(config)? + .with_codegen_config((CodegenConfig::TYPES | CodegenConfig::VARS).complement()) + .header_contents("usb-input.h", &header_contents); + + // Only allowlist files in the usb-specific files to avoid + // duplicate definitions + for header_file in config.headers(ApiSubset::Usb)? { + builder = builder.allowlist_file(format!("(?i).*{header_file}.*")); + } + builder + }; + trace!(bindgen_builder = ?bindgen_builder); + + let output_file_path = out_path.join("usb.rs"); + Ok(bindgen_builder + .generate() + .expect("Bindings should succeed to generate") + .write_to_file(&output_file_path) + .map_err(|source| IoError::with_path(output_file_path, source))?) +} + +/// Generates a `wdf_function_count.rs` file in `OUT_DIR` which contains the +/// definition of the function `get_wdf_function_count()`. This is required to +/// be generated here since the size of the table is derived from either a +/// global symbol that newer WDF versions expose, or an enum that older versions +/// use. +fn generate_wdf_function_count(out_path: &Path, config: &Config) -> Result<(), IoError> { + const MINIMUM_MINOR_VERSION_TO_GENERATE_WDF_FUNCTION_COUNT: u8 = 25; + + let generated_file_path = out_path.join("wdf_function_count.rs"); + let mut generated_file = File::create(&generated_file_path) + .map_err(|source| IoError::with_path(&generated_file_path, source))?; + + let is_wdf_function_count_generated = match *config { + Config { + driver_config: + DriverConfig::Kmdf(KmdfConfig { + kmdf_version_major, + target_kmdf_version_minor, + .. + }), + .. + } => { + kmdf_version_major >= 1 + && target_kmdf_version_minor >= MINIMUM_MINOR_VERSION_TO_GENERATE_WDF_FUNCTION_COUNT + } + + Config { + driver_config: + DriverConfig::Umdf(UmdfConfig { + umdf_version_major, + target_umdf_version_minor, + .. + }), + .. + } => { + umdf_version_major >= 2 + && target_umdf_version_minor >= MINIMUM_MINOR_VERSION_TO_GENERATE_WDF_FUNCTION_COUNT + } + + _ => { + unreachable!( + "generate_wdf_function_table is only called with WDF driver configurations" + ) + } + }; + + let wdf_function_table_count_snippet = WDF_FUNCTION_COUNT_FUNCTION_TEMPLATE.replace( + WDF_FUNCTION_COUNT_PLACEHOLDER, + if is_wdf_function_count_generated { + WDF_FUNCTION_COUNT_DECLARATION_EXTERNAL_SYMBOL + } else { + WDF_FUNCTION_COUNT_DECLARATION_TABLE_INDEX + }, + ); + + generated_file + .write_all(wdf_function_table_count_snippet.as_bytes()) + .map_err(|source| IoError::with_path(generated_file_path, source))?; + Ok(()) +} + +/// Generates a `macros.rs` file in `OUT_DIR` which contains a +/// `call_unsafe_wdf_function_binding!` macro that redirects to the +/// `wdk_macros::call_unsafe_wdf_function_binding` `proc_macro` . This is +/// required in order to add an additional argument with the path to the file +/// containing generated types. There is currently no other way to pass +/// `OUT_DIR` of `wdk-sys` to the `proc_macro`. +fn generate_call_unsafe_wdf_function_binding_macro(out_path: &Path) -> Result<(), IoError> { + let generated_file_path = out_path.join("call_unsafe_wdf_function_binding.rs"); + let mut generated_file = File::create(&generated_file_path) + .map_err(|source| IoError::with_path(&generated_file_path, source))?; + generated_file + .write_all( + CALL_UNSAFE_WDF_BINDING_TEMPLATE + .replace( + OUT_DIR_PLACEHOLDER, + out_path.join("types.rs").to_str().expect( + "path to file with generated type information should successfully convert \ + to a str", + ), + ) + .as_bytes(), + ) + .map_err(|source| IoError::with_path(generated_file_path, source))?; + Ok(()) +} + +/// Generates a `test_stubs.rs` file in `OUT_DIR` which contains stubs required +/// for tests to compile. This should only generate the stubs whose names are +/// dependent on the WDK configuration, and would otherwise be impossible to +/// just include in `src/test_stubs.rs` directly. +fn generate_test_stubs(out_path: &Path, config: &Config) -> Result<(), IoError> { + let stubs_file_path = out_path.join("test_stubs.rs"); + let mut stubs_file = File::create(&stubs_file_path) + .map_err(|source| IoError::with_path(&stubs_file_path, source))?; + stubs_file + .write_all( + TEST_STUBS_TEMPLATE + .replace( + WDFFUNCTIONS_SYMBOL_NAME_PLACEHOLDER, + &config.compute_wdffunctions_symbol_name().expect( + "KMDF and UMDF configs should always have a computable WdfFunctions \ + symbol name", + ), + ) + .as_bytes(), + ) + .map_err(|source| IoError::with_path(stubs_file_path, source))?; + Ok(()) +} + +/// Starts parallel bindgen tasks for generating binding files. +fn start_bindgen_tasks<'scope>( + thread_scope: &'scope thread::Scope<'scope, '_>, + out_path: &'scope Path, + config: &'scope Config, + thread_join_handles: &mut Vec>>, +) { + info_span!("bindgen generation").in_scope(|| { + for (file_name, generate_function) in BINDGEN_FILE_GENERATORS_TUPLES { + let current_span = Span::current(); + + thread_join_handles.push( + thread::Builder::new() + .name(format!("bindgen {file_name} generator")) + .spawn_scoped(thread_scope, move || { + // Parent span must be manually set since spans do not persist across thread boundaries: https://github.com/tokio-rs/tracing/issues/1391 + info_span!(parent: ¤t_span, "worker thread", generated_file_name = file_name).in_scope(|| generate_function(out_path, config)) + }) + .expect("Scoped Thread should spawn successfully"), + ); + } + }); +} + +/// Starts a task that compiles a C shim to expose WDF symbols hidden by +/// `__declspec(selectany)`. +fn start_wdf_symbol_export_tasks<'scope>( + thread_scope: &'scope thread::Scope<'scope, '_>, + out_path: &'scope Path, + config: &'scope Config, + thread_join_handles: &mut Vec>>, +) { + let current_span = Span::current(); + + // Compile a c library to expose symbols that are not exposed because of + // __declspec(selectany) + thread_join_handles.push( + thread::Builder::new() + .name("wdf.c cc compilation".to_string()) + .spawn_scoped(thread_scope, move || { + // Parent span must be manually set since spans do not persist across thread boundaries: https://github.com/tokio-rs/tracing/issues/1391 + info_span!(parent: current_span, "cc").in_scope(|| { + info!("Compiling wdf.c"); + + // Write all included headers into wdf.c (existing file, if present + // (i.e. incremental rebuild), is truncated) + let wdf_c_file_path = out_path.join("wdf.c"); + { + let mut wdf_c_file = File::create(&wdf_c_file_path) + .map_err(|source| IoError::with_path(&wdf_c_file_path, source))?; + wdf_c_file + .write_all( + config + // This should include the entirety of the `ENABLED_API_SUBSETS`, but this is currently blocked by issues with mutually exclusive headers: https://github.com/microsoft/windows-drivers-rs/issues/515 + .bindgen_header_contents([ + ApiSubset::Base, + ApiSubset::Wdf, + #[cfg(feature = "hid")] + ApiSubset::Hid, + #[cfg(feature = "spb")] + ApiSubset::Spb, + ])? + .as_bytes(), + ) + .map_err(|source| IoError::with_path(&wdf_c_file_path, source))?; + + // Explicitly sync_all to surface any IO errors (File::drop + // silently ignores close errors) + wdf_c_file + .sync_all() + .map_err(|source| IoError::with_path(&wdf_c_file_path, source))?; + } + + let mut cc_builder = cc::Build::new(); + for (key, value) in config.preprocessor_definitions() { + cc_builder.define(&key, value.as_deref()); + } + + cc_builder + .includes(config.include_paths()?) + .file(wdf_c_file_path) + .compile("wdf"); + Ok::<(), ConfigError>(()) + }) + }) + .expect("Scoped Thread should spawn successfully"), + ); +} + +/// Starts generation/compilation tasks for WDF-specific artifacts for driver +/// configurations. +/// +/// Uses the `start_*_tasks` naming convention: dispatches work to scoped +/// threads and returns after scheduling. +fn start_wdf_artifact_tasks<'scope>( + thread_scope: &'scope thread::Scope<'scope, '_>, + out_path: &'scope Path, + config: &'scope Config, + thread_join_handles: &mut Vec>>, +) -> anyhow::Result<()> { + if let DriverConfig::Kmdf(_) | DriverConfig::Umdf(_) = config.driver_config { + start_wdf_symbol_export_tasks(thread_scope, out_path, config, thread_join_handles); + + info_span!("wdf_function_count.rs generation") + .in_scope(|| generate_wdf_function_count(out_path, config))?; + + info_span!("call_unsafe_wdf_function_binding.rs generation") + .in_scope(|| generate_call_unsafe_wdf_function_binding_macro(out_path))?; + + info_span!("test_stubs.rs generation") + .in_scope(|| generate_test_stubs(out_path, config))?; + } + Ok(()) +} + +/// Joins all worker threads and collects their results +fn join_worker_threads( + thread_join_handles: Vec>>, +) -> anyhow::Result<()> { + for join_handle in thread_join_handles { + let thread_name = join_handle.thread().name().unwrap_or("UNNAMED").to_string(); + + match join_handle.join() { + // Forward panics to the main thread + Err(panic_payload) => { + panic::resume_unwind(panic_payload); + } + + Ok(thread_result) => { + thread_result.with_context(|| { + format!(r#""{thread_name}" thread failed to exit successfully"#) + })?; + } + } + } + Ok(()) +} + +fn main() -> anyhow::Result<()> { + initialize_tracing()?; + + configure_wdk_library_build_and_then(|config| { + let out_path = PathBuf::from( + env::var("OUT_DIR").expect("OUT_DIR should be exist in Cargo build environment"), + ); + + thread::scope(|thread_scope| { + let mut thread_join_handles = Vec::new(); + + start_bindgen_tasks(thread_scope, &out_path, &config, &mut thread_join_handles); + start_wdf_artifact_tasks(thread_scope, &out_path, &config, &mut thread_join_handles)?; + + join_worker_threads(thread_join_handles) + })?; + + Ok::<(), anyhow::Error>(()) + })?; + + Ok(()) +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/constants.rs b/packaging/windows/drivers/vendor/wdk-sys/src/constants.rs new file mode 100644 index 0000000..ac37822 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/constants.rs @@ -0,0 +1,2775 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +#![allow(missing_docs)] + +pub use bindings::*; +#[cfg(any(driver_model__driver_type = "WDM", driver_model__driver_type = "KMDF"))] +pub use kernel_mode::*; +#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] +pub use wdf::*; + +use crate::types::NTSTATUS; + +#[allow(non_upper_case_globals)] +#[rustversion::attr( + any( + all(not(nightly), since(1.78)), + all(nightly, since(2024-02-09)), + ), + // required until following issue is resolved: https://github.com/rust-lang/rust-bindgen/issues/2710 + allow(clippy::manual_c_str_literals) +)] +#[allow(clippy::unreadable_literal)] +mod bindings { + // allow wildcards for types module since underlying c code relies on all + // type definitions being in scope + #[allow(clippy::wildcard_imports)] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/constants.rs")); +} + +#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] +mod wdf { + use crate::types::{PVOID, PWDF_OBJECT_ATTRIBUTES}; + + pub const WDF_NO_OBJECT_ATTRIBUTES: PWDF_OBJECT_ATTRIBUTES = core::ptr::null_mut(); + pub const WDF_NO_EVENT_CALLBACK: PVOID = core::ptr::null_mut(); + pub const WDF_NO_HANDLE: PVOID = core::ptr::null_mut(); + pub const WDF_NO_CONTEXT: PVOID = core::ptr::null_mut(); + pub const WDF_NO_SEND_OPTIONS: PVOID = core::ptr::null_mut(); +} + +#[cfg(any(driver_model__driver_type = "WDM", driver_model__driver_type = "KMDF"))] +mod kernel_mode { + use crate::types::POOL_FLAGS; + + // Macros with MSVC C Integer Constant Suffixes are not supported by bindgen, so they must be manually ported or imported from elsewhere: https://github.com/rust-lang/rust-bindgen/issues/2600 + pub const POOL_FLAG_REQUIRED_START: POOL_FLAGS = 0x0000_0000_0000_0001; + pub const POOL_FLAG_USE_QUOTA: POOL_FLAGS = 0x0000_0000_0000_0001; // Charge quota + pub const POOL_FLAG_UNINITIALIZED: POOL_FLAGS = 0x0000_0000_0000_0002; // Don't zero-initialize allocation + pub const POOL_FLAG_SESSION: POOL_FLAGS = 0x0000_0000_0000_0004; // Use session specific pool + pub const POOL_FLAG_CACHE_ALIGNED: POOL_FLAGS = 0x0000_0000_0000_0008; // Cache aligned allocation + pub const POOL_FLAG_RESERVED1: POOL_FLAGS = 0x0000_0000_0000_0010; // Reserved for system use + pub const POOL_FLAG_RAISE_ON_FAILURE: POOL_FLAGS = 0x0000_0000_0000_0020; // Raise exception on failure + pub const POOL_FLAG_NON_PAGED: POOL_FLAGS = 0x0000_0000_0000_0040; // Non paged pool NX + pub const POOL_FLAG_NON_PAGED_EXECUTE: POOL_FLAGS = 0x0000_0000_0000_0080; // Non paged pool executable + pub const POOL_FLAG_PAGED: POOL_FLAGS = 0x0000_0000_0000_0100; // Paged pool + pub const POOL_FLAG_RESERVED2: POOL_FLAGS = 0x0000_0000_0000_0200; // Reserved for system use + pub const POOL_FLAG_RESERVED3: POOL_FLAGS = 0x0000_0000_0000_0400; // Reserved for system use + pub const POOL_FLAG_REQUIRED_END: POOL_FLAGS = 0x0000_0000_8000_0000; + pub const POOL_FLAG_OPTIONAL_START: POOL_FLAGS = 0x0000_0001_0000_0000; + pub const POOL_FLAG_SPECIAL_POOL: POOL_FLAGS = 0x0000_0001_0000_0000; // Make special pool allocation + pub const POOL_FLAG_OPTIONAL_END: POOL_FLAGS = 0x8000_0000_0000_0000; +} + +// Due to linker issues with windows_sys, these definitions are manually +// imported definitions from windows_sys::Win32::Foundation: +pub const STATUS_ABANDONED: NTSTATUS = 128_i32; +pub const STATUS_ABANDONED_WAIT_0: NTSTATUS = 128_i32; +pub const STATUS_ABANDONED_WAIT_63: NTSTATUS = 191_i32; +pub const STATUS_ABANDON_HIBERFILE: NTSTATUS = 1_073_741_875_i32; +pub const STATUS_ABIOS_INVALID_COMMAND: NTSTATUS = -1_073_741_549_i32; +pub const STATUS_ABIOS_INVALID_LID: NTSTATUS = -1_073_741_548_i32; +pub const STATUS_ABIOS_INVALID_SELECTOR: NTSTATUS = -1_073_741_546_i32; +pub const STATUS_ABIOS_LID_ALREADY_OWNED: NTSTATUS = -1_073_741_551_i32; +pub const STATUS_ABIOS_LID_NOT_EXIST: NTSTATUS = -1_073_741_552_i32; +pub const STATUS_ABIOS_NOT_LID_OWNER: NTSTATUS = -1_073_741_550_i32; +pub const STATUS_ABIOS_NOT_PRESENT: NTSTATUS = -1_073_741_553_i32; +pub const STATUS_ABIOS_SELECTOR_NOT_AVAILABLE: NTSTATUS = -1_073_741_547_i32; +pub const STATUS_ACCESS_AUDIT_BY_POLICY: NTSTATUS = 1_073_741_874_i32; +pub const STATUS_ACCESS_DENIED: NTSTATUS = -1_073_741_790_i32; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT: NTSTATUS = -1_073_740_959_i32; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_OTHER: NTSTATUS = -1_073_740_956_i32; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_PATH: NTSTATUS = -1_073_740_958_i32; +pub const STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER: NTSTATUS = -1_073_740_957_i32; +pub const STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: NTSTATUS = -1_073_740_942_i32; +pub const STATUS_ACCESS_VIOLATION: NTSTATUS = -1_073_741_819_i32; +pub const STATUS_ACPI_ACQUIRE_GLOBAL_LOCK: NTSTATUS = -1_072_431_086_i32; +pub const STATUS_ACPI_ADDRESS_NOT_MAPPED: NTSTATUS = -1_072_431_092_i32; +pub const STATUS_ACPI_ALREADY_INITIALIZED: NTSTATUS = -1_072_431_085_i32; +pub const STATUS_ACPI_ASSERT_FAILED: NTSTATUS = -1_072_431_101_i32; +pub const STATUS_ACPI_FATAL: NTSTATUS = -1_072_431_098_i32; +pub const STATUS_ACPI_HANDLER_COLLISION: NTSTATUS = -1_072_431_090_i32; +pub const STATUS_ACPI_INCORRECT_ARGUMENT_COUNT: NTSTATUS = -1_072_431_093_i32; +pub const STATUS_ACPI_INVALID_ACCESS_SIZE: NTSTATUS = -1_072_431_087_i32; +pub const STATUS_ACPI_INVALID_ARGTYPE: NTSTATUS = -1_072_431_096_i32; +pub const STATUS_ACPI_INVALID_ARGUMENT: NTSTATUS = -1_072_431_099_i32; +pub const STATUS_ACPI_INVALID_DATA: NTSTATUS = -1_072_431_089_i32; +pub const STATUS_ACPI_INVALID_EVENTTYPE: NTSTATUS = -1_072_431_091_i32; +pub const STATUS_ACPI_INVALID_INDEX: NTSTATUS = -1_072_431_100_i32; +pub const STATUS_ACPI_INVALID_MUTEX_LEVEL: NTSTATUS = -1_072_431_083_i32; +pub const STATUS_ACPI_INVALID_OBJTYPE: NTSTATUS = -1_072_431_095_i32; +pub const STATUS_ACPI_INVALID_OPCODE: NTSTATUS = -1_072_431_103_i32; +pub const STATUS_ACPI_INVALID_REGION: NTSTATUS = -1_072_431_088_i32; +pub const STATUS_ACPI_INVALID_SUPERNAME: NTSTATUS = -1_072_431_097_i32; +pub const STATUS_ACPI_INVALID_TABLE: NTSTATUS = -1_072_431_079_i32; +pub const STATUS_ACPI_INVALID_TARGETTYPE: NTSTATUS = -1_072_431_094_i32; +pub const STATUS_ACPI_MUTEX_NOT_OWNED: NTSTATUS = -1_072_431_082_i32; +pub const STATUS_ACPI_MUTEX_NOT_OWNER: NTSTATUS = -1_072_431_081_i32; +pub const STATUS_ACPI_NOT_INITIALIZED: NTSTATUS = -1_072_431_084_i32; +pub const STATUS_ACPI_POWER_REQUEST_FAILED: NTSTATUS = -1_072_431_071_i32; +pub const STATUS_ACPI_REG_HANDLER_FAILED: NTSTATUS = -1_072_431_072_i32; +pub const STATUS_ACPI_RS_ACCESS: NTSTATUS = -1_072_431_080_i32; +pub const STATUS_ACPI_STACK_OVERFLOW: NTSTATUS = -1_072_431_102_i32; +pub const STATUS_ADAPTER_HARDWARE_ERROR: NTSTATUS = -1_073_741_630_i32; +pub const STATUS_ADDRESS_ALREADY_ASSOCIATED: NTSTATUS = -1_073_741_256_i32; +pub const STATUS_ADDRESS_ALREADY_EXISTS: NTSTATUS = -1_073_741_302_i32; +pub const STATUS_ADDRESS_CLOSED: NTSTATUS = -1_073_741_301_i32; +pub const STATUS_ADDRESS_NOT_ASSOCIATED: NTSTATUS = -1_073_741_255_i32; +pub const STATUS_ADMINLESS_ACCESS_DENIED: NTSTATUS = -1_073_700_348_i32; +pub const STATUS_ADVANCED_INSTALLER_FAILED: NTSTATUS = -1_072_365_536_i32; +pub const STATUS_AGENTS_EXHAUSTED: NTSTATUS = -1_073_741_691_i32; +pub const STATUS_ALERTED: NTSTATUS = 257_i32; +pub const STATUS_ALIAS_EXISTS: NTSTATUS = -1_073_741_484_i32; +pub const STATUS_ALLOCATE_BUCKET: NTSTATUS = -1_073_741_265_i32; +pub const STATUS_ALLOTTED_SPACE_EXCEEDED: NTSTATUS = -1_073_741_671_i32; +pub const STATUS_ALL_SIDS_FILTERED: NTSTATUS = -1_073_740_962_i32; +pub const STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED: NTSTATUS = -1_073_740_798_i32; +pub const STATUS_ALPC_CHECK_COMPLETION_LIST: NTSTATUS = 1_073_741_872_i32; +pub const STATUS_ALREADY_COMMITTED: NTSTATUS = -1_073_741_791_i32; +pub const STATUS_ALREADY_COMPLETE: NTSTATUS = 255_i32; +pub const STATUS_ALREADY_DISCONNECTED: NTSTATUS = -2_147_483_611_i32; +pub const STATUS_ALREADY_HAS_STREAM_ID: NTSTATUS = -1_073_740_530_i32; +pub const STATUS_ALREADY_INITIALIZED: NTSTATUS = -1_073_740_528_i32; +pub const STATUS_ALREADY_REGISTERED: NTSTATUS = -1_073_740_008_i32; +pub const STATUS_ALREADY_WIN32: NTSTATUS = 1_073_741_851_i32; +pub const STATUS_AMBIGUOUS_SYSTEM_DEVICE: NTSTATUS = -1_073_740_719_i32; +pub const STATUS_APC_RETURNED_WHILE_IMPERSONATING: NTSTATUS = -1_073_740_015_i32; +pub const STATUS_APISET_NOT_HOSTED: NTSTATUS = -1_073_740_671_i32; +pub const STATUS_APISET_NOT_PRESENT: NTSTATUS = -1_073_740_670_i32; +pub const STATUS_APPEXEC_APP_COMPAT_BLOCK: NTSTATUS = -1_058_275_320_i32; +pub const STATUS_APPEXEC_CALLER_WAIT_TIMEOUT: NTSTATUS = -1_058_275_319_i32; +pub const STATUS_APPEXEC_CALLER_WAIT_TIMEOUT_LICENSING: NTSTATUS = -1_058_275_317_i32; +pub const STATUS_APPEXEC_CALLER_WAIT_TIMEOUT_RESOURCES: NTSTATUS = -1_058_275_316_i32; +pub const STATUS_APPEXEC_CALLER_WAIT_TIMEOUT_TERMINATION: NTSTATUS = -1_058_275_318_i32; +pub const STATUS_APPEXEC_CONDITION_NOT_SATISFIED: NTSTATUS = -1_058_275_328_i32; +pub const STATUS_APPEXEC_HANDLE_INVALIDATED: NTSTATUS = -1_058_275_327_i32; +pub const STATUS_APPEXEC_HOST_ID_MISMATCH: NTSTATUS = -1_058_275_322_i32; +pub const STATUS_APPEXEC_INVALID_HOST_GENERATION: NTSTATUS = -1_058_275_326_i32; +pub const STATUS_APPEXEC_INVALID_HOST_STATE: NTSTATUS = -1_058_275_324_i32; +pub const STATUS_APPEXEC_NO_DONOR: NTSTATUS = -1_058_275_323_i32; +pub const STATUS_APPEXEC_UNEXPECTED_PROCESS_REGISTRATION: NTSTATUS = -1_058_275_325_i32; +pub const STATUS_APPEXEC_UNKNOWN_USER: NTSTATUS = -1_058_275_321_i32; +pub const STATUS_APPHELP_BLOCK: NTSTATUS = -1_073_740_963_i32; +pub const STATUS_APPX_FILE_NOT_ENCRYPTED: NTSTATUS = -1_073_740_634_i32; +pub const STATUS_APPX_INTEGRITY_FAILURE_CLR_NGEN: NTSTATUS = -1_073_740_673_i32; +pub const STATUS_APP_DATA_CORRUPT: NTSTATUS = -1_073_700_221_i32; +pub const STATUS_APP_DATA_EXPIRED: NTSTATUS = -1_073_700_222_i32; +pub const STATUS_APP_DATA_LIMIT_EXCEEDED: NTSTATUS = -1_073_700_220_i32; +pub const STATUS_APP_DATA_NOT_FOUND: NTSTATUS = -1_073_700_223_i32; +pub const STATUS_APP_DATA_REBOOT_REQUIRED: NTSTATUS = -1_073_700_219_i32; +pub const STATUS_APP_INIT_FAILURE: NTSTATUS = -1_073_741_499_i32; +pub const STATUS_ARBITRATION_UNHANDLED: NTSTATUS = 1_073_741_862_i32; +pub const STATUS_ARRAY_BOUNDS_EXCEEDED: NTSTATUS = -1_073_741_684_i32; +pub const STATUS_ASSERTION_FAILURE: NTSTATUS = -1_073_740_768_i32; +pub const STATUS_ATTACHED_EXECUTABLE_MEMORY_WRITE: NTSTATUS = -1_073_739_995_i32; +pub const STATUS_ATTRIBUTE_NOT_PRESENT: NTSTATUS = -1_073_740_532_i32; +pub const STATUS_AUDIO_ENGINE_NODE_NOT_FOUND: NTSTATUS = -1_069_285_375_i32; +pub const STATUS_AUDITING_DISABLED: NTSTATUS = -1_073_740_970_i32; +pub const STATUS_AUDIT_FAILED: NTSTATUS = -1_073_741_244_i32; +pub const STATUS_AUTHIP_FAILURE: NTSTATUS = -1_073_700_730_i32; +pub const STATUS_AUTH_TAG_MISMATCH: NTSTATUS = -1_073_700_862_i32; +pub const STATUS_BACKUP_CONTROLLER: NTSTATUS = -1_073_741_433_i32; +pub const STATUS_BAD_BINDINGS: NTSTATUS = -1_073_740_965_i32; +pub const STATUS_BAD_CLUSTERS: NTSTATUS = -1_073_739_771_i32; +pub const STATUS_BAD_COMPRESSION_BUFFER: NTSTATUS = -1_073_741_246_i32; +pub const STATUS_BAD_CURRENT_DIRECTORY: NTSTATUS = 1_073_741_831_i32; +pub const STATUS_BAD_DATA: NTSTATUS = -1_073_739_509_i32; +pub const STATUS_BAD_DESCRIPTOR_FORMAT: NTSTATUS = -1_073_741_593_i32; +pub const STATUS_BAD_DEVICE_TYPE: NTSTATUS = -1_073_741_621_i32; +pub const STATUS_BAD_DLL_ENTRYPOINT: NTSTATUS = -1_073_741_231_i32; +pub const STATUS_BAD_FILE_TYPE: NTSTATUS = -1_073_739_517_i32; +pub const STATUS_BAD_FUNCTION_TABLE: NTSTATUS = -1_073_741_569_i32; +pub const STATUS_BAD_IMPERSONATION_LEVEL: NTSTATUS = -1_073_741_659_i32; +pub const STATUS_BAD_INHERITANCE_ACL: NTSTATUS = -1_073_741_699_i32; +pub const STATUS_BAD_INITIAL_PC: NTSTATUS = -1_073_741_814_i32; +pub const STATUS_BAD_INITIAL_STACK: NTSTATUS = -1_073_741_815_i32; +pub const STATUS_BAD_KEY: NTSTATUS = -1_073_739_510_i32; +pub const STATUS_BAD_LOGON_SESSION_STATE: NTSTATUS = -1_073_741_564_i32; +pub const STATUS_BAD_MASTER_BOOT_RECORD: NTSTATUS = -1_073_741_655_i32; +pub const STATUS_BAD_MCFG_TABLE: NTSTATUS = -1_073_739_512_i32; +pub const STATUS_BAD_NETWORK_NAME: NTSTATUS = -1_073_741_620_i32; +pub const STATUS_BAD_NETWORK_PATH: NTSTATUS = -1_073_741_634_i32; +pub const STATUS_BAD_REMOTE_ADAPTER: NTSTATUS = -1_073_741_627_i32; +pub const STATUS_BAD_SERVICE_ENTRYPOINT: NTSTATUS = -1_073_741_230_i32; +pub const STATUS_BAD_STACK: NTSTATUS = -1_073_741_784_i32; +pub const STATUS_BAD_TOKEN_TYPE: NTSTATUS = -1_073_741_656_i32; +pub const STATUS_BAD_VALIDATION_CLASS: NTSTATUS = -1_073_741_657_i32; +pub const STATUS_BAD_WORKING_SET_LIMIT: NTSTATUS = -1_073_741_748_i32; +pub const STATUS_BCD_NOT_ALL_ENTRIES_IMPORTED: NTSTATUS = -2_143_748_095_i32; +pub const STATUS_BCD_NOT_ALL_ENTRIES_SYNCHRONIZED: NTSTATUS = -2_143_748_093_i32; +pub const STATUS_BCD_TOO_MANY_ELEMENTS: NTSTATUS = -1_070_006_270_i32; +pub const STATUS_BEGINNING_OF_MEDIA: NTSTATUS = -2_147_483_617_i32; +pub const STATUS_BEYOND_VDL: NTSTATUS = -1_073_740_750_i32; +pub const STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT: NTSTATUS = -1_073_741_458_i32; +pub const STATUS_BIZRULES_NOT_ENABLED: NTSTATUS = 1_073_741_876_i32; +pub const STATUS_BLOCKED_BY_PARENTAL_CONTROLS: NTSTATUS = -1_073_740_664_i32; +pub const STATUS_BLOCK_SHARED: NTSTATUS = -1_073_739_499_i32; +pub const STATUS_BLOCK_SOURCE_WEAK_REFERENCE_INVALID: NTSTATUS = -1_073_739_501_i32; +pub const STATUS_BLOCK_TARGET_WEAK_REFERENCE_INVALID: NTSTATUS = -1_073_739_500_i32; +pub const STATUS_BLOCK_TOO_MANY_REFERENCES: NTSTATUS = -1_073_740_660_i32; +pub const STATUS_BLOCK_WEAK_REFERENCE_INVALID: NTSTATUS = -1_073_739_502_i32; +pub const STATUS_BREAKPOINT: NTSTATUS = -2_147_483_645_i32; +pub const STATUS_BTH_ATT_ATTRIBUTE_NOT_FOUND: NTSTATUS = -1_069_416_438_i32; +pub const STATUS_BTH_ATT_ATTRIBUTE_NOT_LONG: NTSTATUS = -1_069_416_437_i32; +pub const STATUS_BTH_ATT_INSUFFICIENT_AUTHENTICATION: NTSTATUS = -1_069_416_443_i32; +pub const STATUS_BTH_ATT_INSUFFICIENT_AUTHORIZATION: NTSTATUS = -1_069_416_440_i32; +pub const STATUS_BTH_ATT_INSUFFICIENT_ENCRYPTION: NTSTATUS = -1_069_416_433_i32; +pub const STATUS_BTH_ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE: NTSTATUS = -1_069_416_436_i32; +pub const STATUS_BTH_ATT_INSUFFICIENT_RESOURCES: NTSTATUS = -1_069_416_431_i32; +pub const STATUS_BTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH: NTSTATUS = -1_069_416_435_i32; +pub const STATUS_BTH_ATT_INVALID_HANDLE: NTSTATUS = -1_069_416_447_i32; +pub const STATUS_BTH_ATT_INVALID_OFFSET: NTSTATUS = -1_069_416_441_i32; +pub const STATUS_BTH_ATT_INVALID_PDU: NTSTATUS = -1_069_416_444_i32; +pub const STATUS_BTH_ATT_PREPARE_QUEUE_FULL: NTSTATUS = -1_069_416_439_i32; +pub const STATUS_BTH_ATT_READ_NOT_PERMITTED: NTSTATUS = -1_069_416_446_i32; +pub const STATUS_BTH_ATT_REQUEST_NOT_SUPPORTED: NTSTATUS = -1_069_416_442_i32; +pub const STATUS_BTH_ATT_UNKNOWN_ERROR: NTSTATUS = -1_069_412_352_i32; +pub const STATUS_BTH_ATT_UNLIKELY: NTSTATUS = -1_069_416_434_i32; +pub const STATUS_BTH_ATT_UNSUPPORTED_GROUP_TYPE: NTSTATUS = -1_069_416_432_i32; +pub const STATUS_BTH_ATT_WRITE_NOT_PERMITTED: NTSTATUS = -1_069_416_445_i32; +pub const STATUS_BUFFER_ALL_ZEROS: NTSTATUS = 279_i32; +pub const STATUS_BUFFER_OVERFLOW: NTSTATUS = -2_147_483_643_i32; +pub const STATUS_BUFFER_TOO_SMALL: NTSTATUS = -1_073_741_789_i32; +pub const STATUS_BUS_RESET: NTSTATUS = -2_147_483_619_i32; +pub const STATUS_BYPASSIO_FLT_NOT_SUPPORTED: NTSTATUS = -1_073_740_590_i32; +pub const STATUS_CACHE_PAGE_LOCKED: NTSTATUS = 277_i32; +pub const STATUS_CALLBACK_BYPASS: NTSTATUS = -1_073_740_541_i32; +pub const STATUS_CALLBACK_INVOKE_INLINE: NTSTATUS = -1_073_740_661_i32; +pub const STATUS_CALLBACK_POP_STACK: NTSTATUS = -1_073_740_765_i32; +pub const STATUS_CALLBACK_RETURNED_LANG: NTSTATUS = -1_073_740_001_i32; +pub const STATUS_CALLBACK_RETURNED_LDR_LOCK: NTSTATUS = -1_073_740_002_i32; +pub const STATUS_CALLBACK_RETURNED_PRI_BACK: NTSTATUS = -1_073_740_000_i32; +pub const STATUS_CALLBACK_RETURNED_THREAD_AFFINITY: NTSTATUS = -1_073_739_999_i32; +pub const STATUS_CALLBACK_RETURNED_THREAD_PRIORITY: NTSTATUS = -1_073_740_005_i32; +pub const STATUS_CALLBACK_RETURNED_TRANSACTION: NTSTATUS = -1_073_740_003_i32; +pub const STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING: NTSTATUS = -1_073_740_016_i32; +pub const STATUS_CANCELLED: NTSTATUS = -1_073_741_536_i32; +pub const STATUS_CANNOT_ABORT_TRANSACTIONS: NTSTATUS = -1_072_103_347_i32; +pub const STATUS_CANNOT_ACCEPT_TRANSACTED_WORK: NTSTATUS = -1_072_103_348_i32; +pub const STATUS_CANNOT_BREAK_OPLOCK: NTSTATUS = -1_073_739_511_i32; +pub const STATUS_CANNOT_DELETE: NTSTATUS = -1_073_741_535_i32; +pub const STATUS_CANNOT_EXECUTE_FILE_IN_TRANSACTION: NTSTATUS = -1_072_103_356_i32; +pub const STATUS_CANNOT_GRANT_REQUESTED_OPLOCK: NTSTATUS = -2_147_483_602_i32; +pub const STATUS_CANNOT_IMPERSONATE: NTSTATUS = -1_073_741_555_i32; +pub const STATUS_CANNOT_LOAD_REGISTRY_FILE: NTSTATUS = -1_073_741_288_i32; +pub const STATUS_CANNOT_MAKE: NTSTATUS = -1_073_741_078_i32; +pub const STATUS_CANNOT_SWITCH_RUNLEVEL: NTSTATUS = -1_073_700_543_i32; +pub const STATUS_CANT_ACCESS_DOMAIN_INFO: NTSTATUS = -1_073_741_606_i32; +pub const STATUS_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: NTSTATUS = -1_072_103_369_i32; +pub const STATUS_CANT_CLEAR_ENCRYPTION_FLAG: NTSTATUS = -1_073_740_616_i32; +pub const STATUS_CANT_CREATE_MORE_STREAM_MINIVERSIONS: NTSTATUS = -1_072_103_386_i32; +pub const STATUS_CANT_CROSS_RM_BOUNDARY: NTSTATUS = -1_072_103_368_i32; +pub const STATUS_CANT_DISABLE_MANDATORY: NTSTATUS = -1_073_741_731_i32; +pub const STATUS_CANT_ENABLE_DENY_ONLY: NTSTATUS = -1_073_741_133_i32; +pub const STATUS_CANT_OPEN_ANONYMOUS: NTSTATUS = -1_073_741_658_i32; +pub const STATUS_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: NTSTATUS = -1_072_103_387_i32; +pub const STATUS_CANT_RECOVER_WITH_HANDLE_OPEN: NTSTATUS = -2_145_845_199_i32; +pub const STATUS_CANT_TERMINATE_SELF: NTSTATUS = -1_073_741_605_i32; +pub const STATUS_CANT_WAIT: NTSTATUS = -1_073_741_608_i32; +pub const STATUS_CARDBUS_NOT_SUPPORTED: NTSTATUS = 1_073_741_863_i32; +pub const STATUS_CASE_DIFFERING_NAMES_IN_DIR: NTSTATUS = -1_073_740_621_i32; +pub const STATUS_CASE_SENSITIVE_PATH: NTSTATUS = -1_073_740_614_i32; +pub const STATUS_CC_NEEDS_CALLBACK_SECTION_DRAIN: NTSTATUS = -1_073_700_856_i32; +pub const STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE: NTSTATUS = -1_073_740_012_i32; +pub const STATUS_CERTIFICATE_VALIDATION_PREFERENCE_CONFLICT: NTSTATUS = -1_073_741_387_i32; +pub const STATUS_CHECKING_FILE_SYSTEM: NTSTATUS = 1_073_741_844_i32; +pub const STATUS_CHECKOUT_REQUIRED: NTSTATUS = -1_073_739_518_i32; +pub const STATUS_CHILD_MUST_BE_VOLATILE: NTSTATUS = -1_073_741_439_i32; +pub const STATUS_CHILD_PROCESS_BLOCKED: NTSTATUS = -1_073_740_643_i32; +pub const STATUS_CIMFS_IMAGE_CORRUPT: NTSTATUS = -1_073_692_671_i32; +pub const STATUS_CIMFS_IMAGE_VERSION_NOT_SUPPORTED: NTSTATUS = -1_073_692_670_i32; +pub const STATUS_CLEANER_CARTRIDGE_INSTALLED: NTSTATUS = -2_147_483_609_i32; +pub const STATUS_CLIENT_SERVER_PARAMETERS_INVALID: NTSTATUS = -1_073_741_277_i32; +pub const STATUS_CLIP_DEVICE_LICENSE_MISSING: NTSTATUS = -1_058_406_397_i32; +pub const STATUS_CLIP_KEYHOLDER_LICENSE_MISSING_OR_INVALID: NTSTATUS = -1_058_406_395_i32; +pub const STATUS_CLIP_LICENSE_DEVICE_ID_MISMATCH: NTSTATUS = -1_058_406_390_i32; +pub const STATUS_CLIP_LICENSE_EXPIRED: NTSTATUS = -1_058_406_394_i32; +pub const STATUS_CLIP_LICENSE_HARDWARE_ID_OUT_OF_TOLERANCE: NTSTATUS = -1_058_406_391_i32; +pub const STATUS_CLIP_LICENSE_INVALID_SIGNATURE: NTSTATUS = -1_058_406_396_i32; +pub const STATUS_CLIP_LICENSE_NOT_FOUND: NTSTATUS = -1_058_406_398_i32; +pub const STATUS_CLIP_LICENSE_NOT_SIGNED: NTSTATUS = -1_058_406_392_i32; +pub const STATUS_CLIP_LICENSE_SIGNED_BY_UNKNOWN_SOURCE: NTSTATUS = -1_058_406_393_i32; +pub const STATUS_CLOUD_FILE_ACCESS_DENIED: NTSTATUS = -1_073_688_808_i32; +pub const STATUS_CLOUD_FILE_ALREADY_CONNECTED: NTSTATUS = -1_073_688_823_i32; +pub const STATUS_CLOUD_FILE_AUTHENTICATION_FAILED: NTSTATUS = -1_073_688_817_i32; +pub const STATUS_CLOUD_FILE_CONNECTED_PROVIDER_ONLY: NTSTATUS = -1_073_688_819_i32; +pub const STATUS_CLOUD_FILE_DEHYDRATION_DISALLOWED: NTSTATUS = -1_073_688_800_i32; +pub const STATUS_CLOUD_FILE_INCOMPATIBLE_HARDLINKS: NTSTATUS = -1_073_688_807_i32; +pub const STATUS_CLOUD_FILE_INSUFFICIENT_RESOURCES: NTSTATUS = -1_073_688_816_i32; +pub const STATUS_CLOUD_FILE_INVALID_REQUEST: NTSTATUS = -1_073_688_821_i32; +pub const STATUS_CLOUD_FILE_IN_USE: NTSTATUS = -1_073_688_812_i32; +pub const STATUS_CLOUD_FILE_METADATA_CORRUPT: NTSTATUS = -1_073_688_830_i32; +pub const STATUS_CLOUD_FILE_METADATA_TOO_LARGE: NTSTATUS = -1_073_688_829_i32; +pub const STATUS_CLOUD_FILE_NETWORK_UNAVAILABLE: NTSTATUS = -1_073_688_815_i32; +pub const STATUS_CLOUD_FILE_NOT_IN_SYNC: NTSTATUS = -1_073_688_824_i32; +pub const STATUS_CLOUD_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_688_822_i32; +pub const STATUS_CLOUD_FILE_NOT_UNDER_SYNC_ROOT: NTSTATUS = -1_073_688_813_i32; +pub const STATUS_CLOUD_FILE_PINNED: NTSTATUS = -1_073_688_811_i32; +pub const STATUS_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH: NTSTATUS = -2_147_430_656_i32; +pub const STATUS_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE: NTSTATUS = -2_147_430_652_i32; +pub const STATUS_CLOUD_FILE_PROPERTY_CORRUPT: NTSTATUS = -1_073_688_809_i32; +pub const STATUS_CLOUD_FILE_PROPERTY_LOCK_CONFLICT: NTSTATUS = -1_073_688_806_i32; +pub const STATUS_CLOUD_FILE_PROPERTY_VERSION_NOT_SUPPORTED: NTSTATUS = -1_073_688_826_i32; +pub const STATUS_CLOUD_FILE_PROVIDER_NOT_RUNNING: NTSTATUS = -1_073_688_831_i32; +pub const STATUS_CLOUD_FILE_PROVIDER_TERMINATED: NTSTATUS = -1_073_688_803_i32; +pub const STATUS_CLOUD_FILE_READ_ONLY_VOLUME: NTSTATUS = -1_073_688_820_i32; +pub const STATUS_CLOUD_FILE_REQUEST_ABORTED: NTSTATUS = -1_073_688_810_i32; +pub const STATUS_CLOUD_FILE_REQUEST_CANCELED: NTSTATUS = -1_073_688_805_i32; +pub const STATUS_CLOUD_FILE_REQUEST_TIMEOUT: NTSTATUS = -1_073_688_801_i32; +pub const STATUS_CLOUD_FILE_SYNC_ROOT_METADATA_CORRUPT: NTSTATUS = -1_073_688_832_i32; +pub const STATUS_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS: NTSTATUS = -2_147_430_651_i32; +pub const STATUS_CLOUD_FILE_UNSUCCESSFUL: NTSTATUS = -1_073_688_814_i32; +pub const STATUS_CLOUD_FILE_US_MESSAGE_TIMEOUT: NTSTATUS = -1_073_688_799_i32; +pub const STATUS_CLOUD_FILE_VALIDATION_FAILED: NTSTATUS = -1_073_688_818_i32; +pub const STATUS_CLUSTER_CAM_TICKET_REPLAY_DETECTED: NTSTATUS = -1_072_496_591_i32; +pub const STATUS_CLUSTER_CSV_AUTO_PAUSE_ERROR: NTSTATUS = -1_072_496_607_i32; +pub const STATUS_CLUSTER_CSV_INVALID_HANDLE: NTSTATUS = -1_072_496_599_i32; +pub const STATUS_CLUSTER_CSV_NOT_REDIRECTED: NTSTATUS = -1_072_496_605_i32; +pub const STATUS_CLUSTER_CSV_NO_SNAPSHOTS: NTSTATUS = -1_072_496_601_i32; +pub const STATUS_CLUSTER_CSV_READ_OPLOCK_BREAK_IN_PROGRESS: NTSTATUS = -1_072_496_608_i32; +pub const STATUS_CLUSTER_CSV_REDIRECTED: NTSTATUS = -1_072_496_606_i32; +pub const STATUS_CLUSTER_CSV_SNAPSHOT_CREATION_IN_PROGRESS: NTSTATUS = -1_072_496_603_i32; +pub const STATUS_CLUSTER_CSV_SUPPORTED_ONLY_ON_COORDINATOR: NTSTATUS = -1_072_496_592_i32; +pub const STATUS_CLUSTER_CSV_VOLUME_DRAINING: NTSTATUS = -1_072_496_604_i32; +pub const STATUS_CLUSTER_CSV_VOLUME_DRAINING_SUCCEEDED_DOWNLEVEL: NTSTATUS = -1_072_496_602_i32; +pub const STATUS_CLUSTER_CSV_VOLUME_NOT_LOCAL: NTSTATUS = -1_072_496_615_i32; +pub const STATUS_CLUSTER_INVALID_NETWORK: NTSTATUS = -1_072_496_624_i32; +pub const STATUS_CLUSTER_INVALID_NETWORK_PROVIDER: NTSTATUS = -1_072_496_629_i32; +pub const STATUS_CLUSTER_INVALID_NODE: NTSTATUS = -1_072_496_639_i32; +pub const STATUS_CLUSTER_INVALID_REQUEST: NTSTATUS = -1_072_496_630_i32; +pub const STATUS_CLUSTER_JOIN_IN_PROGRESS: NTSTATUS = -1_072_496_637_i32; +pub const STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS: NTSTATUS = -1_072_496_625_i32; +pub const STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND: NTSTATUS = -1_072_496_635_i32; +pub const STATUS_CLUSTER_NETINTERFACE_EXISTS: NTSTATUS = -1_072_496_632_i32; +pub const STATUS_CLUSTER_NETINTERFACE_NOT_FOUND: NTSTATUS = -1_072_496_631_i32; +pub const STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE: NTSTATUS = -2_146_238_460_i32; +pub const STATUS_CLUSTER_NETWORK_ALREADY_ONLINE: NTSTATUS = -2_146_238_461_i32; +pub const STATUS_CLUSTER_NETWORK_EXISTS: NTSTATUS = -1_072_496_634_i32; +pub const STATUS_CLUSTER_NETWORK_NOT_FOUND: NTSTATUS = -1_072_496_633_i32; +pub const STATUS_CLUSTER_NETWORK_NOT_INTERNAL: NTSTATUS = -1_072_496_618_i32; +pub const STATUS_CLUSTER_NODE_ALREADY_DOWN: NTSTATUS = -2_146_238_462_i32; +pub const STATUS_CLUSTER_NODE_ALREADY_MEMBER: NTSTATUS = -2_146_238_459_i32; +pub const STATUS_CLUSTER_NODE_ALREADY_UP: NTSTATUS = -2_146_238_463_i32; +pub const STATUS_CLUSTER_NODE_DOWN: NTSTATUS = -1_072_496_628_i32; +pub const STATUS_CLUSTER_NODE_EXISTS: NTSTATUS = -1_072_496_638_i32; +pub const STATUS_CLUSTER_NODE_NOT_FOUND: NTSTATUS = -1_072_496_636_i32; +pub const STATUS_CLUSTER_NODE_NOT_MEMBER: NTSTATUS = -1_072_496_626_i32; +pub const STATUS_CLUSTER_NODE_NOT_PAUSED: NTSTATUS = -1_072_496_620_i32; +pub const STATUS_CLUSTER_NODE_PAUSED: NTSTATUS = -1_072_496_621_i32; +pub const STATUS_CLUSTER_NODE_UNREACHABLE: NTSTATUS = -1_072_496_627_i32; +pub const STATUS_CLUSTER_NODE_UP: NTSTATUS = -1_072_496_622_i32; +pub const STATUS_CLUSTER_NON_CSV_PATH: NTSTATUS = -1_072_496_616_i32; +pub const STATUS_CLUSTER_NO_NET_ADAPTERS: NTSTATUS = -1_072_496_623_i32; +pub const STATUS_CLUSTER_NO_SECURITY_CONTEXT: NTSTATUS = -1_072_496_619_i32; +pub const STATUS_CLUSTER_POISONED: NTSTATUS = -1_072_496_617_i32; +pub const STATUS_COMMITMENT_LIMIT: NTSTATUS = -1_073_741_523_i32; +pub const STATUS_COMMITMENT_MINIMUM: NTSTATUS = -1_073_741_112_i32; +pub const STATUS_COMPRESSED_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_740_677_i32; +pub const STATUS_COMPRESSION_DISABLED: NTSTATUS = -1_073_740_762_i32; +pub const STATUS_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: NTSTATUS = -1_072_103_338_i32; +pub const STATUS_COMPRESSION_NOT_BENEFICIAL: NTSTATUS = -1_073_740_689_i32; +pub const STATUS_CONFLICTING_ADDRESSES: NTSTATUS = -1_073_741_800_i32; +pub const STATUS_CONNECTION_ABORTED: NTSTATUS = -1_073_741_247_i32; +pub const STATUS_CONNECTION_ACTIVE: NTSTATUS = -1_073_741_253_i32; +pub const STATUS_CONNECTION_COUNT_LIMIT: NTSTATUS = -1_073_741_242_i32; +pub const STATUS_CONNECTION_DISCONNECTED: NTSTATUS = -1_073_741_300_i32; +pub const STATUS_CONNECTION_INVALID: NTSTATUS = -1_073_741_254_i32; +pub const STATUS_CONNECTION_IN_USE: NTSTATUS = -1_073_741_560_i32; +pub const STATUS_CONNECTION_REFUSED: NTSTATUS = -1_073_741_258_i32; +pub const STATUS_CONNECTION_RESET: NTSTATUS = -1_073_741_299_i32; +pub const STATUS_CONTAINER_ASSIGNED: NTSTATUS = -1_073_740_536_i32; +pub const STATUS_CONTENT_BLOCKED: NTSTATUS = -1_073_739_772_i32; +pub const STATUS_CONTEXT_MISMATCH: NTSTATUS = -1_073_740_007_i32; +pub const STATUS_CONTEXT_STOWED_EXCEPTION: NTSTATUS = -1_073_741_188_i32; +pub const STATUS_CONTROL_C_EXIT: NTSTATUS = -1_073_741_510_i32; +pub const STATUS_CONTROL_STACK_VIOLATION: NTSTATUS = -1_073_741_390_i32; +pub const STATUS_CONVERT_TO_LARGE: NTSTATUS = -1_073_741_268_i32; +pub const STATUS_COPY_PROTECTION_FAILURE: NTSTATUS = -1_073_741_051_i32; +pub const STATUS_CORRUPT_LOG_CLEARED: NTSTATUS = -1_073_739_763_i32; +pub const STATUS_CORRUPT_LOG_CORRUPTED: NTSTATUS = -1_073_739_766_i32; +pub const STATUS_CORRUPT_LOG_DELETED_FULL: NTSTATUS = -1_073_739_764_i32; +pub const STATUS_CORRUPT_LOG_OVERFULL: NTSTATUS = -1_073_739_767_i32; +pub const STATUS_CORRUPT_LOG_UNAVAILABLE: NTSTATUS = -1_073_739_765_i32; +pub const STATUS_CORRUPT_LOG_UPLEVEL_RECORDS: NTSTATUS = -1_073_739_759_i32; +pub const STATUS_CORRUPT_SYSTEM_FILE: NTSTATUS = -1_073_741_116_i32; +pub const STATUS_COULD_NOT_INTERPRET: NTSTATUS = -1_073_741_639_i32; +pub const STATUS_COULD_NOT_RESIZE_LOG: NTSTATUS = -2_145_845_239_i32; +pub const STATUS_CPU_SET_INVALID: NTSTATUS = -1_073_741_393_i32; +pub const STATUS_CRASH_DUMP: NTSTATUS = 278_i32; +pub const STATUS_CRC_ERROR: NTSTATUS = -1_073_741_761_i32; +pub const STATUS_CRED_REQUIRES_CONFIRMATION: NTSTATUS = -1_073_740_736_i32; +pub const STATUS_CRM_PROTOCOL_ALREADY_EXISTS: NTSTATUS = -1_072_103_409_i32; +pub const STATUS_CRM_PROTOCOL_NOT_FOUND: NTSTATUS = -1_072_103_407_i32; +pub const STATUS_CROSSREALM_DELEGATION_FAILURE: NTSTATUS = -1_073_740_789_i32; +pub const STATUS_CROSS_PARTITION_VIOLATION: NTSTATUS = -1_073_740_277_i32; +pub const STATUS_CRYPTO_SYSTEM_INVALID: NTSTATUS = -1_073_741_069_i32; +pub const STATUS_CSS_AUTHENTICATION_FAILURE: NTSTATUS = -1_073_741_050_i32; +pub const STATUS_CSS_KEY_NOT_ESTABLISHED: NTSTATUS = -1_073_741_048_i32; +pub const STATUS_CSS_KEY_NOT_PRESENT: NTSTATUS = -1_073_741_049_i32; +pub const STATUS_CSS_REGION_MISMATCH: NTSTATUS = -1_073_741_046_i32; +pub const STATUS_CSS_RESETS_EXHAUSTED: NTSTATUS = -1_073_741_045_i32; +pub const STATUS_CSS_SCRAMBLED_SECTOR: NTSTATUS = -1_073_741_047_i32; +pub const STATUS_CSV_IO_PAUSE_TIMEOUT: NTSTATUS = -1_072_496_600_i32; +pub const STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: NTSTATUS = -1_073_740_733_i32; +pub const STATUS_CS_ENCRYPTION_FILE_NOT_CSE: NTSTATUS = -1_073_740_731_i32; +pub const STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: NTSTATUS = -1_073_740_735_i32; +pub const STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: NTSTATUS = -1_073_740_732_i32; +pub const STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER: NTSTATUS = -1_073_740_734_i32; +pub const STATUS_CTLOG_INCONSISTENT_TRACKING_FILE: NTSTATUS = -1_069_940_700_i32; +pub const STATUS_CTLOG_INVALID_TRACKING_STATE: NTSTATUS = -1_069_940_701_i32; +pub const STATUS_CTLOG_LOGFILE_SIZE_EXCEEDED_MAXSIZE: NTSTATUS = -1_069_940_703_i32; +pub const STATUS_CTLOG_TRACKING_NOT_INITIALIZED: NTSTATUS = -1_069_940_704_i32; +pub const STATUS_CTLOG_VHD_CHANGED_OFFLINE: NTSTATUS = -1_069_940_702_i32; +pub const STATUS_CTL_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_741_737_i32; +pub const STATUS_CTX_BAD_VIDEO_MODE: NTSTATUS = -1_073_086_440_i32; +pub const STATUS_CTX_CDM_CONNECT: NTSTATUS = 1_074_397_188_i32; +pub const STATUS_CTX_CDM_DISCONNECT: NTSTATUS = 1_074_397_189_i32; +pub const STATUS_CTX_CLIENT_LICENSE_IN_USE: NTSTATUS = -1_073_086_412_i32; +pub const STATUS_CTX_CLIENT_LICENSE_NOT_SET: NTSTATUS = -1_073_086_413_i32; +pub const STATUS_CTX_CLIENT_QUERY_TIMEOUT: NTSTATUS = -1_073_086_426_i32; +pub const STATUS_CTX_CLOSE_PENDING: NTSTATUS = -1_073_086_458_i32; +pub const STATUS_CTX_CONSOLE_CONNECT: NTSTATUS = -1_073_086_424_i32; +pub const STATUS_CTX_CONSOLE_DISCONNECT: NTSTATUS = -1_073_086_425_i32; +pub const STATUS_CTX_GRAPHICS_INVALID: NTSTATUS = -1_073_086_430_i32; +pub const STATUS_CTX_INVALID_MODEMNAME: NTSTATUS = -1_073_086_455_i32; +pub const STATUS_CTX_INVALID_PD: NTSTATUS = -1_073_086_462_i32; +pub const STATUS_CTX_INVALID_WD: NTSTATUS = -1_073_086_418_i32; +pub const STATUS_CTX_LICENSE_CLIENT_INVALID: NTSTATUS = -1_073_086_446_i32; +pub const STATUS_CTX_LICENSE_EXPIRED: NTSTATUS = -1_073_086_444_i32; +pub const STATUS_CTX_LICENSE_NOT_AVAILABLE: NTSTATUS = -1_073_086_445_i32; +pub const STATUS_CTX_LOGON_DISABLED: NTSTATUS = -1_073_086_409_i32; +pub const STATUS_CTX_MODEM_INF_NOT_FOUND: NTSTATUS = -1_073_086_456_i32; +pub const STATUS_CTX_MODEM_RESPONSE_BUSY: NTSTATUS = -1_073_086_450_i32; +pub const STATUS_CTX_MODEM_RESPONSE_NO_CARRIER: NTSTATUS = -1_073_086_452_i32; +pub const STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE: NTSTATUS = -1_073_086_451_i32; +pub const STATUS_CTX_MODEM_RESPONSE_TIMEOUT: NTSTATUS = -1_073_086_453_i32; +pub const STATUS_CTX_MODEM_RESPONSE_VOICE: NTSTATUS = -1_073_086_449_i32; +pub const STATUS_CTX_NOT_CONSOLE: NTSTATUS = -1_073_086_428_i32; +pub const STATUS_CTX_NO_OUTBUF: NTSTATUS = -1_073_086_457_i32; +pub const STATUS_CTX_PD_NOT_FOUND: NTSTATUS = -1_073_086_461_i32; +pub const STATUS_CTX_RESPONSE_ERROR: NTSTATUS = -1_073_086_454_i32; +pub const STATUS_CTX_SECURITY_LAYER_ERROR: NTSTATUS = -1_073_086_408_i32; +pub const STATUS_CTX_SHADOW_DENIED: NTSTATUS = -1_073_086_422_i32; +pub const STATUS_CTX_SHADOW_DISABLED: NTSTATUS = -1_073_086_415_i32; +pub const STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE: NTSTATUS = -1_073_086_411_i32; +pub const STATUS_CTX_SHADOW_INVALID: NTSTATUS = -1_073_086_416_i32; +pub const STATUS_CTX_SHADOW_NOT_RUNNING: NTSTATUS = -1_073_086_410_i32; +pub const STATUS_CTX_TD_ERROR: NTSTATUS = -1_073_086_448_i32; +pub const STATUS_CTX_WD_NOT_FOUND: NTSTATUS = -1_073_086_417_i32; +pub const STATUS_CTX_WINSTATION_ACCESS_DENIED: NTSTATUS = -1_073_086_421_i32; +pub const STATUS_CTX_WINSTATION_BUSY: NTSTATUS = -1_073_086_441_i32; +pub const STATUS_CTX_WINSTATION_NAME_COLLISION: NTSTATUS = -1_073_086_442_i32; +pub const STATUS_CTX_WINSTATION_NAME_INVALID: NTSTATUS = -1_073_086_463_i32; +pub const STATUS_CTX_WINSTATION_NOT_FOUND: NTSTATUS = -1_073_086_443_i32; +pub const STATUS_CURRENT_DOMAIN_NOT_ALLOWED: NTSTATUS = -1_073_741_079_i32; +pub const STATUS_CURRENT_TRANSACTION_NOT_VALID: NTSTATUS = -1_072_103_400_i32; +pub const STATUS_DATATYPE_MISALIGNMENT: NTSTATUS = -2_147_483_646_i32; +pub const STATUS_DATATYPE_MISALIGNMENT_ERROR: NTSTATUS = -1_073_741_115_i32; +pub const STATUS_DATA_CHECKSUM_ERROR: NTSTATUS = -1_073_740_688_i32; +pub const STATUS_DATA_ERROR: NTSTATUS = -1_073_741_762_i32; +pub const STATUS_DATA_LATE_ERROR: NTSTATUS = -1_073_741_763_i32; +pub const STATUS_DATA_LOST_REPAIR: NTSTATUS = -2_147_481_597_i32; +pub const STATUS_DATA_NOT_ACCEPTED: NTSTATUS = -1_073_741_285_i32; +pub const STATUS_DATA_OVERRUN: NTSTATUS = -1_073_741_764_i32; +pub const STATUS_DATA_OVERWRITTEN: NTSTATUS = 304_i32; +pub const STATUS_DAX_MAPPING_EXISTS: NTSTATUS = -1_073_740_644_i32; +pub const STATUS_DEBUGGER_INACTIVE: NTSTATUS = -1_073_740_972_i32; +pub const STATUS_DEBUG_ATTACH_FAILED: NTSTATUS = -1_073_741_287_i32; +pub const STATUS_DECRYPTION_FAILED: NTSTATUS = -1_073_741_173_i32; +pub const STATUS_DELAY_LOAD_FAILED: NTSTATUS = -1_073_740_782_i32; +pub const STATUS_DELETE_PENDING: NTSTATUS = -1_073_741_738_i32; +pub const STATUS_DESTINATION_ELEMENT_FULL: NTSTATUS = -1_073_741_180_i32; +pub const STATUS_DEVICE_ALREADY_ATTACHED: NTSTATUS = -1_073_741_768_i32; +pub const STATUS_DEVICE_BUSY: NTSTATUS = -2_147_483_631_i32; +pub const STATUS_DEVICE_CONFIGURATION_ERROR: NTSTATUS = -1_073_741_438_i32; +pub const STATUS_DEVICE_DATA_ERROR: NTSTATUS = -1_073_741_668_i32; +pub const STATUS_DEVICE_DOES_NOT_EXIST: NTSTATUS = -1_073_741_632_i32; +pub const STATUS_DEVICE_DOOR_OPEN: NTSTATUS = -2_147_482_999_i32; +pub const STATUS_DEVICE_ENUMERATION_ERROR: NTSTATUS = -1_073_740_954_i32; +pub const STATUS_DEVICE_FEATURE_NOT_SUPPORTED: NTSTATUS = -1_073_740_701_i32; +pub const STATUS_DEVICE_HARDWARE_ERROR: NTSTATUS = -1_073_740_669_i32; +pub const STATUS_DEVICE_HINT_NAME_BUFFER_TOO_SMALL: NTSTATUS = -1_073_740_650_i32; +pub const STATUS_DEVICE_HUNG: NTSTATUS = -1_073_740_537_i32; +pub const STATUS_DEVICE_INSUFFICIENT_RESOURCES: NTSTATUS = -1_073_740_696_i32; +pub const STATUS_DEVICE_IN_MAINTENANCE: NTSTATUS = -1_073_740_647_i32; +pub const STATUS_DEVICE_NOT_CONNECTED: NTSTATUS = -1_073_741_667_i32; +pub const STATUS_DEVICE_NOT_PARTITIONED: NTSTATUS = -1_073_741_452_i32; +pub const STATUS_DEVICE_NOT_READY: NTSTATUS = -1_073_741_661_i32; +pub const STATUS_DEVICE_OFF_LINE: NTSTATUS = -2_147_483_632_i32; +pub const STATUS_DEVICE_PAPER_EMPTY: NTSTATUS = -2_147_483_634_i32; +pub const STATUS_DEVICE_POWERED_OFF: NTSTATUS = -2_147_483_633_i32; +pub const STATUS_DEVICE_POWER_CYCLE_REQUIRED: NTSTATUS = -2_147_483_599_i32; +pub const STATUS_DEVICE_POWER_FAILURE: NTSTATUS = -1_073_741_666_i32; +pub const STATUS_DEVICE_PROTOCOL_ERROR: NTSTATUS = -1_073_741_434_i32; +pub const STATUS_DEVICE_REMOVED: NTSTATUS = -1_073_741_130_i32; +pub const STATUS_DEVICE_REQUIRES_CLEANING: NTSTATUS = -2_147_483_000_i32; +pub const STATUS_DEVICE_RESET_REQUIRED: NTSTATUS = -2_147_483_210_i32; +pub const STATUS_DEVICE_SUPPORT_IN_PROGRESS: NTSTATUS = -2_147_483_600_i32; +pub const STATUS_DEVICE_UNREACHABLE: NTSTATUS = -1_073_740_700_i32; +pub const STATUS_DEVICE_UNRESPONSIVE: NTSTATUS = -1_073_740_534_i32; +pub const STATUS_DFS_EXIT_PATH_FOUND: NTSTATUS = -1_073_741_669_i32; +pub const STATUS_DFS_UNAVAILABLE: NTSTATUS = -1_073_741_203_i32; +pub const STATUS_DIF_BINDING_API_NOT_FOUND: NTSTATUS = -1_073_738_625_i32; +pub const STATUS_DIF_IOCALLBACK_NOT_REPLACED: NTSTATUS = -1_073_738_634_i32; +pub const STATUS_DIF_LIVEDUMP_LIMIT_EXCEEDED: NTSTATUS = -1_073_738_633_i32; +pub const STATUS_DIF_VOLATILE_DRIVER_HOTPATCHED: NTSTATUS = -1_073_738_631_i32; +pub const STATUS_DIF_VOLATILE_DRIVER_IS_NOT_RUNNING: NTSTATUS = -1_073_738_629_i32; +pub const STATUS_DIF_VOLATILE_INVALID_INFO: NTSTATUS = -1_073_738_630_i32; +pub const STATUS_DIF_VOLATILE_NOT_ALLOWED: NTSTATUS = -1_073_738_626_i32; +pub const STATUS_DIF_VOLATILE_PLUGIN_CHANGE_NOT_ALLOWED: NTSTATUS = -1_073_738_627_i32; +pub const STATUS_DIF_VOLATILE_PLUGIN_IS_NOT_RUNNING: NTSTATUS = -1_073_738_628_i32; +pub const STATUS_DIF_VOLATILE_SECTION_NOT_LOCKED: NTSTATUS = -1_073_738_632_i32; +pub const STATUS_DIRECTORY_IS_A_REPARSE_POINT: NTSTATUS = -1_073_741_183_i32; +pub const STATUS_DIRECTORY_NOT_EMPTY: NTSTATUS = -1_073_741_567_i32; +pub const STATUS_DIRECTORY_NOT_RM: NTSTATUS = -1_072_103_416_i32; +pub const STATUS_DIRECTORY_NOT_SUPPORTED: NTSTATUS = -1_073_740_676_i32; +pub const STATUS_DIRECTORY_SERVICE_REQUIRED: NTSTATUS = -1_073_741_135_i32; +pub const STATUS_DISK_CORRUPT_ERROR: NTSTATUS = -1_073_741_774_i32; +pub const STATUS_DISK_FULL: NTSTATUS = -1_073_741_697_i32; +pub const STATUS_DISK_OPERATION_FAILED: NTSTATUS = -1_073_741_462_i32; +pub const STATUS_DISK_QUOTA_EXCEEDED: NTSTATUS = -1_073_739_774_i32; +pub const STATUS_DISK_RECALIBRATE_FAILED: NTSTATUS = -1_073_741_463_i32; +pub const STATUS_DISK_REPAIR_DISABLED: NTSTATUS = -1_073_739_776_i32; +pub const STATUS_DISK_REPAIR_REDIRECTED: NTSTATUS = 1_073_743_879_i32; +pub const STATUS_DISK_REPAIR_UNSUCCESSFUL: NTSTATUS = -1_073_739_768_i32; +pub const STATUS_DISK_RESET_FAILED: NTSTATUS = -1_073_741_461_i32; +pub const STATUS_DISK_RESOURCES_EXHAUSTED: NTSTATUS = -1_073_740_703_i32; +pub const STATUS_DLL_INIT_FAILED: NTSTATUS = -1_073_741_502_i32; +pub const STATUS_DLL_INIT_FAILED_LOGOFF: NTSTATUS = -1_073_741_205_i32; +pub const STATUS_DLL_MIGHT_BE_INCOMPATIBLE: NTSTATUS = -2_147_483_604_i32; +pub const STATUS_DLL_MIGHT_BE_INSECURE: NTSTATUS = -2_147_483_605_i32; +pub const STATUS_DLL_NOT_FOUND: NTSTATUS = -1_073_741_515_i32; +pub const STATUS_DM_OPERATION_LIMIT_EXCEEDED: NTSTATUS = -1_070_135_808_i32; +pub const STATUS_DOMAIN_CONTROLLER_NOT_FOUND: NTSTATUS = -1_073_741_261_i32; +pub const STATUS_DOMAIN_CTRLR_CONFIG_ERROR: NTSTATUS = -1_073_741_474_i32; +pub const STATUS_DOMAIN_EXISTS: NTSTATUS = -1_073_741_600_i32; +pub const STATUS_DOMAIN_LIMIT_EXCEEDED: NTSTATUS = -1_073_741_599_i32; +pub const STATUS_DOMAIN_TRUST_INCONSISTENT: NTSTATUS = -1_073_741_413_i32; +pub const STATUS_DRIVERS_LEAKING_LOCKED_PAGES: NTSTATUS = 1_073_741_869_i32; +pub const STATUS_DRIVER_BLOCKED: NTSTATUS = -1_073_740_948_i32; +pub const STATUS_DRIVER_BLOCKED_CRITICAL: NTSTATUS = -1_073_740_949_i32; +pub const STATUS_DRIVER_CANCEL_TIMEOUT: NTSTATUS = -1_073_741_282_i32; +pub const STATUS_DRIVER_DATABASE_ERROR: NTSTATUS = -1_073_740_947_i32; +pub const STATUS_DRIVER_ENTRYPOINT_NOT_FOUND: NTSTATUS = -1_073_741_213_i32; +pub const STATUS_DRIVER_FAILED_PRIOR_UNLOAD: NTSTATUS = -1_073_740_914_i32; +pub const STATUS_DRIVER_FAILED_SLEEP: NTSTATUS = -1_073_741_118_i32; +pub const STATUS_DRIVER_INTERNAL_ERROR: NTSTATUS = -1_073_741_437_i32; +pub const STATUS_DRIVER_ORDINAL_NOT_FOUND: NTSTATUS = -1_073_741_214_i32; +pub const STATUS_DRIVER_PROCESS_TERMINATED: NTSTATUS = -1_073_740_720_i32; +pub const STATUS_DRIVER_UNABLE_TO_LOAD: NTSTATUS = -1_073_741_204_i32; +pub const STATUS_DS_ADMIN_LIMIT_EXCEEDED: NTSTATUS = -1_073_741_119_i32; +pub const STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: NTSTATUS = -1_073_740_968_i32; +pub const STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS: NTSTATUS = -1_073_741_148_i32; +pub const STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED: NTSTATUS = -1_073_741_149_i32; +pub const STATUS_DS_BUSY: NTSTATUS = -1_073_741_147_i32; +pub const STATUS_DS_CANT_MOD_OBJ_CLASS: NTSTATUS = -1_073_741_138_i32; +pub const STATUS_DS_CANT_MOD_PRIMARYGROUPID: NTSTATUS = -1_073_741_104_i32; +pub const STATUS_DS_CANT_ON_NON_LEAF: NTSTATUS = -1_073_741_140_i32; +pub const STATUS_DS_CANT_ON_RDN: NTSTATUS = -1_073_741_139_i32; +pub const STATUS_DS_CANT_START: NTSTATUS = -1_073_741_087_i32; +pub const STATUS_DS_CROSS_DOM_MOVE_FAILED: NTSTATUS = -1_073_741_137_i32; +pub const STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST: NTSTATUS = -1_073_740_774_i32; +pub const STATUS_DS_DOMAIN_RENAME_IN_PROGRESS: NTSTATUS = -1_073_739_775_i32; +pub const STATUS_DS_DUPLICATE_ID_FOUND: NTSTATUS = -1_073_740_795_i32; +pub const STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST: NTSTATUS = -1_073_740_773_i32; +pub const STATUS_DS_GC_NOT_AVAILABLE: NTSTATUS = -1_073_741_136_i32; +pub const STATUS_DS_GC_REQUIRED: NTSTATUS = -1_073_741_084_i32; +pub const STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: NTSTATUS = -1_073_741_094_i32; +pub const STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: NTSTATUS = -1_073_741_097_i32; +pub const STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: NTSTATUS = -1_073_741_096_i32; +pub const STATUS_DS_GROUP_CONVERSION_ERROR: NTSTATUS = -1_073_740_794_i32; +pub const STATUS_DS_HAVE_PRIMARY_MEMBERS: NTSTATUS = -1_073_741_092_i32; +pub const STATUS_DS_INCORRECT_ROLE_OWNER: NTSTATUS = -1_073_741_143_i32; +pub const STATUS_DS_INIT_FAILURE: NTSTATUS = -1_073_741_086_i32; +pub const STATUS_DS_INIT_FAILURE_CONSOLE: NTSTATUS = -1_073_741_076_i32; +pub const STATUS_DS_INVALID_ATTRIBUTE_SYNTAX: NTSTATUS = -1_073_741_150_i32; +pub const STATUS_DS_INVALID_GROUP_TYPE: NTSTATUS = -1_073_741_100_i32; +pub const STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: NTSTATUS = -1_073_741_093_i32; +pub const STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: NTSTATUS = -1_073_741_083_i32; +pub const STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: NTSTATUS = -1_073_741_081_i32; +pub const STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY: NTSTATUS = 289_i32; +pub const STATUS_DS_NAME_NOT_UNIQUE: NTSTATUS = -1_073_740_796_i32; +pub const STATUS_DS_NO_ATTRIBUTE_OR_VALUE: NTSTATUS = -1_073_741_151_i32; +pub const STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS: NTSTATUS = -1_073_741_082_i32; +pub const STATUS_DS_NO_MORE_RIDS: NTSTATUS = -1_073_741_144_i32; +pub const STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: NTSTATUS = -1_073_741_099_i32; +pub const STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: NTSTATUS = -1_073_741_098_i32; +pub const STATUS_DS_NO_RIDS_ALLOCATED: NTSTATUS = -1_073_741_145_i32; +pub const STATUS_DS_OBJ_CLASS_VIOLATION: NTSTATUS = -1_073_741_141_i32; +pub const STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: NTSTATUS = -1_073_700_729_i32; +pub const STATUS_DS_OID_NOT_FOUND: NTSTATUS = -1_073_700_728_i32; +pub const STATUS_DS_RIDMGR_DISABLED: NTSTATUS = -1_073_741_126_i32; +pub const STATUS_DS_RIDMGR_INIT_ERROR: NTSTATUS = -1_073_741_142_i32; +pub const STATUS_DS_SAM_INIT_FAILURE: NTSTATUS = -1_073_741_109_i32; +pub const STATUS_DS_SAM_INIT_FAILURE_CONSOLE: NTSTATUS = -1_073_741_075_i32; +pub const STATUS_DS_SENSITIVE_GROUP_VIOLATION: NTSTATUS = -1_073_741_107_i32; +pub const STATUS_DS_SHUTTING_DOWN: NTSTATUS = 1_073_742_704_i32; +pub const STATUS_DS_SRC_SID_EXISTS_IN_FOREST: NTSTATUS = -1_073_740_775_i32; +pub const STATUS_DS_UNAVAILABLE: NTSTATUS = -1_073_741_146_i32; +pub const STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: NTSTATUS = -1_073_741_095_i32; +pub const STATUS_DS_VERSION_CHECK_FAILURE: NTSTATUS = -1_073_740_971_i32; +pub const STATUS_DUPLICATE_NAME: NTSTATUS = -1_073_741_635_i32; +pub const STATUS_DUPLICATE_OBJECTID: NTSTATUS = -1_073_741_270_i32; +pub const STATUS_DUPLICATE_PRIVILEGES: NTSTATUS = -1_073_741_402_i32; +pub const STATUS_DYNAMIC_CODE_BLOCKED: NTSTATUS = -1_073_740_284_i32; +pub const STATUS_EAS_NOT_SUPPORTED: NTSTATUS = -1_073_741_745_i32; +pub const STATUS_EA_CORRUPT_ERROR: NTSTATUS = -1_073_741_741_i32; +pub const STATUS_EA_LIST_INCONSISTENT: NTSTATUS = -2_147_483_628_i32; +pub const STATUS_EA_TOO_LARGE: NTSTATUS = -1_073_741_744_i32; +pub const STATUS_EFS_ALG_BLOB_TOO_BIG: NTSTATUS = -1_073_740_974_i32; +pub const STATUS_EFS_NOT_ALLOWED_IN_TRANSACTION: NTSTATUS = -1_072_103_362_i32; +pub const STATUS_ELEVATION_REQUIRED: NTSTATUS = -1_073_740_756_i32; +pub const STATUS_EMULATION_BREAKPOINT: NTSTATUS = 1_073_741_880_i32; +pub const STATUS_EMULATION_SYSCALL: NTSTATUS = 1_073_741_881_i32; +pub const STATUS_ENCLAVE_FAILURE: NTSTATUS = -1_073_740_657_i32; +pub const STATUS_ENCLAVE_IS_TERMINATING: NTSTATUS = -1_073_740_526_i32; +pub const STATUS_ENCLAVE_NOT_TERMINATED: NTSTATUS = -1_073_740_527_i32; +pub const STATUS_ENCLAVE_VIOLATION: NTSTATUS = -1_073_740_638_i32; +pub const STATUS_ENCOUNTERED_WRITE_IN_PROGRESS: NTSTATUS = -1_073_740_749_i32; +pub const STATUS_ENCRYPTED_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_740_605_i32; +pub const STATUS_ENCRYPTED_IO_NOT_POSSIBLE: NTSTATUS = -1_073_739_760_i32; +pub const STATUS_ENCRYPTING_METADATA_DISALLOWED: NTSTATUS = -1_073_740_617_i32; +pub const STATUS_ENCRYPTION_DISABLED: NTSTATUS = -1_073_740_618_i32; +pub const STATUS_ENCRYPTION_FAILED: NTSTATUS = -1_073_741_174_i32; +pub const STATUS_END_OF_FILE: NTSTATUS = -1_073_741_807_i32; +pub const STATUS_END_OF_MEDIA: NTSTATUS = -2_147_483_618_i32; +pub const STATUS_ENLISTMENT_NOT_FOUND: NTSTATUS = -1_072_103_344_i32; +pub const STATUS_ENLISTMENT_NOT_SUPERIOR: NTSTATUS = -1_072_103_373_i32; +pub const STATUS_ENTRYPOINT_NOT_FOUND: NTSTATUS = -1_073_741_511_i32; +pub const STATUS_EOF_ON_GHOSTED_RANGE: NTSTATUS = -1_073_700_857_i32; +pub const STATUS_EOM_OVERFLOW: NTSTATUS = -1_073_741_449_i32; +pub const STATUS_ERROR_PROCESS_NOT_IN_JOB: NTSTATUS = -1_073_741_394_i32; +pub const STATUS_EVALUATION_EXPIRATION: NTSTATUS = -1_073_741_208_i32; +pub const STATUS_EVENTLOG_CANT_START: NTSTATUS = -1_073_741_425_i32; +pub const STATUS_EVENTLOG_FILE_CHANGED: NTSTATUS = -1_073_741_417_i32; +pub const STATUS_EVENTLOG_FILE_CORRUPT: NTSTATUS = -1_073_741_426_i32; +pub const STATUS_EVENT_DONE: NTSTATUS = 1_073_741_842_i32; +pub const STATUS_EVENT_PENDING: NTSTATUS = 1_073_741_843_i32; +pub const STATUS_EXECUTABLE_MEMORY_WRITE: NTSTATUS = -1_073_739_997_i32; +pub const STATUS_EXPIRED_HANDLE: NTSTATUS = -1_072_103_328_i32; +pub const STATUS_EXTERNAL_BACKING_PROVIDER_UNKNOWN: NTSTATUS = -1_073_740_690_i32; +pub const STATUS_EXTERNAL_SYSKEY_NOT_SUPPORTED: NTSTATUS = -1_073_740_639_i32; +pub const STATUS_EXTRANEOUS_INFORMATION: NTSTATUS = -2_147_483_625_i32; +pub const STATUS_FAILED_DRIVER_ENTRY: NTSTATUS = -1_073_740_955_i32; +pub const STATUS_FAILED_STACK_SWITCH: NTSTATUS = -1_073_740_941_i32; +pub const STATUS_FAIL_CHECK: NTSTATUS = -1_073_741_271_i32; +pub const STATUS_FAIL_FAST_EXCEPTION: NTSTATUS = -1_073_740_286_i32; +pub const STATUS_FASTPATH_REJECTED: NTSTATUS = -1_073_700_844_i32; +pub const STATUS_FATAL_APP_EXIT: NTSTATUS = 1_073_741_845_i32; +pub const STATUS_FATAL_MEMORY_EXHAUSTION: NTSTATUS = -1_073_741_395_i32; +pub const STATUS_FATAL_USER_CALLBACK_EXCEPTION: NTSTATUS = -1_073_740_771_i32; +pub const STATUS_FILEMARK_DETECTED: NTSTATUS = -2_147_483_621_i32; +pub const STATUS_FILES_OPEN: NTSTATUS = -1_073_741_561_i32; +pub const STATUS_FILE_CHECKED_OUT: NTSTATUS = -1_073_739_519_i32; +pub const STATUS_FILE_CLOSED: NTSTATUS = -1_073_741_528_i32; +pub const STATUS_FILE_CORRUPT_ERROR: NTSTATUS = -1_073_741_566_i32; +pub const STATUS_FILE_DELETED: NTSTATUS = -1_073_741_533_i32; +pub const STATUS_FILE_ENCRYPTED: NTSTATUS = -1_073_741_165_i32; +pub const STATUS_FILE_FORCED_CLOSED: NTSTATUS = -1_073_741_642_i32; +pub const STATUS_FILE_HANDLE_REVOKED: NTSTATUS = -1_073_739_504_i32; +pub const STATUS_FILE_IDENTITY_NOT_PERSISTENT: NTSTATUS = -1_072_103_370_i32; +pub const STATUS_FILE_INVALID: NTSTATUS = -1_073_741_672_i32; +pub const STATUS_FILE_IS_A_DIRECTORY: NTSTATUS = -1_073_741_638_i32; +pub const STATUS_FILE_IS_OFFLINE: NTSTATUS = -1_073_741_209_i32; +pub const STATUS_FILE_LOCKED_WITH_ONLY_READERS: NTSTATUS = 298_i32; +pub const STATUS_FILE_LOCKED_WITH_WRITERS: NTSTATUS = 299_i32; +pub const STATUS_FILE_LOCK_CONFLICT: NTSTATUS = -1_073_741_740_i32; +pub const STATUS_FILE_METADATA_OPTIMIZATION_IN_PROGRESS: NTSTATUS = -1_073_741_397_i32; +pub const STATUS_FILE_NOT_AVAILABLE: NTSTATUS = -1_073_740_697_i32; +pub const STATUS_FILE_NOT_ENCRYPTED: NTSTATUS = -1_073_741_167_i32; +pub const STATUS_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_740_620_i32; +pub const STATUS_FILE_PROTECTED_UNDER_DPL: NTSTATUS = -1_073_740_637_i32; +pub const STATUS_FILE_RENAMED: NTSTATUS = -1_073_741_611_i32; +pub const STATUS_FILE_SNAP_INVALID_PARAMETER: NTSTATUS = -1_073_679_099_i32; +pub const STATUS_FILE_SNAP_IN_PROGRESS: NTSTATUS = -1_073_679_104_i32; +pub const STATUS_FILE_SNAP_IO_NOT_COORDINATED: NTSTATUS = -1_073_679_101_i32; +pub const STATUS_FILE_SNAP_MODIFY_NOT_SUPPORTED: NTSTATUS = -1_073_679_102_i32; +pub const STATUS_FILE_SNAP_UNEXPECTED_ERROR: NTSTATUS = -1_073_679_100_i32; +pub const STATUS_FILE_SNAP_USER_SECTION_NOT_SUPPORTED: NTSTATUS = -1_073_679_103_i32; +pub const STATUS_FILE_SYSTEM_LIMITATION: NTSTATUS = -1_073_740_761_i32; +pub const STATUS_FILE_SYSTEM_VIRTUALIZATION_BUSY: NTSTATUS = -1_073_689_085_i32; +pub const STATUS_FILE_SYSTEM_VIRTUALIZATION_INVALID_OPERATION: NTSTATUS = -1_073_689_083_i32; +pub const STATUS_FILE_SYSTEM_VIRTUALIZATION_METADATA_CORRUPT: NTSTATUS = -1_073_689_086_i32; +pub const STATUS_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN: NTSTATUS = -1_073_689_084_i32; +pub const STATUS_FILE_SYSTEM_VIRTUALIZATION_UNAVAILABLE: NTSTATUS = -1_073_689_087_i32; +pub const STATUS_FILE_TOO_LARGE: NTSTATUS = -1_073_739_516_i32; +pub const STATUS_FIRMWARE_IMAGE_INVALID: NTSTATUS = -1_073_740_667_i32; +pub const STATUS_FIRMWARE_SLOT_INVALID: NTSTATUS = -1_073_740_668_i32; +pub const STATUS_FIRMWARE_UPDATED: NTSTATUS = 1_073_741_868_i32; +pub const STATUS_FLOATED_SECTION: NTSTATUS = -1_072_103_349_i32; +pub const STATUS_FLOAT_DENORMAL_OPERAND: NTSTATUS = -1_073_741_683_i32; +pub const STATUS_FLOAT_DIVIDE_BY_ZERO: NTSTATUS = -1_073_741_682_i32; +pub const STATUS_FLOAT_INEXACT_RESULT: NTSTATUS = -1_073_741_681_i32; +pub const STATUS_FLOAT_INVALID_OPERATION: NTSTATUS = -1_073_741_680_i32; +pub const STATUS_FLOAT_MULTIPLE_FAULTS: NTSTATUS = -1_073_741_132_i32; +pub const STATUS_FLOAT_MULTIPLE_TRAPS: NTSTATUS = -1_073_741_131_i32; +pub const STATUS_FLOAT_OVERFLOW: NTSTATUS = -1_073_741_679_i32; +pub const STATUS_FLOAT_STACK_CHECK: NTSTATUS = -1_073_741_678_i32; +pub const STATUS_FLOAT_UNDERFLOW: NTSTATUS = -1_073_741_677_i32; +pub const STATUS_FLOPPY_BAD_REGISTERS: NTSTATUS = -1_073_741_464_i32; +pub const STATUS_FLOPPY_ID_MARK_NOT_FOUND: NTSTATUS = -1_073_741_467_i32; +pub const STATUS_FLOPPY_UNKNOWN_ERROR: NTSTATUS = -1_073_741_465_i32; +pub const STATUS_FLOPPY_VOLUME: NTSTATUS = -1_073_741_468_i32; +pub const STATUS_FLOPPY_WRONG_CYLINDER: NTSTATUS = -1_073_741_466_i32; +pub const STATUS_FLT_ALREADY_ENLISTED: NTSTATUS = -1_071_906_789_i32; +pub const STATUS_FLT_BUFFER_TOO_SMALL: NTSTATUS = -2_145_648_639_i32; +pub const STATUS_FLT_CBDQ_DISABLED: NTSTATUS = -1_071_906_802_i32; +pub const STATUS_FLT_CONTEXT_ALLOCATION_NOT_FOUND: NTSTATUS = -1_071_906_794_i32; +pub const STATUS_FLT_CONTEXT_ALREADY_DEFINED: NTSTATUS = -1_071_906_814_i32; +pub const STATUS_FLT_CONTEXT_ALREADY_LINKED: NTSTATUS = -1_071_906_788_i32; +pub const STATUS_FLT_DELETING_OBJECT: NTSTATUS = -1_071_906_805_i32; +pub const STATUS_FLT_DISALLOW_FAST_IO: NTSTATUS = -1_071_906_812_i32; +pub const STATUS_FLT_DO_NOT_ATTACH: NTSTATUS = -1_071_906_801_i32; +pub const STATUS_FLT_DO_NOT_DETACH: NTSTATUS = -1_071_906_800_i32; +pub const STATUS_FLT_DUPLICATE_ENTRY: NTSTATUS = -1_071_906_803_i32; +pub const STATUS_FLT_FILTER_NOT_FOUND: NTSTATUS = -1_071_906_797_i32; +pub const STATUS_FLT_FILTER_NOT_READY: NTSTATUS = -1_071_906_808_i32; +pub const STATUS_FLT_INSTANCE_ALTITUDE_COLLISION: NTSTATUS = -1_071_906_799_i32; +pub const STATUS_FLT_INSTANCE_NAME_COLLISION: NTSTATUS = -1_071_906_798_i32; +pub const STATUS_FLT_INSTANCE_NOT_FOUND: NTSTATUS = -1_071_906_795_i32; +pub const STATUS_FLT_INTERNAL_ERROR: NTSTATUS = -1_071_906_806_i32; +pub const STATUS_FLT_INVALID_ASYNCHRONOUS_REQUEST: NTSTATUS = -1_071_906_813_i32; +pub const STATUS_FLT_INVALID_CONTEXT_REGISTRATION: NTSTATUS = -1_071_906_793_i32; +pub const STATUS_FLT_INVALID_NAME_REQUEST: NTSTATUS = -1_071_906_811_i32; +pub const STATUS_FLT_IO_COMPLETE: NTSTATUS = 1_835_009_i32; +pub const STATUS_FLT_MUST_BE_NONPAGED_POOL: NTSTATUS = -1_071_906_804_i32; +pub const STATUS_FLT_NAME_CACHE_MISS: NTSTATUS = -1_071_906_792_i32; +pub const STATUS_FLT_NOT_INITIALIZED: NTSTATUS = -1_071_906_809_i32; +pub const STATUS_FLT_NOT_SAFE_TO_POST_OPERATION: NTSTATUS = -1_071_906_810_i32; +pub const STATUS_FLT_NO_DEVICE_OBJECT: NTSTATUS = -1_071_906_791_i32; +pub const STATUS_FLT_NO_HANDLER_DEFINED: NTSTATUS = -1_071_906_815_i32; +pub const STATUS_FLT_NO_WAITER_FOR_REPLY: NTSTATUS = -1_071_906_784_i32; +pub const STATUS_FLT_POST_OPERATION_CLEANUP: NTSTATUS = -1_071_906_807_i32; +pub const STATUS_FLT_REGISTRATION_BUSY: NTSTATUS = -1_071_906_781_i32; +pub const STATUS_FLT_VOLUME_ALREADY_MOUNTED: NTSTATUS = -1_071_906_790_i32; +pub const STATUS_FLT_VOLUME_NOT_FOUND: NTSTATUS = -1_071_906_796_i32; +pub const STATUS_FLT_WCOS_NOT_SUPPORTED: NTSTATUS = -1_071_906_780_i32; +pub const STATUS_FORMS_AUTH_REQUIRED: NTSTATUS = -1_073_739_515_i32; +pub const STATUS_FOUND_OUT_OF_SCOPE: NTSTATUS = -1_073_741_266_i32; +pub const STATUS_FREE_SPACE_TOO_FRAGMENTED: NTSTATUS = -1_073_740_645_i32; +pub const STATUS_FREE_VM_NOT_AT_BASE: NTSTATUS = -1_073_741_665_i32; +pub const STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY: NTSTATUS = 294_i32; +pub const STATUS_FS_DRIVER_REQUIRED: NTSTATUS = -1_073_741_412_i32; +pub const STATUS_FS_METADATA_INCONSISTENT: NTSTATUS = -1_073_740_520_i32; +pub const STATUS_FT_DI_SCAN_REQUIRED: NTSTATUS = -1_073_740_692_i32; +pub const STATUS_FT_MISSING_MEMBER: NTSTATUS = -1_073_741_473_i32; +pub const STATUS_FT_ORPHANING: NTSTATUS = -1_073_741_459_i32; +pub const STATUS_FT_READ_FAILURE: NTSTATUS = -1_073_740_629_i32; +pub const STATUS_FT_READ_FROM_COPY: NTSTATUS = 1_073_741_877_i32; +pub const STATUS_FT_READ_FROM_COPY_FAILURE: NTSTATUS = -1_073_740_609_i32; +pub const STATUS_FT_READ_RECOVERY_FROM_BACKUP: NTSTATUS = 1_073_741_834_i32; +pub const STATUS_FT_WRITE_FAILURE: NTSTATUS = -1_073_740_693_i32; +pub const STATUS_FT_WRITE_RECOVERY: NTSTATUS = 1_073_741_835_i32; +pub const STATUS_FULLSCREEN_MODE: NTSTATUS = -1_073_741_479_i32; +pub const STATUS_FVE_ACTION_NOT_ALLOWED: NTSTATUS = -1_071_579_127_i32; +pub const STATUS_FVE_AUTH_INVALID_APPLICATION: NTSTATUS = -1_071_579_109_i32; +pub const STATUS_FVE_AUTH_INVALID_CONFIG: NTSTATUS = -1_071_579_108_i32; +pub const STATUS_FVE_BAD_DATA: NTSTATUS = -1_071_579_126_i32; +pub const STATUS_FVE_BAD_INFORMATION: NTSTATUS = -1_071_579_134_i32; +pub const STATUS_FVE_BAD_METADATA_POINTER: NTSTATUS = -1_071_579_105_i32; +pub const STATUS_FVE_BAD_PARTITION_SIZE: NTSTATUS = -1_071_579_131_i32; +pub const STATUS_FVE_CONV_READ_ERROR: NTSTATUS = -1_071_579_123_i32; +pub const STATUS_FVE_CONV_RECOVERY_FAILED: NTSTATUS = -1_071_579_096_i32; +pub const STATUS_FVE_CONV_WRITE_ERROR: NTSTATUS = -1_071_579_122_i32; +pub const STATUS_FVE_DATASET_FULL: NTSTATUS = -1_071_579_069_i32; +pub const STATUS_FVE_DEBUGGER_ENABLED: NTSTATUS = -1_071_579_107_i32; +pub const STATUS_FVE_DEVICE_LOCKEDOUT: NTSTATUS = -1_071_579_077_i32; +pub const STATUS_FVE_DRY_RUN_FAILED: NTSTATUS = -1_071_579_106_i32; +pub const STATUS_FVE_EDRIVE_BAND_ENUMERATION_FAILED: NTSTATUS = -1_071_579_071_i32; +pub const STATUS_FVE_EDRIVE_DRY_RUN_FAILED: NTSTATUS = -1_071_579_080_i32; +pub const STATUS_FVE_ENH_PIN_INVALID: NTSTATUS = -1_071_579_087_i32; +pub const STATUS_FVE_FAILED_AUTHENTICATION: NTSTATUS = -1_071_579_119_i32; +pub const STATUS_FVE_FAILED_SECTOR_SIZE: NTSTATUS = -1_071_579_120_i32; +pub const STATUS_FVE_FAILED_WRONG_FS: NTSTATUS = -1_071_579_132_i32; +pub const STATUS_FVE_FS_MOUNTED: NTSTATUS = -1_071_579_129_i32; +pub const STATUS_FVE_FS_NOT_EXTENDED: NTSTATUS = -1_071_579_130_i32; +pub const STATUS_FVE_FULL_ENCRYPTION_NOT_ALLOWED_ON_TP_STORAGE: NTSTATUS = -1_071_579_086_i32; +pub const STATUS_FVE_INVALID_DATUM_TYPE: NTSTATUS = -1_071_579_094_i32; +pub const STATUS_FVE_KEYFILE_INVALID: NTSTATUS = -1_071_579_116_i32; +pub const STATUS_FVE_KEYFILE_NOT_FOUND: NTSTATUS = -1_071_579_117_i32; +pub const STATUS_FVE_KEYFILE_NO_VMK: NTSTATUS = -1_071_579_115_i32; +pub const STATUS_FVE_LOCKED_VOLUME: NTSTATUS = -1_071_579_136_i32; +pub const STATUS_FVE_METADATA_FULL: NTSTATUS = -1_071_579_068_i32; +pub const STATUS_FVE_MOR_FAILED: NTSTATUS = -1_071_579_099_i32; +pub const STATUS_FVE_NOT_ALLOWED_ON_CLUSTER: NTSTATUS = -1_071_579_083_i32; +pub const STATUS_FVE_NOT_ALLOWED_ON_CSV_STACK: NTSTATUS = -1_071_579_084_i32; +pub const STATUS_FVE_NOT_ALLOWED_TO_UPGRADE_WHILE_CONVERTING: NTSTATUS = -1_071_579_082_i32; +pub const STATUS_FVE_NOT_DATA_VOLUME: NTSTATUS = -1_071_579_124_i32; +pub const STATUS_FVE_NOT_DE_VOLUME: NTSTATUS = -1_071_579_075_i32; +pub const STATUS_FVE_NOT_ENCRYPTED: NTSTATUS = -1_071_579_135_i32; +pub const STATUS_FVE_NOT_OS_VOLUME: NTSTATUS = -1_071_579_118_i32; +pub const STATUS_FVE_NO_AUTOUNLOCK_MASTER_KEY: NTSTATUS = -1_071_579_100_i32; +pub const STATUS_FVE_NO_FEATURE_LICENSE: NTSTATUS = -1_071_579_098_i32; +pub const STATUS_FVE_NO_LICENSE: NTSTATUS = -1_071_579_128_i32; +pub const STATUS_FVE_OLD_METADATA_COPY: NTSTATUS = -1_071_579_104_i32; +pub const STATUS_FVE_OSV_KSR_NOT_ALLOWED: NTSTATUS = -1_071_579_072_i32; +pub const STATUS_FVE_OVERLAPPED_UPDATE: NTSTATUS = -1_071_579_121_i32; +pub const STATUS_FVE_PARTIAL_METADATA: NTSTATUS = -2_145_320_959_i32; +pub const STATUS_FVE_PIN_INVALID: NTSTATUS = -1_071_579_110_i32; +pub const STATUS_FVE_POLICY_ON_RDV_EXCLUSION_LIST: NTSTATUS = -1_071_579_070_i32; +pub const STATUS_FVE_POLICY_USER_DISABLE_RDV_NOT_ALLOWED: NTSTATUS = -1_071_579_097_i32; +pub const STATUS_FVE_PROTECTION_CANNOT_BE_DISABLED: NTSTATUS = -1_071_579_073_i32; +pub const STATUS_FVE_PROTECTION_DISABLED: NTSTATUS = -1_071_579_074_i32; +pub const STATUS_FVE_RAW_ACCESS: NTSTATUS = -1_071_579_102_i32; +pub const STATUS_FVE_RAW_BLOCKED: NTSTATUS = -1_071_579_101_i32; +pub const STATUS_FVE_REBOOT_REQUIRED: NTSTATUS = -1_071_579_103_i32; +pub const STATUS_FVE_SECUREBOOT_CONFIG_CHANGE: NTSTATUS = -1_071_579_078_i32; +pub const STATUS_FVE_SECUREBOOT_DISABLED: NTSTATUS = -1_071_579_079_i32; +pub const STATUS_FVE_TOO_SMALL: NTSTATUS = -1_071_579_133_i32; +pub const STATUS_FVE_TPM_DISABLED: NTSTATUS = -1_071_579_114_i32; +pub const STATUS_FVE_TPM_INVALID_PCR: NTSTATUS = -1_071_579_112_i32; +pub const STATUS_FVE_TPM_NO_VMK: NTSTATUS = -1_071_579_111_i32; +pub const STATUS_FVE_TPM_SRK_AUTH_NOT_ZERO: NTSTATUS = -1_071_579_113_i32; +pub const STATUS_FVE_TRANSIENT_STATE: NTSTATUS = -2_145_320_958_i32; +pub const STATUS_FVE_VIRTUALIZED_SPACE_TOO_BIG: NTSTATUS = -1_071_579_095_i32; +pub const STATUS_FVE_VOLUME_EXTEND_PREVENTS_EOW_DECRYPT: NTSTATUS = -1_071_579_076_i32; +pub const STATUS_FVE_VOLUME_NOT_BOUND: NTSTATUS = -1_071_579_125_i32; +pub const STATUS_FVE_VOLUME_TOO_SMALL: NTSTATUS = -1_071_579_088_i32; +pub const STATUS_FVE_WIPE_CANCEL_NOT_APPLICABLE: NTSTATUS = -1_071_579_081_i32; +pub const STATUS_FVE_WIPE_NOT_ALLOWED_ON_TP_STORAGE: NTSTATUS = -1_071_579_085_i32; +pub const STATUS_FWP_ACTION_INCOMPATIBLE_WITH_LAYER: NTSTATUS = -1_071_513_556_i32; +pub const STATUS_FWP_ACTION_INCOMPATIBLE_WITH_SUBLAYER: NTSTATUS = -1_071_513_555_i32; +pub const STATUS_FWP_ALREADY_EXISTS: NTSTATUS = -1_071_513_591_i32; +pub const STATUS_FWP_BUILTIN_OBJECT: NTSTATUS = -1_071_513_577_i32; +pub const STATUS_FWP_CALLOUT_NOTIFICATION_FAILED: NTSTATUS = -1_071_513_545_i32; +pub const STATUS_FWP_CALLOUT_NOT_FOUND: NTSTATUS = -1_071_513_599_i32; +pub const STATUS_FWP_CANNOT_PEND: NTSTATUS = -1_071_513_341_i32; +pub const STATUS_FWP_CONDITION_NOT_FOUND: NTSTATUS = -1_071_513_598_i32; +pub const STATUS_FWP_CONNECTIONS_DISABLED: NTSTATUS = -1_071_513_535_i32; +pub const STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_CALLOUT: NTSTATUS = -1_071_513_553_i32; +pub const STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_LAYER: NTSTATUS = -1_071_513_554_i32; +pub const STATUS_FWP_DROP_NOICMP: NTSTATUS = -1_071_513_340_i32; +pub const STATUS_FWP_DUPLICATE_AUTH_METHOD: NTSTATUS = -1_071_513_540_i32; +pub const STATUS_FWP_DUPLICATE_CONDITION: NTSTATUS = -1_071_513_558_i32; +pub const STATUS_FWP_DUPLICATE_KEYMOD: NTSTATUS = -1_071_513_557_i32; +pub const STATUS_FWP_DYNAMIC_SESSION_IN_PROGRESS: NTSTATUS = -1_071_513_589_i32; +pub const STATUS_FWP_EM_NOT_SUPPORTED: NTSTATUS = -1_071_513_550_i32; +pub const STATUS_FWP_FILTER_NOT_FOUND: NTSTATUS = -1_071_513_597_i32; +pub const STATUS_FWP_IKEEXT_NOT_RUNNING: NTSTATUS = -1_071_513_532_i32; +pub const STATUS_FWP_INCOMPATIBLE_AUTH_METHOD: NTSTATUS = -1_071_513_552_i32; +pub const STATUS_FWP_INCOMPATIBLE_CIPHER_TRANSFORM: NTSTATUS = -1_071_513_542_i32; +pub const STATUS_FWP_INCOMPATIBLE_DH_GROUP: NTSTATUS = -1_071_513_551_i32; +pub const STATUS_FWP_INCOMPATIBLE_LAYER: NTSTATUS = -1_071_513_580_i32; +pub const STATUS_FWP_INCOMPATIBLE_SA_STATE: NTSTATUS = -1_071_513_573_i32; +pub const STATUS_FWP_INCOMPATIBLE_TXN: NTSTATUS = -1_071_513_583_i32; +pub const STATUS_FWP_INJECT_HANDLE_CLOSING: NTSTATUS = -1_071_513_343_i32; +pub const STATUS_FWP_INJECT_HANDLE_STALE: NTSTATUS = -1_071_513_342_i32; +pub const STATUS_FWP_INVALID_ACTION_TYPE: NTSTATUS = -1_071_513_564_i32; +pub const STATUS_FWP_INVALID_AUTH_TRANSFORM: NTSTATUS = -1_071_513_544_i32; +pub const STATUS_FWP_INVALID_CIPHER_TRANSFORM: NTSTATUS = -1_071_513_543_i32; +pub const STATUS_FWP_INVALID_DNS_NAME: NTSTATUS = -1_071_513_534_i32; +pub const STATUS_FWP_INVALID_ENUMERATOR: NTSTATUS = -1_071_513_571_i32; +pub const STATUS_FWP_INVALID_FLAGS: NTSTATUS = -1_071_513_570_i32; +pub const STATUS_FWP_INVALID_INTERVAL: NTSTATUS = -1_071_513_567_i32; +pub const STATUS_FWP_INVALID_NET_MASK: NTSTATUS = -1_071_513_569_i32; +pub const STATUS_FWP_INVALID_PARAMETER: NTSTATUS = -1_071_513_547_i32; +pub const STATUS_FWP_INVALID_RANGE: NTSTATUS = -1_071_513_568_i32; +pub const STATUS_FWP_INVALID_TRANSFORM_COMBINATION: NTSTATUS = -1_071_513_541_i32; +pub const STATUS_FWP_INVALID_TUNNEL_ENDPOINT: NTSTATUS = -1_071_513_539_i32; +pub const STATUS_FWP_INVALID_WEIGHT: NTSTATUS = -1_071_513_563_i32; +pub const STATUS_FWP_IN_USE: NTSTATUS = -1_071_513_590_i32; +pub const STATUS_FWP_KEY_DICTATION_INVALID_KEYING_MATERIAL: NTSTATUS = -1_071_513_536_i32; +pub const STATUS_FWP_KEY_DICTATOR_ALREADY_REGISTERED: NTSTATUS = -1_071_513_537_i32; +pub const STATUS_FWP_KM_CLIENTS_ONLY: NTSTATUS = -1_071_513_579_i32; +pub const STATUS_FWP_L2_DRIVER_NOT_READY: NTSTATUS = -1_071_513_538_i32; +pub const STATUS_FWP_LAYER_NOT_FOUND: NTSTATUS = -1_071_513_596_i32; +pub const STATUS_FWP_LIFETIME_MISMATCH: NTSTATUS = -1_071_513_578_i32; +pub const STATUS_FWP_MATCH_TYPE_MISMATCH: NTSTATUS = -1_071_513_562_i32; +pub const STATUS_FWP_NET_EVENTS_DISABLED: NTSTATUS = -1_071_513_581_i32; +pub const STATUS_FWP_NEVER_MATCH: NTSTATUS = -1_071_513_549_i32; +pub const STATUS_FWP_NOTIFICATION_DROPPED: NTSTATUS = -1_071_513_575_i32; +pub const STATUS_FWP_NOT_FOUND: NTSTATUS = -1_071_513_592_i32; +pub const STATUS_FWP_NO_TXN_IN_PROGRESS: NTSTATUS = -1_071_513_587_i32; +pub const STATUS_FWP_NULL_DISPLAY_NAME: NTSTATUS = -1_071_513_565_i32; +pub const STATUS_FWP_NULL_POINTER: NTSTATUS = -1_071_513_572_i32; +pub const STATUS_FWP_OUT_OF_BOUNDS: NTSTATUS = -1_071_513_560_i32; +pub const STATUS_FWP_PROVIDER_CONTEXT_MISMATCH: NTSTATUS = -1_071_513_548_i32; +pub const STATUS_FWP_PROVIDER_CONTEXT_NOT_FOUND: NTSTATUS = -1_071_513_594_i32; +pub const STATUS_FWP_PROVIDER_NOT_FOUND: NTSTATUS = -1_071_513_595_i32; +pub const STATUS_FWP_RESERVED: NTSTATUS = -1_071_513_559_i32; +pub const STATUS_FWP_SESSION_ABORTED: NTSTATUS = -1_071_513_584_i32; +pub const STATUS_FWP_STILL_ON: NTSTATUS = -1_071_513_533_i32; +pub const STATUS_FWP_SUBLAYER_NOT_FOUND: NTSTATUS = -1_071_513_593_i32; +pub const STATUS_FWP_TCPIP_NOT_READY: NTSTATUS = -1_071_513_344_i32; +pub const STATUS_FWP_TIMEOUT: NTSTATUS = -1_071_513_582_i32; +pub const STATUS_FWP_TOO_MANY_CALLOUTS: NTSTATUS = -1_071_513_576_i32; +pub const STATUS_FWP_TOO_MANY_SUBLAYERS: NTSTATUS = -1_071_513_546_i32; +pub const STATUS_FWP_TRAFFIC_MISMATCH: NTSTATUS = -1_071_513_574_i32; +pub const STATUS_FWP_TXN_ABORTED: NTSTATUS = -1_071_513_585_i32; +pub const STATUS_FWP_TXN_IN_PROGRESS: NTSTATUS = -1_071_513_586_i32; +pub const STATUS_FWP_TYPE_MISMATCH: NTSTATUS = -1_071_513_561_i32; +pub const STATUS_FWP_WRONG_SESSION: NTSTATUS = -1_071_513_588_i32; +pub const STATUS_FWP_ZERO_LENGTH_ARRAY: NTSTATUS = -1_071_513_566_i32; +pub const STATUS_GDI_HANDLE_LEAK: NTSTATUS = -2_143_354_879_i32; +pub const STATUS_GENERIC_COMMAND_FAILED: NTSTATUS = -1_072_365_530_i32; +pub const STATUS_GENERIC_NOT_MAPPED: NTSTATUS = -1_073_741_594_i32; +pub const STATUS_GHOSTED: NTSTATUS = 303_i32; +pub const STATUS_GPIO_CLIENT_INFORMATION_INVALID: NTSTATUS = -1_073_700_574_i32; +pub const STATUS_GPIO_INCOMPATIBLE_CONNECT_MODE: NTSTATUS = -1_073_700_570_i32; +pub const STATUS_GPIO_INTERRUPT_ALREADY_UNMASKED: NTSTATUS = -2_147_442_393_i32; +pub const STATUS_GPIO_INVALID_REGISTRATION_PACKET: NTSTATUS = -1_073_700_572_i32; +pub const STATUS_GPIO_OPERATION_DENIED: NTSTATUS = -1_073_700_571_i32; +pub const STATUS_GPIO_VERSION_NOT_SUPPORTED: NTSTATUS = -1_073_700_573_i32; +pub const STATUS_GRACEFUL_DISCONNECT: NTSTATUS = -1_073_741_257_i32; +pub const STATUS_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED: NTSTATUS = -1_071_774_661_i32; +pub const STATUS_GRAPHICS_ADAPTER_CHAIN_NOT_READY: NTSTATUS = -1_071_774_669_i32; +pub const STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE: NTSTATUS = -1_071_774_936_i32; +pub const STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET: NTSTATUS = -1_071_774_935_i32; +pub const STATUS_GRAPHICS_ADAPTER_WAS_RESET: NTSTATUS = -1_071_775_741_i32; +pub const STATUS_GRAPHICS_ALLOCATION_BUSY: NTSTATUS = -1_071_775_486_i32; +pub const STATUS_GRAPHICS_ALLOCATION_CLOSED: NTSTATUS = -1_071_775_470_i32; +pub const STATUS_GRAPHICS_ALLOCATION_CONTENT_LOST: NTSTATUS = -1_071_775_466_i32; +pub const STATUS_GRAPHICS_ALLOCATION_INVALID: NTSTATUS = -1_071_775_482_i32; +pub const STATUS_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION: NTSTATUS = -1_071_774_886_i32; +pub const STATUS_GRAPHICS_CANNOTCOLORCONVERT: NTSTATUS = -1_071_775_736_i32; +pub const STATUS_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN: NTSTATUS = -1_071_774_909_i32; +pub const STATUS_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION: NTSTATUS = -1_071_775_479_i32; +pub const STATUS_GRAPHICS_CANT_LOCK_MEMORY: NTSTATUS = -1_071_775_487_i32; +pub const STATUS_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION: NTSTATUS = -1_071_775_471_i32; +pub const STATUS_GRAPHICS_CHAINLINKS_NOT_ENUMERATED: NTSTATUS = -1_071_774_670_i32; +pub const STATUS_GRAPHICS_CHAINLINKS_NOT_POWERED_ON: NTSTATUS = -1_071_774_667_i32; +pub const STATUS_GRAPHICS_CHAINLINKS_NOT_STARTED: NTSTATUS = -1_071_774_668_i32; +pub const STATUS_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED: NTSTATUS = -1_071_774_719_i32; +pub const STATUS_GRAPHICS_CLIENTVIDPN_NOT_SET: NTSTATUS = -1_071_774_884_i32; +pub const STATUS_GRAPHICS_COPP_NOT_SUPPORTED: NTSTATUS = -1_071_774_463_i32; +pub const STATUS_GRAPHICS_DATASET_IS_EMPTY: NTSTATUS = 1_075_708_747_i32; +pub const STATUS_GRAPHICS_DDCCI_INVALID_CAPABILITIES_STRING: NTSTATUS = -1_071_774_329_i32; +pub const STATUS_GRAPHICS_DDCCI_INVALID_DATA: NTSTATUS = -1_071_774_331_i32; +pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM: NTSTATUS = -1_071_774_325_i32; +pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND: NTSTATUS = -1_071_774_327_i32; +pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH: NTSTATUS = -1_071_774_326_i32; +pub const STATUS_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE: NTSTATUS = + -1_071_774_330_i32; +pub const STATUS_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED: NTSTATUS = -1_071_774_332_i32; +pub const STATUS_GRAPHICS_DEPENDABLE_CHILD_STATUS: NTSTATUS = 1_075_708_988_i32; +pub const STATUS_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP: NTSTATUS = -1_071_774_238_i32; +pub const STATUS_GRAPHICS_DRIVER_MISMATCH: NTSTATUS = -1_071_775_735_i32; +pub const STATUS_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION: NTSTATUS = + -1_071_774_939_i32; +pub const STATUS_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET: NTSTATUS = -1_071_774_945_i32; +pub const STATUS_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET: NTSTATUS = -1_071_774_947_i32; +pub const STATUS_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED: NTSTATUS = -1_071_774_904_i32; +pub const STATUS_GRAPHICS_GPU_EXCEPTION_ON_DEVICE: NTSTATUS = -1_071_775_232_i32; +pub const STATUS_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST: NTSTATUS = -1_071_774_335_i32; +pub const STATUS_GRAPHICS_I2C_ERROR_RECEIVING_DATA: NTSTATUS = -1_071_774_333_i32; +pub const STATUS_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA: NTSTATUS = -1_071_774_334_i32; +pub const STATUS_GRAPHICS_I2C_NOT_SUPPORTED: NTSTATUS = -1_071_774_336_i32; +pub const STATUS_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT: NTSTATUS = -1_071_774_891_i32; +pub const STATUS_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE: NTSTATUS = -1_071_774_666_i32; +pub const STATUS_GRAPHICS_INDIRECT_DISPLAY_ABANDON_SWAPCHAIN: NTSTATUS = -1_071_775_726_i32; +pub const STATUS_GRAPHICS_INDIRECT_DISPLAY_DEVICE_STOPPED: NTSTATUS = -1_071_775_725_i32; +pub const STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER: NTSTATUS = -1_071_775_743_i32; +pub const STATUS_GRAPHICS_INTERNAL_ERROR: NTSTATUS = -1_071_774_233_i32; +pub const STATUS_GRAPHICS_INVALID_ACTIVE_REGION: NTSTATUS = -1_071_774_965_i32; +pub const STATUS_GRAPHICS_INVALID_ALLOCATION_HANDLE: NTSTATUS = -1_071_775_468_i32; +pub const STATUS_GRAPHICS_INVALID_ALLOCATION_INSTANCE: NTSTATUS = -1_071_775_469_i32; +pub const STATUS_GRAPHICS_INVALID_ALLOCATION_USAGE: NTSTATUS = -1_071_775_472_i32; +pub const STATUS_GRAPHICS_INVALID_CLIENT_TYPE: NTSTATUS = -1_071_774_885_i32; +pub const STATUS_GRAPHICS_INVALID_COLORBASIS: NTSTATUS = -1_071_774_914_i32; +pub const STATUS_GRAPHICS_INVALID_COPYPROTECTION_TYPE: NTSTATUS = -1_071_774_897_i32; +pub const STATUS_GRAPHICS_INVALID_DISPLAY_ADAPTER: NTSTATUS = -1_071_775_742_i32; +pub const STATUS_GRAPHICS_INVALID_DRIVER_MODEL: NTSTATUS = -1_071_775_740_i32; +pub const STATUS_GRAPHICS_INVALID_FREQUENCY: NTSTATUS = -1_071_774_966_i32; +pub const STATUS_GRAPHICS_INVALID_GAMMA_RAMP: NTSTATUS = -1_071_774_905_i32; +pub const STATUS_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM: NTSTATUS = -1_071_774_890_i32; +pub const STATUS_GRAPHICS_INVALID_MONITORDESCRIPTOR: NTSTATUS = -1_071_774_933_i32; +pub const STATUS_GRAPHICS_INVALID_MONITORDESCRIPTORSET: NTSTATUS = -1_071_774_934_i32; +pub const STATUS_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN: NTSTATUS = -1_071_774_889_i32; +pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE: NTSTATUS = -1_071_774_948_i32; +pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET: NTSTATUS = -1_071_774_949_i32; +pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT: NTSTATUS = -1_071_774_888_i32; +pub const STATUS_GRAPHICS_INVALID_MONITOR_SOURCEMODESET: NTSTATUS = -1_071_774_943_i32; +pub const STATUS_GRAPHICS_INVALID_MONITOR_SOURCE_MODE: NTSTATUS = -1_071_774_942_i32; +pub const STATUS_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION: NTSTATUS = + -1_071_774_907_i32; +pub const STATUS_GRAPHICS_INVALID_PATH_CONTENT_TYPE: NTSTATUS = -1_071_774_898_i32; +pub const STATUS_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL: NTSTATUS = -1_071_774_908_i32; +pub const STATUS_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE: NTSTATUS = -1_071_774_324_i32; +pub const STATUS_GRAPHICS_INVALID_PIXELFORMAT: NTSTATUS = -1_071_774_915_i32; +pub const STATUS_GRAPHICS_INVALID_PIXELVALUEACCESSMODE: NTSTATUS = -1_071_774_913_i32; +pub const STATUS_GRAPHICS_INVALID_POINTER: NTSTATUS = -1_071_774_236_i32; +pub const STATUS_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE: NTSTATUS = -1_071_774_918_i32; +pub const STATUS_GRAPHICS_INVALID_SCANLINE_ORDERING: NTSTATUS = -1_071_774_894_i32; +pub const STATUS_GRAPHICS_INVALID_STRIDE: NTSTATUS = -1_071_774_916_i32; +pub const STATUS_GRAPHICS_INVALID_TOTAL_REGION: NTSTATUS = -1_071_774_964_i32; +pub const STATUS_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET: NTSTATUS = -1_071_774_955_i32; +pub const STATUS_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET: NTSTATUS = -1_071_774_954_i32; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE: NTSTATUS = -1_071_774_972_i32; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE: NTSTATUS = -1_071_774_960_i32; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET: NTSTATUS = -1_071_774_971_i32; +pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE: NTSTATUS = -1_071_774_959_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN: NTSTATUS = -1_071_774_973_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN_PRESENT_PATH: NTSTATUS = -1_071_774_951_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN_SOURCEMODESET: NTSTATUS = -1_071_774_968_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TARGETMODESET: NTSTATUS = -1_071_774_967_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE: NTSTATUS = -1_071_774_929_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY: NTSTATUS = -1_071_774_976_i32; +pub const STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON: NTSTATUS = + -1_071_774_899_i32; +pub const STATUS_GRAPHICS_INVALID_VISIBLEREGION_SIZE: NTSTATUS = -1_071_774_917_i32; +pub const STATUS_GRAPHICS_LEADLINK_NOT_ENUMERATED: NTSTATUS = -1_071_774_671_i32; +pub const STATUS_GRAPHICS_LEADLINK_START_DEFERRED: NTSTATUS = 1_075_708_983_i32; +pub const STATUS_GRAPHICS_LINK_CONFIGURATION_IN_PROGRESS: NTSTATUS = -2_145_517_568_i32; +pub const STATUS_GRAPHICS_MAX_NUM_PATHS_REACHED: NTSTATUS = -1_071_774_887_i32; +pub const STATUS_GRAPHICS_MCA_INTERNAL_ERROR: NTSTATUS = -1_071_774_328_i32; +pub const STATUS_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED: NTSTATUS = -1_071_774_237_i32; +pub const STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET: NTSTATUS = -1_071_774_956_i32; +pub const STATUS_GRAPHICS_MODE_ID_MUST_BE_UNIQUE: NTSTATUS = -1_071_774_940_i32; +pub const STATUS_GRAPHICS_MODE_NOT_IN_MODESET: NTSTATUS = -1_071_774_902_i32; +pub const STATUS_GRAPHICS_MODE_NOT_PINNED: NTSTATUS = 1_075_708_679_i32; +pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET: NTSTATUS = -1_071_774_931_i32; +pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE: NTSTATUS = -1_071_774_930_i32; +pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET: NTSTATUS = -1_071_774_932_i32; +pub const STATUS_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER: NTSTATUS = + -1_071_774_924_i32; +pub const STATUS_GRAPHICS_MONITOR_NOT_CONNECTED: NTSTATUS = -1_071_774_920_i32; +pub const STATUS_GRAPHICS_MONITOR_NO_LONGER_EXISTS: NTSTATUS = -1_071_774_323_i32; +pub const STATUS_GRAPHICS_MPO_ALLOCATION_UNPINNED: NTSTATUS = -1_071_775_720_i32; +pub const STATUS_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED: NTSTATUS = -1_071_774_903_i32; +pub const STATUS_GRAPHICS_NOT_A_LINKED_ADAPTER: NTSTATUS = -1_071_774_672_i32; +pub const STATUS_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER: NTSTATUS = -1_071_775_744_i32; +pub const STATUS_GRAPHICS_NOT_POST_DEVICE_DRIVER: NTSTATUS = -1_071_774_664_i32; +pub const STATUS_GRAPHICS_NO_ACTIVE_VIDPN: NTSTATUS = -1_071_774_922_i32; +pub const STATUS_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS: NTSTATUS = -1_071_774_892_i32; +pub const STATUS_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET: NTSTATUS = -1_071_774_925_i32; +pub const STATUS_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME: NTSTATUS = -1_071_774_239_i32; +pub const STATUS_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT: NTSTATUS = -1_071_774_911_i32; +pub const STATUS_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE: NTSTATUS = -1_071_774_235_i32; +pub const STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET: NTSTATUS = 1_075_708_748_i32; +pub const STATUS_GRAPHICS_NO_PREFERRED_MODE: NTSTATUS = 1_075_708_702_i32; +pub const STATUS_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN: NTSTATUS = -1_071_774_941_i32; +pub const STATUS_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY: NTSTATUS = -1_071_774_950_i32; +pub const STATUS_GRAPHICS_NO_VIDEO_MEMORY: NTSTATUS = -1_071_775_488_i32; +pub const STATUS_GRAPHICS_NO_VIDPNMGR: NTSTATUS = -1_071_774_923_i32; +pub const STATUS_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED: NTSTATUS = -1_071_774_240_i32; +pub const STATUS_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE: NTSTATUS = -1_071_774_440_i32; +pub const STATUS_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR: NTSTATUS = -1_071_774_434_i32; +pub const STATUS_GRAPHICS_OPM_HDCP_SRM_NEVER_SET: NTSTATUS = -1_071_774_442_i32; +pub const STATUS_GRAPHICS_OPM_INTERNAL_ERROR: NTSTATUS = -1_071_774_453_i32; +pub const STATUS_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST: NTSTATUS = -1_071_774_431_i32; +pub const STATUS_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS: NTSTATUS = -1_071_774_461_i32; +pub const STATUS_GRAPHICS_OPM_INVALID_HANDLE: NTSTATUS = -1_071_774_452_i32; +pub const STATUS_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST: NTSTATUS = -1_071_774_435_i32; +pub const STATUS_GRAPHICS_OPM_INVALID_SRM: NTSTATUS = -1_071_774_446_i32; +pub const STATUS_GRAPHICS_OPM_NOT_SUPPORTED: NTSTATUS = -1_071_774_464_i32; +pub const STATUS_GRAPHICS_OPM_NO_PROTECTED_OUTPUTS_EXIST: NTSTATUS = -1_071_774_459_i32; +pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP: NTSTATUS = -1_071_774_444_i32; +pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA: NTSTATUS = -1_071_774_443_i32; +pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP: NTSTATUS = -1_071_774_445_i32; +pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS: NTSTATUS = + -1_071_774_436_i32; +pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS: NTSTATUS = + -1_071_774_433_i32; +pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_NO_LONGER_EXISTS: NTSTATUS = -1_071_774_438_i32; +pub const STATUS_GRAPHICS_OPM_RESOLUTION_TOO_HIGH: NTSTATUS = -1_071_774_441_i32; +pub const STATUS_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED: NTSTATUS = -1_071_774_432_i32; +pub const STATUS_GRAPHICS_OPM_SPANNING_MODE_ENABLED: NTSTATUS = -1_071_774_449_i32; +pub const STATUS_GRAPHICS_OPM_THEATER_MODE_ENABLED: NTSTATUS = -1_071_774_448_i32; +pub const STATUS_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL: NTSTATUS = -1_071_774_234_i32; +pub const STATUS_GRAPHICS_PARTIAL_DATA_POPULATED: NTSTATUS = 1_075_707_914_i32; +pub const STATUS_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY: NTSTATUS = -1_071_774_957_i32; +pub const STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED: NTSTATUS = + 1_075_708_753_i32; +pub const STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED: NTSTATUS = + -1_071_774_906_i32; +pub const STATUS_GRAPHICS_PATH_NOT_IN_TOPOLOGY: NTSTATUS = -1_071_774_937_i32; +pub const STATUS_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET: NTSTATUS = -1_071_774_958_i32; +pub const STATUS_GRAPHICS_POLLING_TOO_FREQUENTLY: NTSTATUS = 1_075_708_985_i32; +pub const STATUS_GRAPHICS_PRESENT_BUFFER_NOT_BOUND: NTSTATUS = -1_071_775_728_i32; +pub const STATUS_GRAPHICS_PRESENT_DENIED: NTSTATUS = -1_071_775_737_i32; +pub const STATUS_GRAPHICS_PRESENT_INVALID_WINDOW: NTSTATUS = -1_071_775_729_i32; +pub const STATUS_GRAPHICS_PRESENT_MODE_CHANGED: NTSTATUS = -1_071_775_739_i32; +pub const STATUS_GRAPHICS_PRESENT_OCCLUDED: NTSTATUS = -1_071_775_738_i32; +pub const STATUS_GRAPHICS_PRESENT_REDIRECTION_DISABLED: NTSTATUS = -1_071_775_733_i32; +pub const STATUS_GRAPHICS_PRESENT_UNOCCLUDED: NTSTATUS = -1_071_775_732_i32; +pub const STATUS_GRAPHICS_PVP_HFS_FAILED: NTSTATUS = -1_071_774_447_i32; +pub const STATUS_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH: NTSTATUS = -1_071_774_450_i32; +pub const STATUS_GRAPHICS_RESOURCES_NOT_RELATED: NTSTATUS = -1_071_774_928_i32; +pub const STATUS_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS: NTSTATUS = -1_071_774_232_i32; +pub const STATUS_GRAPHICS_SKIP_ALLOCATION_PREPARATION: NTSTATUS = 1_075_708_417_i32; +pub const STATUS_GRAPHICS_SOURCE_ALREADY_IN_SET: NTSTATUS = -1_071_774_953_i32; +pub const STATUS_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE: NTSTATUS = -1_071_774_927_i32; +pub const STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY: NTSTATUS = -1_071_774_919_i32; +pub const STATUS_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED: NTSTATUS = -1_071_774_720_i32; +pub const STATUS_GRAPHICS_STALE_MODESET: NTSTATUS = -1_071_774_944_i32; +pub const STATUS_GRAPHICS_STALE_VIDPN_TOPOLOGY: NTSTATUS = -1_071_774_921_i32; +pub const STATUS_GRAPHICS_START_DEFERRED: NTSTATUS = 1_075_708_986_i32; +pub const STATUS_GRAPHICS_TARGET_ALREADY_IN_SET: NTSTATUS = -1_071_774_952_i32; +pub const STATUS_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE: NTSTATUS = -1_071_774_926_i32; +pub const STATUS_GRAPHICS_TARGET_NOT_IN_TOPOLOGY: NTSTATUS = -1_071_774_912_i32; +pub const STATUS_GRAPHICS_TOO_MANY_REFERENCES: NTSTATUS = -1_071_775_485_i32; +pub const STATUS_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED: NTSTATUS = -1_071_774_893_i32; +pub const STATUS_GRAPHICS_TRY_AGAIN_LATER: NTSTATUS = -1_071_775_484_i32; +pub const STATUS_GRAPHICS_TRY_AGAIN_NOW: NTSTATUS = -1_071_775_483_i32; +pub const STATUS_GRAPHICS_UAB_NOT_SUPPORTED: NTSTATUS = -1_071_774_462_i32; +pub const STATUS_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS: NTSTATUS = -1_071_774_896_i32; +pub const STATUS_GRAPHICS_UNKNOWN_CHILD_STATUS: NTSTATUS = 1_075_708_975_i32; +pub const STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE: NTSTATUS = -1_071_775_481_i32; +pub const STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED: NTSTATUS = -1_071_775_480_i32; +pub const STATUS_GRAPHICS_VAIL_STATE_CHANGED: NTSTATUS = -1_071_775_727_i32; +pub const STATUS_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES: NTSTATUS = -1_071_774_938_i32; +pub const STATUS_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED: NTSTATUS = -1_071_774_970_i32; +pub const STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: NTSTATUS = -1_071_774_910_i32; +pub const STATUS_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED: NTSTATUS = -1_071_774_974_i32; +pub const STATUS_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED: NTSTATUS = -1_071_774_975_i32; +pub const STATUS_GRAPHICS_WINDOWDC_NOT_AVAILABLE: NTSTATUS = -1_071_775_731_i32; +pub const STATUS_GRAPHICS_WINDOWLESS_PRESENT_DISABLED: NTSTATUS = -1_071_775_730_i32; +pub const STATUS_GRAPHICS_WRONG_ALLOCATION_DEVICE: NTSTATUS = -1_071_775_467_i32; +pub const STATUS_GROUP_EXISTS: NTSTATUS = -1_073_741_723_i32; +pub const STATUS_GUARD_PAGE_VIOLATION: NTSTATUS = -2_147_483_647_i32; +pub const STATUS_GUIDS_EXHAUSTED: NTSTATUS = -1_073_741_693_i32; +pub const STATUS_GUID_SUBSTITUTION_MADE: NTSTATUS = -2_147_483_636_i32; +pub const STATUS_HANDLES_CLOSED: NTSTATUS = -2_147_483_638_i32; +pub const STATUS_HANDLE_NOT_CLOSABLE: NTSTATUS = -1_073_741_259_i32; +pub const STATUS_HANDLE_NO_LONGER_VALID: NTSTATUS = -1_072_103_384_i32; +pub const STATUS_HANDLE_REVOKED: NTSTATUS = -1_073_700_858_i32; +pub const STATUS_HARDWARE_MEMORY_ERROR: NTSTATUS = -1_073_740_023_i32; +pub const STATUS_HASH_NOT_PRESENT: NTSTATUS = -1_073_700_607_i32; +pub const STATUS_HASH_NOT_SUPPORTED: NTSTATUS = -1_073_700_608_i32; +pub const STATUS_HAS_SYSTEM_CRITICAL_FILES: NTSTATUS = -1_073_740_611_i32; +pub const STATUS_HDAUDIO_CONNECTION_LIST_NOT_SUPPORTED: NTSTATUS = -1_069_285_373_i32; +pub const STATUS_HDAUDIO_EMPTY_CONNECTION_LIST: NTSTATUS = -1_069_285_374_i32; +pub const STATUS_HDAUDIO_NO_LOGICAL_DEVICES_CREATED: NTSTATUS = -1_069_285_372_i32; +pub const STATUS_HDAUDIO_NULL_LINKED_LIST_ENTRY: NTSTATUS = -1_069_285_371_i32; +pub const STATUS_HEAP_CORRUPTION: NTSTATUS = -1_073_740_940_i32; +pub const STATUS_HEURISTIC_DAMAGE_POSSIBLE: NTSTATUS = 1_075_380_225_i32; +pub const STATUS_HIBERNATED: NTSTATUS = 1_073_741_866_i32; +pub const STATUS_HIBERNATION_FAILURE: NTSTATUS = -1_073_740_783_i32; +pub const STATUS_HIVE_UNLOADED: NTSTATUS = -1_073_740_763_i32; +pub const STATUS_HMAC_NOT_SUPPORTED: NTSTATUS = -1_073_700_863_i32; +pub const STATUS_HOPLIMIT_EXCEEDED: NTSTATUS = -1_073_700_846_i32; +pub const STATUS_HOST_DOWN: NTSTATUS = -1_073_740_976_i32; +pub const STATUS_HOST_UNREACHABLE: NTSTATUS = -1_073_741_251_i32; +pub const STATUS_HUNG_DISPLAY_DRIVER_THREAD: NTSTATUS = -1_073_740_779_i32; +pub const STATUS_HV_ACCESS_DENIED: NTSTATUS = -1_070_268_410_i32; +pub const STATUS_HV_ACKNOWLEDGED: NTSTATUS = -1_070_268_394_i32; +pub const STATUS_HV_CALL_PENDING: NTSTATUS = -1_070_268_295_i32; +pub const STATUS_HV_CPUID_FEATURE_VALIDATION_ERROR: NTSTATUS = -1_070_268_356_i32; +pub const STATUS_HV_CPUID_XSAVE_FEATURE_VALIDATION_ERROR: NTSTATUS = -1_070_268_355_i32; +pub const STATUS_HV_DEVICE_NOT_IN_DOMAIN: NTSTATUS = -1_070_268_298_i32; +pub const STATUS_HV_EVENT_BUFFER_ALREADY_FREED: NTSTATUS = -1_070_268_300_i32; +pub const STATUS_HV_FEATURE_UNAVAILABLE: NTSTATUS = -1_070_268_386_i32; +pub const STATUS_HV_INACTIVE: NTSTATUS = -1_070_268_388_i32; +pub const STATUS_HV_INSUFFICIENT_BUFFER: NTSTATUS = -1_070_268_365_i32; +pub const STATUS_HV_INSUFFICIENT_BUFFERS: NTSTATUS = -1_070_268_397_i32; +pub const STATUS_HV_INSUFFICIENT_CONTIGUOUS_MEMORY: NTSTATUS = -1_070_268_299_i32; +pub const STATUS_HV_INSUFFICIENT_CONTIGUOUS_MEMORY_MIRRORING: NTSTATUS = -1_070_268_286_i32; +pub const STATUS_HV_INSUFFICIENT_CONTIGUOUS_ROOT_MEMORY: NTSTATUS = -1_070_268_285_i32; +pub const STATUS_HV_INSUFFICIENT_CONTIGUOUS_ROOT_MEMORY_MIRRORING: NTSTATUS = -1_070_268_283_i32; +pub const STATUS_HV_INSUFFICIENT_DEVICE_DOMAINS: NTSTATUS = -1_070_268_360_i32; +pub const STATUS_HV_INSUFFICIENT_MEMORY: NTSTATUS = -1_070_268_405_i32; +pub const STATUS_HV_INSUFFICIENT_MEMORY_MIRRORING: NTSTATUS = -1_070_268_287_i32; +pub const STATUS_HV_INSUFFICIENT_ROOT_MEMORY: NTSTATUS = -1_070_268_301_i32; +pub const STATUS_HV_INSUFFICIENT_ROOT_MEMORY_MIRRORING: NTSTATUS = -1_070_268_284_i32; +pub const STATUS_HV_INVALID_ALIGNMENT: NTSTATUS = -1_070_268_412_i32; +pub const STATUS_HV_INVALID_CONNECTION_ID: NTSTATUS = -1_070_268_398_i32; +pub const STATUS_HV_INVALID_CPU_GROUP_ID: NTSTATUS = -1_070_268_305_i32; +pub const STATUS_HV_INVALID_CPU_GROUP_STATE: NTSTATUS = -1_070_268_304_i32; +pub const STATUS_HV_INVALID_DEVICE_ID: NTSTATUS = -1_070_268_329_i32; +pub const STATUS_HV_INVALID_DEVICE_STATE: NTSTATUS = -1_070_268_328_i32; +pub const STATUS_HV_INVALID_HYPERCALL_CODE: NTSTATUS = -1_070_268_414_i32; +pub const STATUS_HV_INVALID_HYPERCALL_INPUT: NTSTATUS = -1_070_268_413_i32; +pub const STATUS_HV_INVALID_LP_INDEX: NTSTATUS = -1_070_268_351_i32; +pub const STATUS_HV_INVALID_PARAMETER: NTSTATUS = -1_070_268_411_i32; +pub const STATUS_HV_INVALID_PARTITION_ID: NTSTATUS = -1_070_268_403_i32; +pub const STATUS_HV_INVALID_PARTITION_STATE: NTSTATUS = -1_070_268_409_i32; +pub const STATUS_HV_INVALID_PORT_ID: NTSTATUS = -1_070_268_399_i32; +pub const STATUS_HV_INVALID_PROXIMITY_DOMAIN_INFO: NTSTATUS = -1_070_268_390_i32; +pub const STATUS_HV_INVALID_REGISTER_VALUE: NTSTATUS = -1_070_268_336_i32; +pub const STATUS_HV_INVALID_SAVE_RESTORE_STATE: NTSTATUS = -1_070_268_393_i32; +pub const STATUS_HV_INVALID_SYNIC_STATE: NTSTATUS = -1_070_268_392_i32; +pub const STATUS_HV_INVALID_VP_INDEX: NTSTATUS = -1_070_268_402_i32; +pub const STATUS_HV_INVALID_VP_STATE: NTSTATUS = -1_070_268_395_i32; +pub const STATUS_HV_INVALID_VTL_STATE: NTSTATUS = -1_070_268_335_i32; +pub const STATUS_HV_MSR_ACCESS_FAILED: NTSTATUS = -1_070_268_288_i32; +pub const STATUS_HV_NESTED_VM_EXIT: NTSTATUS = -1_070_268_297_i32; +pub const STATUS_HV_NOT_ACKNOWLEDGED: NTSTATUS = -1_070_268_396_i32; +pub const STATUS_HV_NOT_ALLOWED_WITH_NESTED_VIRT_ACTIVE: NTSTATUS = -1_070_268_302_i32; +pub const STATUS_HV_NOT_PRESENT: NTSTATUS = -1_070_264_320_i32; +pub const STATUS_HV_NO_DATA: NTSTATUS = -1_070_268_389_i32; +pub const STATUS_HV_NO_RESOURCES: NTSTATUS = -1_070_268_387_i32; +pub const STATUS_HV_NX_NOT_DETECTED: NTSTATUS = -1_070_268_331_i32; +pub const STATUS_HV_OBJECT_IN_USE: NTSTATUS = -1_070_268_391_i32; +pub const STATUS_HV_OPERATION_DENIED: NTSTATUS = -1_070_268_408_i32; +pub const STATUS_HV_OPERATION_FAILED: NTSTATUS = -1_070_268_303_i32; +pub const STATUS_HV_PAGE_REQUEST_INVALID: NTSTATUS = -1_070_268_320_i32; +pub const STATUS_HV_PARTITION_TOO_DEEP: NTSTATUS = -1_070_268_404_i32; +pub const STATUS_HV_PENDING_PAGE_REQUESTS: NTSTATUS = 3_473_497_i32; +pub const STATUS_HV_PROCESSOR_STARTUP_TIMEOUT: NTSTATUS = -1_070_268_354_i32; +pub const STATUS_HV_PROPERTY_VALUE_OUT_OF_RANGE: NTSTATUS = -1_070_268_406_i32; +pub const STATUS_HV_SMX_ENABLED: NTSTATUS = -1_070_268_353_i32; +pub const STATUS_HV_UNKNOWN_PROPERTY: NTSTATUS = -1_070_268_407_i32; +pub const STATUS_ILLEGAL_CHARACTER: NTSTATUS = -1_073_741_471_i32; +pub const STATUS_ILLEGAL_DLL_RELOCATION: NTSTATUS = -1_073_741_207_i32; +pub const STATUS_ILLEGAL_ELEMENT_ADDRESS: NTSTATUS = -1_073_741_179_i32; +pub const STATUS_ILLEGAL_FLOAT_CONTEXT: NTSTATUS = -1_073_741_494_i32; +pub const STATUS_ILLEGAL_FUNCTION: NTSTATUS = -1_073_741_649_i32; +pub const STATUS_ILLEGAL_INSTRUCTION: NTSTATUS = -1_073_741_795_i32; +pub const STATUS_ILL_FORMED_PASSWORD: NTSTATUS = -1_073_741_717_i32; +pub const STATUS_ILL_FORMED_SERVICE_ENTRY: NTSTATUS = -1_073_741_472_i32; +pub const STATUS_IMAGE_ALREADY_LOADED: NTSTATUS = -1_073_741_554_i32; +pub const STATUS_IMAGE_ALREADY_LOADED_AS_DLL: NTSTATUS = -1_073_741_411_i32; +pub const STATUS_IMAGE_AT_DIFFERENT_BASE: NTSTATUS = 1_073_741_878_i32; +pub const STATUS_IMAGE_CERT_EXPIRED: NTSTATUS = -1_073_740_283_i32; +pub const STATUS_IMAGE_CERT_REVOKED: NTSTATUS = -1_073_740_285_i32; +pub const STATUS_IMAGE_CHECKSUM_MISMATCH: NTSTATUS = -1_073_741_279_i32; +pub const STATUS_IMAGE_LOADED_AS_PATCH_IMAGE: NTSTATUS = -1_073_740_608_i32; +pub const STATUS_IMAGE_MACHINE_TYPE_MISMATCH: NTSTATUS = 1_073_741_838_i32; +pub const STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE: NTSTATUS = 1_073_741_859_i32; +pub const STATUS_IMAGE_MP_UP_MISMATCH: NTSTATUS = -1_073_741_239_i32; +pub const STATUS_IMAGE_NOT_AT_BASE: NTSTATUS = 1_073_741_827_i32; +pub const STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT: NTSTATUS = -1_073_741_405_i32; +pub const STATUS_IMPLEMENTATION_LIMIT: NTSTATUS = -1_073_740_757_i32; +pub const STATUS_INCOMPATIBLE_DRIVER_BLOCKED: NTSTATUS = -1_073_740_764_i32; +pub const STATUS_INCOMPATIBLE_FILE_MAP: NTSTATUS = -1_073_741_747_i32; +pub const STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: NTSTATUS = + -1_073_741_410_i32; +pub const STATUS_INCORRECT_ACCOUNT_TYPE: NTSTATUS = -1_073_700_727_i32; +pub const STATUS_INDEX_OUT_OF_BOUNDS: NTSTATUS = -1_073_740_591_i32; +pub const STATUS_INDOUBT_TRANSACTIONS_EXIST: NTSTATUS = -1_072_103_366_i32; +pub const STATUS_INFO_LENGTH_MISMATCH: NTSTATUS = -1_073_741_820_i32; +pub const STATUS_INSTANCE_NOT_AVAILABLE: NTSTATUS = -1_073_741_653_i32; +pub const STATUS_INSTRUCTION_MISALIGNMENT: NTSTATUS = -1_073_741_654_i32; +pub const STATUS_INSUFFICIENT_LOGON_INFO: NTSTATUS = -1_073_741_232_i32; +pub const STATUS_INSUFFICIENT_NVRAM_RESOURCES: NTSTATUS = -1_073_740_716_i32; +pub const STATUS_INSUFFICIENT_POWER: NTSTATUS = -1_073_741_090_i32; +pub const STATUS_INSUFFICIENT_RESOURCES: NTSTATUS = -1_073_741_670_i32; +pub const STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: NTSTATUS = + -1_073_740_778_i32; +pub const STATUS_INSUFFICIENT_VIRTUAL_ADDR_RESOURCES: NTSTATUS = -1_073_740_606_i32; +pub const STATUS_INSUFF_SERVER_RESOURCES: NTSTATUS = -1_073_741_307_i32; +pub const STATUS_INTEGER_DIVIDE_BY_ZERO: NTSTATUS = -1_073_741_676_i32; +pub const STATUS_INTEGER_OVERFLOW: NTSTATUS = -1_073_741_675_i32; +pub const STATUS_INTERMIXED_KERNEL_EA_OPERATION: NTSTATUS = -1_073_740_687_i32; +pub const STATUS_INTERNAL_DB_CORRUPTION: NTSTATUS = -1_073_741_596_i32; +pub const STATUS_INTERNAL_DB_ERROR: NTSTATUS = -1_073_741_480_i32; +pub const STATUS_INTERNAL_ERROR: NTSTATUS = -1_073_741_595_i32; +pub const STATUS_INTERRUPTED: NTSTATUS = -1_073_740_523_i32; +pub const STATUS_INTERRUPT_STILL_CONNECTED: NTSTATUS = 296_i32; +pub const STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED: NTSTATUS = 295_i32; +pub const STATUS_INVALID_ACCOUNT_NAME: NTSTATUS = -1_073_741_726_i32; +pub const STATUS_INVALID_ACE_CONDITION: NTSTATUS = -1_073_741_406_i32; +pub const STATUS_INVALID_ACL: NTSTATUS = -1_073_741_705_i32; +pub const STATUS_INVALID_ADDRESS: NTSTATUS = -1_073_741_503_i32; +pub const STATUS_INVALID_ADDRESS_COMPONENT: NTSTATUS = -1_073_741_305_i32; +pub const STATUS_INVALID_ADDRESS_WILDCARD: NTSTATUS = -1_073_741_304_i32; +pub const STATUS_INVALID_BLOCK_LENGTH: NTSTATUS = -1_073_741_453_i32; +pub const STATUS_INVALID_BUFFER_SIZE: NTSTATUS = -1_073_741_306_i32; +pub const STATUS_INVALID_CAP: NTSTATUS = -1_073_740_539_i32; +pub const STATUS_INVALID_CID: NTSTATUS = -1_073_741_813_i32; +pub const STATUS_INVALID_COMPUTER_NAME: NTSTATUS = -1_073_741_534_i32; +pub const STATUS_INVALID_CONNECTION: NTSTATUS = -1_073_741_504_i32; +pub const STATUS_INVALID_CRUNTIME_PARAMETER: NTSTATUS = -1_073_740_777_i32; +pub const STATUS_INVALID_DEVICE_OBJECT_PARAMETER: NTSTATUS = -1_073_740_951_i32; +pub const STATUS_INVALID_DEVICE_REQUEST: NTSTATUS = -1_073_741_808_i32; +pub const STATUS_INVALID_DEVICE_STATE: NTSTATUS = -1_073_741_436_i32; +pub const STATUS_INVALID_DISPOSITION: NTSTATUS = -1_073_741_786_i32; +pub const STATUS_INVALID_DOMAIN_ROLE: NTSTATUS = -1_073_741_602_i32; +pub const STATUS_INVALID_DOMAIN_STATE: NTSTATUS = -1_073_741_603_i32; +pub const STATUS_INVALID_EA_FLAG: NTSTATUS = -2_147_483_627_i32; +pub const STATUS_INVALID_EA_NAME: NTSTATUS = -2_147_483_629_i32; +pub const STATUS_INVALID_EXCEPTION_HANDLER: NTSTATUS = -1_073_741_403_i32; +pub const STATUS_INVALID_FIELD_IN_PARAMETER_LIST: NTSTATUS = -1_073_740_683_i32; +pub const STATUS_INVALID_FILE_FOR_SECTION: NTSTATUS = -1_073_741_792_i32; +pub const STATUS_INVALID_GROUP_ATTRIBUTES: NTSTATUS = -1_073_741_660_i32; +pub const STATUS_INVALID_HANDLE: NTSTATUS = -1_073_741_816_i32; +pub const STATUS_INVALID_HW_PROFILE: NTSTATUS = -1_073_741_216_i32; +pub const STATUS_INVALID_IDN_NORMALIZATION: NTSTATUS = -1_073_740_010_i32; +pub const STATUS_INVALID_ID_AUTHORITY: NTSTATUS = -1_073_741_692_i32; +pub const STATUS_INVALID_IMAGE_FORMAT: NTSTATUS = -1_073_741_701_i32; +pub const STATUS_INVALID_IMAGE_HASH: NTSTATUS = -1_073_740_760_i32; +pub const STATUS_INVALID_IMAGE_LE_FORMAT: NTSTATUS = -1_073_741_522_i32; +pub const STATUS_INVALID_IMAGE_NE_FORMAT: NTSTATUS = -1_073_741_541_i32; +pub const STATUS_INVALID_IMAGE_NOT_MZ: NTSTATUS = -1_073_741_521_i32; +pub const STATUS_INVALID_IMAGE_PROTECT: NTSTATUS = -1_073_741_520_i32; +pub const STATUS_INVALID_IMAGE_WIN_16: NTSTATUS = -1_073_741_519_i32; +pub const STATUS_INVALID_IMAGE_WIN_32: NTSTATUS = -1_073_740_967_i32; +pub const STATUS_INVALID_IMAGE_WIN_64: NTSTATUS = -1_073_740_966_i32; +pub const STATUS_INVALID_IMPORT_OF_NON_DLL: NTSTATUS = -1_073_740_945_i32; +pub const STATUS_INVALID_INFO_CLASS: NTSTATUS = -1_073_741_821_i32; +pub const STATUS_INVALID_INITIATOR_TARGET_PATH: NTSTATUS = -1_073_740_681_i32; +pub const STATUS_INVALID_KERNEL_INFO_VERSION: NTSTATUS = -1_073_700_860_i32; +pub const STATUS_INVALID_LABEL: NTSTATUS = -1_073_740_730_i32; +pub const STATUS_INVALID_LDT_DESCRIPTOR: NTSTATUS = -1_073_741_542_i32; +pub const STATUS_INVALID_LDT_OFFSET: NTSTATUS = -1_073_741_543_i32; +pub const STATUS_INVALID_LDT_SIZE: NTSTATUS = -1_073_741_544_i32; +pub const STATUS_INVALID_LEVEL: NTSTATUS = -1_073_741_496_i32; +pub const STATUS_INVALID_LOCK_RANGE: NTSTATUS = -1_073_741_407_i32; +pub const STATUS_INVALID_LOCK_SEQUENCE: NTSTATUS = -1_073_741_794_i32; +pub const STATUS_INVALID_LOGON_HOURS: NTSTATUS = -1_073_741_713_i32; +pub const STATUS_INVALID_LOGON_TYPE: NTSTATUS = -1_073_741_557_i32; +pub const STATUS_INVALID_MEMBER: NTSTATUS = -1_073_741_445_i32; +pub const STATUS_INVALID_MESSAGE: NTSTATUS = -1_073_740_030_i32; +pub const STATUS_INVALID_NETWORK_RESPONSE: NTSTATUS = -1_073_741_629_i32; +pub const STATUS_INVALID_OFFSET_ALIGNMENT: NTSTATUS = -1_073_740_684_i32; +pub const STATUS_INVALID_OPLOCK_PROTOCOL: NTSTATUS = -1_073_741_597_i32; +pub const STATUS_INVALID_OWNER: NTSTATUS = -1_073_741_734_i32; +pub const STATUS_INVALID_PACKAGE_SID_LENGTH: NTSTATUS = -1_073_700_350_i32; +pub const STATUS_INVALID_PAGE_PROTECTION: NTSTATUS = -1_073_741_755_i32; +pub const STATUS_INVALID_PARAMETER: NTSTATUS = -1_073_741_811_i32; +pub const STATUS_INVALID_PARAMETER_1: NTSTATUS = -1_073_741_585_i32; +pub const STATUS_INVALID_PARAMETER_10: NTSTATUS = -1_073_741_576_i32; +pub const STATUS_INVALID_PARAMETER_11: NTSTATUS = -1_073_741_575_i32; +pub const STATUS_INVALID_PARAMETER_12: NTSTATUS = -1_073_741_574_i32; +pub const STATUS_INVALID_PARAMETER_2: NTSTATUS = -1_073_741_584_i32; +pub const STATUS_INVALID_PARAMETER_3: NTSTATUS = -1_073_741_583_i32; +pub const STATUS_INVALID_PARAMETER_4: NTSTATUS = -1_073_741_582_i32; +pub const STATUS_INVALID_PARAMETER_5: NTSTATUS = -1_073_741_581_i32; +pub const STATUS_INVALID_PARAMETER_6: NTSTATUS = -1_073_741_580_i32; +pub const STATUS_INVALID_PARAMETER_7: NTSTATUS = -1_073_741_579_i32; +pub const STATUS_INVALID_PARAMETER_8: NTSTATUS = -1_073_741_578_i32; +pub const STATUS_INVALID_PARAMETER_9: NTSTATUS = -1_073_741_577_i32; +pub const STATUS_INVALID_PARAMETER_MIX: NTSTATUS = -1_073_741_776_i32; +pub const STATUS_INVALID_PEP_INFO_VERSION: NTSTATUS = -1_073_700_859_i32; +pub const STATUS_INVALID_PIPE_STATE: NTSTATUS = -1_073_741_651_i32; +pub const STATUS_INVALID_PLUGPLAY_DEVICE_PATH: NTSTATUS = -1_073_741_215_i32; +pub const STATUS_INVALID_PORT_ATTRIBUTES: NTSTATUS = -1_073_741_778_i32; +pub const STATUS_INVALID_PORT_HANDLE: NTSTATUS = -1_073_741_758_i32; +pub const STATUS_INVALID_PRIMARY_GROUP: NTSTATUS = -1_073_741_733_i32; +pub const STATUS_INVALID_QUOTA_LOWER: NTSTATUS = -1_073_741_775_i32; +pub const STATUS_INVALID_READ_MODE: NTSTATUS = -1_073_741_644_i32; +pub const STATUS_INVALID_RUNLEVEL_SETTING: NTSTATUS = -1_073_700_542_i32; +pub const STATUS_INVALID_SECURITY_DESCR: NTSTATUS = -1_073_741_703_i32; +pub const STATUS_INVALID_SERVER_STATE: NTSTATUS = -1_073_741_604_i32; +pub const STATUS_INVALID_SESSION: NTSTATUS = -1_073_740_715_i32; +pub const STATUS_INVALID_SID: NTSTATUS = -1_073_741_704_i32; +pub const STATUS_INVALID_SIGNATURE: NTSTATUS = -1_073_700_864_i32; +pub const STATUS_INVALID_STATE_TRANSITION: NTSTATUS = -1_073_700_861_i32; +pub const STATUS_INVALID_SUB_AUTHORITY: NTSTATUS = -1_073_741_706_i32; +pub const STATUS_INVALID_SYSTEM_SERVICE: NTSTATUS = -1_073_741_796_i32; +pub const STATUS_INVALID_TASK_INDEX: NTSTATUS = -1_073_740_543_i32; +pub const STATUS_INVALID_TASK_NAME: NTSTATUS = -1_073_740_544_i32; +pub const STATUS_INVALID_THREAD: NTSTATUS = -1_073_740_004_i32; +pub const STATUS_INVALID_TOKEN: NTSTATUS = -1_073_740_699_i32; +pub const STATUS_INVALID_TRANSACTION: NTSTATUS = -1_072_103_422_i32; +pub const STATUS_INVALID_UNWIND_TARGET: NTSTATUS = -1_073_741_783_i32; +pub const STATUS_INVALID_USER_BUFFER: NTSTATUS = -1_073_741_592_i32; +pub const STATUS_INVALID_USER_PRINCIPAL_NAME: NTSTATUS = -1_073_740_772_i32; +pub const STATUS_INVALID_VARIANT: NTSTATUS = -1_073_741_262_i32; +pub const STATUS_INVALID_VIEW_SIZE: NTSTATUS = -1_073_741_793_i32; +pub const STATUS_INVALID_VOLUME_LABEL: NTSTATUS = -1_073_741_690_i32; +pub const STATUS_INVALID_WEIGHT: NTSTATUS = -1_073_740_712_i32; +pub const STATUS_INVALID_WORKSTATION: NTSTATUS = -1_073_741_712_i32; +pub const STATUS_IN_PAGE_ERROR: NTSTATUS = -1_073_741_818_i32; +pub const STATUS_IORING_COMPLETION_QUEUE_TOO_BIG: NTSTATUS = -1_069_154_299_i32; +pub const STATUS_IORING_COMPLETION_QUEUE_TOO_FULL: NTSTATUS = -1_069_154_296_i32; +pub const STATUS_IORING_CORRUPT: NTSTATUS = -1_069_154_297_i32; +pub const STATUS_IORING_REQUIRED_FLAG_NOT_SUPPORTED: NTSTATUS = -1_069_154_303_i32; +pub const STATUS_IORING_SUBMISSION_QUEUE_FULL: NTSTATUS = -1_069_154_302_i32; +pub const STATUS_IORING_SUBMISSION_QUEUE_TOO_BIG: NTSTATUS = -1_069_154_300_i32; +pub const STATUS_IORING_SUBMIT_IN_PROGRESS: NTSTATUS = -1_069_154_298_i32; +pub const STATUS_IORING_VERSION_NOT_SUPPORTED: NTSTATUS = -1_069_154_301_i32; +pub const STATUS_IO_DEVICE_ERROR: NTSTATUS = -1_073_741_435_i32; +pub const STATUS_IO_DEVICE_INVALID_DATA: NTSTATUS = -1_073_741_392_i32; +pub const STATUS_IO_OPERATION_TIMEOUT: NTSTATUS = -1_073_740_675_i32; +pub const STATUS_IO_PREEMPTED: NTSTATUS = -1_068_433_407_i32; +pub const STATUS_IO_PRIVILEGE_FAILED: NTSTATUS = -1_073_741_513_i32; +pub const STATUS_IO_REISSUE_AS_CACHED: NTSTATUS = -1_073_479_623_i32; +pub const STATUS_IO_REPARSE_DATA_INVALID: NTSTATUS = -1_073_741_192_i32; +pub const STATUS_IO_REPARSE_TAG_INVALID: NTSTATUS = -1_073_741_194_i32; +pub const STATUS_IO_REPARSE_TAG_MISMATCH: NTSTATUS = -1_073_741_193_i32; +pub const STATUS_IO_REPARSE_TAG_NOT_HANDLED: NTSTATUS = -1_073_741_191_i32; +pub const STATUS_IO_TIMEOUT: NTSTATUS = -1_073_741_643_i32; +pub const STATUS_IO_UNALIGNED_WRITE: NTSTATUS = -1_073_741_391_i32; +pub const STATUS_IPSEC_AUTH_FIREWALL_DROP: NTSTATUS = -1_070_202_872_i32; +pub const STATUS_IPSEC_BAD_SPI: NTSTATUS = -1_070_202_879_i32; +pub const STATUS_IPSEC_CLEAR_TEXT_DROP: NTSTATUS = -1_070_202_873_i32; +pub const STATUS_IPSEC_DOSP_BLOCK: NTSTATUS = -1_070_170_112_i32; +pub const STATUS_IPSEC_DOSP_INVALID_PACKET: NTSTATUS = -1_070_170_110_i32; +pub const STATUS_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: NTSTATUS = -1_070_170_107_i32; +pub const STATUS_IPSEC_DOSP_MAX_ENTRIES: NTSTATUS = -1_070_170_108_i32; +pub const STATUS_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: NTSTATUS = -1_070_170_106_i32; +pub const STATUS_IPSEC_DOSP_RECEIVED_MULTICAST: NTSTATUS = -1_070_170_111_i32; +pub const STATUS_IPSEC_DOSP_STATE_LOOKUP_FAILED: NTSTATUS = -1_070_170_109_i32; +pub const STATUS_IPSEC_INTEGRITY_CHECK_FAILED: NTSTATUS = -1_070_202_874_i32; +pub const STATUS_IPSEC_INVALID_PACKET: NTSTATUS = -1_070_202_875_i32; +pub const STATUS_IPSEC_QUEUE_OVERFLOW: NTSTATUS = -1_073_700_848_i32; +pub const STATUS_IPSEC_REPLAY_CHECK_FAILED: NTSTATUS = -1_070_202_876_i32; +pub const STATUS_IPSEC_SA_LIFETIME_EXPIRED: NTSTATUS = -1_070_202_878_i32; +pub const STATUS_IPSEC_THROTTLE_DROP: NTSTATUS = -1_070_202_871_i32; +pub const STATUS_IPSEC_WRONG_SA: NTSTATUS = -1_070_202_877_i32; +pub const STATUS_IP_ADDRESS_CONFLICT1: NTSTATUS = -1_073_741_228_i32; +pub const STATUS_IP_ADDRESS_CONFLICT2: NTSTATUS = -1_073_741_227_i32; +pub const STATUS_ISSUING_CA_UNTRUSTED: NTSTATUS = -1_073_740_918_i32; +pub const STATUS_ISSUING_CA_UNTRUSTED_KDC: NTSTATUS = -1_073_740_787_i32; +pub const STATUS_JOB_NOT_EMPTY: NTSTATUS = -1_073_740_529_i32; +pub const STATUS_JOB_NO_CONTAINER: NTSTATUS = -1_073_740_535_i32; +pub const STATUS_JOURNAL_DELETE_IN_PROGRESS: NTSTATUS = -1_073_741_129_i32; +pub const STATUS_JOURNAL_ENTRY_DELETED: NTSTATUS = -1_073_741_105_i32; +pub const STATUS_JOURNAL_NOT_ACTIVE: NTSTATUS = -1_073_741_128_i32; +pub const STATUS_KDC_CERT_EXPIRED: NTSTATUS = -1_073_740_786_i32; +pub const STATUS_KDC_CERT_REVOKED: NTSTATUS = -1_073_740_785_i32; +pub const STATUS_KDC_INVALID_REQUEST: NTSTATUS = -1_073_741_061_i32; +pub const STATUS_KDC_UNABLE_TO_REFER: NTSTATUS = -1_073_741_060_i32; +pub const STATUS_KDC_UNKNOWN_ETYPE: NTSTATUS = -1_073_741_059_i32; +pub const STATUS_KERNEL_APC: NTSTATUS = 256_i32; +pub const STATUS_KERNEL_EXECUTABLE_MEMORY_WRITE: NTSTATUS = -1_073_739_996_i32; +pub const STATUS_KEY_DELETED: NTSTATUS = -1_073_741_444_i32; +pub const STATUS_KEY_HAS_CHILDREN: NTSTATUS = -1_073_741_440_i32; +pub const STATUS_LAST_ADMIN: NTSTATUS = -1_073_741_719_i32; +pub const STATUS_LICENSE_QUOTA_EXCEEDED: NTSTATUS = -1_073_741_223_i32; +pub const STATUS_LICENSE_VIOLATION: NTSTATUS = -1_073_741_206_i32; +pub const STATUS_LINK_FAILED: NTSTATUS = -1_073_741_506_i32; +pub const STATUS_LINK_TIMEOUT: NTSTATUS = -1_073_741_505_i32; +pub const STATUS_LM_CROSS_ENCRYPTION_REQUIRED: NTSTATUS = -1_073_741_441_i32; +pub const STATUS_LOCAL_DISCONNECT: NTSTATUS = -1_073_741_509_i32; +pub const STATUS_LOCAL_POLICY_MODIFICATION_NOT_SUPPORTED: NTSTATUS = -1_073_700_726_i32; +pub const STATUS_LOCAL_USER_SESSION_KEY: NTSTATUS = 1_073_741_830_i32; +pub const STATUS_LOCK_NOT_GRANTED: NTSTATUS = -1_073_741_739_i32; +pub const STATUS_LOGIN_TIME_RESTRICTION: NTSTATUS = -1_073_741_241_i32; +pub const STATUS_LOGIN_WKSTA_RESTRICTION: NTSTATUS = -1_073_741_240_i32; +pub const STATUS_LOGON_NOT_GRANTED: NTSTATUS = -1_073_741_483_i32; +pub const STATUS_LOGON_SERVER_CONFLICT: NTSTATUS = -1_073_741_518_i32; +pub const STATUS_LOGON_SESSION_COLLISION: NTSTATUS = -1_073_741_563_i32; +pub const STATUS_LOGON_SESSION_EXISTS: NTSTATUS = -1_073_741_586_i32; +pub const STATUS_LOG_APPENDED_FLUSH_FAILED: NTSTATUS = -1_072_037_841_i32; +pub const STATUS_LOG_ARCHIVE_IN_PROGRESS: NTSTATUS = -1_072_037_855_i32; +pub const STATUS_LOG_ARCHIVE_NOT_IN_PROGRESS: NTSTATUS = -1_072_037_856_i32; +pub const STATUS_LOG_BLOCKS_EXHAUSTED: NTSTATUS = -1_072_037_882_i32; +pub const STATUS_LOG_BLOCK_INCOMPLETE: NTSTATUS = -1_072_037_884_i32; +pub const STATUS_LOG_BLOCK_INVALID: NTSTATUS = -1_072_037_878_i32; +pub const STATUS_LOG_BLOCK_VERSION: NTSTATUS = -1_072_037_879_i32; +pub const STATUS_LOG_CANT_DELETE: NTSTATUS = -1_072_037_871_i32; +pub const STATUS_LOG_CLIENT_ALREADY_REGISTERED: NTSTATUS = -1_072_037_852_i32; +pub const STATUS_LOG_CLIENT_NOT_REGISTERED: NTSTATUS = -1_072_037_851_i32; +pub const STATUS_LOG_CONTAINER_LIMIT_EXCEEDED: NTSTATUS = -1_072_037_870_i32; +pub const STATUS_LOG_CONTAINER_OPEN_FAILED: NTSTATUS = -1_072_037_847_i32; +pub const STATUS_LOG_CONTAINER_READ_FAILED: NTSTATUS = -1_072_037_849_i32; +pub const STATUS_LOG_CONTAINER_STATE_INVALID: NTSTATUS = -1_072_037_846_i32; +pub const STATUS_LOG_CONTAINER_WRITE_FAILED: NTSTATUS = -1_072_037_848_i32; +pub const STATUS_LOG_CORRUPTION_DETECTED: NTSTATUS = -1_072_103_376_i32; +pub const STATUS_LOG_DEDICATED: NTSTATUS = -1_072_037_857_i32; +pub const STATUS_LOG_EPHEMERAL: NTSTATUS = -1_072_037_854_i32; +pub const STATUS_LOG_FILE_FULL: NTSTATUS = -1_073_741_432_i32; +pub const STATUS_LOG_FULL: NTSTATUS = -1_072_037_859_i32; +pub const STATUS_LOG_FULL_HANDLER_IN_PROGRESS: NTSTATUS = -1_072_037_850_i32; +pub const STATUS_LOG_GROWTH_FAILED: NTSTATUS = -1_072_103_399_i32; +pub const STATUS_LOG_HARD_ERROR: NTSTATUS = 1_073_741_850_i32; +pub const STATUS_LOG_INCONSISTENT_SECURITY: NTSTATUS = -1_072_037_842_i32; +pub const STATUS_LOG_INVALID_RANGE: NTSTATUS = -1_072_037_883_i32; +pub const STATUS_LOG_METADATA_CORRUPT: NTSTATUS = -1_072_037_875_i32; +pub const STATUS_LOG_METADATA_FLUSH_FAILED: NTSTATUS = -1_072_037_843_i32; +pub const STATUS_LOG_METADATA_INCONSISTENT: NTSTATUS = -1_072_037_873_i32; +pub const STATUS_LOG_METADATA_INVALID: NTSTATUS = -1_072_037_874_i32; +pub const STATUS_LOG_MULTIPLEXED: NTSTATUS = -1_072_037_858_i32; +pub const STATUS_LOG_NOT_ENOUGH_CONTAINERS: NTSTATUS = -1_072_037_853_i32; +pub const STATUS_LOG_NO_RESTART: NTSTATUS = 1_075_445_772_i32; +pub const STATUS_LOG_PINNED: NTSTATUS = -1_072_037_844_i32; +pub const STATUS_LOG_PINNED_ARCHIVE_TAIL: NTSTATUS = -1_072_037_864_i32; +pub const STATUS_LOG_PINNED_RESERVATION: NTSTATUS = -1_072_037_840_i32; +pub const STATUS_LOG_POLICY_ALREADY_INSTALLED: NTSTATUS = -1_072_037_868_i32; +pub const STATUS_LOG_POLICY_CONFLICT: NTSTATUS = -1_072_037_865_i32; +pub const STATUS_LOG_POLICY_INVALID: NTSTATUS = -1_072_037_866_i32; +pub const STATUS_LOG_POLICY_NOT_INSTALLED: NTSTATUS = -1_072_037_867_i32; +pub const STATUS_LOG_READ_CONTEXT_INVALID: NTSTATUS = -1_072_037_881_i32; +pub const STATUS_LOG_READ_MODE_INVALID: NTSTATUS = -1_072_037_877_i32; +pub const STATUS_LOG_RECORDS_RESERVED_INVALID: NTSTATUS = -1_072_037_862_i32; +pub const STATUS_LOG_RECORD_NONEXISTENT: NTSTATUS = -1_072_037_863_i32; +pub const STATUS_LOG_RESERVATION_INVALID: NTSTATUS = -1_072_037_872_i32; +pub const STATUS_LOG_RESIZE_INVALID_SIZE: NTSTATUS = -1_072_103_413_i32; +pub const STATUS_LOG_RESTART_INVALID: NTSTATUS = -1_072_037_880_i32; +pub const STATUS_LOG_SECTOR_INVALID: NTSTATUS = -1_072_037_887_i32; +pub const STATUS_LOG_SECTOR_PARITY_INVALID: NTSTATUS = -1_072_037_886_i32; +pub const STATUS_LOG_SECTOR_REMAPPED: NTSTATUS = -1_072_037_885_i32; +pub const STATUS_LOG_SPACE_RESERVED_INVALID: NTSTATUS = -1_072_037_861_i32; +pub const STATUS_LOG_START_OF_LOG: NTSTATUS = -1_072_037_869_i32; +pub const STATUS_LOG_STATE_INVALID: NTSTATUS = -1_072_037_845_i32; +pub const STATUS_LOG_TAIL_INVALID: NTSTATUS = -1_072_037_860_i32; +pub const STATUS_LONGJUMP: NTSTATUS = -2_147_483_610_i32; +pub const STATUS_LOST_MODE_LOGON_RESTRICTION: NTSTATUS = -1_073_741_043_i32; +pub const STATUS_LOST_WRITEBEHIND_DATA: NTSTATUS = -1_073_741_278_i32; +pub const STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: NTSTATUS = -1_073_700_734_i32; +pub const STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: NTSTATUS = -1_073_700_736_i32; +pub const STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: NTSTATUS = -1_073_700_735_i32; +pub const STATUS_LPAC_ACCESS_DENIED: NTSTATUS = -1_073_700_349_i32; +pub const STATUS_LPC_HANDLE_COUNT_EXCEEDED: NTSTATUS = -1_073_739_998_i32; +pub const STATUS_LPC_INVALID_CONNECTION_USAGE: NTSTATUS = -1_073_740_026_i32; +pub const STATUS_LPC_RECEIVE_BUFFER_EXPECTED: NTSTATUS = -1_073_740_027_i32; +pub const STATUS_LPC_REPLY_LOST: NTSTATUS = -1_073_741_229_i32; +pub const STATUS_LPC_REQUESTS_NOT_ALLOWED: NTSTATUS = -1_073_740_025_i32; +pub const STATUS_LUIDS_EXHAUSTED: NTSTATUS = -1_073_741_707_i32; +pub const STATUS_MAGAZINE_NOT_PRESENT: NTSTATUS = -1_073_741_178_i32; +pub const STATUS_MAPPED_ALIGNMENT: NTSTATUS = -1_073_741_280_i32; +pub const STATUS_MAPPED_FILE_SIZE_ZERO: NTSTATUS = -1_073_741_538_i32; +pub const STATUS_MARKED_TO_DISALLOW_WRITES: NTSTATUS = -1_073_740_659_i32; +pub const STATUS_MARSHALL_OVERFLOW: NTSTATUS = -1_073_741_263_i32; +pub const STATUS_MAX_REFERRALS_EXCEEDED: NTSTATUS = -1_073_741_068_i32; +pub const STATUS_MCA_EXCEPTION: NTSTATUS = -1_073_740_013_i32; +pub const STATUS_MCA_OCCURED: NTSTATUS = -1_073_740_950_i32; +pub const STATUS_MEDIA_CHANGED: NTSTATUS = -2_147_483_620_i32; +pub const STATUS_MEDIA_CHECK: NTSTATUS = -2_147_483_616_i32; +pub const STATUS_MEDIA_WRITE_PROTECTED: NTSTATUS = -1_073_741_662_i32; +pub const STATUS_MEMBERS_PRIMARY_GROUP: NTSTATUS = -1_073_741_529_i32; +pub const STATUS_MEMBER_IN_ALIAS: NTSTATUS = -1_073_741_485_i32; +pub const STATUS_MEMBER_IN_GROUP: NTSTATUS = -1_073_741_721_i32; +pub const STATUS_MEMBER_NOT_IN_ALIAS: NTSTATUS = -1_073_741_486_i32; +pub const STATUS_MEMBER_NOT_IN_GROUP: NTSTATUS = -1_073_741_720_i32; +pub const STATUS_MEMORY_NOT_ALLOCATED: NTSTATUS = -1_073_741_664_i32; +pub const STATUS_MESSAGE_LOST: NTSTATUS = -1_073_740_031_i32; +pub const STATUS_MESSAGE_NOT_FOUND: NTSTATUS = -1_073_741_559_i32; +pub const STATUS_MESSAGE_RETRIEVED: NTSTATUS = 1_073_741_870_i32; +pub const STATUS_MFT_TOO_FRAGMENTED: NTSTATUS = -1_073_741_052_i32; +pub const STATUS_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: NTSTATUS = -1_072_103_388_i32; +pub const STATUS_MISSING_SYSTEMFILE: NTSTATUS = -1_073_741_501_i32; +pub const STATUS_MONITOR_INVALID_DESCRIPTOR_CHECKSUM: NTSTATUS = -1_071_841_277_i32; +pub const STATUS_MONITOR_INVALID_DETAILED_TIMING_BLOCK: NTSTATUS = -1_071_841_271_i32; +pub const STATUS_MONITOR_INVALID_MANUFACTURE_DATE: NTSTATUS = -1_071_841_270_i32; +pub const STATUS_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK: NTSTATUS = -1_071_841_274_i32; +pub const STATUS_MONITOR_INVALID_STANDARD_TIMING_BLOCK: NTSTATUS = -1_071_841_276_i32; +pub const STATUS_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK: NTSTATUS = -1_071_841_273_i32; +pub const STATUS_MONITOR_NO_DESCRIPTOR: NTSTATUS = -1_071_841_279_i32; +pub const STATUS_MONITOR_NO_MORE_DESCRIPTOR_DATA: NTSTATUS = -1_071_841_272_i32; +pub const STATUS_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT: NTSTATUS = -1_071_841_278_i32; +pub const STATUS_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED: NTSTATUS = -1_071_841_275_i32; +pub const STATUS_MORE_ENTRIES: NTSTATUS = 261_i32; +pub const STATUS_MORE_PROCESSING_REQUIRED: NTSTATUS = -1_073_741_802_i32; +pub const STATUS_MOUNT_POINT_NOT_RESOLVED: NTSTATUS = -1_073_740_952_i32; +pub const STATUS_MP_PROCESSOR_MISMATCH: NTSTATUS = 1_073_741_865_i32; +pub const STATUS_MUI_FILE_NOT_FOUND: NTSTATUS = -1_073_020_927_i32; +pub const STATUS_MUI_FILE_NOT_LOADED: NTSTATUS = -1_073_020_922_i32; +pub const STATUS_MUI_INVALID_FILE: NTSTATUS = -1_073_020_926_i32; +pub const STATUS_MUI_INVALID_LOCALE_NAME: NTSTATUS = -1_073_020_924_i32; +pub const STATUS_MUI_INVALID_RC_CONFIG: NTSTATUS = -1_073_020_925_i32; +pub const STATUS_MUI_INVALID_ULTIMATEFALLBACK_NAME: NTSTATUS = -1_073_020_923_i32; +pub const STATUS_MULTIPLE_FAULT_VIOLATION: NTSTATUS = -1_073_741_080_i32; +pub const STATUS_MUST_BE_KDC: NTSTATUS = -1_073_741_067_i32; +pub const STATUS_MUTANT_LIMIT_EXCEEDED: NTSTATUS = -1_073_741_423_i32; +pub const STATUS_MUTANT_NOT_OWNED: NTSTATUS = -1_073_741_754_i32; +pub const STATUS_MUTUAL_AUTHENTICATION_FAILED: NTSTATUS = -1_073_741_117_i32; +pub const STATUS_NAME_TOO_LONG: NTSTATUS = -1_073_741_562_i32; +pub const STATUS_NDIS_ADAPTER_NOT_FOUND: NTSTATUS = -1_071_448_058_i32; +pub const STATUS_NDIS_ADAPTER_NOT_READY: NTSTATUS = -1_071_448_047_i32; +pub const STATUS_NDIS_ADAPTER_REMOVED: NTSTATUS = -1_071_448_040_i32; +pub const STATUS_NDIS_ALREADY_MAPPED: NTSTATUS = -1_071_448_035_i32; +pub const STATUS_NDIS_BAD_CHARACTERISTICS: NTSTATUS = -1_071_448_059_i32; +pub const STATUS_NDIS_BAD_VERSION: NTSTATUS = -1_071_448_060_i32; +pub const STATUS_NDIS_BUFFER_TOO_SHORT: NTSTATUS = -1_071_448_042_i32; +pub const STATUS_NDIS_CLOSING: NTSTATUS = -1_071_448_062_i32; +pub const STATUS_NDIS_DEVICE_FAILED: NTSTATUS = -1_071_448_056_i32; +pub const STATUS_NDIS_DOT11_AP_BAND_CURRENTLY_NOT_AVAILABLE: NTSTATUS = -1_071_439_866_i32; +pub const STATUS_NDIS_DOT11_AP_BAND_NOT_ALLOWED: NTSTATUS = -1_071_439_864_i32; +pub const STATUS_NDIS_DOT11_AP_CHANNEL_CURRENTLY_NOT_AVAILABLE: NTSTATUS = -1_071_439_867_i32; +pub const STATUS_NDIS_DOT11_AP_CHANNEL_NOT_ALLOWED: NTSTATUS = -1_071_439_865_i32; +pub const STATUS_NDIS_DOT11_AUTO_CONFIG_ENABLED: NTSTATUS = -1_071_439_872_i32; +pub const STATUS_NDIS_DOT11_MEDIA_IN_USE: NTSTATUS = -1_071_439_871_i32; +pub const STATUS_NDIS_DOT11_POWER_STATE_INVALID: NTSTATUS = -1_071_439_870_i32; +pub const STATUS_NDIS_ERROR_READING_FILE: NTSTATUS = -1_071_448_036_i32; +pub const STATUS_NDIS_FILE_NOT_FOUND: NTSTATUS = -1_071_448_037_i32; +pub const STATUS_NDIS_GROUP_ADDRESS_IN_USE: NTSTATUS = -1_071_448_038_i32; +pub const STATUS_NDIS_INDICATION_REQUIRED: NTSTATUS = 1_076_035_585_i32; +pub const STATUS_NDIS_INTERFACE_NOT_FOUND: NTSTATUS = -1_071_448_021_i32; +pub const STATUS_NDIS_INVALID_ADDRESS: NTSTATUS = -1_071_448_030_i32; +pub const STATUS_NDIS_INVALID_DATA: NTSTATUS = -1_071_448_043_i32; +pub const STATUS_NDIS_INVALID_DEVICE_REQUEST: NTSTATUS = -1_071_448_048_i32; +pub const STATUS_NDIS_INVALID_LENGTH: NTSTATUS = -1_071_448_044_i32; +pub const STATUS_NDIS_INVALID_OID: NTSTATUS = -1_071_448_041_i32; +pub const STATUS_NDIS_INVALID_PACKET: NTSTATUS = -1_071_448_049_i32; +pub const STATUS_NDIS_INVALID_PORT: NTSTATUS = -1_071_448_019_i32; +pub const STATUS_NDIS_INVALID_PORT_STATE: NTSTATUS = -1_071_448_018_i32; +pub const STATUS_NDIS_LOW_POWER_STATE: NTSTATUS = -1_071_448_017_i32; +pub const STATUS_NDIS_MEDIA_DISCONNECTED: NTSTATUS = -1_071_448_033_i32; +pub const STATUS_NDIS_MULTICAST_EXISTS: NTSTATUS = -1_071_448_054_i32; +pub const STATUS_NDIS_MULTICAST_FULL: NTSTATUS = -1_071_448_055_i32; +pub const STATUS_NDIS_MULTICAST_NOT_FOUND: NTSTATUS = -1_071_448_053_i32; +pub const STATUS_NDIS_NOT_SUPPORTED: NTSTATUS = -1_071_447_877_i32; +pub const STATUS_NDIS_NO_QUEUES: NTSTATUS = -1_071_448_015_i32; +pub const STATUS_NDIS_OFFLOAD_CONNECTION_REJECTED: NTSTATUS = -1_071_443_950_i32; +pub const STATUS_NDIS_OFFLOAD_PATH_REJECTED: NTSTATUS = -1_071_443_949_i32; +pub const STATUS_NDIS_OFFLOAD_POLICY: NTSTATUS = -1_071_443_953_i32; +pub const STATUS_NDIS_OPEN_FAILED: NTSTATUS = -1_071_448_057_i32; +pub const STATUS_NDIS_PAUSED: NTSTATUS = -1_071_448_022_i32; +pub const STATUS_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL: NTSTATUS = -1_071_439_868_i32; +pub const STATUS_NDIS_PM_WOL_PATTERN_LIST_FULL: NTSTATUS = -1_071_439_869_i32; +pub const STATUS_NDIS_REINIT_REQUIRED: NTSTATUS = -1_071_448_016_i32; +pub const STATUS_NDIS_REQUEST_ABORTED: NTSTATUS = -1_071_448_052_i32; +pub const STATUS_NDIS_RESET_IN_PROGRESS: NTSTATUS = -1_071_448_051_i32; +pub const STATUS_NDIS_RESOURCE_CONFLICT: NTSTATUS = -1_071_448_034_i32; +pub const STATUS_NDIS_UNSUPPORTED_MEDIA: NTSTATUS = -1_071_448_039_i32; +pub const STATUS_NDIS_UNSUPPORTED_REVISION: NTSTATUS = -1_071_448_020_i32; +pub const STATUS_ND_QUEUE_OVERFLOW: NTSTATUS = -1_073_700_847_i32; +pub const STATUS_NEEDS_REGISTRATION: NTSTATUS = -1_073_740_663_i32; +pub const STATUS_NEEDS_REMEDIATION: NTSTATUS = -1_073_740_702_i32; +pub const STATUS_NETLOGON_NOT_STARTED: NTSTATUS = -1_073_741_422_i32; +pub const STATUS_NETWORK_ACCESS_DENIED: NTSTATUS = -1_073_741_622_i32; +pub const STATUS_NETWORK_ACCESS_DENIED_EDP: NTSTATUS = -1_073_740_658_i32; +pub const STATUS_NETWORK_AUTHENTICATION_PROMPT_CANCELED: NTSTATUS = -1_067_646_972_i32; +pub const STATUS_NETWORK_BUSY: NTSTATUS = -1_073_741_633_i32; +pub const STATUS_NETWORK_CREDENTIAL_CONFLICT: NTSTATUS = -1_073_741_419_i32; +pub const STATUS_NETWORK_NAME_DELETED: NTSTATUS = -1_073_741_623_i32; +pub const STATUS_NETWORK_OPEN_RESTRICTION: NTSTATUS = -1_073_741_311_i32; +pub const STATUS_NETWORK_SESSION_EXPIRED: NTSTATUS = -1_073_740_964_i32; +pub const STATUS_NETWORK_UNREACHABLE: NTSTATUS = -1_073_741_252_i32; +pub const STATUS_NET_WRITE_FAULT: NTSTATUS = -1_073_741_614_i32; +pub const STATUS_NOINTERFACE: NTSTATUS = -1_073_741_127_i32; +pub const STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: NTSTATUS = -1_073_741_416_i32; +pub const STATUS_NOLOGON_SERVER_TRUST_ACCOUNT: NTSTATUS = -1_073_741_414_i32; +pub const STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT: NTSTATUS = -1_073_741_415_i32; +pub const STATUS_NONCONTINUABLE_EXCEPTION: NTSTATUS = -1_073_741_787_i32; +pub const STATUS_NONEXISTENT_EA_ENTRY: NTSTATUS = -1_073_741_743_i32; +pub const STATUS_NONEXISTENT_SECTOR: NTSTATUS = -1_073_741_803_i32; +pub const STATUS_NONE_MAPPED: NTSTATUS = -1_073_741_709_i32; +pub const STATUS_NOTHING_TO_TERMINATE: NTSTATUS = 290_i32; +pub const STATUS_NOTIFICATION_GUID_ALREADY_DEFINED: NTSTATUS = -1_073_741_404_i32; +pub const STATUS_NOTIFY_CLEANUP: NTSTATUS = 267_i32; +pub const STATUS_NOTIFY_ENUM_DIR: NTSTATUS = 268_i32; +pub const STATUS_NOT_ALLOWED_ON_SYSTEM_FILE: NTSTATUS = -1_073_741_401_i32; +pub const STATUS_NOT_ALL_ASSIGNED: NTSTATUS = 262_i32; +pub const STATUS_NOT_APPCONTAINER: NTSTATUS = -1_073_700_352_i32; +pub const STATUS_NOT_A_CLOUD_FILE: NTSTATUS = -1_073_688_825_i32; +pub const STATUS_NOT_A_CLOUD_SYNC_ROOT: NTSTATUS = -1_073_688_802_i32; +pub const STATUS_NOT_A_DAX_VOLUME: NTSTATUS = -1_073_740_623_i32; +pub const STATUS_NOT_A_DIRECTORY: NTSTATUS = -1_073_741_565_i32; +pub const STATUS_NOT_A_REPARSE_POINT: NTSTATUS = -1_073_741_195_i32; +pub const STATUS_NOT_A_TIERED_VOLUME: NTSTATUS = -1_073_740_531_i32; +pub const STATUS_NOT_CAPABLE: NTSTATUS = -1_073_740_759_i32; +pub const STATUS_NOT_CLIENT_SESSION: NTSTATUS = -1_073_741_289_i32; +pub const STATUS_NOT_COMMITTED: NTSTATUS = -1_073_741_779_i32; +pub const STATUS_NOT_DAX_MAPPABLE: NTSTATUS = -1_073_740_622_i32; +pub const STATUS_NOT_EXPORT_FORMAT: NTSTATUS = -1_073_741_166_i32; +pub const STATUS_NOT_FOUND: NTSTATUS = -1_073_741_275_i32; +pub const STATUS_NOT_GUI_PROCESS: NTSTATUS = -1_073_740_538_i32; +pub const STATUS_NOT_IMPLEMENTED: NTSTATUS = -1_073_741_822_i32; +pub const STATUS_NOT_LOCKED: NTSTATUS = -1_073_741_782_i32; +pub const STATUS_NOT_LOGON_PROCESS: NTSTATUS = -1_073_741_587_i32; +pub const STATUS_NOT_MAPPED_DATA: NTSTATUS = -1_073_741_688_i32; +pub const STATUS_NOT_MAPPED_VIEW: NTSTATUS = -1_073_741_799_i32; +pub const STATUS_NOT_READ_FROM_COPY: NTSTATUS = -1_073_740_694_i32; +pub const STATUS_NOT_REDUNDANT_STORAGE: NTSTATUS = -1_073_740_679_i32; +pub const STATUS_NOT_REGISTRY_FILE: NTSTATUS = -1_073_741_476_i32; +pub const STATUS_NOT_SAFE_MODE_DRIVER: NTSTATUS = -1_073_740_961_i32; +pub const STATUS_NOT_SAME_DEVICE: NTSTATUS = -1_073_741_612_i32; +pub const STATUS_NOT_SAME_OBJECT: NTSTATUS = -1_073_741_396_i32; +pub const STATUS_NOT_SERVER_SESSION: NTSTATUS = -1_073_741_290_i32; +pub const STATUS_NOT_SNAPSHOT_VOLUME: NTSTATUS = -1_072_103_353_i32; +pub const STATUS_NOT_SUPPORTED: NTSTATUS = -1_073_741_637_i32; +pub const STATUS_NOT_SUPPORTED_IN_APPCONTAINER: NTSTATUS = -1_073_700_351_i32; +pub const STATUS_NOT_SUPPORTED_ON_DAX: NTSTATUS = -1_073_740_646_i32; +pub const STATUS_NOT_SUPPORTED_ON_SBS: NTSTATUS = -1_073_741_056_i32; +pub const STATUS_NOT_SUPPORTED_WITH_AUDITING: NTSTATUS = -1_073_740_595_i32; +pub const STATUS_NOT_SUPPORTED_WITH_BTT: NTSTATUS = -1_073_740_619_i32; +pub const STATUS_NOT_SUPPORTED_WITH_BYPASSIO: NTSTATUS = -1_073_740_601_i32; +pub const STATUS_NOT_SUPPORTED_WITH_CACHED_HANDLE: NTSTATUS = -1_073_740_587_i32; +pub const STATUS_NOT_SUPPORTED_WITH_COMPRESSION: NTSTATUS = -1_073_740_598_i32; +pub const STATUS_NOT_SUPPORTED_WITH_DEDUPLICATION: NTSTATUS = -1_073_740_596_i32; +pub const STATUS_NOT_SUPPORTED_WITH_ENCRYPTION: NTSTATUS = -1_073_740_599_i32; +pub const STATUS_NOT_SUPPORTED_WITH_MONITORING: NTSTATUS = -1_073_740_594_i32; +pub const STATUS_NOT_SUPPORTED_WITH_REPLICATION: NTSTATUS = -1_073_740_597_i32; +pub const STATUS_NOT_SUPPORTED_WITH_SNAPSHOT: NTSTATUS = -1_073_740_593_i32; +pub const STATUS_NOT_SUPPORTED_WITH_VIRTUALIZATION: NTSTATUS = -1_073_740_592_i32; +pub const STATUS_NOT_TINY_STREAM: NTSTATUS = -1_073_741_274_i32; +pub const STATUS_NO_ACE_CONDITION: NTSTATUS = -2_147_483_601_i32; +pub const STATUS_NO_APPLICABLE_APP_LICENSES_FOUND: NTSTATUS = -1_058_406_399_i32; +pub const STATUS_NO_APPLICATION_PACKAGE: NTSTATUS = -1_073_741_398_i32; +pub const STATUS_NO_BROWSER_SERVERS_FOUND: NTSTATUS = -1_073_741_284_i32; +pub const STATUS_NO_BYPASSIO_DRIVER_SUPPORT: NTSTATUS = -1_073_740_600_i32; +pub const STATUS_NO_CALLBACK_ACTIVE: NTSTATUS = -1_073_741_224_i32; +pub const STATUS_NO_DATA_DETECTED: NTSTATUS = -2_147_483_614_i32; +pub const STATUS_NO_EAS_ON_FILE: NTSTATUS = -1_073_741_742_i32; +pub const STATUS_NO_EFS: NTSTATUS = -1_073_741_170_i32; +pub const STATUS_NO_EVENT_PAIR: NTSTATUS = -1_073_741_490_i32; +pub const STATUS_NO_GUID_TRANSLATION: NTSTATUS = -1_073_741_556_i32; +pub const STATUS_NO_IMPERSONATION_TOKEN: NTSTATUS = -1_073_741_732_i32; +pub const STATUS_NO_INHERITANCE: NTSTATUS = -2_147_483_637_i32; +pub const STATUS_NO_IP_ADDRESSES: NTSTATUS = -1_073_741_071_i32; +pub const STATUS_NO_KERB_KEY: NTSTATUS = -1_073_741_022_i32; +pub const STATUS_NO_KEY: NTSTATUS = -1_073_739_508_i32; +pub const STATUS_NO_LDT: NTSTATUS = -1_073_741_545_i32; +pub const STATUS_NO_LINK_TRACKING_IN_TRANSACTION: NTSTATUS = -1_072_103_335_i32; +pub const STATUS_NO_LOGON_SERVERS: NTSTATUS = -1_073_741_730_i32; +pub const STATUS_NO_LOG_SPACE: NTSTATUS = -1_073_741_443_i32; +pub const STATUS_NO_MATCH: NTSTATUS = -1_073_741_198_i32; +pub const STATUS_NO_MEDIA: NTSTATUS = -1_073_741_448_i32; +pub const STATUS_NO_MEDIA_IN_DEVICE: NTSTATUS = -1_073_741_805_i32; +pub const STATUS_NO_MEMORY: NTSTATUS = -1_073_741_801_i32; +pub const STATUS_NO_MORE_EAS: NTSTATUS = -2_147_483_630_i32; +pub const STATUS_NO_MORE_ENTRIES: NTSTATUS = -2_147_483_622_i32; +pub const STATUS_NO_MORE_FILES: NTSTATUS = -2_147_483_642_i32; +pub const STATUS_NO_MORE_MATCHES: NTSTATUS = -1_073_741_197_i32; +pub const STATUS_NO_PAGEFILE: NTSTATUS = -1_073_741_497_i32; +pub const STATUS_NO_PA_DATA: NTSTATUS = -1_073_741_064_i32; +pub const STATUS_NO_PHYSICALLY_ALIGNED_FREE_SPACE_FOUND: NTSTATUS = -1_073_740_635_i32; +pub const STATUS_NO_QUOTAS_FOR_ACCOUNT: NTSTATUS = 269_i32; +pub const STATUS_NO_RANGES_PROCESSED: NTSTATUS = -1_073_740_704_i32; +pub const STATUS_NO_RECOVERY_POLICY: NTSTATUS = -1_073_741_171_i32; +pub const STATUS_NO_S4U_PROT_SUPPORT: NTSTATUS = -1_073_740_790_i32; +pub const STATUS_NO_SAVEPOINT_WITH_OPEN_FILES: NTSTATUS = -1_072_103_352_i32; +pub const STATUS_NO_SECRETS: NTSTATUS = -1_073_740_943_i32; +pub const STATUS_NO_SECURITY_CONTEXT: NTSTATUS = -1_073_740_755_i32; +pub const STATUS_NO_SECURITY_ON_OBJECT: NTSTATUS = -1_073_741_609_i32; +pub const STATUS_NO_SPOOL_SPACE: NTSTATUS = -1_073_741_625_i32; +pub const STATUS_NO_SUCH_ALIAS: NTSTATUS = -1_073_741_487_i32; +pub const STATUS_NO_SUCH_DEVICE: NTSTATUS = -1_073_741_810_i32; +pub const STATUS_NO_SUCH_DOMAIN: NTSTATUS = -1_073_741_601_i32; +pub const STATUS_NO_SUCH_FILE: NTSTATUS = -1_073_741_809_i32; +pub const STATUS_NO_SUCH_GROUP: NTSTATUS = -1_073_741_722_i32; +pub const STATUS_NO_SUCH_MEMBER: NTSTATUS = -1_073_741_446_i32; +pub const STATUS_NO_SUCH_PACKAGE: NTSTATUS = -1_073_741_570_i32; +pub const STATUS_NO_SUCH_PRIVILEGE: NTSTATUS = -1_073_741_728_i32; +pub const STATUS_NO_TGT_REPLY: NTSTATUS = -1_073_741_073_i32; +pub const STATUS_NO_TOKEN: NTSTATUS = -1_073_741_700_i32; +pub const STATUS_NO_TRACKING_SERVICE: NTSTATUS = -1_073_741_153_i32; +pub const STATUS_NO_TRUST_LSA_SECRET: NTSTATUS = -1_073_741_430_i32; +pub const STATUS_NO_TRUST_SAM_ACCOUNT: NTSTATUS = -1_073_741_429_i32; +pub const STATUS_NO_TXF_METADATA: NTSTATUS = -2_145_845_207_i32; +pub const STATUS_NO_UNICODE_TRANSLATION: NTSTATUS = -1_073_740_009_i32; +pub const STATUS_NO_USER_KEYS: NTSTATUS = -1_073_741_168_i32; +pub const STATUS_NO_USER_SESSION_KEY: NTSTATUS = -1_073_741_310_i32; +pub const STATUS_NO_WORK_DONE: NTSTATUS = -2_147_483_598_i32; +pub const STATUS_NO_YIELD_PERFORMED: NTSTATUS = 1_073_741_860_i32; +pub const STATUS_NTLM_BLOCKED: NTSTATUS = -1_073_740_776_i32; +pub const STATUS_NT_CROSS_ENCRYPTION_REQUIRED: NTSTATUS = -1_073_741_475_i32; +pub const STATUS_NULL_LM_PASSWORD: NTSTATUS = 1_073_741_837_i32; +pub const STATUS_OBJECTID_EXISTS: NTSTATUS = -1_073_741_269_i32; +pub const STATUS_OBJECTID_NOT_FOUND: NTSTATUS = -1_073_741_072_i32; +pub const STATUS_OBJECT_IS_IMMUTABLE: NTSTATUS = -1_073_740_610_i32; +pub const STATUS_OBJECT_NAME_COLLISION: NTSTATUS = -1_073_741_771_i32; +pub const STATUS_OBJECT_NAME_EXISTS: NTSTATUS = 1_073_741_824_i32; +pub const STATUS_OBJECT_NAME_INVALID: NTSTATUS = -1_073_741_773_i32; +pub const STATUS_OBJECT_NAME_NOT_FOUND: NTSTATUS = -1_073_741_772_i32; +pub const STATUS_OBJECT_NOT_EXTERNALLY_BACKED: NTSTATUS = -1_073_740_691_i32; +pub const STATUS_OBJECT_NO_LONGER_EXISTS: NTSTATUS = -1_072_103_391_i32; +pub const STATUS_OBJECT_PATH_INVALID: NTSTATUS = -1_073_741_767_i32; +pub const STATUS_OBJECT_PATH_NOT_FOUND: NTSTATUS = -1_073_741_766_i32; +pub const STATUS_OBJECT_PATH_SYNTAX_BAD: NTSTATUS = -1_073_741_765_i32; +pub const STATUS_OBJECT_TYPE_MISMATCH: NTSTATUS = -1_073_741_788_i32; +pub const STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_700_189_i32; +pub const STATUS_OFFLOAD_READ_FLT_NOT_SUPPORTED: NTSTATUS = -1_073_700_191_i32; +pub const STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_700_188_i32; +pub const STATUS_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: NTSTATUS = -1_073_700_190_i32; +pub const STATUS_ONLY_IF_CONNECTED: NTSTATUS = -1_073_741_108_i32; +pub const STATUS_OPEN_FAILED: NTSTATUS = -1_073_741_514_i32; +pub const STATUS_OPERATION_IN_PROGRESS: NTSTATUS = -1_073_740_682_i32; +pub const STATUS_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: NTSTATUS = -1_072_103_334_i32; +pub const STATUS_OPLOCK_BREAK_IN_PROGRESS: NTSTATUS = 264_i32; +pub const STATUS_OPLOCK_HANDLE_CLOSED: NTSTATUS = 534_i32; +pub const STATUS_OPLOCK_NOT_GRANTED: NTSTATUS = -1_073_741_598_i32; +pub const STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE: NTSTATUS = 533_i32; +pub const STATUS_ORDINAL_NOT_FOUND: NTSTATUS = -1_073_741_512_i32; +pub const STATUS_ORPHAN_NAME_EXHAUSTED: NTSTATUS = -1_073_739_762_i32; +pub const STATUS_PACKAGE_NOT_AVAILABLE: NTSTATUS = -1_073_740_649_i32; +pub const STATUS_PACKAGE_UPDATING: NTSTATUS = -1_073_740_695_i32; +pub const STATUS_PAGEFILE_CREATE_FAILED: NTSTATUS = -1_073_741_498_i32; +pub const STATUS_PAGEFILE_NOT_SUPPORTED: NTSTATUS = -1_073_740_603_i32; +pub const STATUS_PAGEFILE_QUOTA: NTSTATUS = -1_073_741_817_i32; +pub const STATUS_PAGEFILE_QUOTA_EXCEEDED: NTSTATUS = -1_073_741_524_i32; +pub const STATUS_PAGE_FAULT_COPY_ON_WRITE: NTSTATUS = 274_i32; +pub const STATUS_PAGE_FAULT_DEMAND_ZERO: NTSTATUS = 273_i32; +pub const STATUS_PAGE_FAULT_GUARD_PAGE: NTSTATUS = 275_i32; +pub const STATUS_PAGE_FAULT_PAGING_FILE: NTSTATUS = 276_i32; +pub const STATUS_PAGE_FAULT_RETRY: NTSTATUS = 873_i32; +pub const STATUS_PAGE_FAULT_TRANSITION: NTSTATUS = 272_i32; +pub const STATUS_PARAMETER_QUOTA_EXCEEDED: NTSTATUS = -1_073_740_784_i32; +pub const STATUS_PARITY_ERROR: NTSTATUS = -1_073_741_781_i32; +pub const STATUS_PARTIAL_COPY: NTSTATUS = -2_147_483_635_i32; +pub const STATUS_PARTITION_FAILURE: NTSTATUS = -1_073_741_454_i32; +pub const STATUS_PARTITION_TERMINATING: NTSTATUS = -1_073_740_640_i32; +pub const STATUS_PASSWORD_CHANGE_REQUIRED: NTSTATUS = -1_073_741_044_i32; +pub const STATUS_PASSWORD_RESTRICTION: NTSTATUS = -1_073_741_716_i32; +pub const STATUS_PATCH_CONFLICT: NTSTATUS = -1_073_740_628_i32; +pub const STATUS_PATCH_DEFERRED: NTSTATUS = 1_073_741_879_i32; +pub const STATUS_PATCH_NOT_REGISTERED: NTSTATUS = -1_073_740_588_i32; +pub const STATUS_PATH_NOT_COVERED: NTSTATUS = -1_073_741_225_i32; +pub const STATUS_PCP_ATTESTATION_CHALLENGE_NOT_SET: NTSTATUS = -1_071_046_638_i32; +pub const STATUS_PCP_AUTHENTICATION_FAILED: NTSTATUS = -1_071_046_648_i32; +pub const STATUS_PCP_AUTHENTICATION_IGNORED: NTSTATUS = -1_071_046_647_i32; +pub const STATUS_PCP_BUFFER_LENGTH_MISMATCH: NTSTATUS = -1_071_046_626_i32; +pub const STATUS_PCP_BUFFER_TOO_SMALL: NTSTATUS = -1_071_046_650_i32; +pub const STATUS_PCP_CLAIM_TYPE_NOT_SUPPORTED: NTSTATUS = -1_071_046_628_i32; +pub const STATUS_PCP_DEVICE_NOT_FOUND: NTSTATUS = -1_071_046_643_i32; +pub const STATUS_PCP_DEVICE_NOT_READY: NTSTATUS = -1_071_046_655_i32; +pub const STATUS_PCP_ERROR_MASK: NTSTATUS = -1_071_046_656_i32; +pub const STATUS_PCP_FLAG_NOT_SUPPORTED: NTSTATUS = -1_071_046_652_i32; +pub const STATUS_PCP_IFX_RSA_KEY_CREATION_BLOCKED: NTSTATUS = -1_071_046_625_i32; +pub const STATUS_PCP_INTERNAL_ERROR: NTSTATUS = -1_071_046_649_i32; +pub const STATUS_PCP_INVALID_HANDLE: NTSTATUS = -1_071_046_654_i32; +pub const STATUS_PCP_INVALID_PARAMETER: NTSTATUS = -1_071_046_653_i32; +pub const STATUS_PCP_KEY_ALREADY_FINALIZED: NTSTATUS = -1_071_046_636_i32; +pub const STATUS_PCP_KEY_HANDLE_INVALIDATED: NTSTATUS = -1_071_046_622_i32; +pub const STATUS_PCP_KEY_NOT_AIK: NTSTATUS = -1_071_046_631_i32; +pub const STATUS_PCP_KEY_NOT_AUTHENTICATED: NTSTATUS = -1_071_046_632_i32; +pub const STATUS_PCP_KEY_NOT_FINALIZED: NTSTATUS = -1_071_046_639_i32; +pub const STATUS_PCP_KEY_NOT_LOADED: NTSTATUS = -1_071_046_641_i32; +pub const STATUS_PCP_KEY_NOT_SIGNING_KEY: NTSTATUS = -1_071_046_630_i32; +pub const STATUS_PCP_KEY_USAGE_POLICY_INVALID: NTSTATUS = -1_071_046_634_i32; +pub const STATUS_PCP_KEY_USAGE_POLICY_NOT_SUPPORTED: NTSTATUS = -1_071_046_635_i32; +pub const STATUS_PCP_LOCKED_OUT: NTSTATUS = -1_071_046_629_i32; +pub const STATUS_PCP_NOT_PCR_BOUND: NTSTATUS = -1_071_046_637_i32; +pub const STATUS_PCP_NOT_SUPPORTED: NTSTATUS = -1_071_046_651_i32; +pub const STATUS_PCP_NO_KEY_CERTIFICATION: NTSTATUS = -1_071_046_640_i32; +pub const STATUS_PCP_POLICY_NOT_FOUND: NTSTATUS = -1_071_046_646_i32; +pub const STATUS_PCP_PROFILE_NOT_FOUND: NTSTATUS = -1_071_046_645_i32; +pub const STATUS_PCP_RAW_POLICY_NOT_SUPPORTED: NTSTATUS = -1_071_046_623_i32; +pub const STATUS_PCP_SOFT_KEY_ERROR: NTSTATUS = -1_071_046_633_i32; +pub const STATUS_PCP_TICKET_MISSING: NTSTATUS = -1_071_046_624_i32; +pub const STATUS_PCP_TPM_VERSION_NOT_SUPPORTED: NTSTATUS = -1_071_046_627_i32; +pub const STATUS_PCP_UNSUPPORTED_PSS_SALT: NTSTATUS = 1_076_437_027_i32; +pub const STATUS_PCP_VALIDATION_FAILED: NTSTATUS = -1_071_046_644_i32; +pub const STATUS_PCP_WRONG_PARENT: NTSTATUS = -1_071_046_642_i32; +pub const STATUS_PENDING: NTSTATUS = 259_i32; +pub const STATUS_PER_USER_TRUST_QUOTA_EXCEEDED: NTSTATUS = -1_073_740_799_i32; +pub const STATUS_PIPE_BROKEN: NTSTATUS = -1_073_741_493_i32; +pub const STATUS_PIPE_BUSY: NTSTATUS = -1_073_741_650_i32; +pub const STATUS_PIPE_CLOSING: NTSTATUS = -1_073_741_647_i32; +pub const STATUS_PIPE_CONNECTED: NTSTATUS = -1_073_741_646_i32; +pub const STATUS_PIPE_DISCONNECTED: NTSTATUS = -1_073_741_648_i32; +pub const STATUS_PIPE_EMPTY: NTSTATUS = -1_073_741_607_i32; +pub const STATUS_PIPE_LISTENING: NTSTATUS = -1_073_741_645_i32; +pub const STATUS_PIPE_NOT_AVAILABLE: NTSTATUS = -1_073_741_652_i32; +pub const STATUS_PKINIT_CLIENT_FAILURE: NTSTATUS = -1_073_740_916_i32; +pub const STATUS_PKINIT_FAILURE: NTSTATUS = -1_073_741_024_i32; +pub const STATUS_PKINIT_NAME_MISMATCH: NTSTATUS = -1_073_741_063_i32; +pub const STATUS_PKU2U_CERT_FAILURE: NTSTATUS = -1_073_740_753_i32; +pub const STATUS_PLATFORM_MANIFEST_BINARY_ID_NOT_FOUND: NTSTATUS = -1_058_340_859_i32; +pub const STATUS_PLATFORM_MANIFEST_CATALOG_NOT_AUTHORIZED: NTSTATUS = -1_058_340_860_i32; +pub const STATUS_PLATFORM_MANIFEST_FILE_NOT_AUTHORIZED: NTSTATUS = -1_058_340_861_i32; +pub const STATUS_PLATFORM_MANIFEST_INVALID: NTSTATUS = -1_058_340_862_i32; +pub const STATUS_PLATFORM_MANIFEST_NOT_ACTIVE: NTSTATUS = -1_058_340_858_i32; +pub const STATUS_PLATFORM_MANIFEST_NOT_AUTHORIZED: NTSTATUS = -1_058_340_863_i32; +pub const STATUS_PLATFORM_MANIFEST_NOT_SIGNED: NTSTATUS = -1_058_340_857_i32; +pub const STATUS_PLUGPLAY_NO_DEVICE: NTSTATUS = -1_073_741_218_i32; +pub const STATUS_PLUGPLAY_QUERY_VETOED: NTSTATUS = -2_147_483_608_i32; +pub const STATUS_PNP_BAD_MPS_TABLE: NTSTATUS = -1_073_479_627_i32; +pub const STATUS_PNP_DEVICE_CONFIGURATION_PENDING: NTSTATUS = -1_073_740_651_i32; +pub const STATUS_PNP_DRIVER_CONFIGURATION_INCOMPLETE: NTSTATUS = -1_073_740_653_i32; +pub const STATUS_PNP_DRIVER_CONFIGURATION_NOT_FOUND: NTSTATUS = -1_073_740_654_i32; +pub const STATUS_PNP_DRIVER_PACKAGE_NOT_FOUND: NTSTATUS = -1_073_740_655_i32; +pub const STATUS_PNP_FUNCTION_DRIVER_REQUIRED: NTSTATUS = -1_073_740_652_i32; +pub const STATUS_PNP_INVALID_ID: NTSTATUS = -1_073_479_624_i32; +pub const STATUS_PNP_IRQ_TRANSLATION_FAILED: NTSTATUS = -1_073_479_625_i32; +pub const STATUS_PNP_NO_COMPAT_DRIVERS: NTSTATUS = -1_073_740_656_i32; +pub const STATUS_PNP_REBOOT_REQUIRED: NTSTATUS = -1_073_741_102_i32; +pub const STATUS_PNP_RESTART_ENUMERATION: NTSTATUS = -1_073_741_106_i32; +pub const STATUS_PNP_TRANSLATION_FAILED: NTSTATUS = -1_073_479_626_i32; +pub const STATUS_POLICY_OBJECT_NOT_FOUND: NTSTATUS = -1_073_741_158_i32; +pub const STATUS_POLICY_ONLY_IN_DS: NTSTATUS = -1_073_741_157_i32; +pub const STATUS_PORT_ALREADY_HAS_COMPLETION_LIST: NTSTATUS = -1_073_740_006_i32; +pub const STATUS_PORT_ALREADY_SET: NTSTATUS = -1_073_741_752_i32; +pub const STATUS_PORT_CLOSED: NTSTATUS = -1_073_740_032_i32; +pub const STATUS_PORT_CONNECTION_REFUSED: NTSTATUS = -1_073_741_759_i32; +pub const STATUS_PORT_DISCONNECTED: NTSTATUS = -1_073_741_769_i32; +pub const STATUS_PORT_DO_NOT_DISTURB: NTSTATUS = -1_073_741_770_i32; +pub const STATUS_PORT_MESSAGE_TOO_LONG: NTSTATUS = -1_073_741_777_i32; +pub const STATUS_PORT_NOT_SET: NTSTATUS = -1_073_740_973_i32; +pub const STATUS_PORT_UNREACHABLE: NTSTATUS = -1_073_741_249_i32; +pub const STATUS_POSSIBLE_DEADLOCK: NTSTATUS = -1_073_741_420_i32; +pub const STATUS_POWER_STATE_INVALID: NTSTATUS = -1_073_741_101_i32; +pub const STATUS_PREDEFINED_HANDLE: NTSTATUS = 1_073_741_846_i32; +pub const STATUS_PRENT4_MACHINE_ACCOUNT: NTSTATUS = -1_073_740_969_i32; +pub const STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED: NTSTATUS = 270_i32; +pub const STATUS_PRINT_CANCELLED: NTSTATUS = -1_073_741_624_i32; +pub const STATUS_PRINT_QUEUE_FULL: NTSTATUS = -1_073_741_626_i32; +pub const STATUS_PRIVILEGED_INSTRUCTION: NTSTATUS = -1_073_741_674_i32; +pub const STATUS_PRIVILEGE_NOT_HELD: NTSTATUS = -1_073_741_727_i32; +pub const STATUS_PROACTIVE_SCAN_IN_PROGRESS: NTSTATUS = -1_073_739_761_i32; +pub const STATUS_PROCEDURE_NOT_FOUND: NTSTATUS = -1_073_741_702_i32; +pub const STATUS_PROCESS_CLONED: NTSTATUS = 297_i32; +pub const STATUS_PROCESS_IN_JOB: NTSTATUS = 292_i32; +pub const STATUS_PROCESS_IS_PROTECTED: NTSTATUS = -1_073_740_014_i32; +pub const STATUS_PROCESS_IS_TERMINATING: NTSTATUS = -1_073_741_558_i32; +pub const STATUS_PROCESS_NOT_IN_JOB: NTSTATUS = 291_i32; +pub const STATUS_PROFILING_AT_LIMIT: NTSTATUS = -1_073_741_613_i32; +pub const STATUS_PROFILING_NOT_STARTED: NTSTATUS = -1_073_741_641_i32; +pub const STATUS_PROFILING_NOT_STOPPED: NTSTATUS = -1_073_741_640_i32; +pub const STATUS_PROPSET_NOT_FOUND: NTSTATUS = -1_073_741_264_i32; +pub const STATUS_PROTOCOL_NOT_SUPPORTED: NTSTATUS = -1_073_700_845_i32; +pub const STATUS_PROTOCOL_UNREACHABLE: NTSTATUS = -1_073_741_250_i32; +pub const STATUS_PTE_CHANGED: NTSTATUS = -1_073_740_748_i32; +pub const STATUS_PURGE_FAILED: NTSTATUS = -1_073_740_747_i32; +pub const STATUS_PWD_HISTORY_CONFLICT: NTSTATUS = -1_073_741_220_i32; +pub const STATUS_PWD_TOO_LONG: NTSTATUS = -1_073_741_190_i32; +pub const STATUS_PWD_TOO_RECENT: NTSTATUS = -1_073_741_221_i32; +pub const STATUS_PWD_TOO_SHORT: NTSTATUS = -1_073_741_222_i32; +pub const STATUS_QUERY_STORAGE_ERROR: NTSTATUS = -2_143_682_559_i32; +pub const STATUS_QUIC_ALPN_NEG_FAILURE: NTSTATUS = -1_071_382_521_i32; +pub const STATUS_QUIC_CONNECTION_IDLE: NTSTATUS = -1_071_382_523_i32; +pub const STATUS_QUIC_CONNECTION_TIMEOUT: NTSTATUS = -1_071_382_522_i32; +pub const STATUS_QUIC_HANDSHAKE_FAILURE: NTSTATUS = -1_071_382_528_i32; +pub const STATUS_QUIC_INTERNAL_ERROR: NTSTATUS = -1_071_382_525_i32; +pub const STATUS_QUIC_PROTOCOL_VIOLATION: NTSTATUS = -1_071_382_524_i32; +pub const STATUS_QUIC_USER_CANCELED: NTSTATUS = -1_071_382_526_i32; +pub const STATUS_QUIC_VER_NEG_FAILURE: NTSTATUS = -1_071_382_527_i32; +pub const STATUS_QUOTA_ACTIVITY: NTSTATUS = -1_073_740_662_i32; +pub const STATUS_QUOTA_EXCEEDED: NTSTATUS = -1_073_741_756_i32; +pub const STATUS_QUOTA_LIST_INCONSISTENT: NTSTATUS = -1_073_741_210_i32; +pub const STATUS_QUOTA_NOT_ENABLED: NTSTATUS = -1_073_741_399_i32; +pub const STATUS_RANGE_LIST_CONFLICT: NTSTATUS = -1_073_741_182_i32; +pub const STATUS_RANGE_NOT_FOUND: NTSTATUS = -1_073_741_172_i32; +pub const STATUS_RANGE_NOT_LOCKED: NTSTATUS = -1_073_741_698_i32; +pub const STATUS_RDBSS_CONTINUE_OPERATION: NTSTATUS = -1_069_481_982_i32; +pub const STATUS_RDBSS_POST_OPERATION: NTSTATUS = -1_069_481_981_i32; +pub const STATUS_RDBSS_RESTART_OPERATION: NTSTATUS = -1_069_481_983_i32; +pub const STATUS_RDBSS_RETRY_LOOKUP: NTSTATUS = -1_069_481_980_i32; +pub const STATUS_RDP_PROTOCOL_ERROR: NTSTATUS = -1_073_086_414_i32; +pub const STATUS_RECEIVE_EXPEDITED: NTSTATUS = 1_073_741_840_i32; +pub const STATUS_RECEIVE_PARTIAL: NTSTATUS = 1_073_741_839_i32; +pub const STATUS_RECEIVE_PARTIAL_EXPEDITED: NTSTATUS = 1_073_741_841_i32; +pub const STATUS_RECOVERABLE_BUGCHECK: NTSTATUS = -2_147_483_596_i32; +pub const STATUS_RECOVERY_FAILURE: NTSTATUS = -1_073_741_273_i32; +pub const STATUS_RECOVERY_NOT_NEEDED: NTSTATUS = 1_075_380_276_i32; +pub const STATUS_RECURSIVE_DISPATCH: NTSTATUS = -1_073_740_028_i32; +pub const STATUS_REDIRECTOR_HAS_OPEN_HANDLES: NTSTATUS = -2_147_483_613_i32; +pub const STATUS_REDIRECTOR_NOT_STARTED: NTSTATUS = -1_073_741_573_i32; +pub const STATUS_REDIRECTOR_PAUSED: NTSTATUS = -1_073_741_615_i32; +pub const STATUS_REDIRECTOR_STARTED: NTSTATUS = -1_073_741_572_i32; +pub const STATUS_REGISTRY_CORRUPT: NTSTATUS = -1_073_741_492_i32; +pub const STATUS_REGISTRY_HIVE_RECOVERED: NTSTATUS = -2_147_483_606_i32; +pub const STATUS_REGISTRY_IO_FAILED: NTSTATUS = -1_073_741_491_i32; +pub const STATUS_REGISTRY_QUOTA_LIMIT: NTSTATUS = -1_073_741_226_i32; +pub const STATUS_REGISTRY_RECOVERED: NTSTATUS = 1_073_741_833_i32; +pub const STATUS_REG_NAT_CONSUMPTION: NTSTATUS = -1_073_741_111_i32; +pub const STATUS_REINITIALIZATION_NEEDED: NTSTATUS = -1_073_741_177_i32; +pub const STATUS_REMOTE_DISCONNECT: NTSTATUS = -1_073_741_508_i32; +pub const STATUS_REMOTE_FILE_VERSION_MISMATCH: NTSTATUS = -1_072_103_412_i32; +pub const STATUS_REMOTE_NOT_LISTENING: NTSTATUS = -1_073_741_636_i32; +pub const STATUS_REMOTE_RESOURCES: NTSTATUS = -1_073_741_507_i32; +pub const STATUS_REMOTE_SESSION_LIMIT: NTSTATUS = -1_073_741_418_i32; +pub const STATUS_REMOTE_STORAGE_MEDIA_ERROR: NTSTATUS = -1_073_741_154_i32; +pub const STATUS_REMOTE_STORAGE_NOT_ACTIVE: NTSTATUS = -1_073_741_155_i32; +pub const STATUS_REPAIR_NEEDED: NTSTATUS = -1_073_741_400_i32; +pub const STATUS_REPARSE: NTSTATUS = 260_i32; +pub const STATUS_REPARSE_ATTRIBUTE_CONFLICT: NTSTATUS = -1_073_741_134_i32; +pub const STATUS_REPARSE_GLOBAL: NTSTATUS = 872_i32; +pub const STATUS_REPARSE_OBJECT: NTSTATUS = 280_i32; +pub const STATUS_REPARSE_POINT_ENCOUNTERED: NTSTATUS = -1_073_740_533_i32; +pub const STATUS_REPARSE_POINT_NOT_RESOLVED: NTSTATUS = -1_073_741_184_i32; +pub const STATUS_REPLY_MESSAGE_MISMATCH: NTSTATUS = -1_073_741_281_i32; +pub const STATUS_REQUEST_ABORTED: NTSTATUS = -1_073_741_248_i32; +pub const STATUS_REQUEST_CANCELED: NTSTATUS = -1_073_740_029_i32; +pub const STATUS_REQUEST_NOT_ACCEPTED: NTSTATUS = -1_073_741_616_i32; +pub const STATUS_REQUEST_OUT_OF_SEQUENCE: NTSTATUS = -1_073_740_758_i32; +pub const STATUS_REQUEST_PAUSED: NTSTATUS = -1_073_740_711_i32; +pub const STATUS_RESIDENT_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_740_678_i32; +pub const STATUS_RESOURCEMANAGER_NOT_FOUND: NTSTATUS = -1_072_103_345_i32; +pub const STATUS_RESOURCEMANAGER_READ_ONLY: NTSTATUS = 514_i32; +pub const STATUS_RESOURCE_DATA_NOT_FOUND: NTSTATUS = -1_073_741_687_i32; +pub const STATUS_RESOURCE_ENUM_USER_STOP: NTSTATUS = -1_073_020_921_i32; +pub const STATUS_RESOURCE_IN_USE: NTSTATUS = -1_073_740_024_i32; +pub const STATUS_RESOURCE_LANG_NOT_FOUND: NTSTATUS = -1_073_741_308_i32; +pub const STATUS_RESOURCE_NAME_NOT_FOUND: NTSTATUS = -1_073_741_685_i32; +pub const STATUS_RESOURCE_NOT_OWNED: NTSTATUS = -1_073_741_212_i32; +pub const STATUS_RESOURCE_REQUIREMENTS_CHANGED: NTSTATUS = 281_i32; +pub const STATUS_RESOURCE_TYPE_NOT_FOUND: NTSTATUS = -1_073_741_686_i32; +pub const STATUS_RESTART_BOOT_APPLICATION: NTSTATUS = -1_073_740_717_i32; +pub const STATUS_RESUME_HIBERNATION: NTSTATUS = 1_073_741_867_i32; +pub const STATUS_RETRY: NTSTATUS = -1_073_741_267_i32; +pub const STATUS_RETURN_ADDRESS_HIJACK_ATTEMPT: NTSTATUS = -2_147_483_597_i32; +pub const STATUS_REVISION_MISMATCH: NTSTATUS = -1_073_741_735_i32; +pub const STATUS_REVOCATION_OFFLINE_C: NTSTATUS = -1_073_740_917_i32; +pub const STATUS_REVOCATION_OFFLINE_KDC: NTSTATUS = -1_073_740_788_i32; +pub const STATUS_RING_NEWLY_EMPTY: NTSTATUS = 531_i32; +pub const STATUS_RING_PREVIOUSLY_ABOVE_QUOTA: NTSTATUS = 530_i32; +pub const STATUS_RING_PREVIOUSLY_EMPTY: NTSTATUS = 528_i32; +pub const STATUS_RING_PREVIOUSLY_FULL: NTSTATUS = 529_i32; +pub const STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT: NTSTATUS = 532_i32; +pub const STATUS_RKF_ACTIVE_KEY: NTSTATUS = -1_069_547_514_i32; +pub const STATUS_RKF_BLOB_FULL: NTSTATUS = -1_069_547_517_i32; +pub const STATUS_RKF_DUPLICATE_KEY: NTSTATUS = -1_069_547_518_i32; +pub const STATUS_RKF_FILE_BLOCKED: NTSTATUS = -1_069_547_515_i32; +pub const STATUS_RKF_KEY_NOT_FOUND: NTSTATUS = -1_069_547_519_i32; +pub const STATUS_RKF_STORE_FULL: NTSTATUS = -1_069_547_516_i32; +pub const STATUS_RM_ALREADY_STARTED: NTSTATUS = 1_075_380_277_i32; +pub const STATUS_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: NTSTATUS = -1_072_103_331_i32; +pub const STATUS_RM_DISCONNECTED: NTSTATUS = -1_072_103_374_i32; +pub const STATUS_RM_METADATA_CORRUPT: NTSTATUS = -1_072_103_418_i32; +pub const STATUS_RM_NOT_ACTIVE: NTSTATUS = -1_072_103_419_i32; +pub const STATUS_ROLLBACK_TIMER_EXPIRED: NTSTATUS = -1_072_103_364_i32; +pub const STATUS_RTPM_CONTEXT_COMPLETE: NTSTATUS = 2_699_265_i32; +pub const STATUS_RTPM_CONTEXT_CONTINUE: NTSTATUS = 2_699_264_i32; +pub const STATUS_RTPM_INVALID_CONTEXT: NTSTATUS = -1_071_042_556_i32; +pub const STATUS_RTPM_NO_RESULT: NTSTATUS = -1_071_042_558_i32; +pub const STATUS_RTPM_PCR_READ_INCOMPLETE: NTSTATUS = -1_071_042_557_i32; +pub const STATUS_RTPM_UNSUPPORTED_CMD: NTSTATUS = -1_071_042_555_i32; +pub const STATUS_RUNLEVEL_SWITCH_AGENT_TIMEOUT: NTSTATUS = -1_073_700_539_i32; +pub const STATUS_RUNLEVEL_SWITCH_IN_PROGRESS: NTSTATUS = -1_073_700_538_i32; +pub const STATUS_RUNLEVEL_SWITCH_TIMEOUT: NTSTATUS = -1_073_700_541_i32; +pub const STATUS_RWRAW_ENCRYPTED_FILE_NOT_ENCRYPTED: NTSTATUS = -1_073_740_633_i32; +pub const STATUS_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILEOFFSET: NTSTATUS = -1_073_740_632_i32; +pub const STATUS_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILERANGE: NTSTATUS = -1_073_740_631_i32; +pub const STATUS_RWRAW_ENCRYPTED_INVALID_EDATAINFO_PARAMETER: NTSTATUS = -1_073_740_630_i32; +pub const STATUS_RXACT_COMMITTED: NTSTATUS = 266_i32; +pub const STATUS_RXACT_COMMIT_FAILURE: NTSTATUS = -1_073_741_539_i32; +pub const STATUS_RXACT_COMMIT_NECESSARY: NTSTATUS = -2_147_483_624_i32; +pub const STATUS_RXACT_INVALID_STATE: NTSTATUS = -1_073_741_540_i32; +pub const STATUS_RXACT_STATE_CREATED: NTSTATUS = 1_073_741_828_i32; +pub const STATUS_SAM_INIT_FAILURE: NTSTATUS = -1_073_741_085_i32; +pub const STATUS_SAM_NEED_BOOTKEY_FLOPPY: NTSTATUS = -1_073_741_088_i32; +pub const STATUS_SAM_NEED_BOOTKEY_PASSWORD: NTSTATUS = -1_073_741_089_i32; +pub const STATUS_SCRUB_DATA_DISABLED: NTSTATUS = -1_073_740_680_i32; +pub const STATUS_SECCORE_INVALID_COMMAND: NTSTATUS = -1_058_537_472_i32; +pub const STATUS_SECONDARY_IC_PROVIDER_NOT_REGISTERED: NTSTATUS = -1_073_700_575_i32; +pub const STATUS_SECRET_TOO_LONG: NTSTATUS = -1_073_741_481_i32; +pub const STATUS_SECTION_DIRECT_MAP_ONLY: NTSTATUS = -1_073_739_503_i32; +pub const STATUS_SECTION_NOT_EXTENDED: NTSTATUS = -1_073_741_689_i32; +pub const STATUS_SECTION_NOT_IMAGE: NTSTATUS = -1_073_741_751_i32; +pub const STATUS_SECTION_PROTECTION: NTSTATUS = -1_073_741_746_i32; +pub const STATUS_SECTION_TOO_BIG: NTSTATUS = -1_073_741_760_i32; +pub const STATUS_SECUREBOOT_FILE_REPLACED: NTSTATUS = -1_069_350_905_i32; +pub const STATUS_SECUREBOOT_INVALID_POLICY: NTSTATUS = -1_069_350_909_i32; +pub const STATUS_SECUREBOOT_NOT_BASE_POLICY: NTSTATUS = -1_069_350_897_i32; +pub const STATUS_SECUREBOOT_NOT_ENABLED: NTSTATUS = -2_143_092_730_i32; +pub const STATUS_SECUREBOOT_NOT_SUPPLEMENTAL_POLICY: NTSTATUS = -1_069_350_896_i32; +pub const STATUS_SECUREBOOT_PLATFORM_ID_MISMATCH: NTSTATUS = -1_069_350_901_i32; +pub const STATUS_SECUREBOOT_POLICY_MISSING_ANTIROLLBACKVERSION: NTSTATUS = -1_069_350_902_i32; +pub const STATUS_SECUREBOOT_POLICY_NOT_AUTHORIZED: NTSTATUS = -1_069_350_904_i32; +pub const STATUS_SECUREBOOT_POLICY_NOT_SIGNED: NTSTATUS = -1_069_350_907_i32; +pub const STATUS_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: NTSTATUS = -1_069_350_908_i32; +pub const STATUS_SECUREBOOT_POLICY_ROLLBACK_DETECTED: NTSTATUS = -1_069_350_900_i32; +pub const STATUS_SECUREBOOT_POLICY_UNKNOWN: NTSTATUS = -1_069_350_903_i32; +pub const STATUS_SECUREBOOT_POLICY_UPGRADE_MISMATCH: NTSTATUS = -1_069_350_899_i32; +pub const STATUS_SECUREBOOT_POLICY_VIOLATION: NTSTATUS = -1_069_350_910_i32; +pub const STATUS_SECUREBOOT_REQUIRED_POLICY_FILE_MISSING: NTSTATUS = -1_069_350_898_i32; +pub const STATUS_SECUREBOOT_ROLLBACK_DETECTED: NTSTATUS = -1_069_350_911_i32; +pub const STATUS_SECURITY_STREAM_IS_INCONSISTENT: NTSTATUS = -1_073_741_408_i32; +pub const STATUS_SEGMENT_NOTIFICATION: NTSTATUS = 1_073_741_829_i32; +pub const STATUS_SEMAPHORE_LIMIT_EXCEEDED: NTSTATUS = -1_073_741_753_i32; +pub const STATUS_SERIAL_COUNTER_TIMEOUT: NTSTATUS = 1_073_741_836_i32; +pub const STATUS_SERIAL_MORE_WRITES: NTSTATUS = 1_073_741_832_i32; +pub const STATUS_SERIAL_NO_DEVICE_INITED: NTSTATUS = -1_073_741_488_i32; +pub const STATUS_SERVER_DISABLED: NTSTATUS = -1_073_741_696_i32; +pub const STATUS_SERVER_HAS_OPEN_HANDLES: NTSTATUS = -2_147_483_612_i32; +pub const STATUS_SERVER_NOT_DISABLED: NTSTATUS = -1_073_741_695_i32; +pub const STATUS_SERVER_SHUTDOWN_IN_PROGRESS: NTSTATUS = -1_073_741_057_i32; +pub const STATUS_SERVER_SID_MISMATCH: NTSTATUS = -1_073_741_152_i32; +pub const STATUS_SERVER_TRANSPORT_CONFLICT: NTSTATUS = -1_073_741_388_i32; +pub const STATUS_SERVER_UNAVAILABLE: NTSTATUS = -1_073_740_698_i32; +pub const STATUS_SERVICES_FAILED_AUTOSTART: NTSTATUS = 1_073_783_108_i32; +pub const STATUS_SERVICE_NOTIFICATION: NTSTATUS = 1_073_741_848_i32; +pub const STATUS_SESSION_KEY_TOO_SHORT: NTSTATUS = -1_073_740_521_i32; +pub const STATUS_SETMARK_DETECTED: NTSTATUS = -2_147_483_615_i32; +pub const STATUS_SET_CONTEXT_DENIED: NTSTATUS = -1_073_740_278_i32; +pub const STATUS_SHARED_IRQ_BUSY: NTSTATUS = -1_073_741_460_i32; +pub const STATUS_SHARED_POLICY: NTSTATUS = -1_073_741_159_i32; +pub const STATUS_SHARE_UNAVAILABLE: NTSTATUS = -1_073_740_672_i32; +pub const STATUS_SHARING_PAUSED: NTSTATUS = -1_073_741_617_i32; +pub const STATUS_SHARING_VIOLATION: NTSTATUS = -1_073_741_757_i32; +pub const STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: NTSTATUS = -1_073_741_409_i32; +pub const STATUS_SHUTDOWN_IN_PROGRESS: NTSTATUS = -1_073_741_058_i32; +pub const STATUS_SINGLE_STEP: NTSTATUS = -2_147_483_644_i32; +pub const STATUS_SMARTCARD_CARD_BLOCKED: NTSTATUS = -1_073_740_927_i32; +pub const STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED: NTSTATUS = -1_073_740_926_i32; +pub const STATUS_SMARTCARD_CERT_EXPIRED: NTSTATUS = -1_073_740_915_i32; +pub const STATUS_SMARTCARD_CERT_REVOKED: NTSTATUS = -1_073_740_919_i32; +pub const STATUS_SMARTCARD_IO_ERROR: NTSTATUS = -1_073_740_921_i32; +pub const STATUS_SMARTCARD_LOGON_REQUIRED: NTSTATUS = -1_073_741_062_i32; +pub const STATUS_SMARTCARD_NO_CARD: NTSTATUS = -1_073_740_925_i32; +pub const STATUS_SMARTCARD_NO_CERTIFICATE: NTSTATUS = -1_073_740_923_i32; +pub const STATUS_SMARTCARD_NO_KEYSET: NTSTATUS = -1_073_740_922_i32; +pub const STATUS_SMARTCARD_NO_KEY_CONTAINER: NTSTATUS = -1_073_740_924_i32; +pub const STATUS_SMARTCARD_SILENT_CONTEXT: NTSTATUS = -1_073_740_913_i32; +pub const STATUS_SMARTCARD_SUBSYSTEM_FAILURE: NTSTATUS = -1_073_741_023_i32; +pub const STATUS_SMARTCARD_WRONG_PIN: NTSTATUS = -1_073_740_928_i32; +pub const STATUS_SMB1_NOT_AVAILABLE: NTSTATUS = -1_073_740_525_i32; +pub const STATUS_SMB_BAD_CLUSTER_DIALECT: NTSTATUS = -1_067_646_975_i32; +pub const STATUS_SMB_GUEST_LOGON_BLOCKED: NTSTATUS = -1_067_646_974_i32; +pub const STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP: NTSTATUS = -1_067_646_976_i32; +pub const STATUS_SMB_NO_SIGNING_ALGORITHM_OVERLAP: NTSTATUS = -1_067_646_973_i32; +pub const STATUS_SMI_PRIMITIVE_INSTALLER_FAILED: NTSTATUS = -1_072_365_531_i32; +pub const STATUS_SMR_GARBAGE_COLLECTION_REQUIRED: NTSTATUS = -1_073_740_524_i32; +pub const STATUS_SOME_NOT_MAPPED: NTSTATUS = 263_i32; +pub const STATUS_SOURCE_ELEMENT_EMPTY: NTSTATUS = -1_073_741_181_i32; +pub const STATUS_SPACES_ALLOCATION_SIZE_INVALID: NTSTATUS = -1_058_602_994_i32; +pub const STATUS_SPACES_CACHE_FULL: NTSTATUS = -1_058_602_970_i32; +pub const STATUS_SPACES_COMPLETE: NTSTATUS = 15_138_818_i32; +pub const STATUS_SPACES_CORRUPT_METADATA: NTSTATUS = -1_058_602_986_i32; +pub const STATUS_SPACES_DRIVE_LOST_DATA: NTSTATUS = -1_058_602_979_i32; +pub const STATUS_SPACES_DRIVE_NOT_READY: NTSTATUS = -1_058_602_981_i32; +pub const STATUS_SPACES_DRIVE_OPERATIONAL_STATE_INVALID: NTSTATUS = -1_058_602_990_i32; +pub const STATUS_SPACES_DRIVE_REDUNDANCY_INVALID: NTSTATUS = -1_058_603_002_i32; +pub const STATUS_SPACES_DRIVE_SECTOR_SIZE_INVALID: NTSTATUS = -1_058_603_004_i32; +pub const STATUS_SPACES_DRIVE_SPLIT: NTSTATUS = -1_058_602_980_i32; +pub const STATUS_SPACES_DRT_FULL: NTSTATUS = -1_058_602_985_i32; +pub const STATUS_SPACES_ENCLOSURE_AWARE_INVALID: NTSTATUS = -1_058_602_993_i32; +pub const STATUS_SPACES_ENTRY_INCOMPLETE: NTSTATUS = -1_058_602_978_i32; +pub const STATUS_SPACES_ENTRY_INVALID: NTSTATUS = -1_058_602_977_i32; +pub const STATUS_SPACES_EXTENDED_ERROR: NTSTATUS = -1_058_602_996_i32; +pub const STATUS_SPACES_FAULT_DOMAIN_TYPE_INVALID: NTSTATUS = -1_058_603_007_i32; +pub const STATUS_SPACES_FLUSH_METADATA: NTSTATUS = -1_058_602_971_i32; +pub const STATUS_SPACES_INCONSISTENCY: NTSTATUS = -1_058_602_984_i32; +pub const STATUS_SPACES_INTERLEAVE_LENGTH_INVALID: NTSTATUS = -1_058_602_999_i32; +pub const STATUS_SPACES_LOG_NOT_READY: NTSTATUS = -1_058_602_983_i32; +pub const STATUS_SPACES_MAP_REQUIRED: NTSTATUS = -1_058_602_988_i32; +pub const STATUS_SPACES_MARK_DIRTY: NTSTATUS = -1_058_602_976_i32; +pub const STATUS_SPACES_NOT_ENOUGH_DRIVES: NTSTATUS = -1_058_602_997_i32; +pub const STATUS_SPACES_NO_REDUNDANCY: NTSTATUS = -1_058_602_982_i32; +pub const STATUS_SPACES_NUMBER_OF_COLUMNS_INVALID: NTSTATUS = -1_058_602_998_i32; +pub const STATUS_SPACES_NUMBER_OF_DATA_COPIES_INVALID: NTSTATUS = -1_058_603_001_i32; +pub const STATUS_SPACES_NUMBER_OF_GROUPS_INVALID: NTSTATUS = -1_058_602_991_i32; +pub const STATUS_SPACES_PAUSE: NTSTATUS = 15_138_817_i32; +pub const STATUS_SPACES_PD_INVALID_DATA: NTSTATUS = -1_058_602_972_i32; +pub const STATUS_SPACES_PD_LENGTH_MISMATCH: NTSTATUS = -1_058_602_974_i32; +pub const STATUS_SPACES_PD_NOT_FOUND: NTSTATUS = -1_058_602_975_i32; +pub const STATUS_SPACES_PD_UNSUPPORTED_VERSION: NTSTATUS = -1_058_602_973_i32; +pub const STATUS_SPACES_PROVISIONING_TYPE_INVALID: NTSTATUS = -1_058_602_995_i32; +pub const STATUS_SPACES_REDIRECT: NTSTATUS = 15_138_819_i32; +pub const STATUS_SPACES_REPAIRED: NTSTATUS = 15_138_816_i32; +pub const STATUS_SPACES_REPAIR_IN_PROGRESS: NTSTATUS = -1_058_602_969_i32; +pub const STATUS_SPACES_RESILIENCY_TYPE_INVALID: NTSTATUS = -1_058_603_005_i32; +pub const STATUS_SPACES_UNSUPPORTED_VERSION: NTSTATUS = -1_058_602_987_i32; +pub const STATUS_SPACES_UPDATE_COLUMN_STATE: NTSTATUS = -1_058_602_989_i32; +pub const STATUS_SPACES_WRITE_CACHE_SIZE_INVALID: NTSTATUS = -1_058_602_992_i32; +pub const STATUS_SPARSE_FILE_NOT_SUPPORTED: NTSTATUS = -1_073_740_604_i32; +pub const STATUS_SPARSE_NOT_ALLOWED_IN_TRANSACTION: NTSTATUS = -1_072_103_351_i32; +pub const STATUS_SPECIAL_ACCOUNT: NTSTATUS = -1_073_741_532_i32; +pub const STATUS_SPECIAL_GROUP: NTSTATUS = -1_073_741_531_i32; +pub const STATUS_SPECIAL_USER: NTSTATUS = -1_073_741_530_i32; +pub const STATUS_STACK_BUFFER_OVERRUN: NTSTATUS = -1_073_740_791_i32; +pub const STATUS_STACK_OVERFLOW: NTSTATUS = -1_073_741_571_i32; +pub const STATUS_STACK_OVERFLOW_READ: NTSTATUS = -1_073_741_272_i32; +pub const STATUS_STOPPED_ON_SYMLINK: NTSTATUS = -2_147_483_603_i32; +pub const STATUS_STORAGE_LOST_DATA_PERSISTENCE: NTSTATUS = -1_073_740_642_i32; +pub const STATUS_STORAGE_RESERVE_ALREADY_EXISTS: NTSTATUS = -1_073_740_625_i32; +pub const STATUS_STORAGE_RESERVE_DOES_NOT_EXIST: NTSTATUS = -1_073_740_626_i32; +pub const STATUS_STORAGE_RESERVE_ID_INVALID: NTSTATUS = -1_073_740_627_i32; +pub const STATUS_STORAGE_RESERVE_NOT_EMPTY: NTSTATUS = -1_073_740_624_i32; +pub const STATUS_STORAGE_STACK_ACCESS_DENIED: NTSTATUS = -1_073_740_607_i32; +pub const STATUS_STORAGE_TOPOLOGY_ID_MISMATCH: NTSTATUS = -1_073_740_666_i32; +pub const STATUS_STOWED_EXCEPTION: NTSTATUS = -1_073_741_189_i32; +pub const STATUS_STREAM_MINIVERSION_NOT_FOUND: NTSTATUS = -1_072_103_390_i32; +pub const STATUS_STREAM_MINIVERSION_NOT_VALID: NTSTATUS = -1_072_103_389_i32; +pub const STATUS_STRICT_CFG_VIOLATION: NTSTATUS = -1_073_740_282_i32; +pub const STATUS_STRONG_CRYPTO_NOT_SUPPORTED: NTSTATUS = -1_073_741_066_i32; +pub const STATUS_SUCCESS: NTSTATUS = 0_i32; +pub const STATUS_SUSPEND_COUNT_EXCEEDED: NTSTATUS = -1_073_741_750_i32; +pub const STATUS_SVHDX_ERROR_NOT_AVAILABLE: NTSTATUS = -1_067_647_232_i32; +pub const STATUS_SVHDX_ERROR_STORED: NTSTATUS = -1_067_712_512_i32; +pub const STATUS_SVHDX_NO_INITIATOR: NTSTATUS = -1_067_647_221_i32; +pub const STATUS_SVHDX_RESERVATION_CONFLICT: NTSTATUS = -1_067_647_225_i32; +pub const STATUS_SVHDX_UNIT_ATTENTION_AVAILABLE: NTSTATUS = -1_067_647_231_i32; +pub const STATUS_SVHDX_UNIT_ATTENTION_CAPACITY_DATA_CHANGED: NTSTATUS = -1_067_647_230_i32; +pub const STATUS_SVHDX_UNIT_ATTENTION_OPERATING_DEFINITION_CHANGED: NTSTATUS = -1_067_647_226_i32; +pub const STATUS_SVHDX_UNIT_ATTENTION_REGISTRATIONS_PREEMPTED: NTSTATUS = -1_067_647_227_i32; +pub const STATUS_SVHDX_UNIT_ATTENTION_RESERVATIONS_PREEMPTED: NTSTATUS = -1_067_647_229_i32; +pub const STATUS_SVHDX_UNIT_ATTENTION_RESERVATIONS_RELEASED: NTSTATUS = -1_067_647_228_i32; +pub const STATUS_SVHDX_VERSION_MISMATCH: NTSTATUS = -1_067_647_223_i32; +pub const STATUS_SVHDX_WRONG_FILE_TYPE: NTSTATUS = -1_067_647_224_i32; +pub const STATUS_SXS_ACTIVATION_CONTEXT_DISABLED: NTSTATUS = -1_072_365_561_i32; +pub const STATUS_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: NTSTATUS = -1_072_365_538_i32; +pub const STATUS_SXS_ASSEMBLY_MISSING: NTSTATUS = -1_072_365_556_i32; +pub const STATUS_SXS_ASSEMBLY_NOT_FOUND: NTSTATUS = -1_072_365_564_i32; +pub const STATUS_SXS_CANT_GEN_ACTCTX: NTSTATUS = -1_072_365_566_i32; +pub const STATUS_SXS_COMPONENT_STORE_CORRUPT: NTSTATUS = -1_072_365_542_i32; +pub const STATUS_SXS_CORRUPTION: NTSTATUS = -1_072_365_547_i32; +pub const STATUS_SXS_CORRUPT_ACTIVATION_STACK: NTSTATUS = -1_072_365_548_i32; +pub const STATUS_SXS_EARLY_DEACTIVATION: NTSTATUS = -1_072_365_553_i32; +pub const STATUS_SXS_FILE_HASH_MISMATCH: NTSTATUS = -1_072_365_541_i32; +pub const STATUS_SXS_FILE_HASH_MISSING: NTSTATUS = -1_072_365_529_i32; +pub const STATUS_SXS_FILE_NOT_PART_OF_ASSEMBLY: NTSTATUS = -1_072_365_537_i32; +pub const STATUS_SXS_IDENTITIES_DIFFERENT: NTSTATUS = -1_072_365_539_i32; +pub const STATUS_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: NTSTATUS = -1_072_365_544_i32; +pub const STATUS_SXS_IDENTITY_PARSE_ERROR: NTSTATUS = -1_072_365_543_i32; +pub const STATUS_SXS_INVALID_ACTCTXDATA_FORMAT: NTSTATUS = -1_072_365_565_i32; +pub const STATUS_SXS_INVALID_DEACTIVATION: NTSTATUS = -1_072_365_552_i32; +pub const STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: NTSTATUS = -1_072_365_545_i32; +pub const STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: NTSTATUS = -1_072_365_546_i32; +pub const STATUS_SXS_KEY_NOT_FOUND: NTSTATUS = -1_072_365_560_i32; +pub const STATUS_SXS_MANIFEST_FORMAT_ERROR: NTSTATUS = -1_072_365_563_i32; +pub const STATUS_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: NTSTATUS = -1_072_365_540_i32; +pub const STATUS_SXS_MANIFEST_PARSE_ERROR: NTSTATUS = -1_072_365_562_i32; +pub const STATUS_SXS_MANIFEST_TOO_BIG: NTSTATUS = -1_072_365_534_i32; +pub const STATUS_SXS_MULTIPLE_DEACTIVATION: NTSTATUS = -1_072_365_551_i32; +pub const STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET: NTSTATUS = -1_072_365_554_i32; +pub const STATUS_SXS_PROCESS_TERMINATION_REQUESTED: NTSTATUS = -1_072_365_549_i32; +pub const STATUS_SXS_RELEASE_ACTIVATION_CONTEXT: NTSTATUS = 1_075_118_093_i32; +pub const STATUS_SXS_SECTION_NOT_FOUND: NTSTATUS = -1_072_365_567_i32; +pub const STATUS_SXS_SETTING_NOT_REGISTERED: NTSTATUS = -1_072_365_533_i32; +pub const STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: NTSTATUS = -1_072_365_550_i32; +pub const STATUS_SXS_THREAD_QUERIES_DISABLED: NTSTATUS = -1_072_365_557_i32; +pub const STATUS_SXS_TRANSACTION_CLOSURE_INCOMPLETE: NTSTATUS = -1_072_365_532_i32; +pub const STATUS_SXS_VERSION_CONFLICT: NTSTATUS = -1_072_365_559_i32; +pub const STATUS_SXS_WRONG_SECTION_TYPE: NTSTATUS = -1_072_365_558_i32; +pub const STATUS_SYMLINK_CLASS_DISABLED: NTSTATUS = -1_073_740_011_i32; +pub const STATUS_SYNCHRONIZATION_REQUIRED: NTSTATUS = -1_073_741_516_i32; +pub const STATUS_SYSTEM_DEVICE_NOT_FOUND: NTSTATUS = -1_073_740_718_i32; +pub const STATUS_SYSTEM_HIVE_TOO_LARGE: NTSTATUS = -1_073_740_946_i32; +pub const STATUS_SYSTEM_IMAGE_BAD_SIGNATURE: NTSTATUS = -1_073_741_103_i32; +pub const STATUS_SYSTEM_INTEGRITY_INVALID_POLICY: NTSTATUS = -1_058_471_933_i32; +pub const STATUS_SYSTEM_INTEGRITY_POLICY_NOT_SIGNED: NTSTATUS = -1_058_471_932_i32; +pub const STATUS_SYSTEM_INTEGRITY_POLICY_VIOLATION: NTSTATUS = -1_058_471_934_i32; +pub const STATUS_SYSTEM_INTEGRITY_REPUTATION_DANGEROUS_EXT: NTSTATUS = -1_058_471_927_i32; +pub const STATUS_SYSTEM_INTEGRITY_REPUTATION_MALICIOUS: NTSTATUS = -1_058_471_929_i32; +pub const STATUS_SYSTEM_INTEGRITY_REPUTATION_OFFLINE: NTSTATUS = -1_058_471_926_i32; +pub const STATUS_SYSTEM_INTEGRITY_REPUTATION_PUA: NTSTATUS = -1_058_471_928_i32; +pub const STATUS_SYSTEM_INTEGRITY_REPUTATION_UNATTAINABLE: NTSTATUS = -1_058_471_924_i32; +pub const STATUS_SYSTEM_INTEGRITY_REPUTATION_UNFRIENDLY_FILE: NTSTATUS = -1_058_471_925_i32; +pub const STATUS_SYSTEM_INTEGRITY_ROLLBACK_DETECTED: NTSTATUS = -1_058_471_935_i32; +pub const STATUS_SYSTEM_INTEGRITY_SUPPLEMENTAL_POLICY_NOT_AUTHORIZED: NTSTATUS = -1_058_471_930_i32; +pub const STATUS_SYSTEM_INTEGRITY_TOO_MANY_POLICIES: NTSTATUS = -1_058_471_931_i32; +pub const STATUS_SYSTEM_NEEDS_REMEDIATION: NTSTATUS = -1_073_740_674_i32; +pub const STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: NTSTATUS = 1_073_741_873_i32; +pub const STATUS_SYSTEM_POWERSTATE_TRANSITION: NTSTATUS = 1_073_741_871_i32; +pub const STATUS_SYSTEM_PROCESS_TERMINATED: NTSTATUS = -1_073_741_286_i32; +pub const STATUS_SYSTEM_SHUTDOWN: NTSTATUS = -1_073_741_077_i32; +pub const STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED: NTSTATUS = -1_073_740_018_i32; +pub const STATUS_THREADPOOL_HANDLE_EXCEPTION: NTSTATUS = -1_073_740_022_i32; +pub const STATUS_THREADPOOL_RELEASED_DURING_OPERATION: NTSTATUS = -1_073_740_017_i32; +pub const STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED: NTSTATUS = -1_073_740_019_i32; +pub const STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED: NTSTATUS = -1_073_740_020_i32; +pub const STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED: NTSTATUS = -1_073_740_021_i32; +pub const STATUS_THREAD_ALREADY_IN_SESSION: NTSTATUS = -1_073_740_714_i32; +pub const STATUS_THREAD_ALREADY_IN_TASK: NTSTATUS = -1_073_740_542_i32; +pub const STATUS_THREAD_IS_TERMINATING: NTSTATUS = -1_073_741_749_i32; +pub const STATUS_THREAD_NOT_IN_PROCESS: NTSTATUS = -1_073_741_526_i32; +pub const STATUS_THREAD_NOT_IN_SESSION: NTSTATUS = -1_073_740_713_i32; +pub const STATUS_THREAD_NOT_RUNNING: NTSTATUS = -1_073_740_522_i32; +pub const STATUS_THREAD_WAS_SUSPENDED: NTSTATUS = 1_073_741_825_i32; +pub const STATUS_TIMEOUT: NTSTATUS = 258_i32; +pub const STATUS_TIMER_NOT_CANCELED: NTSTATUS = -1_073_741_812_i32; +pub const STATUS_TIMER_RESOLUTION_NOT_SET: NTSTATUS = -1_073_741_243_i32; +pub const STATUS_TIMER_RESUME_IGNORED: NTSTATUS = 1_073_741_861_i32; +pub const STATUS_TIME_DIFFERENCE_AT_DC: NTSTATUS = -1_073_741_517_i32; +pub const STATUS_TM_IDENTITY_MISMATCH: NTSTATUS = -1_072_103_350_i32; +pub const STATUS_TM_INITIALIZATION_FAILED: NTSTATUS = -1_072_103_420_i32; +pub const STATUS_TM_VOLATILE: NTSTATUS = -1_072_103_365_i32; +pub const STATUS_TOKEN_ALREADY_IN_USE: NTSTATUS = -1_073_741_525_i32; +pub const STATUS_TOO_LATE: NTSTATUS = -1_073_741_431_i32; +pub const STATUS_TOO_MANY_ADDRESSES: NTSTATUS = -1_073_741_303_i32; +pub const STATUS_TOO_MANY_COMMANDS: NTSTATUS = -1_073_741_631_i32; +pub const STATUS_TOO_MANY_CONTEXT_IDS: NTSTATUS = -1_073_741_478_i32; +pub const STATUS_TOO_MANY_GUIDS_REQUESTED: NTSTATUS = -1_073_741_694_i32; +pub const STATUS_TOO_MANY_LINKS: NTSTATUS = -1_073_741_211_i32; +pub const STATUS_TOO_MANY_LUIDS_REQUESTED: NTSTATUS = -1_073_741_708_i32; +pub const STATUS_TOO_MANY_NAMES: NTSTATUS = -1_073_741_619_i32; +pub const STATUS_TOO_MANY_NODES: NTSTATUS = -1_073_741_298_i32; +pub const STATUS_TOO_MANY_OPENED_FILES: NTSTATUS = -1_073_741_537_i32; +pub const STATUS_TOO_MANY_PAGING_FILES: NTSTATUS = -1_073_741_673_i32; +pub const STATUS_TOO_MANY_PRINCIPALS: NTSTATUS = -1_073_741_065_i32; +pub const STATUS_TOO_MANY_SECRETS: NTSTATUS = -1_073_741_482_i32; +pub const STATUS_TOO_MANY_SEGMENT_DESCRIPTORS: NTSTATUS = -1_073_740_685_i32; +pub const STATUS_TOO_MANY_SESSIONS: NTSTATUS = -1_073_741_618_i32; +pub const STATUS_TOO_MANY_SIDS: NTSTATUS = -1_073_741_442_i32; +pub const STATUS_TOO_MANY_THREADS: NTSTATUS = -1_073_741_527_i32; +pub const STATUS_TPM_20_E_ASYMMETRIC: NTSTATUS = -1_071_054_719_i32; +pub const STATUS_TPM_20_E_ATTRIBUTES: NTSTATUS = -1_071_054_718_i32; +pub const STATUS_TPM_20_E_AUTHSIZE: NTSTATUS = -1_071_054_524_i32; +pub const STATUS_TPM_20_E_AUTH_CONTEXT: NTSTATUS = -1_071_054_523_i32; +pub const STATUS_TPM_20_E_AUTH_FAIL: NTSTATUS = -1_071_054_706_i32; +pub const STATUS_TPM_20_E_AUTH_MISSING: NTSTATUS = -1_071_054_555_i32; +pub const STATUS_TPM_20_E_AUTH_TYPE: NTSTATUS = -1_071_054_556_i32; +pub const STATUS_TPM_20_E_AUTH_UNAVAILABLE: NTSTATUS = -1_071_054_545_i32; +pub const STATUS_TPM_20_E_BAD_AUTH: NTSTATUS = -1_071_054_686_i32; +pub const STATUS_TPM_20_E_BAD_CONTEXT: NTSTATUS = -1_071_054_512_i32; +pub const STATUS_TPM_20_E_BINDING: NTSTATUS = -1_071_054_683_i32; +pub const STATUS_TPM_20_E_COMMAND_CODE: NTSTATUS = -1_071_054_525_i32; +pub const STATUS_TPM_20_E_COMMAND_SIZE: NTSTATUS = -1_071_054_526_i32; +pub const STATUS_TPM_20_E_CPHASH: NTSTATUS = -1_071_054_511_i32; +pub const STATUS_TPM_20_E_CURVE: NTSTATUS = -1_071_054_682_i32; +pub const STATUS_TPM_20_E_DISABLED: NTSTATUS = -1_071_054_560_i32; +pub const STATUS_TPM_20_E_ECC_CURVE: NTSTATUS = -1_071_054_557_i32; +pub const STATUS_TPM_20_E_ECC_POINT: NTSTATUS = -1_071_054_681_i32; +pub const STATUS_TPM_20_E_EXCLUSIVE: NTSTATUS = -1_071_054_559_i32; +pub const STATUS_TPM_20_E_EXPIRED: NTSTATUS = -1_071_054_685_i32; +pub const STATUS_TPM_20_E_FAILURE: NTSTATUS = -1_071_054_591_i32; +pub const STATUS_TPM_20_E_HANDLE: NTSTATUS = -1_071_054_709_i32; +pub const STATUS_TPM_20_E_HASH: NTSTATUS = -1_071_054_717_i32; +pub const STATUS_TPM_20_E_HIERARCHY: NTSTATUS = -1_071_054_715_i32; +pub const STATUS_TPM_20_E_HMAC: NTSTATUS = -1_071_054_567_i32; +pub const STATUS_TPM_20_E_INITIALIZE: NTSTATUS = -1_071_054_592_i32; +pub const STATUS_TPM_20_E_INSUFFICIENT: NTSTATUS = -1_071_054_694_i32; +pub const STATUS_TPM_20_E_INTEGRITY: NTSTATUS = -1_071_054_689_i32; +pub const STATUS_TPM_20_E_KDF: NTSTATUS = -1_071_054_708_i32; +pub const STATUS_TPM_20_E_KEY: NTSTATUS = -1_071_054_692_i32; +pub const STATUS_TPM_20_E_KEY_SIZE: NTSTATUS = -1_071_054_713_i32; +pub const STATUS_TPM_20_E_MGF: NTSTATUS = -1_071_054_712_i32; +pub const STATUS_TPM_20_E_MODE: NTSTATUS = -1_071_054_711_i32; +pub const STATUS_TPM_20_E_NEEDS_TEST: NTSTATUS = -1_071_054_509_i32; +pub const STATUS_TPM_20_E_NONCE: NTSTATUS = -1_071_054_705_i32; +pub const STATUS_TPM_20_E_NO_RESULT: NTSTATUS = -1_071_054_508_i32; +pub const STATUS_TPM_20_E_NV_AUTHORIZATION: NTSTATUS = -1_071_054_519_i32; +pub const STATUS_TPM_20_E_NV_DEFINED: NTSTATUS = -1_071_054_516_i32; +pub const STATUS_TPM_20_E_NV_LOCKED: NTSTATUS = -1_071_054_520_i32; +pub const STATUS_TPM_20_E_NV_RANGE: NTSTATUS = -1_071_054_522_i32; +pub const STATUS_TPM_20_E_NV_SIZE: NTSTATUS = -1_071_054_521_i32; +pub const STATUS_TPM_20_E_NV_SPACE: NTSTATUS = -1_071_054_517_i32; +pub const STATUS_TPM_20_E_NV_UNINITIALIZED: NTSTATUS = -1_071_054_518_i32; +pub const STATUS_TPM_20_E_PARENT: NTSTATUS = -1_071_054_510_i32; +pub const STATUS_TPM_20_E_PCR: NTSTATUS = -1_071_054_553_i32; +pub const STATUS_TPM_20_E_PCR_CHANGED: NTSTATUS = -1_071_054_552_i32; +pub const STATUS_TPM_20_E_POLICY: NTSTATUS = -1_071_054_554_i32; +pub const STATUS_TPM_20_E_POLICY_CC: NTSTATUS = -1_071_054_684_i32; +pub const STATUS_TPM_20_E_POLICY_FAIL: NTSTATUS = -1_071_054_691_i32; +pub const STATUS_TPM_20_E_PP: NTSTATUS = -1_071_054_704_i32; +pub const STATUS_TPM_20_E_PRIVATE: NTSTATUS = -1_071_054_581_i32; +pub const STATUS_TPM_20_E_RANGE: NTSTATUS = -1_071_054_707_i32; +pub const STATUS_TPM_20_E_REBOOT: NTSTATUS = -1_071_054_544_i32; +pub const STATUS_TPM_20_E_RESERVED_BITS: NTSTATUS = -1_071_054_687_i32; +pub const STATUS_TPM_20_E_SCHEME: NTSTATUS = -1_071_054_702_i32; +pub const STATUS_TPM_20_E_SELECTOR: NTSTATUS = -1_071_054_696_i32; +pub const STATUS_TPM_20_E_SENSITIVE: NTSTATUS = -1_071_054_507_i32; +pub const STATUS_TPM_20_E_SEQUENCE: NTSTATUS = -1_071_054_589_i32; +pub const STATUS_TPM_20_E_SIGNATURE: NTSTATUS = -1_071_054_693_i32; +pub const STATUS_TPM_20_E_SIZE: NTSTATUS = -1_071_054_699_i32; +pub const STATUS_TPM_20_E_SYMMETRIC: NTSTATUS = -1_071_054_698_i32; +pub const STATUS_TPM_20_E_TAG: NTSTATUS = -1_071_054_697_i32; +pub const STATUS_TPM_20_E_TICKET: NTSTATUS = -1_071_054_688_i32; +pub const STATUS_TPM_20_E_TOO_MANY_CONTEXTS: NTSTATUS = -1_071_054_546_i32; +pub const STATUS_TPM_20_E_TYPE: NTSTATUS = -1_071_054_710_i32; +pub const STATUS_TPM_20_E_UNBALANCED: NTSTATUS = -1_071_054_543_i32; +pub const STATUS_TPM_20_E_UPGRADE: NTSTATUS = -1_071_054_547_i32; +pub const STATUS_TPM_20_E_VALUE: NTSTATUS = -1_071_054_716_i32; +pub const STATUS_TPM_ACCESS_DENIED: NTSTATUS = -1_071_050_748_i32; +pub const STATUS_TPM_AREA_LOCKED: NTSTATUS = -1_071_054_788_i32; +pub const STATUS_TPM_AUDITFAILURE: NTSTATUS = -1_071_054_844_i32; +pub const STATUS_TPM_AUDITFAIL_SUCCESSFUL: NTSTATUS = -1_071_054_799_i32; +pub const STATUS_TPM_AUDITFAIL_UNSUCCESSFUL: NTSTATUS = -1_071_054_800_i32; +pub const STATUS_TPM_AUTH2FAIL: NTSTATUS = -1_071_054_819_i32; +pub const STATUS_TPM_AUTHFAIL: NTSTATUS = -1_071_054_847_i32; +pub const STATUS_TPM_AUTH_CONFLICT: NTSTATUS = -1_071_054_789_i32; +pub const STATUS_TPM_BADCONTEXT: NTSTATUS = -1_071_054_758_i32; +pub const STATUS_TPM_BADINDEX: NTSTATUS = -1_071_054_846_i32; +pub const STATUS_TPM_BADTAG: NTSTATUS = -1_071_054_818_i32; +pub const STATUS_TPM_BAD_ATTRIBUTES: NTSTATUS = -1_071_054_782_i32; +pub const STATUS_TPM_BAD_COUNTER: NTSTATUS = -1_071_054_779_i32; +pub const STATUS_TPM_BAD_DATASIZE: NTSTATUS = -1_071_054_805_i32; +pub const STATUS_TPM_BAD_DELEGATE: NTSTATUS = -1_071_054_759_i32; +pub const STATUS_TPM_BAD_HANDLE: NTSTATUS = -1_071_054_760_i32; +pub const STATUS_TPM_BAD_KEY_PROPERTY: NTSTATUS = -1_071_054_808_i32; +pub const STATUS_TPM_BAD_LOCALITY: NTSTATUS = -1_071_054_787_i32; +pub const STATUS_TPM_BAD_MIGRATION: NTSTATUS = -1_071_054_807_i32; +pub const STATUS_TPM_BAD_MODE: NTSTATUS = -1_071_054_804_i32; +pub const STATUS_TPM_BAD_ORDINAL: NTSTATUS = -1_071_054_838_i32; +pub const STATUS_TPM_BAD_PARAMETER: NTSTATUS = -1_071_054_845_i32; +pub const STATUS_TPM_BAD_PARAM_SIZE: NTSTATUS = -1_071_054_823_i32; +pub const STATUS_TPM_BAD_PRESENCE: NTSTATUS = -1_071_054_803_i32; +pub const STATUS_TPM_BAD_SCHEME: NTSTATUS = -1_071_054_806_i32; +pub const STATUS_TPM_BAD_SIGNATURE: NTSTATUS = -1_071_054_750_i32; +pub const STATUS_TPM_BAD_TYPE: NTSTATUS = -1_071_054_796_i32; +pub const STATUS_TPM_BAD_VERSION: NTSTATUS = -1_071_054_802_i32; +pub const STATUS_TPM_CLEAR_DISABLED: NTSTATUS = -1_071_054_843_i32; +pub const STATUS_TPM_COMMAND_BLOCKED: NTSTATUS = -1_071_053_824_i32; +pub const STATUS_TPM_COMMAND_CANCELED: NTSTATUS = -1_071_050_751_i32; +pub const STATUS_TPM_CONTEXT_GAP: NTSTATUS = -1_071_054_777_i32; +pub const STATUS_TPM_DAA_INPUT_DATA0: NTSTATUS = -1_071_054_767_i32; +pub const STATUS_TPM_DAA_INPUT_DATA1: NTSTATUS = -1_071_054_766_i32; +pub const STATUS_TPM_DAA_ISSUER_SETTINGS: NTSTATUS = -1_071_054_765_i32; +pub const STATUS_TPM_DAA_ISSUER_VALIDITY: NTSTATUS = -1_071_054_762_i32; +pub const STATUS_TPM_DAA_RESOURCES: NTSTATUS = -1_071_054_768_i32; +pub const STATUS_TPM_DAA_STAGE: NTSTATUS = -1_071_054_763_i32; +pub const STATUS_TPM_DAA_TPM_SETTINGS: NTSTATUS = -1_071_054_764_i32; +pub const STATUS_TPM_DAA_WRONG_W: NTSTATUS = -1_071_054_761_i32; +pub const STATUS_TPM_DEACTIVATED: NTSTATUS = -1_071_054_842_i32; +pub const STATUS_TPM_DECRYPT_ERROR: NTSTATUS = -1_071_054_815_i32; +pub const STATUS_TPM_DEFEND_LOCK_RUNNING: NTSTATUS = -1_071_052_797_i32; +pub const STATUS_TPM_DELEGATE_ADMIN: NTSTATUS = -1_071_054_771_i32; +pub const STATUS_TPM_DELEGATE_FAMILY: NTSTATUS = -1_071_054_772_i32; +pub const STATUS_TPM_DELEGATE_LOCK: NTSTATUS = -1_071_054_773_i32; +pub const STATUS_TPM_DISABLED: NTSTATUS = -1_071_054_841_i32; +pub const STATUS_TPM_DISABLED_CMD: NTSTATUS = -1_071_054_840_i32; +pub const STATUS_TPM_DOING_SELFTEST: NTSTATUS = -1_071_052_798_i32; +pub const STATUS_TPM_DUPLICATE_VHANDLE: NTSTATUS = -1_071_053_822_i32; +pub const STATUS_TPM_EMBEDDED_COMMAND_BLOCKED: NTSTATUS = -1_071_053_821_i32; +pub const STATUS_TPM_EMBEDDED_COMMAND_UNSUPPORTED: NTSTATUS = -1_071_053_820_i32; +pub const STATUS_TPM_ENCRYPT_ERROR: NTSTATUS = -1_071_054_816_i32; +pub const STATUS_TPM_ERROR_MASK: NTSTATUS = -1_071_054_848_i32; +pub const STATUS_TPM_FAIL: NTSTATUS = -1_071_054_839_i32; +pub const STATUS_TPM_FAILEDSELFTEST: NTSTATUS = -1_071_054_820_i32; +pub const STATUS_TPM_FAMILYCOUNT: NTSTATUS = -1_071_054_784_i32; +pub const STATUS_TPM_INAPPROPRIATE_ENC: NTSTATUS = -1_071_054_834_i32; +pub const STATUS_TPM_INAPPROPRIATE_SIG: NTSTATUS = -1_071_054_809_i32; +pub const STATUS_TPM_INSTALL_DISABLED: NTSTATUS = -1_071_054_837_i32; +pub const STATUS_TPM_INSUFFICIENT_BUFFER: NTSTATUS = -1_071_050_747_i32; +pub const STATUS_TPM_INVALID_AUTHHANDLE: NTSTATUS = -1_071_054_814_i32; +pub const STATUS_TPM_INVALID_FAMILY: NTSTATUS = -1_071_054_793_i32; +pub const STATUS_TPM_INVALID_HANDLE: NTSTATUS = -1_071_053_823_i32; +pub const STATUS_TPM_INVALID_KEYHANDLE: NTSTATUS = -1_071_054_836_i32; +pub const STATUS_TPM_INVALID_KEYUSAGE: NTSTATUS = -1_071_054_812_i32; +pub const STATUS_TPM_INVALID_PCR_INFO: NTSTATUS = -1_071_054_832_i32; +pub const STATUS_TPM_INVALID_POSTINIT: NTSTATUS = -1_071_054_810_i32; +pub const STATUS_TPM_INVALID_RESOURCE: NTSTATUS = -1_071_054_795_i32; +pub const STATUS_TPM_INVALID_STRUCTURE: NTSTATUS = -1_071_054_781_i32; +pub const STATUS_TPM_IOERROR: NTSTATUS = -1_071_054_817_i32; +pub const STATUS_TPM_KEYNOTFOUND: NTSTATUS = -1_071_054_835_i32; +pub const STATUS_TPM_KEY_NOTSUPPORTED: NTSTATUS = -1_071_054_790_i32; +pub const STATUS_TPM_KEY_OWNER_CONTROL: NTSTATUS = -1_071_054_780_i32; +pub const STATUS_TPM_MAXNVWRITES: NTSTATUS = -1_071_054_776_i32; +pub const STATUS_TPM_MA_AUTHORITY: NTSTATUS = -1_071_054_753_i32; +pub const STATUS_TPM_MA_DESTINATION: NTSTATUS = -1_071_054_755_i32; +pub const STATUS_TPM_MA_SOURCE: NTSTATUS = -1_071_054_754_i32; +pub const STATUS_TPM_MA_TICKET_SIGNATURE: NTSTATUS = -1_071_054_756_i32; +pub const STATUS_TPM_MIGRATEFAIL: NTSTATUS = -1_071_054_833_i32; +pub const STATUS_TPM_NEEDS_SELFTEST: NTSTATUS = -1_071_052_799_i32; +pub const STATUS_TPM_NOCONTEXTSPACE: NTSTATUS = -1_071_054_749_i32; +pub const STATUS_TPM_NOOPERATOR: NTSTATUS = -1_071_054_775_i32; +pub const STATUS_TPM_NOSPACE: NTSTATUS = -1_071_054_831_i32; +pub const STATUS_TPM_NOSRK: NTSTATUS = -1_071_054_830_i32; +pub const STATUS_TPM_NOTFIPS: NTSTATUS = -1_071_054_794_i32; +pub const STATUS_TPM_NOTLOCAL: NTSTATUS = -1_071_054_797_i32; +pub const STATUS_TPM_NOTRESETABLE: NTSTATUS = -1_071_054_798_i32; +pub const STATUS_TPM_NOTSEALED_BLOB: NTSTATUS = -1_071_054_829_i32; +pub const STATUS_TPM_NOT_FOUND: NTSTATUS = -1_071_050_749_i32; +pub const STATUS_TPM_NOT_FULLWRITE: NTSTATUS = -1_071_054_778_i32; +pub const STATUS_TPM_NO_ENDORSEMENT: NTSTATUS = -1_071_054_813_i32; +pub const STATUS_TPM_NO_NV_PERMISSION: NTSTATUS = -1_071_054_792_i32; +pub const STATUS_TPM_NO_WRAP_TRANSPORT: NTSTATUS = -1_071_054_801_i32; +pub const STATUS_TPM_OWNER_CONTROL: NTSTATUS = -1_071_054_769_i32; +pub const STATUS_TPM_OWNER_SET: NTSTATUS = -1_071_054_828_i32; +pub const STATUS_TPM_PERMANENTEK: NTSTATUS = -1_071_054_751_i32; +pub const STATUS_TPM_PER_NOWRITE: NTSTATUS = -1_071_054_785_i32; +pub const STATUS_TPM_PPI_FUNCTION_UNSUPPORTED: NTSTATUS = -1_071_050_746_i32; +pub const STATUS_TPM_READ_ONLY: NTSTATUS = -1_071_054_786_i32; +pub const STATUS_TPM_REQUIRES_SIGN: NTSTATUS = -1_071_054_791_i32; +pub const STATUS_TPM_RESOURCEMISSING: NTSTATUS = -1_071_054_774_i32; +pub const STATUS_TPM_RESOURCES: NTSTATUS = -1_071_054_827_i32; +pub const STATUS_TPM_RETRY: NTSTATUS = -1_071_052_800_i32; +pub const STATUS_TPM_SHA_ERROR: NTSTATUS = -1_071_054_821_i32; +pub const STATUS_TPM_SHA_THREAD: NTSTATUS = -1_071_054_822_i32; +pub const STATUS_TPM_SHORTRANDOM: NTSTATUS = -1_071_054_826_i32; +pub const STATUS_TPM_SIZE: NTSTATUS = -1_071_054_825_i32; +pub const STATUS_TPM_TOOMANYCONTEXTS: NTSTATUS = -1_071_054_757_i32; +pub const STATUS_TPM_TOO_MANY_CONTEXTS: NTSTATUS = -1_071_050_750_i32; +pub const STATUS_TPM_TRANSPORT_NOTEXCLUSIVE: NTSTATUS = -1_071_054_770_i32; +pub const STATUS_TPM_WRITE_LOCKED: NTSTATUS = -1_071_054_783_i32; +pub const STATUS_TPM_WRONGPCRVAL: NTSTATUS = -1_071_054_824_i32; +pub const STATUS_TPM_WRONG_ENTITYTYPE: NTSTATUS = -1_071_054_811_i32; +pub const STATUS_TPM_ZERO_EXHAUST_ENABLED: NTSTATUS = -1_071_038_464_i32; +pub const STATUS_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: NTSTATUS = -1_072_103_360_i32; +pub const STATUS_TRANSACTIONAL_CONFLICT: NTSTATUS = -1_072_103_423_i32; +pub const STATUS_TRANSACTIONAL_OPEN_NOT_ALLOWED: NTSTATUS = -1_072_103_361_i32; +pub const STATUS_TRANSACTIONMANAGER_IDENTITY_MISMATCH: NTSTATUS = -1_072_103_332_i32; +pub const STATUS_TRANSACTIONMANAGER_NOT_FOUND: NTSTATUS = -1_072_103_343_i32; +pub const STATUS_TRANSACTIONMANAGER_NOT_ONLINE: NTSTATUS = -1_072_103_342_i32; +pub const STATUS_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: NTSTATUS = -1_072_103_341_i32; +pub const STATUS_TRANSACTIONS_NOT_FROZEN: NTSTATUS = -1_072_103_355_i32; +pub const STATUS_TRANSACTIONS_UNSUPPORTED_REMOTE: NTSTATUS = -1_072_103_414_i32; +pub const STATUS_TRANSACTION_ABORTED: NTSTATUS = -1_073_741_297_i32; +pub const STATUS_TRANSACTION_ALREADY_ABORTED: NTSTATUS = -1_072_103_403_i32; +pub const STATUS_TRANSACTION_ALREADY_COMMITTED: NTSTATUS = -1_072_103_402_i32; +pub const STATUS_TRANSACTION_FREEZE_IN_PROGRESS: NTSTATUS = -1_072_103_354_i32; +pub const STATUS_TRANSACTION_INTEGRITY_VIOLATED: NTSTATUS = -1_072_103_333_i32; +pub const STATUS_TRANSACTION_INVALID_ID: NTSTATUS = -1_073_741_292_i32; +pub const STATUS_TRANSACTION_INVALID_MARSHALL_BUFFER: NTSTATUS = -1_072_103_401_i32; +pub const STATUS_TRANSACTION_INVALID_TYPE: NTSTATUS = -1_073_741_291_i32; +pub const STATUS_TRANSACTION_MUST_WRITETHROUGH: NTSTATUS = -1_072_103_330_i32; +pub const STATUS_TRANSACTION_NOT_ACTIVE: NTSTATUS = -1_072_103_421_i32; +pub const STATUS_TRANSACTION_NOT_ENLISTED: NTSTATUS = -1_072_103_327_i32; +pub const STATUS_TRANSACTION_NOT_FOUND: NTSTATUS = -1_072_103_346_i32; +pub const STATUS_TRANSACTION_NOT_JOINED: NTSTATUS = -1_072_103_417_i32; +pub const STATUS_TRANSACTION_NOT_REQUESTED: NTSTATUS = -1_072_103_404_i32; +pub const STATUS_TRANSACTION_NOT_ROOT: NTSTATUS = -1_072_103_340_i32; +pub const STATUS_TRANSACTION_NO_MATCH: NTSTATUS = -1_073_741_294_i32; +pub const STATUS_TRANSACTION_NO_RELEASE: NTSTATUS = -1_073_741_295_i32; +pub const STATUS_TRANSACTION_NO_SUPERIOR: NTSTATUS = -1_072_103_329_i32; +pub const STATUS_TRANSACTION_OBJECT_EXPIRED: NTSTATUS = -1_072_103_339_i32; +pub const STATUS_TRANSACTION_PROPAGATION_FAILED: NTSTATUS = -1_072_103_408_i32; +pub const STATUS_TRANSACTION_RECORD_TOO_LONG: NTSTATUS = -1_072_103_336_i32; +pub const STATUS_TRANSACTION_REQUEST_NOT_VALID: NTSTATUS = -1_072_103_405_i32; +pub const STATUS_TRANSACTION_REQUIRED_PROMOTION: NTSTATUS = -1_072_103_357_i32; +pub const STATUS_TRANSACTION_RESPONDED: NTSTATUS = -1_073_741_293_i32; +pub const STATUS_TRANSACTION_RESPONSE_NOT_ENLISTED: NTSTATUS = -1_072_103_337_i32; +pub const STATUS_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: NTSTATUS = -2_145_845_182_i32; +pub const STATUS_TRANSACTION_SUPERIOR_EXISTS: NTSTATUS = -1_072_103_406_i32; +pub const STATUS_TRANSACTION_TIMED_OUT: NTSTATUS = -1_073_741_296_i32; +pub const STATUS_TRANSLATION_COMPLETE: NTSTATUS = 288_i32; +pub const STATUS_TRANSPORT_FULL: NTSTATUS = -1_073_741_110_i32; +pub const STATUS_TRIGGERED_EXECUTABLE_MEMORY_WRITE: NTSTATUS = -1_073_739_994_i32; +pub const STATUS_TRIM_READ_ZERO_NOT_SUPPORTED: NTSTATUS = -1_073_740_686_i32; +pub const STATUS_TRUSTED_DOMAIN_FAILURE: NTSTATUS = -1_073_741_428_i32; +pub const STATUS_TRUSTED_RELATIONSHIP_FAILURE: NTSTATUS = -1_073_741_427_i32; +pub const STATUS_TRUST_FAILURE: NTSTATUS = -1_073_741_424_i32; +pub const STATUS_TS_INCOMPATIBLE_SESSIONS: NTSTATUS = -1_073_086_407_i32; +pub const STATUS_TS_VIDEO_SUBSYSTEM_ERROR: NTSTATUS = -1_073_086_406_i32; +pub const STATUS_TXF_ATTRIBUTE_CORRUPT: NTSTATUS = -1_072_103_363_i32; +pub const STATUS_TXF_DIR_NOT_EMPTY: NTSTATUS = -1_072_103_367_i32; +pub const STATUS_TXF_METADATA_ALREADY_PRESENT: NTSTATUS = -2_145_845_183_i32; +pub const STATUS_UNABLE_TO_DECOMMIT_VM: NTSTATUS = -1_073_741_780_i32; +pub const STATUS_UNABLE_TO_DELETE_SECTION: NTSTATUS = -1_073_741_797_i32; +pub const STATUS_UNABLE_TO_FREE_VM: NTSTATUS = -1_073_741_798_i32; +pub const STATUS_UNABLE_TO_LOCK_MEDIA: NTSTATUS = -1_073_741_451_i32; +pub const STATUS_UNABLE_TO_UNLOAD_MEDIA: NTSTATUS = -1_073_741_450_i32; +pub const STATUS_UNDEFINED_CHARACTER: NTSTATUS = -1_073_741_469_i32; +pub const STATUS_UNDEFINED_SCOPE: NTSTATUS = -1_073_740_540_i32; +pub const STATUS_UNEXPECTED_IO_ERROR: NTSTATUS = -1_073_741_591_i32; +pub const STATUS_UNEXPECTED_MM_CREATE_ERR: NTSTATUS = -1_073_741_590_i32; +pub const STATUS_UNEXPECTED_MM_EXTEND_ERR: NTSTATUS = -1_073_741_588_i32; +pub const STATUS_UNEXPECTED_MM_MAP_ERROR: NTSTATUS = -1_073_741_589_i32; +pub const STATUS_UNEXPECTED_NETWORK_ERROR: NTSTATUS = -1_073_741_628_i32; +pub const STATUS_UNFINISHED_CONTEXT_DELETED: NTSTATUS = -1_073_741_074_i32; +pub const STATUS_UNHANDLED_EXCEPTION: NTSTATUS = -1_073_741_500_i32; +pub const STATUS_UNKNOWN_REVISION: NTSTATUS = -1_073_741_736_i32; +pub const STATUS_UNMAPPABLE_CHARACTER: NTSTATUS = -1_073_741_470_i32; +pub const STATUS_UNRECOGNIZED_MEDIA: NTSTATUS = -1_073_741_804_i32; +pub const STATUS_UNRECOGNIZED_VOLUME: NTSTATUS = -1_073_741_489_i32; +pub const STATUS_UNSATISFIED_DEPENDENCIES: NTSTATUS = -1_073_740_615_i32; +pub const STATUS_UNSUCCESSFUL: NTSTATUS = -1_073_741_823_i32; +pub const STATUS_UNSUPPORTED_COMPRESSION: NTSTATUS = -1_073_741_217_i32; +pub const STATUS_UNSUPPORTED_PAGING_MODE: NTSTATUS = -1_073_740_613_i32; +pub const STATUS_UNSUPPORTED_PREAUTH: NTSTATUS = -1_073_740_975_i32; +pub const STATUS_UNTRUSTED_MOUNT_POINT: NTSTATUS = -1_073_740_612_i32; +pub const STATUS_UNWIND: NTSTATUS = -1_073_741_785_i32; +pub const STATUS_UNWIND_CONSOLIDATE: NTSTATUS = -2_147_483_607_i32; +pub const STATUS_USER2USER_REQUIRED: NTSTATUS = -1_073_740_792_i32; +pub const STATUS_USER_APC: NTSTATUS = 192_i32; +pub const STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED: NTSTATUS = -1_073_740_797_i32; +pub const STATUS_USER_EXISTS: NTSTATUS = -1_073_741_725_i32; +pub const STATUS_USER_MAPPED_FILE: NTSTATUS = -1_073_741_245_i32; +pub const STATUS_USER_SESSION_DELETED: NTSTATUS = -1_073_741_309_i32; +pub const STATUS_VALIDATE_CONTINUE: NTSTATUS = -1_073_741_199_i32; +pub const STATUS_VALID_CATALOG_HASH: NTSTATUS = 301_i32; +pub const STATUS_VALID_IMAGE_HASH: NTSTATUS = 300_i32; +pub const STATUS_VALID_STRONG_CODE_HASH: NTSTATUS = 302_i32; +pub const STATUS_VARIABLE_NOT_FOUND: NTSTATUS = -1_073_741_568_i32; +pub const STATUS_VDM_DISALLOWED: NTSTATUS = -1_073_740_780_i32; +pub const STATUS_VDM_HARD_ERROR: NTSTATUS = -1_073_741_283_i32; +pub const STATUS_VERIFIER_STOP: NTSTATUS = -1_073_740_767_i32; +pub const STATUS_VERIFY_REQUIRED: NTSTATUS = -2_147_483_626_i32; +pub const STATUS_VHDSET_BACKING_STORAGE_NOT_FOUND: NTSTATUS = -1_067_647_220_i32; +pub const STATUS_VHD_ALREADY_AT_OR_BELOW_MINIMUM_VIRTUAL_SIZE: NTSTATUS = -1_069_940_685_i32; +pub const STATUS_VHD_BITMAP_MISMATCH: NTSTATUS = -1_069_940_724_i32; +pub const STATUS_VHD_BLOCK_ALLOCATION_FAILURE: NTSTATUS = -1_069_940_727_i32; +pub const STATUS_VHD_BLOCK_ALLOCATION_TABLE_CORRUPT: NTSTATUS = -1_069_940_726_i32; +pub const STATUS_VHD_CHANGE_TRACKING_DISABLED: NTSTATUS = -1_069_940_694_i32; +pub const STATUS_VHD_CHILD_PARENT_ID_MISMATCH: NTSTATUS = -1_069_940_722_i32; +pub const STATUS_VHD_CHILD_PARENT_SIZE_MISMATCH: NTSTATUS = -1_069_940_713_i32; +pub const STATUS_VHD_CHILD_PARENT_TIMESTAMP_MISMATCH: NTSTATUS = -1_069_940_721_i32; +pub const STATUS_VHD_COULD_NOT_COMPUTE_MINIMUM_VIRTUAL_SIZE: NTSTATUS = -1_069_940_686_i32; +pub const STATUS_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED: NTSTATUS = -1_069_940_712_i32; +pub const STATUS_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT: NTSTATUS = -1_069_940_711_i32; +pub const STATUS_VHD_DRIVE_FOOTER_CHECKSUM_MISMATCH: NTSTATUS = -1_069_940_734_i32; +pub const STATUS_VHD_DRIVE_FOOTER_CORRUPT: NTSTATUS = -1_069_940_733_i32; +pub const STATUS_VHD_DRIVE_FOOTER_MISSING: NTSTATUS = -1_069_940_735_i32; +pub const STATUS_VHD_FORMAT_UNKNOWN: NTSTATUS = -1_069_940_732_i32; +pub const STATUS_VHD_FORMAT_UNSUPPORTED_VERSION: NTSTATUS = -1_069_940_731_i32; +pub const STATUS_VHD_INVALID_BLOCK_SIZE: NTSTATUS = -1_069_940_725_i32; +pub const STATUS_VHD_INVALID_CHANGE_TRACKING_ID: NTSTATUS = -1_069_940_695_i32; +pub const STATUS_VHD_INVALID_FILE_SIZE: NTSTATUS = -1_069_940_717_i32; +pub const STATUS_VHD_INVALID_SIZE: NTSTATUS = -1_069_940_718_i32; +pub const STATUS_VHD_INVALID_STATE: NTSTATUS = -1_069_940_708_i32; +pub const STATUS_VHD_INVALID_TYPE: NTSTATUS = -1_069_940_709_i32; +pub const STATUS_VHD_METADATA_FULL: NTSTATUS = -1_069_940_696_i32; +pub const STATUS_VHD_METADATA_READ_FAILURE: NTSTATUS = -1_069_940_720_i32; +pub const STATUS_VHD_METADATA_WRITE_FAILURE: NTSTATUS = -1_069_940_719_i32; +pub const STATUS_VHD_MISSING_CHANGE_TRACKING_INFORMATION: NTSTATUS = -1_069_940_688_i32; +pub const STATUS_VHD_PARENT_VHD_ACCESS_DENIED: NTSTATUS = -1_069_940_714_i32; +pub const STATUS_VHD_PARENT_VHD_NOT_FOUND: NTSTATUS = -1_069_940_723_i32; +pub const STATUS_VHD_RESIZE_WOULD_TRUNCATE_DATA: NTSTATUS = -1_069_940_687_i32; +pub const STATUS_VHD_SHARED: NTSTATUS = -1_067_647_222_i32; +pub const STATUS_VHD_SPARSE_HEADER_CHECKSUM_MISMATCH: NTSTATUS = -1_069_940_730_i32; +pub const STATUS_VHD_SPARSE_HEADER_CORRUPT: NTSTATUS = -1_069_940_728_i32; +pub const STATUS_VHD_SPARSE_HEADER_UNSUPPORTED_VERSION: NTSTATUS = -1_069_940_729_i32; +pub const STATUS_VIDEO_DRIVER_DEBUG_REPORT_REQUEST: NTSTATUS = 1_075_511_532_i32; +pub const STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD: NTSTATUS = -1_071_972_118_i32; +pub const STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD_RECOVERED: NTSTATUS = -2_145_713_941_i32; +pub const STATUS_VID_CHILD_GPA_PAGE_SET_CORRUPTED: NTSTATUS = -1_070_137_330_i32; +pub const STATUS_VID_DUPLICATE_HANDLER: NTSTATUS = -1_070_137_343_i32; +pub const STATUS_VID_EXCEEDED_KM_CONTEXT_COUNT_LIMIT: NTSTATUS = -1_070_137_314_i32; +pub const STATUS_VID_EXCEEDED_MBP_ENTRY_MAP_LIMIT: NTSTATUS = -1_070_137_332_i32; +pub const STATUS_VID_HANDLER_NOT_PRESENT: NTSTATUS = -1_070_137_340_i32; +pub const STATUS_VID_INSUFFICIENT_RESOURCES_HV_DEPOSIT: NTSTATUS = -1_070_137_299_i32; +pub const STATUS_VID_INSUFFICIENT_RESOURCES_PHYSICAL_BUFFER: NTSTATUS = -1_070_137_300_i32; +pub const STATUS_VID_INSUFFICIENT_RESOURCES_RESERVE: NTSTATUS = -1_070_137_301_i32; +pub const STATUS_VID_INSUFFICIENT_RESOURCES_WITHDRAW: NTSTATUS = -1_070_137_297_i32; +pub const STATUS_VID_INVALID_CHILD_GPA_PAGE_SET: NTSTATUS = -1_070_137_310_i32; +pub const STATUS_VID_INVALID_GPA_RANGE_HANDLE: NTSTATUS = -1_070_137_323_i32; +pub const STATUS_VID_INVALID_MEMORY_BLOCK_HANDLE: NTSTATUS = -1_070_137_326_i32; +pub const STATUS_VID_INVALID_MESSAGE_QUEUE_HANDLE: NTSTATUS = -1_070_137_324_i32; +pub const STATUS_VID_INVALID_NUMA_NODE_INDEX: NTSTATUS = -1_070_137_328_i32; +pub const STATUS_VID_INVALID_NUMA_SETTINGS: NTSTATUS = -1_070_137_329_i32; +pub const STATUS_VID_INVALID_OBJECT_NAME: NTSTATUS = -1_070_137_339_i32; +pub const STATUS_VID_INVALID_PPM_HANDLE: NTSTATUS = -1_070_137_320_i32; +pub const STATUS_VID_INVALID_PROCESSOR_STATE: NTSTATUS = -1_070_137_315_i32; +pub const STATUS_VID_KM_INTERFACE_ALREADY_INITIALIZED: NTSTATUS = -1_070_137_313_i32; +pub const STATUS_VID_MBPS_ARE_LOCKED: NTSTATUS = -1_070_137_319_i32; +pub const STATUS_VID_MBP_ALREADY_LOCKED_USING_RESERVED_PAGE: NTSTATUS = -1_070_137_307_i32; +pub const STATUS_VID_MBP_COUNT_EXCEEDED_LIMIT: NTSTATUS = -1_070_137_306_i32; +pub const STATUS_VID_MB_PROPERTY_ALREADY_SET_RESET: NTSTATUS = -1_070_137_312_i32; +pub const STATUS_VID_MB_STILL_REFERENCED: NTSTATUS = -1_070_137_331_i32; +pub const STATUS_VID_MEMORY_BLOCK_LOCK_COUNT_EXCEEDED: NTSTATUS = -1_070_137_321_i32; +pub const STATUS_VID_MEMORY_TYPE_NOT_SUPPORTED: NTSTATUS = -1_070_137_298_i32; +pub const STATUS_VID_MESSAGE_QUEUE_ALREADY_EXISTS: NTSTATUS = -1_070_137_333_i32; +pub const STATUS_VID_MESSAGE_QUEUE_CLOSED: NTSTATUS = -1_070_137_318_i32; +pub const STATUS_VID_MESSAGE_QUEUE_NAME_TOO_LONG: NTSTATUS = -1_070_137_337_i32; +pub const STATUS_VID_MMIO_RANGE_DESTROYED: NTSTATUS = -1_070_137_311_i32; +pub const STATUS_VID_NOTIFICATION_QUEUE_ALREADY_ASSOCIATED: NTSTATUS = -1_070_137_327_i32; +pub const STATUS_VID_NO_MEMORY_BLOCK_NOTIFICATION_QUEUE: NTSTATUS = -1_070_137_322_i32; +pub const STATUS_VID_PAGE_RANGE_OVERFLOW: NTSTATUS = -1_070_137_325_i32; +pub const STATUS_VID_PARTITION_ALREADY_EXISTS: NTSTATUS = -1_070_137_336_i32; +pub const STATUS_VID_PARTITION_DOES_NOT_EXIST: NTSTATUS = -1_070_137_335_i32; +pub const STATUS_VID_PARTITION_NAME_NOT_FOUND: NTSTATUS = -1_070_137_334_i32; +pub const STATUS_VID_PARTITION_NAME_TOO_LONG: NTSTATUS = -1_070_137_338_i32; +pub const STATUS_VID_PROCESS_ALREADY_SET: NTSTATUS = -1_070_137_296_i32; +pub const STATUS_VID_QUEUE_FULL: NTSTATUS = -1_070_137_341_i32; +pub const STATUS_VID_REMOTE_NODE_PARENT_GPA_PAGES_USED: NTSTATUS = -2_143_879_167_i32; +pub const STATUS_VID_RESERVE_PAGE_SET_IS_BEING_USED: NTSTATUS = -1_070_137_309_i32; +pub const STATUS_VID_RESERVE_PAGE_SET_TOO_SMALL: NTSTATUS = -1_070_137_308_i32; +pub const STATUS_VID_SAVED_STATE_CORRUPT: NTSTATUS = -1_070_137_305_i32; +pub const STATUS_VID_SAVED_STATE_INCOMPATIBLE: NTSTATUS = -1_070_137_303_i32; +pub const STATUS_VID_SAVED_STATE_UNRECOGNIZED_ITEM: NTSTATUS = -1_070_137_304_i32; +pub const STATUS_VID_STOP_PENDING: NTSTATUS = -1_070_137_316_i32; +pub const STATUS_VID_TOO_MANY_HANDLERS: NTSTATUS = -1_070_137_342_i32; +pub const STATUS_VID_VIRTUAL_PROCESSOR_LIMIT_EXCEEDED: NTSTATUS = -1_070_137_317_i32; +pub const STATUS_VID_VTL_ACCESS_DENIED: NTSTATUS = -1_070_137_302_i32; +pub const STATUS_VIRTDISK_DISK_ALREADY_OWNED: NTSTATUS = -1_069_940_706_i32; +pub const STATUS_VIRTDISK_DISK_ONLINE_AND_WRITABLE: NTSTATUS = -1_069_940_705_i32; +pub const STATUS_VIRTDISK_NOT_VIRTUAL_DISK: NTSTATUS = -1_069_940_715_i32; +pub const STATUS_VIRTDISK_PROVIDER_NOT_FOUND: NTSTATUS = -1_069_940_716_i32; +pub const STATUS_VIRTDISK_UNSUPPORTED_DISK_SECTOR_SIZE: NTSTATUS = -1_069_940_707_i32; +pub const STATUS_VIRTUAL_CIRCUIT_CLOSED: NTSTATUS = -1_073_741_610_i32; +pub const STATUS_VIRTUAL_DISK_LIMITATION: NTSTATUS = -1_069_940_710_i32; +pub const STATUS_VIRUS_DELETED: NTSTATUS = -1_073_739_513_i32; +pub const STATUS_VIRUS_INFECTED: NTSTATUS = -1_073_739_514_i32; +pub const STATUS_VOLMGR_ALL_DISKS_FAILED: NTSTATUS = -1_070_071_767_i32; +pub const STATUS_VOLMGR_BAD_BOOT_DISK: NTSTATUS = -1_070_071_729_i32; +pub const STATUS_VOLMGR_DATABASE_FULL: NTSTATUS = -1_070_071_807_i32; +pub const STATUS_VOLMGR_DIFFERENT_SECTOR_SIZE: NTSTATUS = -1_070_071_730_i32; +pub const STATUS_VOLMGR_DISK_CONFIGURATION_CORRUPTED: NTSTATUS = -1_070_071_806_i32; +pub const STATUS_VOLMGR_DISK_CONFIGURATION_NOT_IN_SYNC: NTSTATUS = -1_070_071_805_i32; +pub const STATUS_VOLMGR_DISK_CONTAINS_NON_SIMPLE_VOLUME: NTSTATUS = -1_070_071_803_i32; +pub const STATUS_VOLMGR_DISK_DUPLICATE: NTSTATUS = -1_070_071_802_i32; +pub const STATUS_VOLMGR_DISK_DYNAMIC: NTSTATUS = -1_070_071_801_i32; +pub const STATUS_VOLMGR_DISK_ID_INVALID: NTSTATUS = -1_070_071_800_i32; +pub const STATUS_VOLMGR_DISK_INVALID: NTSTATUS = -1_070_071_799_i32; +pub const STATUS_VOLMGR_DISK_LAST_VOTER: NTSTATUS = -1_070_071_798_i32; +pub const STATUS_VOLMGR_DISK_LAYOUT_INVALID: NTSTATUS = -1_070_071_797_i32; +pub const STATUS_VOLMGR_DISK_LAYOUT_NON_BASIC_BETWEEN_BASIC_PARTITIONS: NTSTATUS = + -1_070_071_796_i32; +pub const STATUS_VOLMGR_DISK_LAYOUT_NOT_CYLINDER_ALIGNED: NTSTATUS = -1_070_071_795_i32; +pub const STATUS_VOLMGR_DISK_LAYOUT_PARTITIONS_TOO_SMALL: NTSTATUS = -1_070_071_794_i32; +pub const STATUS_VOLMGR_DISK_LAYOUT_PRIMARY_BETWEEN_LOGICAL_PARTITIONS: NTSTATUS = + -1_070_071_793_i32; +pub const STATUS_VOLMGR_DISK_LAYOUT_TOO_MANY_PARTITIONS: NTSTATUS = -1_070_071_792_i32; +pub const STATUS_VOLMGR_DISK_MISSING: NTSTATUS = -1_070_071_791_i32; +pub const STATUS_VOLMGR_DISK_NOT_EMPTY: NTSTATUS = -1_070_071_790_i32; +pub const STATUS_VOLMGR_DISK_NOT_ENOUGH_SPACE: NTSTATUS = -1_070_071_789_i32; +pub const STATUS_VOLMGR_DISK_REVECTORING_FAILED: NTSTATUS = -1_070_071_788_i32; +pub const STATUS_VOLMGR_DISK_SECTOR_SIZE_INVALID: NTSTATUS = -1_070_071_787_i32; +pub const STATUS_VOLMGR_DISK_SET_NOT_CONTAINED: NTSTATUS = -1_070_071_786_i32; +pub const STATUS_VOLMGR_DISK_USED_BY_MULTIPLE_MEMBERS: NTSTATUS = -1_070_071_785_i32; +pub const STATUS_VOLMGR_DISK_USED_BY_MULTIPLE_PLEXES: NTSTATUS = -1_070_071_784_i32; +pub const STATUS_VOLMGR_DYNAMIC_DISK_NOT_SUPPORTED: NTSTATUS = -1_070_071_783_i32; +pub const STATUS_VOLMGR_EXTENT_ALREADY_USED: NTSTATUS = -1_070_071_782_i32; +pub const STATUS_VOLMGR_EXTENT_NOT_CONTIGUOUS: NTSTATUS = -1_070_071_781_i32; +pub const STATUS_VOLMGR_EXTENT_NOT_IN_PUBLIC_REGION: NTSTATUS = -1_070_071_780_i32; +pub const STATUS_VOLMGR_EXTENT_NOT_SECTOR_ALIGNED: NTSTATUS = -1_070_071_779_i32; +pub const STATUS_VOLMGR_EXTENT_OVERLAPS_EBR_PARTITION: NTSTATUS = -1_070_071_778_i32; +pub const STATUS_VOLMGR_EXTENT_VOLUME_LENGTHS_DO_NOT_MATCH: NTSTATUS = -1_070_071_777_i32; +pub const STATUS_VOLMGR_FAULT_TOLERANT_NOT_SUPPORTED: NTSTATUS = -1_070_071_776_i32; +pub const STATUS_VOLMGR_INCOMPLETE_DISK_MIGRATION: NTSTATUS = -2_143_813_630_i32; +pub const STATUS_VOLMGR_INCOMPLETE_REGENERATION: NTSTATUS = -2_143_813_631_i32; +pub const STATUS_VOLMGR_INTERLEAVE_LENGTH_INVALID: NTSTATUS = -1_070_071_775_i32; +pub const STATUS_VOLMGR_MAXIMUM_REGISTERED_USERS: NTSTATUS = -1_070_071_774_i32; +pub const STATUS_VOLMGR_MEMBER_INDEX_DUPLICATE: NTSTATUS = -1_070_071_772_i32; +pub const STATUS_VOLMGR_MEMBER_INDEX_INVALID: NTSTATUS = -1_070_071_771_i32; +pub const STATUS_VOLMGR_MEMBER_IN_SYNC: NTSTATUS = -1_070_071_773_i32; +pub const STATUS_VOLMGR_MEMBER_MISSING: NTSTATUS = -1_070_071_770_i32; +pub const STATUS_VOLMGR_MEMBER_NOT_DETACHED: NTSTATUS = -1_070_071_769_i32; +pub const STATUS_VOLMGR_MEMBER_REGENERATING: NTSTATUS = -1_070_071_768_i32; +pub const STATUS_VOLMGR_MIRROR_NOT_SUPPORTED: NTSTATUS = -1_070_071_717_i32; +pub const STATUS_VOLMGR_NOTIFICATION_RESET: NTSTATUS = -1_070_071_764_i32; +pub const STATUS_VOLMGR_NOT_PRIMARY_PACK: NTSTATUS = -1_070_071_726_i32; +pub const STATUS_VOLMGR_NO_REGISTERED_USERS: NTSTATUS = -1_070_071_766_i32; +pub const STATUS_VOLMGR_NO_SUCH_USER: NTSTATUS = -1_070_071_765_i32; +pub const STATUS_VOLMGR_NO_VALID_LOG_COPIES: NTSTATUS = -1_070_071_720_i32; +pub const STATUS_VOLMGR_NUMBER_OF_DISKS_INVALID: NTSTATUS = -1_070_071_718_i32; +pub const STATUS_VOLMGR_NUMBER_OF_DISKS_IN_MEMBER_INVALID: NTSTATUS = -1_070_071_723_i32; +pub const STATUS_VOLMGR_NUMBER_OF_DISKS_IN_PLEX_INVALID: NTSTATUS = -1_070_071_724_i32; +pub const STATUS_VOLMGR_NUMBER_OF_EXTENTS_INVALID: NTSTATUS = -1_070_071_731_i32; +pub const STATUS_VOLMGR_NUMBER_OF_MEMBERS_INVALID: NTSTATUS = -1_070_071_763_i32; +pub const STATUS_VOLMGR_NUMBER_OF_PLEXES_INVALID: NTSTATUS = -1_070_071_762_i32; +pub const STATUS_VOLMGR_PACK_CONFIG_OFFLINE: NTSTATUS = -1_070_071_728_i32; +pub const STATUS_VOLMGR_PACK_CONFIG_ONLINE: NTSTATUS = -1_070_071_727_i32; +pub const STATUS_VOLMGR_PACK_CONFIG_UPDATE_FAILED: NTSTATUS = -1_070_071_804_i32; +pub const STATUS_VOLMGR_PACK_DUPLICATE: NTSTATUS = -1_070_071_761_i32; +pub const STATUS_VOLMGR_PACK_HAS_QUORUM: NTSTATUS = -1_070_071_756_i32; +pub const STATUS_VOLMGR_PACK_ID_INVALID: NTSTATUS = -1_070_071_760_i32; +pub const STATUS_VOLMGR_PACK_INVALID: NTSTATUS = -1_070_071_759_i32; +pub const STATUS_VOLMGR_PACK_LOG_UPDATE_FAILED: NTSTATUS = -1_070_071_725_i32; +pub const STATUS_VOLMGR_PACK_NAME_INVALID: NTSTATUS = -1_070_071_758_i32; +pub const STATUS_VOLMGR_PACK_OFFLINE: NTSTATUS = -1_070_071_757_i32; +pub const STATUS_VOLMGR_PACK_WITHOUT_QUORUM: NTSTATUS = -1_070_071_755_i32; +pub const STATUS_VOLMGR_PARTITION_STYLE_INVALID: NTSTATUS = -1_070_071_754_i32; +pub const STATUS_VOLMGR_PARTITION_UPDATE_FAILED: NTSTATUS = -1_070_071_753_i32; +pub const STATUS_VOLMGR_PLEX_INDEX_DUPLICATE: NTSTATUS = -1_070_071_751_i32; +pub const STATUS_VOLMGR_PLEX_INDEX_INVALID: NTSTATUS = -1_070_071_750_i32; +pub const STATUS_VOLMGR_PLEX_IN_SYNC: NTSTATUS = -1_070_071_752_i32; +pub const STATUS_VOLMGR_PLEX_LAST_ACTIVE: NTSTATUS = -1_070_071_749_i32; +pub const STATUS_VOLMGR_PLEX_MISSING: NTSTATUS = -1_070_071_748_i32; +pub const STATUS_VOLMGR_PLEX_NOT_RAID5: NTSTATUS = -1_070_071_745_i32; +pub const STATUS_VOLMGR_PLEX_NOT_SIMPLE: NTSTATUS = -1_070_071_744_i32; +pub const STATUS_VOLMGR_PLEX_NOT_SIMPLE_SPANNED: NTSTATUS = -1_070_071_721_i32; +pub const STATUS_VOLMGR_PLEX_REGENERATING: NTSTATUS = -1_070_071_747_i32; +pub const STATUS_VOLMGR_PLEX_TYPE_INVALID: NTSTATUS = -1_070_071_746_i32; +pub const STATUS_VOLMGR_PRIMARY_PACK_PRESENT: NTSTATUS = -1_070_071_719_i32; +pub const STATUS_VOLMGR_RAID5_NOT_SUPPORTED: NTSTATUS = -1_070_071_716_i32; +pub const STATUS_VOLMGR_STRUCTURE_SIZE_INVALID: NTSTATUS = -1_070_071_743_i32; +pub const STATUS_VOLMGR_TOO_MANY_NOTIFICATION_REQUESTS: NTSTATUS = -1_070_071_742_i32; +pub const STATUS_VOLMGR_TRANSACTION_IN_PROGRESS: NTSTATUS = -1_070_071_741_i32; +pub const STATUS_VOLMGR_UNEXPECTED_DISK_LAYOUT_CHANGE: NTSTATUS = -1_070_071_740_i32; +pub const STATUS_VOLMGR_VOLUME_CONTAINS_MISSING_DISK: NTSTATUS = -1_070_071_739_i32; +pub const STATUS_VOLMGR_VOLUME_ID_INVALID: NTSTATUS = -1_070_071_738_i32; +pub const STATUS_VOLMGR_VOLUME_LENGTH_INVALID: NTSTATUS = -1_070_071_737_i32; +pub const STATUS_VOLMGR_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE: NTSTATUS = -1_070_071_736_i32; +pub const STATUS_VOLMGR_VOLUME_MIRRORED: NTSTATUS = -1_070_071_722_i32; +pub const STATUS_VOLMGR_VOLUME_NOT_MIRRORED: NTSTATUS = -1_070_071_735_i32; +pub const STATUS_VOLMGR_VOLUME_NOT_RETAINED: NTSTATUS = -1_070_071_734_i32; +pub const STATUS_VOLMGR_VOLUME_OFFLINE: NTSTATUS = -1_070_071_733_i32; +pub const STATUS_VOLMGR_VOLUME_RETAINED: NTSTATUS = -1_070_071_732_i32; +pub const STATUS_VOLSNAP_ACTIVATION_TIMEOUT: NTSTATUS = -1_068_498_940_i32; +pub const STATUS_VOLSNAP_BOOTFILE_NOT_VALID: NTSTATUS = -1_068_498_941_i32; +pub const STATUS_VOLSNAP_HIBERNATE_READY: NTSTATUS = 293_i32; +pub const STATUS_VOLSNAP_NO_BYPASSIO_WITH_SNAPSHOT: NTSTATUS = -1_068_498_939_i32; +pub const STATUS_VOLSNAP_PREPARE_HIBERNATE: NTSTATUS = -1_073_740_793_i32; +pub const STATUS_VOLUME_DIRTY: NTSTATUS = -1_073_739_770_i32; +pub const STATUS_VOLUME_DISMOUNTED: NTSTATUS = -1_073_741_202_i32; +pub const STATUS_VOLUME_MOUNTED: NTSTATUS = 265_i32; +pub const STATUS_VOLUME_NOT_CLUSTER_ALIGNED: NTSTATUS = -1_073_740_636_i32; +pub const STATUS_VOLUME_NOT_SUPPORTED: NTSTATUS = -1_073_740_602_i32; +pub const STATUS_VOLUME_NOT_UPGRADED: NTSTATUS = -1_073_741_156_i32; +pub const STATUS_VOLUME_WRITE_ACCESS_DENIED: NTSTATUS = -1_073_740_589_i32; +pub const STATUS_VRF_VOLATILE_CFG_AND_IO_ENABLED: NTSTATUS = -1_073_738_744_i32; +pub const STATUS_VRF_VOLATILE_NMI_REGISTERED: NTSTATUS = -1_073_738_738_i32; +pub const STATUS_VRF_VOLATILE_NOT_RUNNABLE_SYSTEM: NTSTATUS = -1_073_738_741_i32; +pub const STATUS_VRF_VOLATILE_NOT_STOPPABLE: NTSTATUS = -1_073_738_743_i32; +pub const STATUS_VRF_VOLATILE_NOT_SUPPORTED_RULECLASS: NTSTATUS = -1_073_738_740_i32; +pub const STATUS_VRF_VOLATILE_PROTECTED_DRIVER: NTSTATUS = -1_073_738_739_i32; +pub const STATUS_VRF_VOLATILE_SAFE_MODE: NTSTATUS = -1_073_738_742_i32; +pub const STATUS_VRF_VOLATILE_SETTINGS_CONFLICT: NTSTATUS = -1_073_738_737_i32; +pub const STATUS_VSM_DMA_PROTECTION_NOT_IN_USE: NTSTATUS = -1_069_219_839_i32; +pub const STATUS_VSM_NOT_INITIALIZED: NTSTATUS = -1_069_219_840_i32; +pub const STATUS_WAIT_0: NTSTATUS = 0_i32; +pub const STATUS_WAIT_1: NTSTATUS = 1_i32; +pub const STATUS_WAIT_2: NTSTATUS = 2_i32; +pub const STATUS_WAIT_3: NTSTATUS = 3_i32; +pub const STATUS_WAIT_63: NTSTATUS = 63_i32; +pub const STATUS_WAIT_FOR_OPLOCK: NTSTATUS = 871_i32; +pub const STATUS_WAKE_SYSTEM: NTSTATUS = 1_073_742_484_i32; +pub const STATUS_WAKE_SYSTEM_DEBUGGER: NTSTATUS = -2_147_483_641_i32; +pub const STATUS_WAS_LOCKED: NTSTATUS = 1_073_741_849_i32; +pub const STATUS_WAS_UNLOCKED: NTSTATUS = 1_073_741_847_i32; +pub const STATUS_WEAK_WHFBKEY_BLOCKED: NTSTATUS = -1_073_741_389_i32; +pub const STATUS_WIM_NOT_BOOTABLE: NTSTATUS = -1_073_740_665_i32; +pub const STATUS_WMI_ALREADY_DISABLED: NTSTATUS = -1_073_741_054_i32; +pub const STATUS_WMI_ALREADY_ENABLED: NTSTATUS = -1_073_741_053_i32; +pub const STATUS_WMI_GUID_DISCONNECTED: NTSTATUS = -1_073_741_055_i32; +pub const STATUS_WMI_GUID_NOT_FOUND: NTSTATUS = -1_073_741_163_i32; +pub const STATUS_WMI_INSTANCE_NOT_FOUND: NTSTATUS = -1_073_741_162_i32; +pub const STATUS_WMI_ITEMID_NOT_FOUND: NTSTATUS = -1_073_741_161_i32; +pub const STATUS_WMI_NOT_SUPPORTED: NTSTATUS = -1_073_741_091_i32; +pub const STATUS_WMI_READ_ONLY: NTSTATUS = -1_073_741_114_i32; +pub const STATUS_WMI_SET_FAILURE: NTSTATUS = -1_073_741_113_i32; +pub const STATUS_WMI_TRY_AGAIN: NTSTATUS = -1_073_741_160_i32; +pub const STATUS_WOF_FILE_RESOURCE_TABLE_CORRUPT: NTSTATUS = -1_073_700_185_i32; +pub const STATUS_WOF_WIM_HEADER_CORRUPT: NTSTATUS = -1_073_700_187_i32; +pub const STATUS_WOF_WIM_RESOURCE_TABLE_CORRUPT: NTSTATUS = -1_073_700_186_i32; +pub const STATUS_WORKING_SET_LIMIT_RANGE: NTSTATUS = 1_073_741_826_i32; +pub const STATUS_WORKING_SET_QUOTA: NTSTATUS = -1_073_741_663_i32; +pub const STATUS_WOW_ASSERTION: NTSTATUS = -1_073_702_760_i32; +pub const STATUS_WRONG_COMPARTMENT: NTSTATUS = -1_073_700_731_i32; +pub const STATUS_WRONG_CREDENTIAL_HANDLE: NTSTATUS = -1_073_741_070_i32; +pub const STATUS_WRONG_EFS: NTSTATUS = -1_073_741_169_i32; +pub const STATUS_WRONG_PASSWORD_CORE: NTSTATUS = -1_073_741_495_i32; +pub const STATUS_WRONG_VOLUME: NTSTATUS = -1_073_741_806_i32; +pub const STATUS_WX86_BREAKPOINT: NTSTATUS = 1_073_741_855_i32; +pub const STATUS_WX86_CONTINUE: NTSTATUS = 1_073_741_853_i32; +pub const STATUS_WX86_CREATEWX86TIB: NTSTATUS = 1_073_741_864_i32; +pub const STATUS_WX86_EXCEPTION_CHAIN: NTSTATUS = 1_073_741_858_i32; +pub const STATUS_WX86_EXCEPTION_CONTINUE: NTSTATUS = 1_073_741_856_i32; +pub const STATUS_WX86_EXCEPTION_LASTCHANCE: NTSTATUS = 1_073_741_857_i32; +pub const STATUS_WX86_FLOAT_STACK_CHECK: NTSTATUS = -1_073_741_200_i32; +pub const STATUS_WX86_INTERNAL_ERROR: NTSTATUS = -1_073_741_201_i32; +pub const STATUS_WX86_SINGLE_STEP: NTSTATUS = 1_073_741_854_i32; +pub const STATUS_WX86_UNSIMULATE: NTSTATUS = 1_073_741_852_i32; +pub const STATUS_XMLDSIG_ERROR: NTSTATUS = -1_073_700_732_i32; +pub const STATUS_XML_ENCODING_MISMATCH: NTSTATUS = -1_072_365_535_i32; +pub const STATUS_XML_PARSE_ERROR: NTSTATUS = -1_073_700_733_i32; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/gpio.rs b/packaging/windows/drivers/vendor/wdk-sys/src/gpio.rs new file mode 100644 index 0000000..742b59a --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/gpio.rs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to GPIO APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in the following headers: `gpio.h`, +//! `gpioclx.h`. Types are not included in this module, but are available in the +//! top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + #[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to GPIO that can \ + be generated by bindgen, so these types are unused" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/gpio.rs")); +} +#[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to GPIO that can be \ + generated by bindgen, so the `bindings` module is empty" +)] +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/hid.rs b/packaging/windows/drivers/vendor/wdk-sys/src/hid.rs new file mode 100644 index 0000000..05c8977 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/hid.rs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to HID APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in the following headers: `hidpddi.h`, +//! `hidport.h`, `HidSpiCx/1.0/hidspicx.h`, `kbdmou.h`, `ntdd8042.h`, +//! `hidclass.h`, `hidsdi.h`, `hidpi.h`, `vhf.h`. Types are not included in this +//! module, but are available in the top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/hid.rs")); +} +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/iddcx.rs b/packaging/windows/drivers/vendor/wdk-sys/src/iddcx.rs new file mode 100644 index 0000000..d7e6781 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/iddcx.rs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to IddCx APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in the following headers: `iddcx/1.10/IddCx.h`. Types are not included in this module, but are available in the +//! top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + #[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to IddCx that can \ + be generated by bindgen, so these types are unused" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/iddcx.rs")); +} +#[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to IddCx that can be \ + generated by bindgen, so the `bindings` module is empty" +)] +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/lib.rs b/packaging/windows/drivers/vendor/wdk-sys/src/lib.rs new file mode 100644 index 0000000..3f8f7ab --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/lib.rs @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct bindings to APIs available in the Windows Development Kit (WDK) + +#![no_std] + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +#[doc(hidden)] +pub use wdk_macros as __proc_macros; + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +pub use crate::{constants::*, types::*}; + +#[cfg(any(driver_model__driver_type = "WDM", driver_model__driver_type = "KMDF"))] +pub mod ntddk; + +#[cfg(driver_model__driver_type = "UMDF")] +pub mod windows; + +#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] +pub mod wdf; + +#[cfg(all( + any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" + ), + feature = "gpio" +))] +pub mod gpio; + +#[cfg(all( + any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" + ), + feature = "hid" +))] +pub mod hid; + +#[cfg(all( + any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" + ), + feature = "parallel-ports" +))] +pub mod parallel_ports; + +#[cfg(all( + any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" + ), + feature = "spb" +))] +pub mod spb; + +#[cfg(all( + any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" + ), + feature = "storage" +))] +pub mod storage; + +#[cfg(all( + any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" + ), + feature = "usb" +))] +pub mod usb; + +#[cfg(all(driver_model__driver_type = "UMDF", feature = "iddcx"))] +pub mod iddcx; + +#[cfg(feature = "test-stubs")] +pub mod test_stubs; + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +mod constants; +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +mod types; + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +mod macros; + +// This is fine because we don't actually have any floating point instruction in +// our binary, thanks to our target defining soft-floats. fltused symbol is +// necessary due to LLVM being too eager to set it: it checks the LLVM IR for +// floating point instructions - even if soft-float is enabled! +#[allow(missing_docs)] +// SAFETY: _fltused is a required Windows linker symbol for floating point support. +// No other symbols in this crate export this name, preventing linker conflicts. +#[unsafe(no_mangle)] +pub static _fltused: () = (); + +// FIXME: Is there any way to avoid these stubs? See https://github.com/rust-lang/rust/issues/101134 +#[cfg(panic = "abort")] +#[allow(missing_docs)] +// SAFETY: __CxxFrameHandler3 is a required Windows C++ exception handler symbol. +// No other symbols in this crate export this name, preventing linker conflicts. +#[unsafe(no_mangle)] +pub const extern "system" fn __CxxFrameHandler3() -> i32 { + 0 +} + +#[cfg(panic = "abort")] +#[allow(missing_docs)] +// SAFETY: __CxxFrameHandler4 is a required Windows C++ exception handler symbol. +// No other symbols in this crate export this name, preventing linker conflicts. +#[unsafe(no_mangle)] +pub const extern "system" fn __CxxFrameHandler4() -> i32 { + // This is a stub for the C++ exception handling frame handler. It's never + // called but it needs to be distinct from __CxxFrameHandler3 to not confuse + // binary analysis tools. We return a different value to prevent folding. + 1 +} + +#[cfg(panic = "abort")] +#[allow(missing_docs)] +// SAFETY: __GSHandlerCheck_EH4 is a required Windows C++ exception handler symbol. +// No other symbols in this crate export this name, preventing linker conflicts. +#[unsafe(no_mangle)] +pub const extern "system" fn __GSHandlerCheck_EH4() -> i32 { + // This is a stub for the C++ exception handling frame handler. It's never + // called but it needs to be distinct from __CxxFrameHandler3 and + // __CxxFrameHandler4 to not confuse binary analysis tools. We return a + // different value to prevent folding. + 2 +} + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +#[must_use] +#[allow(non_snake_case)] +/// Evaluates to TRUE if the return value specified by `nt_status` is a success +/// type (0 − 0x3FFFFFFF) or an informational type (0x40000000 − 0x7FFFFFFF). +/// This function is taken from ntdef.h in the WDK. +/// +/// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and +/// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. +pub const fn NT_SUCCESS(nt_status: NTSTATUS) -> bool { + nt_status >= 0 +} + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +#[must_use] +#[allow(non_snake_case)] +#[allow(clippy::cast_sign_loss)] +/// Evaluates to TRUE if the return value specified by `nt_status` is an +/// informational type (0x40000000 − 0x7FFFFFFF). This function is taken from +/// ntdef.h in the WDK. +/// +/// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and +/// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. +pub const fn NT_INFORMATION(nt_status: NTSTATUS) -> bool { + (nt_status as u32 >> 30) == 1 +} + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +#[must_use] +#[allow(non_snake_case)] +#[allow(clippy::cast_sign_loss)] +/// Evaluates to TRUE if the return value specified by `nt_status` is a warning +/// type (0x80000000 − 0xBFFFFFFF). This function is taken from ntdef.h in the +/// WDK. +/// +/// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and +/// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. +pub const fn NT_WARNING(nt_status: NTSTATUS) -> bool { + (nt_status as u32 >> 30) == 2 +} + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +#[must_use] +#[allow(non_snake_case)] +#[allow(clippy::cast_sign_loss)] +/// Evaluates to TRUE if the return value specified by `nt_status` is an error +/// type (0xC0000000 - 0xFFFFFFFF). This function is taken from ntdef.h in the +/// WDK. +/// +/// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and +/// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. +pub const fn NT_ERROR(nt_status: NTSTATUS) -> bool { + (nt_status as u32 >> 30) == 3 +} + +#[cfg(any(driver_model__driver_type = "WDM", driver_model__driver_type = "KMDF"))] +#[allow(missing_docs)] +#[macro_export] +#[allow(non_snake_case)] +macro_rules! PAGED_CODE { + () => { + debug_assert!(unsafe { $crate::ntddk::KeGetCurrentIrql() <= $crate::APC_LEVEL as u8 }); + }; +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/macros.rs b/packaging/windows/drivers/vendor/wdk-sys/src/macros.rs new file mode 100644 index 0000000..ed3ec97 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/macros.rs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Macros for use in the `wdk-sys` crate. This is especially useful for +//! interacting with WDK apis which are inlined, and so are impossible to +//! generate with [bindgen](https://docs.rs/bindgen/latest/bindgen/). + +#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] +mod wdf { + include!(concat!( + env!("OUT_DIR"), + "/call_unsafe_wdf_function_binding.rs" + )); +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/ntddk.rs b/packaging/windows/drivers/vendor/wdk-sys/src/ntddk.rs new file mode 100644 index 0000000..f1e24b6 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/ntddk.rs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to NTDDK APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in `ntddk.h`. Types are not included in this +//! module, but are available in the top-level `wdk_sys` module. + +pub use bindings::*; + +#[allow(missing_docs)] +#[allow(clippy::derive_partial_eq_without_eq)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/ntddk.rs")); +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/parallel_ports.rs b/packaging/windows/drivers/vendor/wdk-sys/src/parallel_ports.rs new file mode 100644 index 0000000..89a92f3 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/parallel_ports.rs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to Parallel Ports APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in the following headers: `ntddpar.h`, +//! `ntddser.h`, `parallel.h`. Types are not included in this module, but are +//! available in the top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + #[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to SPB that can \ + be generated by bindgen, so these types are unused" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/parallel_ports.rs")); +} +#[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to SPB that can be \ + generated by bindgen, so the `bindings` module is empty" +)] +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/spb.rs b/packaging/windows/drivers/vendor/wdk-sys/src/spb.rs new file mode 100644 index 0000000..f2b81ce --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/spb.rs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to SPB APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in the following headers: `spb.h`, `spbcx.h`, +//! `reshub.h`, `pwmutil.h`. Types are not included in this module, but are +//! available in the top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + #[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to SPB that can \ + be generated by bindgen, so these types are unused" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/spb.rs")); +} +#[allow( + unused_imports, + reason = "in certain versions of the WDK, there are no functions related to SPB that can be \ + generated by bindgen, so the `bindings` module is empty" +)] +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/storage.rs b/packaging/windows/drivers/vendor/wdk-sys/src/storage.rs new file mode 100644 index 0000000..e759e40 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/storage.rs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to Storage APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors for Storage headers. Types are not included in +//! this module, but are available in the top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + #[allow( + unused_imports, + reason = "in certain configurations of the WDK (ex. UMDF), there are no functions related \ + to Storage that can be generated by bindgen, so these types are unused" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/storage.rs")); +} +#[allow( + unused_imports, + reason = "in certain configurations of the WDK (ex. UMDF), there are no functions related to \ + Storage that can be generated by bindgen, so the `bindings` module is empty" +)] +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/test_stubs.rs b/packaging/windows/drivers/vendor/wdk-sys/src/test_stubs.rs new file mode 100644 index 0000000..e917718 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/test_stubs.rs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Any library dependency that depends on `wdk-sys` requires these stubs to +//! provide symbols to successfully compile and run tests. +//! +//! These stubs can be brought into scope by introducing `wdk-sys` with the +//! `test-stubs` feature in the `dev-dependencies` of the crate's `Cargo.toml` + +#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] +pub use wdf::*; + +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +use crate::{DRIVER_OBJECT, NTSTATUS, PCUNICODE_STRING}; + +/// Stubbed version of `DriverEntry` Symbol so that test targets will compile +/// +/// # Safety +/// +/// This function should never be called, so its safety is irrelevant +#[cfg(any( + driver_model__driver_type = "WDM", + driver_model__driver_type = "KMDF", + driver_model__driver_type = "UMDF" +))] +// SAFETY: "DriverEntry" is the required symbol name for Windows driver entry points. +// No other function in this compilation unit exports this name, preventing symbol conflicts. +#[unsafe(export_name = "DriverEntry")] // WDF expects a symbol with the name DriverEntry +pub const unsafe extern "system" fn driver_entry_stub( + _driver: &mut DRIVER_OBJECT, + _registry_path: PCUNICODE_STRING, +) -> NTSTATUS { + 0 +} + +#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] +mod wdf { + use crate::ULONG; + + /// Stubbed version of `WdfFunctionCount` Symbol so that test targets will + /// compile + // SAFETY: WdfFunctionCount is a required WDF symbol for test compilation. + // No other symbols in this crate export this name, preventing linker conflicts. + #[unsafe(no_mangle)] + pub static mut WdfFunctionCount: ULONG = 0; + + include!(concat!(env!("OUT_DIR"), "/test_stubs.rs")); +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/types.rs b/packaging/windows/drivers/vendor/wdk-sys/src/types.rs new file mode 100644 index 0000000..cf50178 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/types.rs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +pub use bindings::*; + +#[allow(missing_docs)] +#[allow(non_upper_case_globals)] +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[rustversion::attr( + any( + all(not(nightly), since(1.88)), + all(nightly, since(2025-04-25)), + ), + allow(unnecessary_transmutes) +)] +#[allow(unsafe_op_in_unsafe_fn)] +#[allow(clippy::cast_lossless)] +#[allow(clippy::cast_possible_truncation)] +#[allow(clippy::cast_possible_wrap)] +#[allow(clippy::cognitive_complexity)] +#[allow(clippy::doc_markdown)] +#[allow(clippy::default_trait_access)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[rustversion::attr( + any( + all(not(nightly), before(1.74)), + all(nightly, before(2023-09-13)), + ), + allow(clippy::incorrect_clone_impl_on_copy_type) +)] +#[rustversion::attr( + any( + all(not(nightly), since(1.74)), + all(nightly, since(2023-09-13)), + ), + allow(clippy::non_canonical_clone_impl) +)] +#[allow(clippy::missing_const_for_fn)] +#[allow(clippy::missing_safety_doc)] +#[allow(clippy::module_name_repetitions)] +#[allow(clippy::multiple_unsafe_ops_per_block)] +#[allow(clippy::must_use_candidate)] +#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[allow(clippy::ptr_as_ptr)] +#[allow(clippy::ptr_offset_with_cast)] +#[rustversion::attr( + any( + all(not(nightly), since(1.77)), + all(nightly, since(2024-01-11)), + ), + allow(clippy::pub_underscore_fields) +)] +#[rustversion::attr( + any( + all(not(nightly), since(1.78)), + all(nightly, since(2024-02-09)), + ), + allow(clippy::ref_as_ptr) +)] +#[allow(clippy::semicolon_if_nothing_returned)] +#[allow(clippy::too_many_arguments)] +#[allow(clippy::too_many_lines)] +#[allow(clippy::transmute_ptr_to_ptr)] +#[allow(clippy::undocumented_unsafe_blocks)] +#[allow(clippy::unnecessary_cast)] +#[allow(clippy::unreadable_literal)] +#[allow(clippy::used_underscore_binding)] +#[allow(clippy::useless_transmute)] +#[allow(clippy::use_self)] +mod bindings { + include!(concat!(env!("OUT_DIR"), "/types.rs")); +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/usb.rs b/packaging/windows/drivers/vendor/wdk-sys/src/usb.rs new file mode 100644 index 0000000..6c2a992 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/usb.rs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to USB APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors for USB headers. Types are not included in this +//! module, but are available in the top-level `wdk_sys` module. + +#[allow( + missing_docs, + reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to \ + generate documentation for their bindings" +)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/usb.rs")); +} +pub use bindings::*; diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/wdf.rs b/packaging/windows/drivers/vendor/wdk-sys/src/wdf.rs new file mode 100644 index 0000000..aaab06c --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/wdf.rs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to WDF APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in `wdf.h`. Types are not included in this +//! module, but are available in the top-level `wdk_sys` module. + +pub use bindings::*; + +#[allow(missing_docs)] +#[allow(clippy::unreadable_literal)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/wdf.rs")); +} + +// This is a workaround to expose the generated function count to the +// `call_unsafe_wdf_function_binding` proc-macro, so that the macro-generated +// code can determine the slice size at runtime. When we are able to +// conditionally compile based off a cfg range for WDF version, this module +// can be removed and the runtime check can be replaced with a conditional +// compilation: https://github.com/microsoft/windows-drivers-rs/issues/276 +#[doc(hidden)] +pub mod __private { + include!(concat!(env!("OUT_DIR"), "/wdf_function_count.rs")); +} diff --git a/packaging/windows/drivers/vendor/wdk-sys/src/windows.rs b/packaging/windows/drivers/vendor/wdk-sys/src/windows.rs new file mode 100644 index 0000000..d57c4c7 --- /dev/null +++ b/packaging/windows/drivers/vendor/wdk-sys/src/windows.rs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 + +//! Direct FFI bindings to WIN32 APIs from the Windows Driver Kit (WDK) +//! +//! This module contains all bindings to functions, constants, methods, +//! constructors and destructors in `windows.h`. Types are not included in this +//! module, but are available in the top-level `wdk_sys` module. + +pub use bindings::*; + +#[allow(missing_docs)] +mod bindings { + #[allow( + clippy::wildcard_imports, + reason = "the underlying c code relies on all type definitions being in scope, which \ + results in the bindgen generated code relying on the generated types being in \ + scope as well" + )] + use crate::types::*; + + include!(concat!(env!("OUT_DIR"), "/windows.rs")); +} diff --git a/packaging/windows/drivers/wdk-probe/Cargo.toml b/packaging/windows/drivers/wdk-probe/Cargo.toml index 2dbfecf..ac69e60 100644 --- a/packaging/windows/drivers/wdk-probe/Cargo.toml +++ b/packaging/windows/drivers/wdk-probe/Cargo.toml @@ -22,5 +22,8 @@ wdk-build.workspace = true [dependencies] wdk.workspace = true -wdk-sys.workspace = true +# `iddcx` feature → wdk-sys runs the IddCx bindgen pass (generate_iddcx) + compiles `wdk_sys::iddcx`. +# This is the M1 make-or-break: does IddCx.h bindgen in wdk-sys's config without a header conflict, and +# do its WDF/DXGI types resolve to wdk-sys's (so the generated module compiles)? +wdk-sys = { workspace = true, features = ["iddcx"] } pf-vdisplay-proto.workspace = true