diff --git a/Cargo.lock b/Cargo.lock index 7d521a67..74dbc07a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -293,9 +293,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -374,9 +371,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -571,12 +568,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -734,7 +725,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -767,7 +757,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 8254e142..440a11d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,6 @@ cfg-if = "1.0.0" clap = "4.5.9" clap-cargo = "0.14.1" itertools = "0.13.0" -lazy_static = "1.5.0" paste = "1.0.15" pretty_assertions = "1.4.0" proc-macro2 = "1.0.86" diff --git a/crates/wdk-build/Cargo.toml b/crates/wdk-build/Cargo.toml index ad92f32f..922c3266 100644 --- a/crates/wdk-build/Cargo.toml +++ b/crates/wdk-build/Cargo.toml @@ -20,7 +20,6 @@ cargo_metadata.workspace = true cfg-if.workspace = true clap = { workspace = true, features = ["derive"] } clap-cargo.workspace = true -lazy_static.workspace = true paste.workspace = true rustversion.workspace = true serde = { workspace = true, features = ["derive"] } diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs index db2e8aa8..fd91da79 100644 --- a/crates/wdk-build/src/lib.rs +++ b/crates/wdk-build/src/lib.rs @@ -22,7 +22,7 @@ mod utils; mod bindgen; -use std::{env, path::PathBuf}; +use std::{env, path::PathBuf, sync::LazyLock}; use cargo_metadata::MetadataCommand; use serde::{Deserialize, Serialize}; @@ -981,14 +981,11 @@ 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 -lazy_static::lazy_static! { - // FIXME: replace lazy_static with std::Lazy once available: https://github.com/rust-lang/rust/issues/109736 - static ref EXPORTED_CFG_SETTINGS: Vec<(&'static str, Vec<&'static str>)> = - vec![("DRIVER_MODEL-DRIVER_TYPE", vec!["WDM", "KMDF", "UMDF"])]; -} +/// 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"])]); #[cfg(test)] mod tests { diff --git a/crates/wdk-macros/src/lib.rs b/crates/wdk-macros/src/lib.rs index cb0b6d63..710fc2b7 100644 --- a/crates/wdk-macros/src/lib.rs +++ b/crates/wdk-macros/src/lib.rs @@ -229,9 +229,24 @@ impl DerivedASTFragments { // arguments for the WDF function is safe befause WDF maintains the strict mapping between the // function table index and the correct function pointer type. unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + + // SAFETY: This is safe because: + // 1. `WdfFunctions` is valid for reads for `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` * `core::mem::size_of::()` + // bytes, and is guaranteed to be aligned and it must be properly aligned. + // 2. `WdfFunctions` points to `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` consecutive properly initialized values of + // type `WDFFUNC`. + // 3. WDF does not mutate the memory referenced by the returned slice for for its entire `'static' lifetime. + // 4. The total size, `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` * `core::mem::size_of::()`, of the slice must be no + // larger than `isize::MAX`. This is proven by the below `const_assert!`. + + debug_assert!(isize::try_from(wdf_function_count * core::mem::size_of::()).is_ok()); + let wdf_function_table = core::slice::from_raw_parts(wdf_function_table, wdf_function_count); + core::mem::transmute( // FIXME: investigate why _WDFFUNCENUM does not have a generated type alias without the underscore prefix - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::#function_table_index as usize], + wdf_function_table[wdk_sys::_WDFFUNCENUM::#function_table_index as usize], ) } ); diff --git a/crates/wdk-sys/Cargo.toml b/crates/wdk-sys/Cargo.toml index d1de5c29..0a0e1d57 100644 --- a/crates/wdk-sys/Cargo.toml +++ b/crates/wdk-sys/Cargo.toml @@ -21,7 +21,6 @@ anyhow.workspace = true bindgen.workspace = true cargo_metadata.workspace = true cc.workspace = true -lazy_static.workspace = true serde_json.workspace = true thiserror.workspace = true tracing.workspace = true @@ -29,7 +28,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } wdk-build.workspace = true [dependencies] -lazy_static = { workspace = true, features = ["spin_no_std"] } rustversion.workspace = true wdk-macros.workspace = true @@ -72,6 +70,3 @@ missing_crate_level_docs = "warn" private_intra_doc_links = "warn" redundant_explicit_links = "warn" unescaped_backticks = "warn" - -[package.metadata.cargo-machete] -ignored = ["lazy_static"] # lazy_static is used in code generated by build.rs diff --git a/crates/wdk-sys/build.rs b/crates/wdk-sys/build.rs index 37f350f3..4bf45a7c 100644 --- a/crates/wdk-sys/build.rs +++ b/crates/wdk-sys/build.rs @@ -10,12 +10,12 @@ use std::{ env, io::Write, path::{Path, PathBuf}, + sync::LazyLock, thread, }; use anyhow::Context; use bindgen::CodegenConfig; -use lazy_static::lazy_static; use tracing::{info, info_span, Span}; use tracing_subscriber::{ filter::{LevelFilter, ParseError}, @@ -31,51 +31,30 @@ use wdk_build::{ UmdfConfig, }; -const NUM_WDF_FUNCTIONS_PLACEHOLDER: &str = - ""; -const WDF_FUNCTION_COUNT_DECLARATION_PLACEHOLDER: &str = - ""; const OUT_DIR_PLACEHOLDER: &str = ""; const WDFFUNCTIONS_SYMBOL_NAME_PLACEHOLDER: &str = ""; - -const WDF_FUNCTION_COUNT_DECLARATION_EXTERNAL_SYMBOL: &str = " - // SAFETY: `crate::WdfFunctionCount` is generated as a mutable static, but is not supposed \ - to be ever mutated by WDF. - let wdf_function_count = unsafe { crate::WdfFunctionCount } as usize;"; -const WDF_FUNCTION_COUNT_DECLARATION_TABLE_INDEX: &str = " - let wdf_function_count = crate::_WDFFUNCENUM::WdfFunctionTableNumEntries as usize;"; - -// FIXME: replace lazy_static with std::Lazy once available: https://github.com/rust-lang/rust/issues/109736 -lazy_static! { - static ref WDF_FUNCTION_TABLE_TEMPLATE: String = format!( - r#" -// FIXME: replace lazy_static with std::Lazy once available: https://github.com/rust-lang/rust/issues/109736 -#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] -lazy_static::lazy_static! {{ - #[allow(missing_docs)] - pub static ref WDF_FUNCTION_TABLE: &'static [crate::WDFFUNC] = {{ - // SAFETY: `WdfFunctions` is generated as a mutable static, but is not supposed to be ever mutated by WDF. - let wdf_function_table = unsafe {{ crate::WdfFunctions }}; -{WDF_FUNCTION_COUNT_DECLARATION_PLACEHOLDER} - - // SAFETY: This is safe because: - // 1. `WdfFunctions` is valid for reads for `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` * `core::mem::size_of::()` - // bytes, and is guaranteed to be aligned and it must be properly aligned. - // 2. `WdfFunctions` points to `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` consecutive properly initialized values of - // type `WDFFUNC`. - // 3. WDF does not mutate the memory referenced by the returned slice for for its entire `'static' lifetime. - // 4. The total size, `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` * `core::mem::size_of::()`, of the slice must be no - // larger than `isize::MAX`. This is proven by the below `debug_assert!`. - unsafe {{ - debug_assert!(isize::try_from(wdf_function_count * core::mem::size_of::()).is_ok()); - core::slice::from_raw_parts(wdf_function_table, wdf_function_count) - }} - }}; -}}"# - ); - static ref CALL_UNSAFE_WDF_BINDING_TEMPLATE: String = format!( +const WDF_FUNCTION_COUNT_PLACEHOLDER: &str = + " = LazyLock::new(|| { + format!( + r"/// function to access the value of the number of functions in the WDF function table. +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. /// @@ -125,8 +104,11 @@ macro_rules! call_unsafe_wdf_function_binding {{ ) }} }}"# - ); - static ref TEST_STUBS_TEMPLATE: String = format!( + ) +}); + +static TEST_STUBS_TEMPLATE: LazyLock = LazyLock::new(|| { + format!( r" use crate::WDFFUNC; @@ -134,9 +116,8 @@ use crate::WDFFUNC; #[no_mangle] pub static mut {WDFFUNCTIONS_SYMBOL_NAME_PLACEHOLDER}: *const WDFFUNC = core::ptr::null(); ", - ); -} - + ) +}); type GenerateFn = fn(&Path, &Config) -> Result<(), ConfigError>; const BINDGEN_FILE_GENERATORS_TUPLES: &[(&str, GenerateFn)] = &[ @@ -259,15 +240,14 @@ fn generate_wdf(out_path: &Path, config: &Config) -> Result<(), ConfigError> { } } -/// Generates a `wdf_function_table.rs` file in `OUT_DIR` which contains the -/// definition of `WDF_FUNCTION_TABLE`. This is required to be generated here +/// Generates a `wdf_function_count.rs` file in `OUT_DIR` which contains the +/// definition of `WDF_FUNCTION_COUNT`. This is required to be generated here /// since the size of the table is derived from either a global symbol -/// (`WDF_FUNCTION_COUNT`) that newer WDF versions expose, or an enum that older -/// versions use. +/// that newer WDF versions expose, or an enum that older versions use. fn generate_wdf_function_table(out_path: &Path, config: &Config) -> std::io::Result<()> { const MINIMUM_MINOR_VERSION_TO_GENERATE_WDF_FUNCTION_COUNT: u8 = 25; - let generated_file_path = out_path.join("wdf_function_table.rs"); + let generated_file_path = out_path.join("wdf_function_count.rs"); let mut generated_file = std::fs::File::create(generated_file_path)?; let is_wdf_function_count_generated = match *config { @@ -304,26 +284,16 @@ fn generate_wdf_function_table(out_path: &Path, config: &Config) -> std::io::Res } }; - let wdf_function_table_code_snippet = if is_wdf_function_count_generated { - WDF_FUNCTION_TABLE_TEMPLATE - .replace(NUM_WDF_FUNCTIONS_PLACEHOLDER, "crate::WdfFunctionCount") - .replace( - WDF_FUNCTION_COUNT_DECLARATION_PLACEHOLDER, - WDF_FUNCTION_COUNT_DECLARATION_EXTERNAL_SYMBOL, - ) - } else { - WDF_FUNCTION_TABLE_TEMPLATE - .replace( - NUM_WDF_FUNCTIONS_PLACEHOLDER, - "crate::_WDFFUNCENUM::WdfFunctionTableNumEntries", - ) - .replace( - WDF_FUNCTION_COUNT_DECLARATION_PLACEHOLDER, - WDF_FUNCTION_COUNT_DECLARATION_TABLE_INDEX, - ) - }; + 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_code_snippet.as_bytes())?; + generated_file.write_all(wdf_function_table_count_snippet.as_bytes())?; Ok(()) } @@ -427,7 +397,7 @@ fn main() -> anyhow::Result<()> { .expect("Scoped Thread should spawn successfully"), ); - info_span!("wdf_function_table.rs generation").in_scope(|| { + info_span!("wdf_function_count.rs generation").in_scope(|| { generate_wdf_function_table(&out_path, &config)?; Ok::<(), std::io::Error>(()) })?; diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index e6627c2e..6820752a 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -5,8 +5,6 @@ #![no_std] -#[cfg(any(driver_model__driver_type = "KMDF", driver_model__driver_type = "UMDF"))] -pub use wdf::WDF_FUNCTION_TABLE; #[cfg(any( driver_model__driver_type = "WDM", driver_model__driver_type = "KMDF", diff --git a/crates/wdk-sys/src/wdf.rs b/crates/wdk-sys/src/wdf.rs index 28e75fc8..8831611d 100644 --- a/crates/wdk-sys/src/wdf.rs +++ b/crates/wdk-sys/src/wdf.rs @@ -20,4 +20,4 @@ mod bindings { include!(concat!(env!("OUT_DIR"), "/wdf.rs")); } -include!(concat!(env!("OUT_DIR"), "/wdf_function_table.rs")); +include!(concat!(env!("OUT_DIR"), "/wdf_function_count.rs")); diff --git a/examples/sample-kmdf-driver/Cargo.lock b/examples/sample-kmdf-driver/Cargo.lock index 68afe172..2733f0cd 100644 --- a/examples/sample-kmdf-driver/Cargo.lock +++ b/examples/sample-kmdf-driver/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -287,9 +287,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -368,9 +365,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -565,12 +562,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -728,7 +719,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -760,7 +750,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/examples/sample-umdf-driver/Cargo.lock b/examples/sample-umdf-driver/Cargo.lock index d95db0be..e8b0ffad 100644 --- a/examples/sample-umdf-driver/Cargo.lock +++ b/examples/sample-umdf-driver/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -287,9 +287,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -368,9 +365,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -563,12 +560,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -716,7 +707,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -744,7 +734,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/examples/sample-wdm-driver/Cargo.lock b/examples/sample-wdm-driver/Cargo.lock index a79d27fb..8c15ea8f 100644 --- a/examples/sample-wdm-driver/Cargo.lock +++ b/examples/sample-wdm-driver/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -287,9 +287,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -368,9 +365,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -565,12 +562,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -728,7 +719,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -760,7 +750,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/tests/config-kmdf/Cargo.lock b/tests/config-kmdf/Cargo.lock index af8a88c1..fda5d141 100644 --- a/tests/config-kmdf/Cargo.lock +++ b/tests/config-kmdf/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -342,9 +342,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -439,9 +436,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -646,12 +643,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -846,7 +837,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -871,7 +861,6 @@ name = "wdk-macros-tests" version = "0.1.0" dependencies = [ "fs4", - "lazy_static", "macrotest", "owo-colors", "paste", @@ -888,7 +877,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/tests/config-umdf/Cargo.lock b/tests/config-umdf/Cargo.lock index 99a963cd..8f84551e 100644 --- a/tests/config-umdf/Cargo.lock +++ b/tests/config-umdf/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -342,9 +342,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -439,9 +436,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -646,12 +643,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -846,7 +837,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -871,7 +861,6 @@ name = "wdk-macros-tests" version = "0.1.0" dependencies = [ "fs4", - "lazy_static", "macrotest", "owo-colors", "paste", @@ -888,7 +877,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/tests/mixed-package-kmdf-workspace/Cargo.lock b/tests/mixed-package-kmdf-workspace/Cargo.lock index 93f31b48..4dc9dca3 100644 --- a/tests/mixed-package-kmdf-workspace/Cargo.lock +++ b/tests/mixed-package-kmdf-workspace/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -298,9 +298,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -383,9 +380,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -570,12 +567,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -733,7 +724,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -765,7 +755,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/tests/umdf-driver-workspace/Cargo.lock b/tests/umdf-driver-workspace/Cargo.lock index 1dee849d..40075533 100644 --- a/tests/umdf-driver-workspace/Cargo.lock +++ b/tests/umdf-driver-workspace/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -305,9 +305,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -386,9 +383,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -573,12 +570,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -726,7 +717,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -754,7 +744,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror", diff --git a/tests/wdk-macros-tests/Cargo.lock b/tests/wdk-macros-tests/Cargo.lock index a963b997..8bcbab9c 100644 --- a/tests/wdk-macros-tests/Cargo.lock +++ b/tests/wdk-macros-tests/Cargo.lock @@ -77,12 +77,6 @@ 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.155" @@ -307,7 +301,6 @@ name = "wdk-macros-tests" version = "0.1.0" dependencies = [ "fs4", - "lazy_static", "macrotest", "owo-colors", "paste", diff --git a/tests/wdk-macros-tests/Cargo.toml b/tests/wdk-macros-tests/Cargo.toml index 7f16c6ef..2edb4df6 100644 --- a/tests/wdk-macros-tests/Cargo.toml +++ b/tests/wdk-macros-tests/Cargo.toml @@ -10,7 +10,6 @@ publish = false [dependencies] fs4 = { version = "0.8.4", features = ["sync"] } -lazy_static = "1.5.0" macrotest = "1.0.13" owo-colors = "4.0.0" paste = "1.0.15" diff --git a/tests/wdk-macros-tests/src/lib.rs b/tests/wdk-macros-tests/src/lib.rs index dc734697..1d722466 100644 --- a/tests/wdk-macros-tests/src/lib.rs +++ b/tests/wdk-macros-tests/src/lib.rs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation // License: MIT OR Apache-2.0 -use std::path::PathBuf; +use std::{path::PathBuf, sync::LazyLock}; use fs4::FileExt; -use lazy_static::lazy_static; pub use macrotest::{expand, expand_args}; pub use owo_colors::OwoColorize; pub use paste::paste; @@ -19,19 +18,20 @@ const TOOLCHAIN_CHANNEL_NAME: &str = "beta"; #[rustversion::nightly] const TOOLCHAIN_CHANNEL_NAME: &str = "nightly"; -lazy_static! { - static ref TESTS_FOLDER_PATH: PathBuf = [env!("CARGO_MANIFEST_DIR"), "tests"].iter().collect(); - static ref INPUTS_FOLDER_PATH: PathBuf = TESTS_FOLDER_PATH.join("inputs"); - pub static ref MACROTEST_INPUT_FOLDER_PATH: PathBuf = INPUTS_FOLDER_PATH.join("macrotest"); - pub static ref TRYBUILD_INPUT_FOLDER_PATH: PathBuf = INPUTS_FOLDER_PATH.join("trybuild"); - static ref OUTPUTS_FOLDER_PATH: PathBuf = TESTS_FOLDER_PATH.join("outputs"); - static ref TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH: PathBuf = - OUTPUTS_FOLDER_PATH.join(TOOLCHAIN_CHANNEL_NAME); - pub static ref MACROTEST_OUTPUT_FOLDER_PATH: PathBuf = - TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH.join("macrotest"); - pub static ref TRYBUILD_OUTPUT_FOLDER_PATH: PathBuf = - TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH.join("trybuild"); -} +static TESTS_FOLDER_PATH: LazyLock = + LazyLock::new(|| [env!("CARGO_MANIFEST_DIR"), "tests"].iter().collect()); +static INPUTS_FOLDER_PATH: LazyLock = LazyLock::new(|| TESTS_FOLDER_PATH.join("inputs")); +pub static MACROTEST_INPUT_FOLDER_PATH: LazyLock = + LazyLock::new(|| INPUTS_FOLDER_PATH.join("macrotest")); +pub static TRYBUILD_INPUT_FOLDER_PATH: LazyLock = + LazyLock::new(|| INPUTS_FOLDER_PATH.join("trybuild")); +static OUTPUTS_FOLDER_PATH: LazyLock = LazyLock::new(|| TESTS_FOLDER_PATH.join("outputs")); +static TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH: LazyLock = + LazyLock::new(|| OUTPUTS_FOLDER_PATH.join(TOOLCHAIN_CHANNEL_NAME)); +pub static MACROTEST_OUTPUT_FOLDER_PATH: LazyLock = + LazyLock::new(|| TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH.join("macrotest")); +pub static TRYBUILD_OUTPUT_FOLDER_PATH: LazyLock = + LazyLock::new(|| TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH.join("trybuild")); /// Given a filename `f` which contains code utilizing /// [`wdk_sys::call_unsafe_wdf_function_binding`], generates a pair of tests to diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_tuple_struct_shadowing.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_tuple_struct_shadowing.expanded.rs index bf31420b..448b77e3 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_tuple_struct_shadowing.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_tuple_struct_shadowing.expanded.rs @@ -39,8 +39,26 @@ fn foo( pnp_power_event_callbacks__: PWDF_PNPPOWER_EVENT_CALLBACKS, ) { let wdf_function: wdk_sys::PFN_WDFDEVICEINITSETPNPPOWEREVENTCALLBACKS = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceInitSetPnpPowerEventCallbacksTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceInitSetPnpPowerEventCallbacksTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_unused_imports.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_unused_imports.expanded.rs index 62cc30dc..e6df5925 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_unused_imports.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/bug_unused_imports.expanded.rs @@ -47,8 +47,26 @@ pub extern "system" fn driver_entry( driver__: *mut WDFDRIVER, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDRIVERCREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create.expanded.rs index ef27cf51..285724a6 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create.expanded.rs @@ -17,8 +17,26 @@ extern "C" fn evt_driver_device_add( device__: *mut WDFDEVICE, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDEVICECREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create_device_interface.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create_device_interface.expanded.rs index a3d848a3..34000471 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create_device_interface.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_device_create_device_interface.expanded.rs @@ -19,8 +19,26 @@ fn create_device_interface(wdf_device: wdk_sys::WDFDEVICE) -> wdk_sys::NTSTATUS reference_string__: PCUNICODE_STRING, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDEVICECREATEDEVICEINTERFACE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateDeviceInterfaceTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateDeviceInterfaceTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_driver_create.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_driver_create.expanded.rs index c29f50c0..029e38ca 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_driver_create.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_driver_create.expanded.rs @@ -24,8 +24,26 @@ pub extern "system" fn driver_entry( driver__: *mut WDFDRIVER, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDRIVERCREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_request_retrieve_output_buffer.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_request_retrieve_output_buffer.expanded.rs index 550a1906..807fa0e0 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_request_retrieve_output_buffer.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_request_retrieve_output_buffer.expanded.rs @@ -16,8 +16,26 @@ fn process_wdf_request(request: wdk_sys::WDFREQUEST) { length__: *mut usize, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFREQUESTRETRIEVEOUTPUTBUFFER = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfRequestRetrieveOutputBufferTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfRequestRetrieveOutputBufferTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_spin_lock_acquire.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_spin_lock_acquire.expanded.rs index 0992a872..8cd2eea4 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_spin_lock_acquire.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_spin_lock_acquire.expanded.rs @@ -8,8 +8,26 @@ fn acquire_lock(wdf_spin_lock: wdk_sys::WDFSPINLOCK) { #[inline(always)] pub unsafe fn wdf_spin_lock_acquire_impl(spin_lock__: WDFSPINLOCK) { let wdf_function: wdk_sys::PFN_WDFSPINLOCKACQUIRE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfSpinLockAcquireTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfSpinLockAcquireTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_verifier_dbg_break_point.expanded.rs b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_verifier_dbg_break_point.expanded.rs index cb73dd15..5d5b999b 100644 --- a/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_verifier_dbg_break_point.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/beta/macrotest/wdf_verifier_dbg_break_point.expanded.rs @@ -8,9 +8,27 @@ fn foo() { #[inline(always)] pub unsafe fn wdf_verifier_dbg_break_point_impl() { let wdf_function: wdk_sys::PFN_WDFVERIFIERDBGBREAKPOINT = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfVerifierDbgBreakPointTableIndex - as usize], + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfVerifierDbgBreakPointTableIndex + as usize], ) }); if let Some(wdf_function) = wdf_function { diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_tuple_struct_shadowing.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_tuple_struct_shadowing.expanded.rs index bf31420b..448b77e3 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_tuple_struct_shadowing.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_tuple_struct_shadowing.expanded.rs @@ -39,8 +39,26 @@ fn foo( pnp_power_event_callbacks__: PWDF_PNPPOWER_EVENT_CALLBACKS, ) { let wdf_function: wdk_sys::PFN_WDFDEVICEINITSETPNPPOWEREVENTCALLBACKS = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceInitSetPnpPowerEventCallbacksTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceInitSetPnpPowerEventCallbacksTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_unused_imports.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_unused_imports.expanded.rs index 62cc30dc..e6df5925 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_unused_imports.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/bug_unused_imports.expanded.rs @@ -47,8 +47,26 @@ pub extern "system" fn driver_entry( driver__: *mut WDFDRIVER, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDRIVERCREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create.expanded.rs index ef27cf51..285724a6 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create.expanded.rs @@ -17,8 +17,26 @@ extern "C" fn evt_driver_device_add( device__: *mut WDFDEVICE, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDEVICECREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create_device_interface.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create_device_interface.expanded.rs index a3d848a3..34000471 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create_device_interface.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_device_create_device_interface.expanded.rs @@ -19,8 +19,26 @@ fn create_device_interface(wdf_device: wdk_sys::WDFDEVICE) -> wdk_sys::NTSTATUS reference_string__: PCUNICODE_STRING, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDEVICECREATEDEVICEINTERFACE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateDeviceInterfaceTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateDeviceInterfaceTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_driver_create.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_driver_create.expanded.rs index c29f50c0..029e38ca 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_driver_create.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_driver_create.expanded.rs @@ -24,8 +24,26 @@ pub extern "system" fn driver_entry( driver__: *mut WDFDRIVER, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDRIVERCREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_request_retrieve_output_buffer.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_request_retrieve_output_buffer.expanded.rs index 550a1906..807fa0e0 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_request_retrieve_output_buffer.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_request_retrieve_output_buffer.expanded.rs @@ -16,8 +16,26 @@ fn process_wdf_request(request: wdk_sys::WDFREQUEST) { length__: *mut usize, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFREQUESTRETRIEVEOUTPUTBUFFER = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfRequestRetrieveOutputBufferTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfRequestRetrieveOutputBufferTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_spin_lock_acquire.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_spin_lock_acquire.expanded.rs index 0992a872..8cd2eea4 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_spin_lock_acquire.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_spin_lock_acquire.expanded.rs @@ -8,8 +8,26 @@ fn acquire_lock(wdf_spin_lock: wdk_sys::WDFSPINLOCK) { #[inline(always)] pub unsafe fn wdf_spin_lock_acquire_impl(spin_lock__: WDFSPINLOCK) { let wdf_function: wdk_sys::PFN_WDFSPINLOCKACQUIRE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfSpinLockAcquireTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfSpinLockAcquireTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_verifier_dbg_break_point.expanded.rs b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_verifier_dbg_break_point.expanded.rs index cb73dd15..e06fecc4 100644 --- a/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_verifier_dbg_break_point.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/nightly/macrotest/wdf_verifier_dbg_break_point.expanded.rs @@ -8,8 +8,26 @@ fn foo() { #[inline(always)] pub unsafe fn wdf_verifier_dbg_break_point_impl() { let wdf_function: wdk_sys::PFN_WDFVERIFIERDBGBREAKPOINT = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfVerifierDbgBreakPointTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfVerifierDbgBreakPointTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_tuple_struct_shadowing.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_tuple_struct_shadowing.expanded.rs index bf31420b..448b77e3 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_tuple_struct_shadowing.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_tuple_struct_shadowing.expanded.rs @@ -39,8 +39,26 @@ fn foo( pnp_power_event_callbacks__: PWDF_PNPPOWER_EVENT_CALLBACKS, ) { let wdf_function: wdk_sys::PFN_WDFDEVICEINITSETPNPPOWEREVENTCALLBACKS = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceInitSetPnpPowerEventCallbacksTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceInitSetPnpPowerEventCallbacksTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_unused_imports.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_unused_imports.expanded.rs index 62cc30dc..e6df5925 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_unused_imports.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/bug_unused_imports.expanded.rs @@ -47,8 +47,26 @@ pub extern "system" fn driver_entry( driver__: *mut WDFDRIVER, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDRIVERCREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create.expanded.rs index ef27cf51..285724a6 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create.expanded.rs @@ -17,8 +17,26 @@ extern "C" fn evt_driver_device_add( device__: *mut WDFDEVICE, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDEVICECREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create_device_interface.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create_device_interface.expanded.rs index a3d848a3..34000471 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create_device_interface.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_device_create_device_interface.expanded.rs @@ -19,8 +19,26 @@ fn create_device_interface(wdf_device: wdk_sys::WDFDEVICE) -> wdk_sys::NTSTATUS reference_string__: PCUNICODE_STRING, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDEVICECREATEDEVICEINTERFACE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateDeviceInterfaceTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDeviceCreateDeviceInterfaceTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_driver_create.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_driver_create.expanded.rs index c29f50c0..029e38ca 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_driver_create.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_driver_create.expanded.rs @@ -24,8 +24,26 @@ pub extern "system" fn driver_entry( driver__: *mut WDFDRIVER, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFDRIVERCREATE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfDriverCreateTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_request_retrieve_output_buffer.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_request_retrieve_output_buffer.expanded.rs index 550a1906..807fa0e0 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_request_retrieve_output_buffer.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_request_retrieve_output_buffer.expanded.rs @@ -16,8 +16,26 @@ fn process_wdf_request(request: wdk_sys::WDFREQUEST) { length__: *mut usize, ) -> NTSTATUS { let wdf_function: wdk_sys::PFN_WDFREQUESTRETRIEVEOUTPUTBUFFER = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfRequestRetrieveOutputBufferTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfRequestRetrieveOutputBufferTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_spin_lock_acquire.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_spin_lock_acquire.expanded.rs index 0992a872..8cd2eea4 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_spin_lock_acquire.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_spin_lock_acquire.expanded.rs @@ -8,8 +8,26 @@ fn acquire_lock(wdf_spin_lock: wdk_sys::WDFSPINLOCK) { #[inline(always)] pub unsafe fn wdf_spin_lock_acquire_impl(spin_lock__: WDFSPINLOCK) { let wdf_function: wdk_sys::PFN_WDFSPINLOCKACQUIRE = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfSpinLockAcquireTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfSpinLockAcquireTableIndex as usize], ) }); diff --git a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_verifier_dbg_break_point.expanded.rs b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_verifier_dbg_break_point.expanded.rs index cb73dd15..afac793b 100644 --- a/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_verifier_dbg_break_point.expanded.rs +++ b/tests/wdk-macros-tests/tests/outputs/stable/macrotest/wdf_verifier_dbg_break_point.expanded.rs @@ -8,8 +8,26 @@ fn foo() { #[inline(always)] pub unsafe fn wdf_verifier_dbg_break_point_impl() { let wdf_function: wdk_sys::PFN_WDFVERIFIERDBGBREAKPOINT = Some(unsafe { + let wdf_function_table = wdk_sys::WdfFunctions; + let wdf_function_count = wdk_sys::wdf::get_wdf_function_count(); + if true { + if !isize::try_from( + wdf_function_count + * core::mem::size_of::(), + ) + .is_ok() + { + ::core::panicking::panic( + "assertion failed: isize::try_from(wdf_function_count *\n core::mem::size_of::()).is_ok()", + ) + } + } + let wdf_function_table = core::slice::from_raw_parts( + wdf_function_table, + wdf_function_count, + ); core::mem::transmute( - wdk_sys::WDF_FUNCTION_TABLE[wdk_sys::_WDFFUNCENUM::WdfVerifierDbgBreakPointTableIndex + wdf_function_table[wdk_sys::_WDFFUNCENUM::WdfVerifierDbgBreakPointTableIndex as usize], ) }); diff --git a/tests/wdk-sys-tests/Cargo.lock b/tests/wdk-sys-tests/Cargo.lock index 3b4cd777..47bc1fe4 100644 --- a/tests/wdk-sys-tests/Cargo.lock +++ b/tests/wdk-sys-tests/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -290,9 +290,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -371,9 +368,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "overload" @@ -558,12 +555,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.11.1" @@ -701,7 +692,6 @@ dependencies = [ "cfg-if", "clap", "clap-cargo", - "lazy_static", "paste", "rustversion", "serde", @@ -729,7 +719,6 @@ dependencies = [ "bindgen", "cargo_metadata", "cc", - "lazy_static", "rustversion", "serde_json", "thiserror",