diff --git a/Cargo.lock b/Cargo.lock
index db6fccad..55b145a4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -296,9 +296,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"
@@ -377,9 +374,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"
@@ -574,12 +571,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"
@@ -737,7 +728,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -771,7 +761,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/Cargo.toml b/Cargo.toml
index fa00ba03..2363a8ea 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.1"
 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 d2667267..bb9d3f1c 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};
@@ -1072,14 +1072,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<Vec<(&'static str, Vec<&'static str>)>> =
+    LazyLock::new(|| vec![("DRIVER_MODEL-DRIVER_TYPE", vec!["WDM", "KMDF", "UMDF"])]);
 
 #[cfg(test)]
 mod tests {
@@ -1276,7 +1273,6 @@ mod tests {
                 config.bindgen_header_contents([ApiSubset::Base]),
                 r#"#include "ntifs.h"
 #include "ntddk.h"
-#include "ntstrsafe.h"
 "#,
             );
         }
@@ -1296,7 +1292,6 @@ mod tests {
                 config.bindgen_header_contents([ApiSubset::Base, ApiSubset::Wdf]),
                 r#"#include "ntifs.h"
 #include "ntddk.h"
-#include "ntstrsafe.h"
 #include "wdf.h"
 "#,
             );
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index 7367ca6a..fd4f1894 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -370,7 +370,7 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer<'a> {
 
 impl<'a> Serializer<'a> {
     /// Create a new instance of the `Serializer` struct
-    pub fn new(dst: &'a mut Vec<(String, String)>) -> Self {
+    pub const fn new(dst: &'a mut Vec<(String, String)>) -> Self {
         Self {
             root_key_name: None,
             dst,
@@ -379,7 +379,7 @@ impl<'a> Serializer<'a> {
 
     /// Create a new instance of the `Serializer` struct with a prefix used as
     /// the root for all keys
-    pub fn with_prefix(prefix: String, dst: &'a mut Vec<(String, String)>) -> Self {
+    pub const fn with_prefix(prefix: String, dst: &'a mut Vec<(String, String)>) -> Self {
         Self {
             root_key_name: Some(prefix),
             dst,
diff --git a/crates/wdk-macros/src/lib.rs b/crates/wdk-macros/src/lib.rs
index cb0b6d63..b4e6b114 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::__private::get_wdf_function_count();
+
+                    // SAFETY: This is safe because:
+                    //         1. `WdfFunctions` is valid for reads for `{NUM_WDF_FUNCTIONS_PLACEHOLDER}` * `core::mem::size_of::<WDFFUNC>()`
+                    //            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::<WDFFUNC>()`, 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::<wdk_sys::WDFFUNC>()).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 531c4adf..755b825b 100644
--- a/crates/wdk-sys/Cargo.toml
+++ b/crates/wdk-sys/Cargo.toml
@@ -22,7 +22,6 @@ bindgen.workspace = true
 cargo_metadata.workspace = true
 cc.workspace = true
 cfg-if.workspace = true
-lazy_static.workspace = true
 serde_json.workspace = true
 thiserror.workspace = true
 tracing.workspace = true
@@ -30,7 +29,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
 
@@ -76,6 +74,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 a69346a2..39784c7e 100644
--- a/crates/wdk-sys/build.rs
+++ b/crates/wdk-sys/build.rs
@@ -12,12 +12,12 @@ use std::{
     io::Write,
     panic,
     path::{Path, PathBuf},
+    sync::LazyLock,
     thread,
 };
 
 use anyhow::Context;
 use bindgen::CodegenConfig;
-use lazy_static::lazy_static;
 use tracing::{info, info_span, trace, Span};
 use tracing_subscriber::{
     filter::{LevelFilter, ParseError},
@@ -34,61 +34,33 @@ use wdk_build::{
     UmdfConfig,
 };
 
-const NUM_WDF_FUNCTIONS_PLACEHOLDER: &str =
-    "<PLACEHOLDER FOR IDENTIFIER FOR VARIABLE CORRESPONDING TO NUMBER OF WDF FUNCTIONS>";
-const WDF_FUNCTION_COUNT_DECLARATION_PLACEHOLDER: &str =
-    "<PLACEHOLDER FOR DECLARATION OF wdf_function_count VARIABLE>";
 const OUT_DIR_PLACEHOLDER: &str =
     "<PLACEHOLDER FOR LITERAL VALUE CONTAINING OUT_DIR OF wdk-sys CRATE>";
 const WDFFUNCTIONS_SYMBOL_NAME_PLACEHOLDER: &str =
     "<PLACEHOLDER FOR LITERAL VALUE CONTAINING WDFFUNCTIONS SYMBOL NAME>";
-
-/// Rust code snippet that declares and initializes `wdf_function_count` based
-/// off the bindgen-generated `WdfFunctionCount` symbol
-///
-/// This is only used in configurations where WDF generates a
-/// `WdfFunctionCount`.
-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;";
-/// Rust code snippet that declares and initializes `wdf_function_count` based
-/// off the bindgen-generated `WdfFunctionTableNumEntries` constant
-///
-/// This is only used in older WDF versions that didn't generate a
-/// `WdfFunctionCount` symbol
-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::<WDFFUNC>()`
-        //            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::<WDFFUNC>()`, 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::<crate::WDFFUNC>()).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 =
+    "<PLACEHOLDER FOR EXPRESSION FOR NUMBER OF WDF FUNCTIONS IN `wdk_sys::WdfFunctions`";
+
+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.
+    (unsafe { crate::WdfFunctionCount }) as usize";
+
+const WDF_FUNCTION_COUNT_DECLARATION_TABLE_INDEX: &str =
+    "crate::_WDFFUNCENUM::WdfFunctionTableNumEntries as usize";
+
+static WDF_FUNCTION_COUNT_FUNCTION_TEMPLATE: LazyLock<String> = LazyLock::new(|| {
+    format!(
+        r"/// 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<String> = LazyLock::new(|| {
+    format!(
         r#"
 /// A procedural macro that allows WDF functions to be called by name.
 ///
@@ -138,18 +110,20 @@ macro_rules! call_unsafe_wdf_function_binding {{
         )
     }}
 }}"#
-    );
-    static ref TEST_STUBS_TEMPLATE: String = format!(
+    )
+});
+
+static TEST_STUBS_TEMPLATE: LazyLock<String> = LazyLock::new(|| {
+    format!(
         r"
 use crate::WDFFUNC;
 
 /// Stubbed version of the symbol that [`WdfFunctions`] links to so that test targets will compile
 #[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)] = &[
@@ -347,15 +321,15 @@ fn generate_hid(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
-/// 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.
-fn generate_wdf_function_table(out_path: &Path, config: &Config) -> std::io::Result<()> {
+/// 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) -> 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 {
@@ -392,26 +366,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(())
 }
 
@@ -540,8 +504,8 @@ fn main() -> anyhow::Result<()> {
                         .expect("Scoped Thread should spawn successfully"),
                 );
 
-                info_span!("wdf_function_table.rs generation").in_scope(|| {
-                    generate_wdf_function_table(out_path, config)?;
+                info_span!("wdf_function_count.rs generation").in_scope(|| {
+                    generate_wdf_function_count(out_path, config)?;
                     Ok::<(), std::io::Error>(())
                 })?;
 
diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs
index 9f0342ac..e0a46d01 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..9115f247 100644
--- a/crates/wdk-sys/src/wdf.rs
+++ b/crates/wdk-sys/src/wdf.rs
@@ -20,4 +20,13 @@ mod bindings {
     include!(concat!(env!("OUT_DIR"), "/wdf.rs"));
 }
 
-include!(concat!(env!("OUT_DIR"), "/wdf_function_table.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/examples/sample-kmdf-driver/Cargo.lock b/examples/sample-kmdf-driver/Cargo.lock
index 526dfb40..fc188719 100644
--- a/examples/sample-kmdf-driver/Cargo.lock
+++ b/examples/sample-kmdf-driver/Cargo.lock
@@ -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"
@@ -568,12 +565,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"
@@ -731,7 +722,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -764,7 +754,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/examples/sample-umdf-driver/Cargo.lock b/examples/sample-umdf-driver/Cargo.lock
index 4c1630ea..1425eb7b 100644
--- a/examples/sample-umdf-driver/Cargo.lock
+++ b/examples/sample-umdf-driver/Cargo.lock
@@ -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"
@@ -566,12 +563,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"
@@ -719,7 +710,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -748,7 +738,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/examples/sample-wdm-driver/Cargo.lock b/examples/sample-wdm-driver/Cargo.lock
index 25dbf949..b9ae0745 100644
--- a/examples/sample-wdm-driver/Cargo.lock
+++ b/examples/sample-wdm-driver/Cargo.lock
@@ -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"
@@ -568,12 +565,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"
@@ -731,7 +722,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -764,7 +754,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/tests/config-kmdf/Cargo.lock b/tests/config-kmdf/Cargo.lock
index 4b2cb1c9..225e1bff 100644
--- a/tests/config-kmdf/Cargo.lock
+++ b/tests/config-kmdf/Cargo.lock
@@ -345,9 +345,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"
@@ -442,9 +439,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"
@@ -649,12 +646,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"
@@ -849,7 +840,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -874,7 +864,6 @@ name = "wdk-macros-tests"
 version = "0.1.0"
 dependencies = [
  "fs4",
- "lazy_static",
  "macrotest",
  "owo-colors",
  "paste",
@@ -892,7 +881,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/tests/config-umdf/Cargo.lock b/tests/config-umdf/Cargo.lock
index 89275340..02d719e8 100644
--- a/tests/config-umdf/Cargo.lock
+++ b/tests/config-umdf/Cargo.lock
@@ -345,9 +345,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"
@@ -442,9 +439,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"
@@ -649,12 +646,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"
@@ -849,7 +840,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -874,7 +864,6 @@ name = "wdk-macros-tests"
 version = "0.1.0"
 dependencies = [
  "fs4",
- "lazy_static",
  "macrotest",
  "owo-colors",
  "paste",
@@ -892,7 +881,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "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 2a9075f2..088eb5f5 100644
--- a/tests/mixed-package-kmdf-workspace/Cargo.lock
+++ b/tests/mixed-package-kmdf-workspace/Cargo.lock
@@ -301,9 +301,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"
@@ -736,7 +727,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -769,7 +759,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/tests/umdf-driver-workspace/Cargo.lock b/tests/umdf-driver-workspace/Cargo.lock
index 9afb1139..2da260d4 100644
--- a/tests/umdf-driver-workspace/Cargo.lock
+++ b/tests/umdf-driver-workspace/Cargo.lock
@@ -308,9 +308,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"
@@ -389,9 +386,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"
@@ -576,12 +573,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"
@@ -729,7 +720,6 @@ dependencies = [
  "cfg-if",
  "clap",
  "clap-cargo",
- "lazy_static",
  "paste",
  "rustversion",
  "serde",
@@ -758,7 +748,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",
diff --git a/tests/wdk-macros-tests/Cargo.lock b/tests/wdk-macros-tests/Cargo.lock
index 63cf183e..0b720ba8 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 c6b8a991..b3297e28 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<PathBuf> =
+    LazyLock::new(|| [env!("CARGO_MANIFEST_DIR"), "tests"].iter().collect());
+static INPUTS_FOLDER_PATH: LazyLock<PathBuf> = LazyLock::new(|| TESTS_FOLDER_PATH.join("inputs"));
+pub static MACROTEST_INPUT_FOLDER_PATH: LazyLock<PathBuf> =
+    LazyLock::new(|| INPUTS_FOLDER_PATH.join("macrotest"));
+pub static TRYBUILD_INPUT_FOLDER_PATH: LazyLock<PathBuf> =
+    LazyLock::new(|| INPUTS_FOLDER_PATH.join("trybuild"));
+static OUTPUTS_FOLDER_PATH: LazyLock<PathBuf> = LazyLock::new(|| TESTS_FOLDER_PATH.join("outputs"));
+static TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH: LazyLock<PathBuf> =
+    LazyLock::new(|| OUTPUTS_FOLDER_PATH.join(TOOLCHAIN_CHANNEL_NAME));
+pub static MACROTEST_OUTPUT_FOLDER_PATH: LazyLock<PathBuf> =
+    LazyLock::new(|| TOOLCHAIN_SPECIFIC_OUTPUTS_FOLDER_PATH.join("macrotest"));
+pub static TRYBUILD_OUTPUT_FOLDER_PATH: LazyLock<PathBuf> =
+    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..ca2b818d 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..fb3d4755 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..0e687de3 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..1e10670e 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..2f60cd9a 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..c2654fcb 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..0e2142bf 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..3e18daad 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,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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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/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..ca2b818d 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..fb3d4755 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..0e687de3 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..1e10670e 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..2f60cd9a 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..c2654fcb 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..0e2142bf 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..3e18daad 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..ca2b818d 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..fb3d4755 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..0e687de3 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..1e10670e 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..2f60cd9a 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..c2654fcb 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..0e2142bf 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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..3e18daad 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::__private::get_wdf_function_count();
+                        if true {
+                            if !isize::try_from(
+                                    wdf_function_count
+                                        * core::mem::size_of::<wdk_sys::WDFFUNC>(),
+                                )
+                                .is_ok()
+                            {
+                                ::core::panicking::panic(
+                                    "assertion failed: isize::try_from(wdf_function_count *\n            core::mem::size_of::<wdk_sys::WDFFUNC>()).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 df4f3799..30eb4893 100644
--- a/tests/wdk-sys-tests/Cargo.lock
+++ b/tests/wdk-sys-tests/Cargo.lock
@@ -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",
@@ -730,7 +720,6 @@ dependencies = [
  "cargo_metadata",
  "cc",
  "cfg-if",
- "lazy_static",
  "rustversion",
  "serde_json",
  "thiserror",