From 77e8e5aeef73200f368ccb942b4577533d39d7b3 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Thu, 7 Nov 2024 15:21:09 -0800
Subject: [PATCH 01/14] Add packages to install alongside the driver to wdk
 metadata

---
 crates/wdk-build/src/lib.rs                   | 126 +-------
 .../wdk-build/src/metadata/driver_install.rs  |  31 ++
 .../wdk-build/src/metadata/driver_settings.rs | 120 +++++++
 crates/wdk-build/src/metadata/mod.rs          |   7 +-
 crates/wdk-build/src/metadata/ser.rs          | 294 ++++++++++--------
 5 files changed, 329 insertions(+), 249 deletions(-)
 create mode 100644 crates/wdk-build/src/metadata/driver_install.rs
 create mode 100644 crates/wdk-build/src/metadata/driver_settings.rs

diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index db2e8aa8..a038403a 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -14,6 +14,8 @@
 
 pub use bindgen::BuilderExt;
 use metadata::TryFromCargoMetadataError;
+use metadata::driver_install::DriverInstall;
+use metadata::driver_settings::DriverConfig;
 
 pub mod cargo_make;
 pub mod metadata;
@@ -39,42 +41,8 @@ pub struct Config {
     cpu_architecture: CpuArchitecture,
     /// Build configuration of driver
     pub driver_config: DriverConfig,
-}
-
-/// The driver type with its associated configuration parameters
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
-#[serde(
-    tag = "DRIVER_TYPE",
-    deny_unknown_fields,
-    rename_all = "UPPERCASE",
-    from = "DeserializableDriverConfig"
-)]
-pub enum DriverConfig {
-    /// Windows Driver Model
-    Wdm,
-    /// Kernel Mode Driver Framework
-    Kmdf(KmdfConfig),
-    /// User Mode Driver Framework
-    Umdf(UmdfConfig),
-}
-
-/// Private enum identical to [`DriverConfig`] but with different tag name to
-/// deserialize from.
-///
-/// [`serde_derive`] doesn't support different tag names for serialization vs.
-/// deserialization, and also doesn't support aliases for tag names, so the
-/// `from` attribute is used in conjunction with this type to facilitate a
-/// different tag name for deserialization.
-///
-/// Relevant Github Issues:
-/// * <https://github.com/serde-rs/serde/issues/2776>
-/// * <https://github.com/serde-rs/serde/issues/2324>
-#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Hash)]
-#[serde(tag = "driver-type", deny_unknown_fields, rename_all = "UPPERCASE")]
-enum DeserializableDriverConfig {
-    Wdm,
-    Kmdf(KmdfConfig),
-    Umdf(UmdfConfig),
+    /// Driver installation settings
+    pub driver_install: DriverInstall
 }
 
 /// The CPU architecture that's configured to be compiled for
@@ -86,36 +54,6 @@ pub enum CpuArchitecture {
     Arm64,
 }
 
-/// The configuration parameters for KMDF drivers
-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
-#[serde(
-    deny_unknown_fields,
-    rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case")
-)]
-pub struct KmdfConfig {
-    /// Major KMDF Version
-    pub kmdf_version_major: u8,
-    /// Minor KMDF Version (Target Version)
-    pub target_kmdf_version_minor: u8,
-    /// Minor KMDF Version (Minimum Required)
-    pub minimum_kmdf_version_minor: Option<u8>,
-}
-
-/// The configuration parameters for UMDF drivers
-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
-#[serde(
-    deny_unknown_fields,
-    rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case")
-)]
-pub struct UmdfConfig {
-    /// Major UMDF Version
-    pub umdf_version_major: u8,
-    /// Minor UMDF Version (Target Version)
-    pub target_umdf_version_minor: u8,
-    /// Minor UMDF Version (Minimum Required)
-    pub minimum_umdf_version_minor: Option<u8>,
-}
-
 /// Errors that could result from configuring a build via [`wdk-build`]
 #[derive(Debug, Error)]
 pub enum ConfigError {
@@ -200,6 +138,7 @@ impl Default for Config {
             ),
             driver_config: DriverConfig::Wdm,
             cpu_architecture: utils::detect_cpu_architecture_in_build_script(),
+            driver_install: Default::default(),
         }
     }
 }
@@ -249,6 +188,7 @@ impl Config {
 
         Ok(Self {
             driver_config: wdk_metadata.driver_model,
+            driver_install: wdk_metadata.driver_install,
             ..Default::default()
         })
     }
@@ -292,6 +232,7 @@ impl Config {
         let serialized_wdk_metadata_map =
             metadata::to_map::<std::collections::BTreeMap<_, _>>(&metadata::Wdk {
                 driver_model: self.driver_config.clone(),
+                driver_install: self.driver_install.clone()
             })?;
 
         for cfg_key in EXPORTED_CFG_SETTINGS.iter().map(|(key, _)| *key) {
@@ -777,56 +718,6 @@ impl Config {
     }
 }
 
-impl From<DeserializableDriverConfig> for DriverConfig {
-    fn from(config: DeserializableDriverConfig) -> Self {
-        match config {
-            DeserializableDriverConfig::Wdm => Self::Wdm,
-            DeserializableDriverConfig::Kmdf(kmdf_config) => Self::Kmdf(kmdf_config),
-            DeserializableDriverConfig::Umdf(umdf_config) => Self::Umdf(umdf_config),
-        }
-    }
-}
-
-impl Default for KmdfConfig {
-    #[must_use]
-    fn default() -> Self {
-        // FIXME: determine default values from TargetVersion and _NT_TARGET_VERSION
-        Self {
-            kmdf_version_major: 1,
-            target_kmdf_version_minor: 33,
-            minimum_kmdf_version_minor: None,
-        }
-    }
-}
-
-impl KmdfConfig {
-    /// Creates a new [`KmdfConfig`] with default values
-    #[must_use]
-    pub fn new() -> Self {
-        Self::default()
-    }
-}
-
-impl Default for UmdfConfig {
-    #[must_use]
-    fn default() -> Self {
-        // FIXME: determine default values from TargetVersion and _NT_TARGET_VERSION
-        Self {
-            umdf_version_major: 2,
-            target_umdf_version_minor: 33,
-            minimum_umdf_version_minor: None,
-        }
-    }
-}
-
-impl UmdfConfig {
-    /// Creates a new [`UmdfConfig`] with default values
-    #[must_use]
-    pub fn new() -> Self {
-        Self::default()
-    }
-}
-
 impl CpuArchitecture {
     /// Converts [`CpuArchitecture`] to the string corresponding to what the
     /// architecture is typically referred to in Windows
@@ -995,6 +886,7 @@ mod tests {
     #[cfg(nightly_toolchain)]
     use std::assert_matches::assert_matches;
     use std::{collections::HashMap, ffi::OsStr, sync::Mutex};
+    use metadata::driver_settings::{KmdfConfig, UmdfConfig};
 
     use super::*;
 
@@ -1172,7 +1064,7 @@ mod tests {
 
     mod compute_wdffunctions_symbol_name {
         use super::*;
-        use crate::{KmdfConfig, UmdfConfig};
+        use metadata::driver_settings::{KmdfConfig, UmdfConfig};
 
         #[test]
         fn kmdf() {
diff --git a/crates/wdk-build/src/metadata/driver_install.rs b/crates/wdk-build/src/metadata/driver_install.rs
new file mode 100644
index 00000000..92489f19
--- /dev/null
+++ b/crates/wdk-build/src/metadata/driver_install.rs
@@ -0,0 +1,31 @@
+// Copyright (c) Microsoft Corporation
+// License: MIT OR Apache-2.0
+
+use serde::{Deserialize, Serialize};
+
+/// The `DRIVER_INSTALL` section of the `metadata.wdk` section of the `Cargo.toml`
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[serde(
+    deny_unknown_fields,
+    rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case")
+)]
+pub struct DriverInstall {
+    /// List of files to be installed with the driver package.
+    pub package_files: Vec<String>
+}
+
+impl Default for DriverInstall {
+    fn default() -> Self {
+        Self {
+            package_files: Vec::new()
+        }
+    }
+}
+
+impl DriverInstall {
+   /// Creates a new [`DriverInstall`] with default values
+   #[must_use]
+    pub fn new() -> Self {
+        Self::default()
+    }
+}
\ No newline at end of file
diff --git a/crates/wdk-build/src/metadata/driver_settings.rs b/crates/wdk-build/src/metadata/driver_settings.rs
new file mode 100644
index 00000000..f9c8a532
--- /dev/null
+++ b/crates/wdk-build/src/metadata/driver_settings.rs
@@ -0,0 +1,120 @@
+// Copyright (c) Microsoft Corporation
+// License: MIT OR Apache-2.0
+
+use serde::{Deserialize, Serialize};
+
+/// The driver type with its associated configuration parameters
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[serde(
+    tag = "DRIVER_TYPE",
+    deny_unknown_fields,
+    rename_all = "UPPERCASE",
+    from = "DeserializableDriverConfig"
+)]
+pub enum DriverConfig {
+    /// Windows Driver Model
+    Wdm,
+    /// Kernel Mode Driver Framework
+    Kmdf(KmdfConfig),
+    /// User Mode Driver Framework
+    Umdf(UmdfConfig),
+}
+
+/// Private enum identical to [`DriverConfig`] but with different tag name to
+/// deserialize from.
+///
+/// [`serde_derive`] doesn't support different tag names for serialization vs.
+/// deserialization, and also doesn't support aliases for tag names, so the
+/// `from` attribute is used in conjunction with this type to facilitate a
+/// different tag name for deserialization.
+///
+/// Relevant Github Issues:
+/// * <https://github.com/serde-rs/serde/issues/2776>
+/// * <https://github.com/serde-rs/serde/issues/2324>
+#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Hash)]
+#[serde(tag = "driver-type", deny_unknown_fields, rename_all = "UPPERCASE")]
+enum DeserializableDriverConfig {
+    Wdm,
+    Kmdf(KmdfConfig),
+    Umdf(UmdfConfig),
+}
+
+/// The configuration parameters for KMDF drivers
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[serde(
+    deny_unknown_fields,
+    rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case")
+)]
+pub struct KmdfConfig {
+    /// Major KMDF Version
+    pub kmdf_version_major: u8,
+    /// Minor KMDF Version (Target Version)
+    pub target_kmdf_version_minor: u8,
+    /// Minor KMDF Version (Minimum Required)
+    pub minimum_kmdf_version_minor: Option<u8>,
+}
+
+/// The configuration parameters for UMDF drivers
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[serde(
+    deny_unknown_fields,
+    rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case")
+)]
+pub struct UmdfConfig {
+    /// Major UMDF Version
+    pub umdf_version_major: u8,
+    /// Minor UMDF Version (Target Version)
+    pub target_umdf_version_minor: u8,
+    /// Minor UMDF Version (Minimum Required)
+    pub minimum_umdf_version_minor: Option<u8>,
+}
+
+impl From<DeserializableDriverConfig> for DriverConfig {
+    fn from(config: DeserializableDriverConfig) -> Self {
+        match config {
+            DeserializableDriverConfig::Wdm => Self::Wdm,
+            DeserializableDriverConfig::Kmdf(kmdf_config) => Self::Kmdf(kmdf_config),
+            DeserializableDriverConfig::Umdf(umdf_config) => Self::Umdf(umdf_config),
+        }
+    }
+}
+
+impl Default for KmdfConfig {
+    #[must_use]
+    fn default() -> Self {
+        // FIXME: determine default values from TargetVersion and _NT_TARGET_VERSION
+        Self {
+            kmdf_version_major: 1,
+            target_kmdf_version_minor: 33,
+            minimum_kmdf_version_minor: None,
+        }
+    }
+}
+
+impl KmdfConfig {
+    /// Creates a new [`KmdfConfig`] with default values
+    #[must_use]
+    pub fn new() -> Self {
+        Self::default()
+    }
+}
+
+impl Default for UmdfConfig {
+    #[must_use]
+    fn default() -> Self {
+        // FIXME: determine default values from TargetVersion and _NT_TARGET_VERSION
+        Self {
+            umdf_version_major: 2,
+            target_umdf_version_minor: 33,
+            minimum_umdf_version_minor: None,
+        }
+    }
+}
+
+impl UmdfConfig {
+    /// Creates a new [`UmdfConfig`] with default values
+    #[must_use]
+    pub fn new() -> Self {
+        Self::default()
+    }
+}
\ No newline at end of file
diff --git a/crates/wdk-build/src/metadata/mod.rs b/crates/wdk-build/src/metadata/mod.rs
index 8dd01d4b..c9182598 100644
--- a/crates/wdk-build/src/metadata/mod.rs
+++ b/crates/wdk-build/src/metadata/mod.rs
@@ -14,6 +14,8 @@ pub use map::Map;
 pub use ser::{to_map, to_map_with_prefix, Serializer};
 
 pub(crate) mod ser;
+pub(crate) mod driver_install;
+pub(crate) mod driver_settings;
 
 mod error;
 mod map;
@@ -25,7 +27,8 @@ use cargo_metadata::Metadata;
 use serde::{Deserialize, Serialize};
 use thiserror::Error;
 
-use crate::DriverConfig;
+use driver_settings::DriverConfig;
+use driver_install::DriverInstall;
 
 /// Metadata specified in the `metadata.wdk` section of the `Cargo.toml`
 /// of a crate that depends on the WDK, or in a cargo workspace.
@@ -40,6 +43,8 @@ use crate::DriverConfig;
 pub struct Wdk {
     /// Metadata corresponding to the `Driver Model` property page in the WDK
     pub driver_model: DriverConfig,
+    /// Metadata corresponding to the `Driver Install` property page in the WDK
+    pub driver_install: DriverInstall
 }
 
 /// Errors that could result from trying to construct a
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index 7367ca6a..f55e4bb2 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -16,6 +16,10 @@ use super::{
 /// as a separator between different node names.
 pub const KEY_NAME_SEPARATOR: char = '-';
 
+/// delimiter used to separate the different elemets in a sequence.
+/// Sequence elements are serialized into a single string with this delimiter.
+pub const SEQ_ELEMENT_SEPARATOR: char = ';';
+
 /// Serialize a value into a [`Map`] where the keys represent a
 /// `KEY_NAME_SEPARATOR`-seperated list of field names.
 ///
@@ -42,6 +46,7 @@ pub const KEY_NAME_SEPARATOR: char = '-';
 ///         target_kmdf_version_minor: 23,
 ///         minimum_kmdf_version_minor: None,
 ///     }),
+///     driver_install: Default::default(),
 /// };
 ///
 /// let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -89,6 +94,7 @@ where
 ///         target_kmdf_version_minor: 33,
 ///         minimum_kmdf_version_minor: Some(31),
 ///     }),
+///     driver_install: Default::default(),
 /// };
 ///
 /// let output = to_map_with_prefix::<BTreeMap<_, _>>("WDK_BUILD_METADATA", &wdk_metadata).unwrap();
@@ -153,10 +159,10 @@ pub struct Serializer<'a> {
 
 impl<'a> ser::Serializer for &'a mut Serializer<'a> {
     type Error = Error;
-    type Ok = ();
+    type Ok = Option<String>;
     type SerializeMap = Impossible<Self::Ok, Self::Error>;
-    type SerializeSeq = Impossible<Self::Ok, Self::Error>;
     type SerializeStruct = Self;
+    type SerializeSeq = SerializerSeq<'a>;
     type SerializeStructVariant = Impossible<Self::Ok, Self::Error>;
     type SerializeTuple = Impossible<Self::Ok, Self::Error>;
     type SerializeTupleStruct = Impossible<Self::Ok, Self::Error>;
@@ -166,115 +172,43 @@ impl<'a> ser::Serializer for &'a mut Serializer<'a> {
         // simple types
         bytes newtype_struct newtype_variant unit_struct unit_variant
         // complex types (returns SerializeXYZ types)
-        map seq struct_variant tuple tuple_struct tuple_variant
+        map struct_variant tuple tuple_struct tuple_variant
     }
 
     fn serialize_str(self, value: &str) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_bool(self, value: bool) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_char(self, value: char) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_i8(self, value: i8) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_i16(self, value: i16) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_i32(self, value: i32) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_i64(self, value: i64) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_f32(self, value: f32) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_f64(self, value: f64) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_none(self) -> Result<Self::Ok> {
@@ -289,83 +223,107 @@ impl<'a> ser::Serializer for &'a mut Serializer<'a> {
     }
 
     fn serialize_unit(self) -> Result<Self::Ok> {
-        Ok(())
+        Ok(None)
     }
 
     fn serialize_u8(self, value: u8) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_u16(self, value: u16) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_u32(self, value: u32) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_u64(self, value: u64) -> Result<Self::Ok> {
-        self.dst.push((
-            self.root_key_name
-                .clone()
-                .ok_or_else(|| Error::EmptySerializationKeyName {
-                    value_being_serialized: value.to_string(),
-                })?,
-            value.to_string(),
-        ));
-        Ok(())
+        Ok(Some(value.to_string()))
     }
 
     fn serialize_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeStruct> {
         Ok(self)
     }
+
+    fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq> {
+        Ok(SerializerSeq::new(
+            self.root_key_name.clone(),
+            self.dst,
+        ))
+    }
 }
 
 impl<'a> ser::SerializeStruct for &'a mut Serializer<'a> {
     type Error = Error;
-    type Ok = ();
+    type Ok = Option<String>;
 
-    fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<Self::Ok>
+    fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
     where
         T: ?Sized + Serialize,
     {
-        value.serialize(&mut Serializer::with_prefix(
-            self.root_key_name.as_ref().map_or_else(
-                || key.to_string(),
-                |root_key_name| format!("{root_key_name}{KEY_NAME_SEPARATOR}{key}"),
-            ),
-            self.dst,
-        ))?;
+        
+        let new_root_key_name = self.root_key_name.clone().map_or_else(
+            || key.to_string(),
+            |root_key_name| format!("{root_key_name}{KEY_NAME_SEPARATOR}{key}"),
+        );
+
+        let mut serializer = Serializer::with_prefix(new_root_key_name.clone(), self.dst);
+        let value_string  = value.serialize(&mut serializer)?;
+       
+        match value_string {
+            Some(value_string) => {
+                self.dst.push((
+                    new_root_key_name,
+                    value_string,
+                ));
+            }
+            None => {}
+        }
+
         Ok(())
     }
 
     fn end(self) -> Result<Self::Ok> {
+        Ok(None)
+    }
+}
+
+pub struct SerializerSeq<'a> {
+    root_key_name: Option<String>,
+    dst: &'a mut Vec<(String, String)>,
+    delimited_string: String
+}
+
+impl <'a> ser::SerializeSeq for SerializerSeq<'a> {
+    type Error = Error;
+    type Ok = Option<String>;
+
+    fn serialize_element<T>(&mut self, value: &T) -> Result<()>
+    where
+        T: ? Sized + Serialize,
+    {
+        let root_key_name = self.root_key_name.clone().unwrap();
+        let mut serializer = Serializer::with_prefix(root_key_name, self.dst);
+        let value_string  = value.serialize(&mut serializer)?.unwrap_or_else(|| {
+            unimplemented!(
+                "Sequence serializer for elements of type {} is not suppoted",
+                std::any::type_name::<T>(),
+            )
+        });
+
+        self.delimited_string.push_str(&value_string);
+        self.delimited_string.push(SEQ_ELEMENT_SEPARATOR);
         Ok(())
     }
+    
+    fn end(self) -> Result<Self::Ok> {
+        self.dst.push((
+            self.root_key_name.unwrap(),
+            self.delimited_string
+        ));
+        Ok(None)
+    }
 }
 
 impl<'a> Serializer<'a> {
@@ -387,6 +345,17 @@ impl<'a> Serializer<'a> {
     }
 }
 
+impl<'a> SerializerSeq<'a> {
+    /// Create a new instance of the `SerializerSeq` struct
+    pub fn new(root_key_name: Option<String>, dst: &'a mut Vec<(String, String)>) -> Self {
+        Self {
+            root_key_name: root_key_name,
+            dst,
+            delimited_string: String::new()
+        }
+    }
+}
+
 #[doc(hidden)]
 /// Helper macro when implementing the `Serializer` part of a new data
 /// format for Serde.
@@ -587,7 +556,7 @@ mod tests {
     };
 
     use super::*;
-    use crate::{metadata, DriverConfig, KmdfConfig, UmdfConfig};
+    use crate::metadata::{self, driver_install::DriverInstall, driver_settings::{DriverConfig, KmdfConfig, UmdfConfig}};
 
     #[test]
     fn test_kmdf() {
@@ -597,6 +566,7 @@ mod tests {
                 target_kmdf_version_minor: 23,
                 minimum_kmdf_version_minor: Some(21),
             }),
+            driver_install: Default::default(),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -615,6 +585,7 @@ mod tests {
                 target_kmdf_version_minor: 23,
                 minimum_kmdf_version_minor: None,
             }),
+            driver_install: Default::default(),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -635,6 +606,7 @@ mod tests {
                 target_kmdf_version_minor: 33,
                 minimum_kmdf_version_minor: Some(31),
             }),
+            driver_install: Default::default(),
         };
 
         let output =
@@ -666,6 +638,7 @@ mod tests {
                 target_kmdf_version_minor: 33,
                 minimum_kmdf_version_minor: Some(31),
             }),
+            driver_install: Default::default(),
         };
 
         let output = to_map::<HashMap<_, _>>(&wdk_metadata).unwrap();
@@ -684,6 +657,7 @@ mod tests {
                 target_umdf_version_minor: 23,
                 minimum_umdf_version_minor: Some(21),
             }),
+            driver_install: Default::default(),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -702,6 +676,7 @@ mod tests {
                 target_umdf_version_minor: 23,
                 minimum_umdf_version_minor: None,
             }),
+            driver_install: Default::default(),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -718,6 +693,7 @@ mod tests {
     fn test_wdm() {
         let wdk_metadata = metadata::Wdk {
             driver_model: DriverConfig::Wdm,
+            driver_install: Default::default(),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -743,4 +719,60 @@ mod tests {
             } if key == "KEY_NAME" && value_1 == "VALUE_1" && value_2 == "VALUE_2"
         ));
     }
+
+    #[test]
+    fn test_package_files() {
+        let wdk_metadata = metadata::Wdk {
+            driver_model: DriverConfig::Wdm,
+            driver_install: DriverInstall {
+                package_files: vec![
+                    "file1.exe".to_string(),
+                    "file2.sys".to_string(),
+                    "file3.dll".to_string(),
+                ],
+            },
+        };
+
+        let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
+
+        assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
+        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], "file1.exe;file2.sys;file3.dll;");
+    }
+
+    #[test]
+    fn test_empty_package_files() {
+        let wdk_metadata = metadata::Wdk {
+            driver_model: DriverConfig::Wdm,
+            driver_install: DriverInstall {
+                package_files: vec![],
+            },
+        };
+
+        let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
+
+        assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
+        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], "");
+    }
+
+    #[derive(Serialize)]
+    struct UnsupportedSequenceStruct {
+        field1: u8,
+        field2: u8,
+    }
+    #[derive(Serialize)]
+    struct UnsupportedSequenceParentStruct {
+        sequence: Vec<UnsupportedSequenceStruct>,
+    }
+    #[test]
+    #[should_panic(expected = "not implemented: Sequence serializer for elements of type &wdk_build::metadata::ser::tests::UnsupportedSequenceStruct is not suppoted")]
+    fn test_unsupported_seq() {
+        let unsuppoted_struct = UnsupportedSequenceParentStruct {
+            sequence: vec![
+                UnsupportedSequenceStruct { field1: 1, field2: 2 },
+                UnsupportedSequenceStruct { field1: 3, field2: 4 },
+            ],
+        };
+
+        let _output = to_map::<BTreeMap<_, _>>(&unsuppoted_struct).unwrap();
+    }
 }

From 0da277954b6d532b32779513e07789a1fa057b51 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Thu, 7 Nov 2024 16:19:57 -0800
Subject: [PATCH 02/14] fix: resolve cargo clippy warnings

---
 crates/wdk-build/src/lib.rs                    |  2 +-
 .../wdk-build/src/metadata/driver_install.rs   | 15 ++++++---------
 .../wdk-build/src/metadata/driver_settings.rs  |  5 +++++
 crates/wdk-build/src/metadata/mod.rs           |  4 ++--
 crates/wdk-build/src/metadata/ser.rs           | 18 +++++++-----------
 crates/wdk-sys/build.rs                        |  4 +---
 6 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index a038403a..20ea36d9 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -138,7 +138,7 @@ impl Default for Config {
             ),
             driver_config: DriverConfig::Wdm,
             cpu_architecture: utils::detect_cpu_architecture_in_build_script(),
-            driver_install: Default::default(),
+            driver_install: DriverInstall::default(),
         }
     }
 }
diff --git a/crates/wdk-build/src/metadata/driver_install.rs b/crates/wdk-build/src/metadata/driver_install.rs
index 92489f19..b48677d2 100644
--- a/crates/wdk-build/src/metadata/driver_install.rs
+++ b/crates/wdk-build/src/metadata/driver_install.rs
@@ -1,10 +1,15 @@
 // Copyright (c) Microsoft Corporation
 // License: MIT OR Apache-2.0
 
+//! Types for the `DriverInstall` section of the `metadata.wdk` section of the `Cargo.toml`
+//!
+//! This section is used to specify files to be installed with the driver package.
+//! This corresponds with the settings in the `Driver Install` property pages
+
 use serde::{Deserialize, Serialize};
 
 /// The `DRIVER_INSTALL` section of the `metadata.wdk` section of the `Cargo.toml`
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Default)]
 #[serde(
     deny_unknown_fields,
     rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "kebab-case")
@@ -14,14 +19,6 @@ pub struct DriverInstall {
     pub package_files: Vec<String>
 }
 
-impl Default for DriverInstall {
-    fn default() -> Self {
-        Self {
-            package_files: Vec::new()
-        }
-    }
-}
-
 impl DriverInstall {
    /// Creates a new [`DriverInstall`] with default values
    #[must_use]
diff --git a/crates/wdk-build/src/metadata/driver_settings.rs b/crates/wdk-build/src/metadata/driver_settings.rs
index f9c8a532..156db16e 100644
--- a/crates/wdk-build/src/metadata/driver_settings.rs
+++ b/crates/wdk-build/src/metadata/driver_settings.rs
@@ -1,6 +1,11 @@
 // Copyright (c) Microsoft Corporation
 // License: MIT OR Apache-2.0
 
+//! Types for the `DriverConfig` section of the `metadata.wdk` section of the `Cargo.toml`
+//! 
+//! This section is used to specify the driver type and its associated configuration parameters.
+//! This corresponds with the settings in the `Driver Model` property pages
+
 use serde::{Deserialize, Serialize};
 
 /// The driver type with its associated configuration parameters
diff --git a/crates/wdk-build/src/metadata/mod.rs b/crates/wdk-build/src/metadata/mod.rs
index c9182598..128e29fe 100644
--- a/crates/wdk-build/src/metadata/mod.rs
+++ b/crates/wdk-build/src/metadata/mod.rs
@@ -14,8 +14,8 @@ pub use map::Map;
 pub use ser::{to_map, to_map_with_prefix, Serializer};
 
 pub(crate) mod ser;
-pub(crate) mod driver_install;
-pub(crate) mod driver_settings;
+pub mod driver_install;
+pub mod driver_settings;
 
 mod error;
 mod map;
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index f55e4bb2..5ce603b0 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -2,8 +2,7 @@
 // License: MIT OR Apache-2.0
 
 use serde::{
-    ser::{self, Impossible},
-    Serialize,
+    ser::{self, Impossible}, Serialize
 };
 
 use super::{
@@ -271,14 +270,11 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer<'a> {
         let mut serializer = Serializer::with_prefix(new_root_key_name.clone(), self.dst);
         let value_string  = value.serialize(&mut serializer)?;
        
-        match value_string {
-            Some(value_string) => {
-                self.dst.push((
-                    new_root_key_name,
-                    value_string,
-                ));
-            }
-            None => {}
+        if let Some(value_string) = value_string {
+            self.dst.push((
+                new_root_key_name,
+                value_string,
+            ));
         }
 
         Ok(())
@@ -349,7 +345,7 @@ impl<'a> SerializerSeq<'a> {
     /// Create a new instance of the `SerializerSeq` struct
     pub fn new(root_key_name: Option<String>, dst: &'a mut Vec<(String, String)>) -> Self {
         Self {
-            root_key_name: root_key_name,
+            root_key_name,
             dst,
             delimited_string: String::new()
         }
diff --git a/crates/wdk-sys/build.rs b/crates/wdk-sys/build.rs
index 37f350f3..7d4f73f7 100644
--- a/crates/wdk-sys/build.rs
+++ b/crates/wdk-sys/build.rs
@@ -26,9 +26,7 @@ use wdk_build::{
     BuilderExt,
     Config,
     ConfigError,
-    DriverConfig,
-    KmdfConfig,
-    UmdfConfig,
+    metadata::driver_settings::{DriverConfig, KmdfConfig, UmdfConfig},
 };
 
 const NUM_WDF_FUNCTIONS_PLACEHOLDER: &str =

From 161e5fbfede6b2ece65e91ce1e077b37fe76f9b5 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Fri, 8 Nov 2024 17:02:46 -0800
Subject: [PATCH 03/14] Cargo Make working for INF only driver.

---
 Cargo.toml                                    |   1 +
 crates/wdk-build/rust-driver-makefile.toml    |  90 ++++++++++++++++++
 crates/wdk-build/src/cargo_make.rs            |  30 ++++++
 crates/wdk-build/src/lib.rs                   |  13 ++-
 .../wdk-build/src/metadata/driver_settings.rs |   4 +
 crates/wdk-build/src/metadata/ser.rs          |  36 +++++--
 crates/wdk-sys/build.rs                       |   1 +
 examples/Makefile.toml                        |   1 +
 examples/sample-null-driver/Cargo.lock        |   7 ++
 examples/sample-null-driver/Cargo.toml        |  61 ++++++++++++
 examples/sample-null-driver/Makefile.toml     |   4 +
 examples/sample-null-driver/README.md         |  41 ++++++++
 .../sample-null-driver/sample_null_driver.inx | Bin 0 -> 3480 bytes
 examples/sample-null-driver/src/lib.rs        |   0
 14 files changed, 281 insertions(+), 8 deletions(-)
 create mode 100644 examples/sample-null-driver/Cargo.lock
 create mode 100644 examples/sample-null-driver/Cargo.toml
 create mode 100644 examples/sample-null-driver/Makefile.toml
 create mode 100644 examples/sample-null-driver/README.md
 create mode 100644 examples/sample-null-driver/sample_null_driver.inx
 create mode 100644 examples/sample-null-driver/src/lib.rs

diff --git a/Cargo.toml b/Cargo.toml
index 8254e142..b51c26f9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,6 +6,7 @@ exclude = [
   "examples/sample-kmdf-driver",
   "examples/sample-umdf-driver",
   "examples/sample-wdm-driver",
+  "examples/sample-null-driver",
   "tests/config-kmdf",
   "tests/config-umdf",
   "tests/config-wdm",
diff --git a/crates/wdk-build/rust-driver-makefile.toml b/crates/wdk-build/rust-driver-makefile.toml
index 903af810..398fcae9 100644
--- a/crates/wdk-build/rust-driver-makefile.toml
+++ b/crates/wdk-build/rust-driver-makefile.toml
@@ -303,6 +303,24 @@ args = [
 private = true
 dependencies = ["setup-wdk-config-env-vars", "generate-driver-binary-file"]
 env = { "WDK_BUILD_DRIVER_EXTENSION" = { source = "${WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE}", default_value = "UNKNOWN_EXTENSION", mapping = { "WDM" = "sys", "KMDF" = "sys", "UMDF" = "dll" } } }
+condition_script_runner_args = [
+  "--base-path",
+  "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}",
+]
+condition_script = '''
+#!@rust
+
+//! ```cargo
+//! [dependencies]
+//! wdk-build = { path = ".", version = "0.3.0" }
+//! anyhow = "1"
+//! ```
+#![allow(unused_doc_comments)]
+
+fn main() -> anyhow::Result<()> {
+    wdk_build::cargo_make::driver_model_is_not_package_condition_script()
+}
+'''
 script_runner = "@rust"
 script_runner_args = [
   "--base-path",
@@ -327,6 +345,24 @@ wdk_build::cargo_make::copy_to_driver_package_folder(
 [tasks.copy-pdb-to-package]
 private = true
 dependencies = ["build"]
+condition_script_runner_args = [
+  "--base-path",
+  "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}",
+]
+condition_script = '''
+#!@rust
+
+//! ```cargo
+//! [dependencies]
+//! wdk-build = { path = ".", version = "0.3.0" }
+//! anyhow = "1"
+//! ```
+#![allow(unused_doc_comments)]
+
+fn main() -> anyhow::Result<()> {
+    wdk_build::cargo_make::driver_model_is_not_package_condition_script()
+}
+'''
 script_runner = "@rust"
 script_runner_args = [
   "--base-path",
@@ -373,6 +409,24 @@ wdk_build::cargo_make::copy_to_driver_package_folder(
 [tasks.copy-map-to-package]
 private = true
 dependencies = ["build"]
+condition_script_runner_args = [
+  "--base-path",
+  "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}",
+]
+condition_script = '''
+#!@rust
+
+//! ```cargo
+//! [dependencies]
+//! wdk-build = { path = ".", version = "0.3.0" }
+//! anyhow = "1"
+//! ```
+#![allow(unused_doc_comments)]
+
+fn main() -> anyhow::Result<()> {
+    wdk_build::cargo_make::driver_model_is_not_package_condition_script()
+}
+'''
 script_runner = "@rust"
 script_runner_args = [
   "--base-path",
@@ -474,6 +528,24 @@ args = [
 [tasks.sign-driver-binary]
 private = true
 dependencies = ["setup-wdk-config-env-vars", "copy-driver-binary-to-package"]
+condition_script_runner_args = [
+  "--base-path",
+  "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}",
+]
+condition_script = '''
+#!@rust
+
+//! ```cargo
+//! [dependencies]
+//! wdk-build = { path = ".", version = "0.3.0" }
+//! anyhow = "1"
+//! ```
+#![allow(unused_doc_comments)]
+
+fn main() -> anyhow::Result<()> {
+    wdk_build::cargo_make::driver_model_is_not_package_condition_script()
+}
+'''
 env = { "WDK_BUILD_SIGNTOOL_SIGN_INPUT_FILE" = "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package/${CARGO_MAKE_CRATE_FS_NAME}.${WDK_BUILD_DRIVER_EXTENSION}" }
 run_task = "signtool-sign"
 
@@ -492,6 +564,24 @@ args = ["verify", "/v", "/pa", "${WDK_BUILD_SIGNTOOL_VERIFY_INPUT_FILE}"]
 [tasks.verify-signature-driver-binary]
 private = true
 dependencies = ["setup-wdk-config-env-vars", "sign-driver-binary"]
+condition_script_runner_args = [
+  "--base-path",
+  "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}",
+]
+condition_script = '''
+#!@rust
+
+//! ```cargo
+//! [dependencies]
+//! wdk-build = { path = ".", version = "0.3.0" }
+//! anyhow = "1"
+//! ```
+#![allow(unused_doc_comments)]
+
+fn main() -> anyhow::Result<()> {
+    wdk_build::cargo_make::driver_model_is_not_package_condition_script()
+}
+'''
 env = { "WDK_BUILD_SIGNTOOL_VERIFY_INPUT_FILE" = "${WDK_BUILD_OUTPUT_DIRECTORY}/${CARGO_MAKE_CRATE_FS_NAME}_package/${CARGO_MAKE_CRATE_FS_NAME}.${WDK_BUILD_DRIVER_EXTENSION}" }
 run_task = "signtool-verify"
 
diff --git a/crates/wdk-build/src/cargo_make.rs b/crates/wdk-build/src/cargo_make.rs
index 26be9942..fd14463e 100644
--- a/crates/wdk-build/src/cargo_make.rs
+++ b/crates/wdk-build/src/cargo_make.rs
@@ -65,6 +65,9 @@ const CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY_ENV_VAR: &str =
     "CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY";
 const CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR: &str = "CARGO_MAKE_CURRENT_TASK_NAME";
 
+/// The environment variable that cargo-make uses to store driver model type
+const WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR: &str = "WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE";
+
 /// `clap` uses an exit code of 2 for usage errors: <https://github.com/clap-rs/clap/blob/14fd853fb9c5b94e371170bbd0ca2bf28ef3abff/clap_builder/src/util/mod.rs#L30C18-L30C28>
 const CLAP_USAGE_EXIT_CODE: i32 = 2;
 
@@ -1106,6 +1109,33 @@ pub fn driver_sample_infverif_condition_script() -> anyhow::Result<()> {
     })
 }
 
+/// `cargo-make` condition script for driver flow tasks in
+/// [`rust-driver-makefile.toml`](../rust-driver-makefile.toml)
+///
+/// # Errors
+///
+/// This function returns an error whenever it determines that the
+/// the driver model is a package and the task should be skipped.
+///
+/// # Panics
+///
+/// Panics if `CARGO_MAKE_CURRENT_TASK_NAME` is not set in the environment
+/// Panics if `WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE` is not set in the environment
+pub fn driver_model_is_not_package_condition_script() -> anyhow::Result<()> {
+    condition_script(|| {
+        let driver_type = env::var(WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR).expect("A driver type should exist in the WDK build metadata");
+        if driver_type == "PACKAGE" {
+            // cargo_make will interpret returning an error from the rust-script
+            // condition_script as skipping the task
+            return Err::<(), anyhow::Error>(anyhow::Error::msg(format!(
+                "Skipping {}  task The driver model is a package.",
+                env::var(CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR).expect("CARGO_MAKE_CURRENT_TASK_NAME should be set by cargo-make")
+            )));
+        }
+        Ok(())
+    })
+}
+
 #[cfg(test)]
 mod tests {
     use crate::ConfigError;
diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index 20ea36d9..a522ad50 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -288,6 +288,7 @@ impl Config {
         let km_or_um_include_path = windows_sdk_include_path.join(match self.driver_config {
             DriverConfig::Wdm | DriverConfig::Kmdf(_) => "km",
             DriverConfig::Umdf(_) => "um",
+            DriverConfig::Package => unreachable!()
         });
         if !km_or_um_include_path.is_dir() {
             return Err(ConfigError::DirectoryNotFound {
@@ -346,7 +347,8 @@ impl Config {
                         .canonicalize()?
                         .strip_extended_length_path_prefix()?,
                 );
-            }
+            },
+            DriverConfig::Package => {}
         }
 
         Ok(include_paths)
@@ -380,6 +382,7 @@ impl Config {
                     DriverConfig::Umdf(_) => {
                         format!("um/{}", self.cpu_architecture.as_windows_str(),)
                     }
+                    DriverConfig::Package => unreachable!()
                 });
         if !windows_sdk_library_path.is_dir() {
             return Err(ConfigError::DirectoryNotFound {
@@ -430,7 +433,8 @@ impl Config {
                         .canonicalize()?
                         .strip_extended_length_path_prefix()?,
                 );
-            }
+            },
+            DriverConfig::Package => (),
         }
 
         // Reverse order of library paths so that paths pushed later into the vec take
@@ -527,6 +531,9 @@ impl Config {
 
                     umdf_definitions
                 }
+                DriverConfig::Package => {
+                    vec![]
+                }
             }
             .into_iter()
             .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))),
@@ -588,6 +595,7 @@ impl Config {
                 (config.umdf_version_major, config.target_umdf_version_minor)
             }
             DriverConfig::Wdm => return None,
+            DriverConfig::Package => unreachable!(),
         };
 
         Some(format!(
@@ -682,6 +690,7 @@ impl Config {
                 // Linker arguments derived from WindowsDriver.UserMode.props in Ni(22H2) WDK
                 println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:WINDOWS");
             }
+            DriverConfig::Package => unreachable!(),
         }
 
         // Emit linker arguments common to all configs
diff --git a/crates/wdk-build/src/metadata/driver_settings.rs b/crates/wdk-build/src/metadata/driver_settings.rs
index 156db16e..bcd0256a 100644
--- a/crates/wdk-build/src/metadata/driver_settings.rs
+++ b/crates/wdk-build/src/metadata/driver_settings.rs
@@ -23,6 +23,8 @@ pub enum DriverConfig {
     Kmdf(KmdfConfig),
     /// User Mode Driver Framework
     Umdf(UmdfConfig),
+    /// INF only drivers e.g. null drivers and extension INFs
+    Package
 }
 
 /// Private enum identical to [`DriverConfig`] but with different tag name to
@@ -42,6 +44,7 @@ enum DeserializableDriverConfig {
     Wdm,
     Kmdf(KmdfConfig),
     Umdf(UmdfConfig),
+    Package
 }
 
 /// The configuration parameters for KMDF drivers
@@ -80,6 +83,7 @@ impl From<DeserializableDriverConfig> for DriverConfig {
             DeserializableDriverConfig::Wdm => Self::Wdm,
             DeserializableDriverConfig::Kmdf(kmdf_config) => Self::Kmdf(kmdf_config),
             DeserializableDriverConfig::Umdf(umdf_config) => Self::Umdf(umdf_config),
+            DeserializableDriverConfig::Package => Self::Package,
         }
     }
 }
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index 5ce603b0..568bb164 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -718,21 +718,45 @@ mod tests {
 
     #[test]
     fn test_package_files() {
+        let package_files = vec![
+            "file1.exe".to_string(),
+            "file2.sys".to_string(),
+            "file3.dll".to_string(),
+        ];
+
+        let wdk_metadata = metadata::Wdk {
+            driver_model: DriverConfig::Wdm,
+            driver_install: DriverInstall {
+                package_files: package_files.clone(),
+            },
+        };
+
+        let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
+
+        assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
+        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";") + ";");
+    }
+
+    #[test]
+    fn test_diverse_package_files() {
+        let package_files = vec![
+            "typical.exe".to_string(),
+            "with whitespace.sys".to_string(),
+            "underscored_file_.dll".to_string(),
+            "noextension".to_string(),
+        ];
+
         let wdk_metadata = metadata::Wdk {
             driver_model: DriverConfig::Wdm,
             driver_install: DriverInstall {
-                package_files: vec![
-                    "file1.exe".to_string(),
-                    "file2.sys".to_string(),
-                    "file3.dll".to_string(),
-                ],
+                package_files: package_files.clone(),
             },
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
 
         assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
-        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], "file1.exe;file2.sys;file3.dll;");
+        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";") + ";");
     }
 
     #[test]
diff --git a/crates/wdk-sys/build.rs b/crates/wdk-sys/build.rs
index 7d4f73f7..1ee0a391 100644
--- a/crates/wdk-sys/build.rs
+++ b/crates/wdk-sys/build.rs
@@ -222,6 +222,7 @@ fn generate_base(out_path: &Path, config: &Config) -> Result<(), ConfigError> {
     let outfile_name = match &config.driver_config {
         DriverConfig::Wdm | DriverConfig::Kmdf(_) => "ntddk.rs",
         DriverConfig::Umdf(_) => "windows.rs",
+        DriverConfig::Package => unreachable!("Package driver should not be running binary build"),
     };
     info!("Generating bindings to WDK: {outfile_name}.rs");
 
diff --git a/examples/Makefile.toml b/examples/Makefile.toml
index 4bced674..b1c360ef 100644
--- a/examples/Makefile.toml
+++ b/examples/Makefile.toml
@@ -6,4 +6,5 @@ CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = [
   "sample-kmdf-driver",
   "sample-umdf-driver",
   "sample-wdm-driver",
+  "sample-null-driver",
 ]
diff --git a/examples/sample-null-driver/Cargo.lock b/examples/sample-null-driver/Cargo.lock
new file mode 100644
index 00000000..33496518
--- /dev/null
+++ b/examples/sample-null-driver/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "sample-null-driver"
+version = "0.1.0"
diff --git a/examples/sample-null-driver/Cargo.toml b/examples/sample-null-driver/Cargo.toml
new file mode 100644
index 00000000..f181f3ab
--- /dev/null
+++ b/examples/sample-null-driver/Cargo.toml
@@ -0,0 +1,61 @@
+[package]
+edition = "2021"
+name = "sample-null-driver"
+version = "0.1.0"
+description = "A sample NULL driver that demonstrates compiling NULL drivers in RUST"
+repository = "https://github.com/microsoft/windows-drivers-rs"
+readme = "README.md"
+license = "MIT OR Apache-2.0"
+keywords = ["windows", "driver", "sample", "example"]
+categories = ["hardware-support"]
+publish = false
+
+[package.metadata.wdk.driver-model]
+driver-type = "PACKAGE"
+
+[package.metadata.wdk.driver-install]
+package-files = []
+
+[lib]
+crate-type = ["cdylib"]
+
+[build-dependencies]
+
+[dependencies]
+
+[features]
+default = []
+
+[profile.dev]
+panic = "abort"
+lto = true
+
+[profile.release]
+panic = "abort"
+lto = true
+
+[lints.rust]
+missing_docs = "warn"
+unsafe_op_in_unsafe_fn = "forbid"
+
+[lints.clippy]
+# Lint Groups
+all = { level = "deny", priority = -1 }
+pedantic = { level = "warn", priority = -1 }
+nursery = { level = "warn", priority = -1 }
+cargo = { level = "warn", priority = -1 }
+# Individual Lints
+multiple_unsafe_ops_per_block = "forbid"
+undocumented_unsafe_blocks = "forbid"
+unnecessary_safety_doc = "forbid"
+
+[lints.rustdoc]
+bare_urls = "warn"
+broken_intra_doc_links = "warn"
+invalid_codeblock_attributes = "warn"
+invalid_html_tags = "warn"
+invalid_rust_codeblocks = "warn"
+missing_crate_level_docs = "warn"
+private_intra_doc_links = "warn"
+redundant_explicit_links = "warn"
+unescaped_backticks = "warn"
diff --git a/examples/sample-null-driver/Makefile.toml b/examples/sample-null-driver/Makefile.toml
new file mode 100644
index 00000000..be118bb4
--- /dev/null
+++ b/examples/sample-null-driver/Makefile.toml
@@ -0,0 +1,4 @@
+extend = [
+  { path = "../../crates/wdk-build/rust-driver-makefile.toml" },
+  { path = "../../crates/wdk-build/rust-driver-sample-makefile.toml" },
+]
diff --git a/examples/sample-null-driver/README.md b/examples/sample-null-driver/README.md
new file mode 100644
index 00000000..a6a6e79e
--- /dev/null
+++ b/examples/sample-null-driver/README.md
@@ -0,0 +1,41 @@
+# Sample NULL Rust Driver
+
+## Pre-requisites
+
+* WDK environment (either via eWDK or installed WDK)
+* LLVM
+
+## Build
+
+* Run `cargo make` in this directory
+
+## Install
+
+1. Copy the following to the DUT (Device Under Test: the computer you want to test the driver on):
+   1. The driver `package` folder located in the [Cargo Output Directory](https://doc.rust-lang.org/cargo/guide/build-cache.html). The Cargo Output Directory changes based off of build profile, target architecture, etc.
+     * Ex. `<REPO_ROOT>\target\x86_64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\x86_64-pc-windows-msvc\release\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\debug\package`, `<REPO_ROOT>\target\aarch64-pc-windows-msvc\release\package`,
+     `<REPO_ROOT>\target\debug\package`,
+     `<REPO_ROOT>\target\release\package`
+   2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT
+     * Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment
+2. Install the Certificate on the DUT:
+   1. Double click the certificate
+   2. Click Install Certificate
+   3. Store Location: Local Machine -> Next
+   4. Place all certificates in the following Store -> Browse -> Trusted Root Certification Authorities -> Ok -> Next
+   5. Repeat 2-4 for Store -> Browse -> Trusted Publishers -> Ok -> Next
+   6. Finish
+3. Install the driver:
+   * In the package directory, run: `pnputil.exe /add-driver sample_kmdf_driver.inf /install`
+4. Create a software device:
+   * In the directory that `devgen.exe` was copied to, run: `devgen.exe /add /hardwareid "root\SAMPLE_KMDF_HW_ID"`
+
+## Test
+
+* To capture prints:
+  * Start [DebugView](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview)
+    1. Enable `Capture Kernel`
+    2. Enable `Enable Verbose Kernel Output`
+  * Alternatively, you can see prints in an active Windbg session.
+    1. Attach WinDBG
+    2. `ed nt!Kd_DEFAULT_Mask 0xFFFFFFFF`
diff --git a/examples/sample-null-driver/sample_null_driver.inx b/examples/sample-null-driver/sample_null_driver.inx
new file mode 100644
index 0000000000000000000000000000000000000000..23f3dcd8c1f6a90e626ab2021a4fe6149cc6abee
GIT binary patch
literal 3480
zcmd6qT~8ZF6o$`rrTzzt)>0w`3*)p&6mdZ@EmrxGm!=oAvK&KFRDvU~NsFTV^|a4B
zXNQ?xQ`c}6jn+FmbLM=!=VOll`TWwhzKHR)ePu7LWrdCHoxQh9JLl`ru9;mj>)XsO
z>;tPai?lm7h4LosytO}U4&5W0*kj%YP*2#ITFLV!?1_HH3H^>)xnOoxar<&mkaef_
zDp*=pI{qHCEckkh#?t*78-$R?7SEb}Yron6#QJu`tYGcXPFP(FXLmqx3>IZL;pgJn
z9CJxev_B!|!p^EQlJn7?^4+uVk^aJ-F<)oavrYSsS(h>4d);1x`Gl`^+py<68&JGv
zr^~Fz?{oVU^g0ec`VgeZw^1|6YFl%+z;eaG6*#o3^H+FuA5Tu~Pi&vsU+g+2-9X`Z
z_K{r%pF4i;`#!v8tUJD<c>_v{xjDT2gwsThy^LppH2Fami>gF}64VvJI_q4!l{W2L
zngOVF(f>&pYn6vw&%1g42zO;f<SANZ%l}7hEAwWH^XF(ABY&0iQGz78hABD*AT3PC
z=yn-mz%Aa!zB6z+$4gtaj812VVK;HjW3Wl(T=(o}8&;TY@NQ?8Ma(@W66FAEmE%Hs
zod}KcR>iJv;Y09?5>Kf}V>G!A5hfpa2G6P}X@k=o)DGBJYzsFbd&SxqEYGmO^LZN-
zc5IK#?u2aWkWrm5x@6@hS^47D&eH`hoqKR`+!eRyR9@9n#krzzQfZiKb*$7m?GqwY
z6?lpzzoE%C)*X|pyEa0LUzqJP+oM{Is9gP;*2_6BTH(6J8zJS(7JSpqQ6kCnIr-)8
zedi~tRb!<9nb|E)E%3^-Bi%QvWS!*7clSl1!<k%*ST8&y>w8|&?vhcblNS}8$2_ly
zJl!z`H_Hfr7K|g-3Vb?bcffoXYMseB%in&Jk66z&l;?Atl3yNn-u>p)SY5=J{vcL|
z`rT63BgM5esPCP?<2_pE=T+604ew=gR7TV<eIN3xxbHI`fSJ}@rt*D8t~BLIj_$+W
zQi-jqf2zyu!~XzJsV@-rC(MWZwt~!E<S9dE_)T?Ex9b$t+%n00h@H}4NL&n&co^Q&
zV8605_x=wdOJwy;km<L67fahzj53S=5!%HF(%lk!!46b6JTY!o&(_pQs3(f|+<(6%
z!Ru-4Kw@^?CpX-a8}@hTiPRVQ*bEjd>vtBTO=zv*%OiYy#QmnIo%3#T@eVM*Ulw^a
zSDg1Fc-C(r-GRb;j;wdcKjR(mhLX<PWyNmDJDn!)=C{kr^F8nU>-8b8qftuBz9CMd
l<fKo`>88B&y<GB;h?AxI_mQ|Z`{`zNN!-(HxtvAr{{l(z@GSrU

literal 0
HcmV?d00001

diff --git a/examples/sample-null-driver/src/lib.rs b/examples/sample-null-driver/src/lib.rs
new file mode 100644
index 00000000..e69de29b

From d796125309330bba2a142a4dd4949df2a14562c9 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 13 Nov 2024 16:12:13 -0800
Subject: [PATCH 04/14] Add cargo make task to copy package files to driver
 package folder.

---
 crates/wdk-build/rust-driver-makefile.toml    |  19 ++++++
 crates/wdk-build/src/cargo_make.rs            |  25 +++++++
 crates/wdk-build/src/lib.rs                   |  61 ++++++++++++++----
 crates/wdk-build/src/metadata/mod.rs          |   2 +-
 crates/wdk-build/src/metadata/ser.rs          |  25 ++++---
 .../sample-null-driver/sample_null_driver.inx | Bin 3480 -> 3600 bytes
 6 files changed, 111 insertions(+), 21 deletions(-)

diff --git a/crates/wdk-build/rust-driver-makefile.toml b/crates/wdk-build/rust-driver-makefile.toml
index 398fcae9..44e711c6 100644
--- a/crates/wdk-build/rust-driver-makefile.toml
+++ b/crates/wdk-build/rust-driver-makefile.toml
@@ -447,6 +447,24 @@ wdk_build::cargo_make::copy_to_driver_package_folder(
 )?
 '''
 
+[tasks.copy-package-files-to-package]
+private = true
+script_runner = "@rust"
+script_runner_args = [
+  "--base-path",
+  "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}",
+]
+script = '''
+//! ```cargo
+//! [dependencies]
+//! wdk-build = { path = ".", version = "0.3.0" }
+//! ```
+#![allow(unused_doc_comments)]
+
+wdk_build::cargo_make::copy_package_files_to_driver_package_folder()?
+'''
+
+
 [tasks.inf2cat]
 private = true
 dependencies = ["copy-driver-binary-to-package", "copy-inf-to-package"]
@@ -599,6 +617,7 @@ dependencies = [
   "copy-inf-to-package",
   "copy-map-to-package",
   "copy-certificate-to-package",
+  "copy-package-files-to-package",
   "sign-driver-binary",
   "verify-signature-driver-binary",
   "sign-cat",
diff --git a/crates/wdk-build/src/cargo_make.rs b/crates/wdk-build/src/cargo_make.rs
index fd14463e..222f3f30 100644
--- a/crates/wdk-build/src/cargo_make.rs
+++ b/crates/wdk-build/src/cargo_make.rs
@@ -68,6 +68,9 @@ const CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR: &str = "CARGO_MAKE_CURRENT_TASK_NAME
 /// The environment variable that cargo-make uses to store driver model type
 const WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR: &str = "WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE";
 
+/// The environment variable that cargo-make uses to store additional files to be pacakaged with the driver
+const WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR: &str = "WDK_BUILD_METADATA-DRIVER_INSTALL-PACKAGE_FILES";
+
 /// `clap` uses an exit code of 2 for usage errors: <https://github.com/clap-rs/clap/blob/14fd853fb9c5b94e371170bbd0ca2bf28ef3abff/clap_builder/src/util/mod.rs#L30C18-L30C28>
 const CLAP_USAGE_EXIT_CODE: i32 = 2;
 
@@ -728,6 +731,7 @@ pub fn copy_to_driver_package_folder<P: AsRef<Path>>(path_to_copy: P) -> Result<
         std::fs::create_dir(&package_folder_path)?;
     }
 
+    eprintln!("Copying {:?} to {:?}", path_to_copy, package_folder_path);
     let destination_path = package_folder_path.join(
         path_to_copy
             .file_name()
@@ -1136,6 +1140,27 @@ pub fn driver_model_is_not_package_condition_script() -> anyhow::Result<()> {
     })
 }
 
+/// Copy the addition files specified in the wdk metadata to the  Driver Package folder
+///
+/// # Panics
+/// 
+/// Panics if `WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES` is not set in the environment
+pub fn copy_package_files_to_driver_package_folder() -> Result<(), ConfigError> {
+    let package_files: Vec<PathBuf>  = env::var(WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR)
+        .expect("The package files should be set by the wdk-build-init task")
+        .split_terminator(metadata::ser::SEQ_ELEMENT_SEPARATOR)
+        .map(PathBuf::from)
+        .collect();
+
+    package_files
+        .iter()
+        .try_for_each(|package_file|{
+            copy_to_driver_package_folder(package_file.as_path())
+        })?;
+    
+    Ok(())
+}
+
 #[cfg(test)]
 mod tests {
     use crate::ConfigError;
diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index a522ad50..5e25ba33 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -42,7 +42,7 @@ pub struct Config {
     /// Build configuration of driver
     pub driver_config: DriverConfig,
     /// Driver installation settings
-    pub driver_install: DriverInstall
+    pub driver_install: Option<DriverInstall>
 }
 
 /// The CPU architecture that's configured to be compiled for
@@ -126,6 +126,11 @@ rustflags = [\"-C\", \"target-feature=+crt-static\"]
     /// [`metadata::Wdk`]
     #[error(transparent)]
     SerdeError(#[from] metadata::Error),
+
+
+    /// Error returned when wdk build runs for [`metadata::driver_settings::DriverConfig::Package`]
+    #[error("Package driver type does not support building binaries. It should be used for null drivers and extension infs only.")]
+    PackageDriverTypeBuildNotSupported,
 }
 
 impl Default for Config {
@@ -138,7 +143,7 @@ impl Default for Config {
             ),
             driver_config: DriverConfig::Wdm,
             cpu_architecture: utils::detect_cpu_architecture_in_build_script(),
-            driver_install: DriverInstall::default(),
+            driver_install: None,
         }
     }
 }
@@ -232,7 +237,7 @@ impl Config {
         let serialized_wdk_metadata_map =
             metadata::to_map::<std::collections::BTreeMap<_, _>>(&metadata::Wdk {
                 driver_model: self.driver_config.clone(),
-                driver_install: self.driver_install.clone()
+                driver_install: self.driver_install.clone(),
             })?;
 
         for cfg_key in EXPORTED_CFG_SETTINGS.iter().map(|(key, _)| *key) {
@@ -288,7 +293,9 @@ impl Config {
         let km_or_um_include_path = windows_sdk_include_path.join(match self.driver_config {
             DriverConfig::Wdm | DriverConfig::Kmdf(_) => "km",
             DriverConfig::Umdf(_) => "um",
-            DriverConfig::Package => unreachable!()
+            DriverConfig::Package => {
+                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+            },
         });
         if !km_or_um_include_path.is_dir() {
             return Err(ConfigError::DirectoryNotFound {
@@ -348,7 +355,9 @@ impl Config {
                         .strip_extended_length_path_prefix()?,
                 );
             },
-            DriverConfig::Package => {}
+            DriverConfig::Package => {
+                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+            },
         }
 
         Ok(include_paths)
@@ -382,7 +391,9 @@ impl Config {
                     DriverConfig::Umdf(_) => {
                         format!("um/{}", self.cpu_architecture.as_windows_str(),)
                     }
-                    DriverConfig::Package => unreachable!()
+                    DriverConfig::Package => {
+                        return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+                    },
                 });
         if !windows_sdk_library_path.is_dir() {
             return Err(ConfigError::DirectoryNotFound {
@@ -434,7 +445,9 @@ impl Config {
                         .strip_extended_length_path_prefix()?,
                 );
             },
-            DriverConfig::Package => (),
+            DriverConfig::Package => {
+                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+            },
         }
 
         // Reverse order of library paths so that paths pushed later into the vec take
@@ -531,9 +544,7 @@ impl Config {
 
                     umdf_definitions
                 }
-                DriverConfig::Package => {
-                    vec![]
-                }
+                DriverConfig::Package => unreachable!()
             }
             .into_iter()
             .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))),
@@ -690,7 +701,9 @@ impl Config {
                 // Linker arguments derived from WindowsDriver.UserMode.props in Ni(22H2) WDK
                 println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:WINDOWS");
             }
-            DriverConfig::Package => unreachable!(),
+            DriverConfig::Package => {
+                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+            },
         }
 
         // Emit linker arguments common to all configs
@@ -1058,6 +1071,21 @@ mod tests {
         assert_eq!(config.cpu_architecture, CpuArchitecture::Arm64);
     }
 
+    #[test]
+    fn package_config() {
+        let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "aarch64")], || Config {
+            driver_config: DriverConfig::Package,
+            ..Config::default()
+        });
+
+        #[cfg(nightly_toolchain)]
+        assert_matches!(
+            config.driver_config,
+            DriverConfig::Package
+        );
+        assert_eq!(config.cpu_architecture, CpuArchitecture::Arm64);
+    }
+
     #[test]
     fn test_try_from_cargo_str() {
         assert_eq!(
@@ -1118,5 +1146,16 @@ mod tests {
 
             assert_eq!(result, None);
         }
+
+        #[test]
+        #[should_panic]
+        fn package() {
+            let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config {
+                driver_config: DriverConfig::Package,
+                ..Default::default()
+            });
+
+            let _ = config.compute_wdffunctions_symbol_name();
+        }
     }
 }
diff --git a/crates/wdk-build/src/metadata/mod.rs b/crates/wdk-build/src/metadata/mod.rs
index 128e29fe..4a3ea21e 100644
--- a/crates/wdk-build/src/metadata/mod.rs
+++ b/crates/wdk-build/src/metadata/mod.rs
@@ -44,7 +44,7 @@ pub struct Wdk {
     /// Metadata corresponding to the `Driver Model` property page in the WDK
     pub driver_model: DriverConfig,
     /// Metadata corresponding to the `Driver Install` property page in the WDK
-    pub driver_install: DriverInstall
+    pub driver_install: Option<DriverInstall>
 }
 
 /// Errors that could result from trying to construct a
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index 568bb164..79233488 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -314,9 +314,16 @@ impl <'a> ser::SerializeSeq for SerializerSeq<'a> {
     }
     
     fn end(self) -> Result<Self::Ok> {
+        // Remove the trailing delimiter.
+        let delimited_string = if self.delimited_string.is_empty() {
+            String::new()
+        } else {
+            self.delimited_string[..self.delimited_string.len() - 1].to_string()
+        };
+
         self.dst.push((
             self.root_key_name.unwrap(),
-            self.delimited_string
+            delimited_string,
         ));
         Ok(None)
     }
@@ -726,15 +733,15 @@ mod tests {
 
         let wdk_metadata = metadata::Wdk {
             driver_model: DriverConfig::Wdm,
-            driver_install: DriverInstall {
+            driver_install: Some(DriverInstall {
                 package_files: package_files.clone(),
-            },
+            }),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
 
         assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
-        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";") + ";");
+        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";"));
     }
 
     #[test]
@@ -748,24 +755,24 @@ mod tests {
 
         let wdk_metadata = metadata::Wdk {
             driver_model: DriverConfig::Wdm,
-            driver_install: DriverInstall {
+            driver_install: Some(DriverInstall {
                 package_files: package_files.clone(),
-            },
+            }),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
 
         assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
-        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";") + ";");
+        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";"));
     }
 
     #[test]
     fn test_empty_package_files() {
         let wdk_metadata = metadata::Wdk {
             driver_model: DriverConfig::Wdm,
-            driver_install: DriverInstall {
+            driver_install: Some(DriverInstall {
                 package_files: vec![],
-            },
+            }),
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
diff --git a/examples/sample-null-driver/sample_null_driver.inx b/examples/sample-null-driver/sample_null_driver.inx
index 23f3dcd8c1f6a90e626ab2021a4fe6149cc6abee..0bd5636a7678542e2bf8476a5fec29d51da4ccbc 100644
GIT binary patch
delta 117
zcmbOsJwaxJ36r}yg9U>lgCT=6gE4~%kk$o~ra-nOkYxyjDL}R^gA-7d1%nHaWdMZE
zKy1R`2Gr*QRBOm!&S1E?nkk%%HJBllp=k0|9?eO-Cj1HvU@k)$LncEqL+a$yJZAwW
CU=+vz

delta 88
zcmbOrGedfV36r}CLkfd2gBe3AgC&DGkgW@388a9$m;zabK$r~V>oO!UqybrmK$Zc6
c1rQqmRU`pr41p|TAZf9=nkk%XvKQ|$0FaRm{{R30


From e23a9e5b0af52cb1c3b6e5104b04010e0e75cb20 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 13 Nov 2024 17:38:26 -0800
Subject: [PATCH 05/14] add sample null driver workspace with sample app and
 driver packages

---
 Cargo.lock                                    |  19 +++---
 Cargo.toml                                    |   1 +
 crates/wdk-build/Cargo.toml                   |   1 +
 crates/wdk-build/src/cargo_make.rs            |  16 ++++-
 crates/wdk-build/src/metadata/ser.rs          |   8 +--
 examples/sample-kmdf-driver/Cargo.lock        |  19 +++---
 .../sample-null-driver-workspace/Cargo.lock   |  11 ++++
 .../sample-null-driver-workspace/Cargo.toml   |  30 +++++++++
 .../README.md                                 |   0
 .../crates/driver}/Cargo.lock                 |   0
 .../crates/driver/Cargo.toml                  |  12 ++++
 .../crates/driver/Makefile.toml               |   4 ++
 .../crates/driver}/sample_null_driver.inx     | Bin 3600 -> 2524 bytes
 .../crates/driver}/src/lib.rs                 |   0
 .../crates/sample-app/Cargo.toml              |   6 ++
 .../crates/sample-app/src/main.rs             |   3 +
 examples/sample-null-driver/Cargo.toml        |  61 ------------------
 examples/sample-null-driver/Makefile.toml     |   4 --
 examples/sample-umdf-driver/Cargo.lock        |  19 +++---
 examples/sample-wdm-driver/Cargo.lock         |  19 +++---
 tests/config-kmdf/Cargo.lock                  |  19 +++---
 tests/config-umdf/Cargo.lock                  |  19 +++---
 tests/mixed-package-kmdf-workspace/Cargo.lock |  19 +++---
 tests/umdf-driver-workspace/Cargo.lock        |  19 +++---
 tests/wdk-sys-tests/Cargo.lock                |  19 +++---
 25 files changed, 173 insertions(+), 155 deletions(-)
 create mode 100644 examples/sample-null-driver-workspace/Cargo.lock
 create mode 100644 examples/sample-null-driver-workspace/Cargo.toml
 rename examples/{sample-null-driver => sample-null-driver-workspace}/README.md (100%)
 rename examples/{sample-null-driver => sample-null-driver-workspace/crates/driver}/Cargo.lock (100%)
 create mode 100644 examples/sample-null-driver-workspace/crates/driver/Cargo.toml
 create mode 100644 examples/sample-null-driver-workspace/crates/driver/Makefile.toml
 rename examples/{sample-null-driver => sample-null-driver-workspace/crates/driver}/sample_null_driver.inx (67%)
 rename examples/{sample-null-driver => sample-null-driver-workspace/crates/driver}/src/lib.rs (100%)
 create mode 100644 examples/sample-null-driver-workspace/crates/sample-app/Cargo.toml
 create mode 100644 examples/sample-null-driver-workspace/crates/sample-app/src/main.rs
 delete mode 100644 examples/sample-null-driver/Cargo.toml
 delete mode 100644 examples/sample-null-driver/Makefile.toml

diff --git a/Cargo.lock b/Cargo.lock
index 7d521a67..caf140f9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -436,14 +436,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.5"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -457,13 +457,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -474,9 +474,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -736,6 +736,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/Cargo.toml b/Cargo.toml
index b51c26f9..e700477d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -59,6 +59,7 @@ thiserror = "1.0.62"
 tracing = "0.1.40"
 tracing-subscriber = "0.3.18"
 windows = "0.58.0"
+regex = "1.11.1"
 
 # The following workspace.metadata.wdk sections can be uncommented to configure the workspace for a specific WDK configuration (ex. for rust-analyzer to resolve things for a specific configuration)
 
diff --git a/crates/wdk-build/Cargo.toml b/crates/wdk-build/Cargo.toml
index ad92f32f..288ab7f7 100644
--- a/crates/wdk-build/Cargo.toml
+++ b/crates/wdk-build/Cargo.toml
@@ -31,6 +31,7 @@ windows = { workspace = true, features = [
   "Win32_Foundation",
   "Win32_System_Registry",
 ] }
+regex.workspace = true
 
 [dev-dependencies]
 windows = { workspace = true, features = ["Win32_UI_Shell"] }
diff --git a/crates/wdk-build/src/cargo_make.rs b/crates/wdk-build/src/cargo_make.rs
index 222f3f30..aaa6f1fa 100644
--- a/crates/wdk-build/src/cargo_make.rs
+++ b/crates/wdk-build/src/cargo_make.rs
@@ -1146,16 +1146,26 @@ pub fn driver_model_is_not_package_condition_script() -> anyhow::Result<()> {
 /// 
 /// Panics if `WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES` is not set in the environment
 pub fn copy_package_files_to_driver_package_folder() -> Result<(), ConfigError> {
-    let package_files: Vec<PathBuf>  = env::var(WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR)
+    let package_files: Vec<String>  = env::var(WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR)
         .expect("The package files should be set by the wdk-build-init task")
         .split_terminator(metadata::ser::SEQ_ELEMENT_SEPARATOR)
-        .map(PathBuf::from)
+        .map(String::from)
         .collect();
 
+    let env_variable_regex = regex::Regex::new(r"\$\{(\w+)\}").unwrap();
     package_files
         .iter()
         .try_for_each(|package_file|{
-            copy_to_driver_package_folder(package_file.as_path())
+            // Evaluate environment variables in the package file path.
+            let package_file_evaluated = env_variable_regex.replace_all(package_file, |captures: &regex::Captures| {
+                print!("Evaluating environment variable {}", &captures[1]);
+                env::var(&captures[1]).unwrap_or_else(|_| {
+                    panic!("The environment variable {} should be set", &captures[1])
+                })
+            }).to_string();
+
+            let package_file_path = Path::new(&package_file_evaluated);
+            copy_to_driver_package_folder(package_file_path)
         })?;
     
     Ok(())
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index 79233488..e253bf21 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -34,9 +34,7 @@ pub const SEQ_ELEMENT_SEPARATOR: char = ';';
 /// use std::collections::BTreeMap;
 ///
 /// use wdk_build::{
-///     metadata::{self, to_map},
-///     DriverConfig,
-///     KmdfConfig,
+///     metadata::{self, to_map, driver_settings::{ DriverConfig, KmdfConfig },
 /// };
 ///
 /// let wdk_metadata = metadata::Wdk {
@@ -82,9 +80,7 @@ where
 /// use std::collections::BTreeMap;
 ///
 /// use wdk_build::{
-///     metadata::{self, to_map_with_prefix},
-///     DriverConfig,
-///     KmdfConfig,
+///     metadata::{self, to_map, driver_settings::{ DriverConfig, KmdfConfig },
 /// };
 ///
 /// let wdk_metadata = metadata::Wdk {
diff --git a/examples/sample-kmdf-driver/Cargo.lock b/examples/sample-kmdf-driver/Cargo.lock
index 68afe172..917a0613 100644
--- a/examples/sample-kmdf-driver/Cargo.lock
+++ b/examples/sample-kmdf-driver/Cargo.lock
@@ -420,14 +420,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.5"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -441,13 +441,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -458,9 +458,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -730,6 +730,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-null-driver-workspace/Cargo.lock b/examples/sample-null-driver-workspace/Cargo.lock
new file mode 100644
index 00000000..96572523
--- /dev/null
+++ b/examples/sample-null-driver-workspace/Cargo.lock
@@ -0,0 +1,11 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "sample-null-driver"
+version = "0.1.0"
+
+[[package]]
+name = "sample_app"
+version = "0.1.0"
diff --git a/examples/sample-null-driver-workspace/Cargo.toml b/examples/sample-null-driver-workspace/Cargo.toml
new file mode 100644
index 00000000..8b6061bb
--- /dev/null
+++ b/examples/sample-null-driver-workspace/Cargo.toml
@@ -0,0 +1,30 @@
+[workspace]
+members = ["crates/sample-app", "crates/driver"]
+resolver = "2"
+
+[workspace.package]
+version = "0.1.0"
+edition = "2021"
+description = "A sample NULL driver that demonstrates compiling NULL drivers in RUST"
+repository = "https://github.com/microsoft/windows-drivers-rs"
+readme = "README.md"
+license = "MIT OR Apache-2.0"
+keywords = ["windows", "driver", "sample", "example"]
+categories = ["hardware-support"]
+publish = false
+
+[workspace.metadata.wdk.driver-model]
+driver-type = "PACKAGE"
+
+[workspace.metadata.wdk.driver-install]
+package-files = ["${WDK_BUILD_OUTPUT_DIRECTORY}/sample_app.exe", "${WDK_BUILD_OUTPUT_DIRECTORY}/sample_app.pdb"]
+
+[workspace.dependencies]
+
+[profile.dev]
+panic = "abort"
+lto = true
+
+[profile.release]
+panic = "abort"
+lto = true
\ No newline at end of file
diff --git a/examples/sample-null-driver/README.md b/examples/sample-null-driver-workspace/README.md
similarity index 100%
rename from examples/sample-null-driver/README.md
rename to examples/sample-null-driver-workspace/README.md
diff --git a/examples/sample-null-driver/Cargo.lock b/examples/sample-null-driver-workspace/crates/driver/Cargo.lock
similarity index 100%
rename from examples/sample-null-driver/Cargo.lock
rename to examples/sample-null-driver-workspace/crates/driver/Cargo.lock
diff --git a/examples/sample-null-driver-workspace/crates/driver/Cargo.toml b/examples/sample-null-driver-workspace/crates/driver/Cargo.toml
new file mode 100644
index 00000000..0019a933
--- /dev/null
+++ b/examples/sample-null-driver-workspace/crates/driver/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "sample-null-driver"
+version.workspace = true
+edition.workspace = true
+
+# This driver package uses the metadata from the workspace, but still needs this tag to signal that its a driver crate that needs packaging
+[package.metadata.wdk]
+
+[lib]
+crate-type = ["cdylib"]
+# Tests from root driver crates must be excluded since there's no way to prevent linker args from being passed to their unit tests: https://github.com/rust-lang/cargo/issues/12663
+test = false
\ No newline at end of file
diff --git a/examples/sample-null-driver-workspace/crates/driver/Makefile.toml b/examples/sample-null-driver-workspace/crates/driver/Makefile.toml
new file mode 100644
index 00000000..b619c10f
--- /dev/null
+++ b/examples/sample-null-driver-workspace/crates/driver/Makefile.toml
@@ -0,0 +1,4 @@
+extend = [
+  { path = "../../../../crates/wdk-build/rust-driver-makefile.toml" },
+  { path = "../../../../crates/wdk-build/rust-driver-sample-makefile.toml" },
+]
diff --git a/examples/sample-null-driver/sample_null_driver.inx b/examples/sample-null-driver-workspace/crates/driver/sample_null_driver.inx
similarity index 67%
rename from examples/sample-null-driver/sample_null_driver.inx
rename to examples/sample-null-driver-workspace/crates/driver/sample_null_driver.inx
index 0bd5636a7678542e2bf8476a5fec29d51da4ccbc..4d7815eaecae700a9bd1125bcb5a1f0d669ba581 100644
GIT binary patch
delta 97
zcmbOrb4Pf?4rcjchD3&3h608hhE#@lAiDqv^?>XOAhu;N-29%!kVzVkqRBu7lYQ8?
UG3ziGf!LdWaou2??8SQw0I#qbR{#J2

delta 856
zcma)4+e!ja6kVB@89}0~C@An{h(IHgp2`PPA;}Ch>Y>ZfWeCAaMhkqh*WQft3H?A&
z5B)^Y2lO$meY`YDNF2`0K4<T}_S$QouV`oC<$YXDh2mxwHJqV=hMMuOKgA5y84I@u
zmnh(d&L%@@Tq&&K1QCRh!6laq2Ukd=LjN`DjBxOiTh?BQmVGobs*Adf9h4E@M4W4t
z+w#DbbP<Pl0@n*=OaT|TB~8gmU|mH*$!EjwV|Od+Ao!*p0@Kk7skpdDm9Y-vVzAU>
zDABgG?WJ#{ggf1=O~T$Rdq|AG8~cAgTaL4l97#2_c4ug@xG3q6V0Wd3YL|$b3`Cct
z=x<v4%&HG%Bvr;(Jd9z3*%joe=>f@SY1vd*&Lw_}JmqK?=#{%Jw#?e)#D{T(kFZIN
zz|Ik8mv5s)T#;{|cA4Lp#?BMh<)~aTk%2Y!sYY)fTk~%J&083jvBxbE%U>!Ld#t^K
z+M=R2x{KBT*+P=9*TONi{&}l5<NCvv*IeZjal$lK7}i4LH4-v?0j;;1H<#6^5mcYX
RoH{pWCq!9KRW)ILd;=C?lQsYV

diff --git a/examples/sample-null-driver/src/lib.rs b/examples/sample-null-driver-workspace/crates/driver/src/lib.rs
similarity index 100%
rename from examples/sample-null-driver/src/lib.rs
rename to examples/sample-null-driver-workspace/crates/driver/src/lib.rs
diff --git a/examples/sample-null-driver-workspace/crates/sample-app/Cargo.toml b/examples/sample-null-driver-workspace/crates/sample-app/Cargo.toml
new file mode 100644
index 00000000..90498ed4
--- /dev/null
+++ b/examples/sample-null-driver-workspace/crates/sample-app/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "sample_app"
+version.workspace = true
+edition.workspace = true
+
+[dependencies]
diff --git a/examples/sample-null-driver-workspace/crates/sample-app/src/main.rs b/examples/sample-null-driver-workspace/crates/sample-app/src/main.rs
new file mode 100644
index 00000000..e7a11a96
--- /dev/null
+++ b/examples/sample-null-driver-workspace/crates/sample-app/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/examples/sample-null-driver/Cargo.toml b/examples/sample-null-driver/Cargo.toml
deleted file mode 100644
index f181f3ab..00000000
--- a/examples/sample-null-driver/Cargo.toml
+++ /dev/null
@@ -1,61 +0,0 @@
-[package]
-edition = "2021"
-name = "sample-null-driver"
-version = "0.1.0"
-description = "A sample NULL driver that demonstrates compiling NULL drivers in RUST"
-repository = "https://github.com/microsoft/windows-drivers-rs"
-readme = "README.md"
-license = "MIT OR Apache-2.0"
-keywords = ["windows", "driver", "sample", "example"]
-categories = ["hardware-support"]
-publish = false
-
-[package.metadata.wdk.driver-model]
-driver-type = "PACKAGE"
-
-[package.metadata.wdk.driver-install]
-package-files = []
-
-[lib]
-crate-type = ["cdylib"]
-
-[build-dependencies]
-
-[dependencies]
-
-[features]
-default = []
-
-[profile.dev]
-panic = "abort"
-lto = true
-
-[profile.release]
-panic = "abort"
-lto = true
-
-[lints.rust]
-missing_docs = "warn"
-unsafe_op_in_unsafe_fn = "forbid"
-
-[lints.clippy]
-# Lint Groups
-all = { level = "deny", priority = -1 }
-pedantic = { level = "warn", priority = -1 }
-nursery = { level = "warn", priority = -1 }
-cargo = { level = "warn", priority = -1 }
-# Individual Lints
-multiple_unsafe_ops_per_block = "forbid"
-undocumented_unsafe_blocks = "forbid"
-unnecessary_safety_doc = "forbid"
-
-[lints.rustdoc]
-bare_urls = "warn"
-broken_intra_doc_links = "warn"
-invalid_codeblock_attributes = "warn"
-invalid_html_tags = "warn"
-invalid_rust_codeblocks = "warn"
-missing_crate_level_docs = "warn"
-private_intra_doc_links = "warn"
-redundant_explicit_links = "warn"
-unescaped_backticks = "warn"
diff --git a/examples/sample-null-driver/Makefile.toml b/examples/sample-null-driver/Makefile.toml
deleted file mode 100644
index be118bb4..00000000
--- a/examples/sample-null-driver/Makefile.toml
+++ /dev/null
@@ -1,4 +0,0 @@
-extend = [
-  { path = "../../crates/wdk-build/rust-driver-makefile.toml" },
-  { path = "../../crates/wdk-build/rust-driver-sample-makefile.toml" },
-]
diff --git a/examples/sample-umdf-driver/Cargo.lock b/examples/sample-umdf-driver/Cargo.lock
index d95db0be..3ca9aeaf 100644
--- a/examples/sample-umdf-driver/Cargo.lock
+++ b/examples/sample-umdf-driver/Cargo.lock
@@ -420,14 +420,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.5"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -441,13 +441,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -458,9 +458,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -718,6 +718,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-wdm-driver/Cargo.lock b/examples/sample-wdm-driver/Cargo.lock
index a79d27fb..5e6bd925 100644
--- a/examples/sample-wdm-driver/Cargo.lock
+++ b/examples/sample-wdm-driver/Cargo.lock
@@ -420,14 +420,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.5"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -441,13 +441,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -458,9 +458,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -730,6 +730,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-kmdf/Cargo.lock b/tests/config-kmdf/Cargo.lock
index af8a88c1..33861e80 100644
--- a/tests/config-kmdf/Cargo.lock
+++ b/tests/config-kmdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.4"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.6",
- "regex-syntax 0.8.3",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.6"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.3",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.3"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -848,6 +848,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-umdf/Cargo.lock b/tests/config-umdf/Cargo.lock
index 99a963cd..c57a1707 100644
--- a/tests/config-umdf/Cargo.lock
+++ b/tests/config-umdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.4"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.6",
- "regex-syntax 0.8.3",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.6"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.3",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.3"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -848,6 +848,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/mixed-package-kmdf-workspace/Cargo.lock b/tests/mixed-package-kmdf-workspace/Cargo.lock
index 93f31b48..a7ee6cb3 100644
--- a/tests/mixed-package-kmdf-workspace/Cargo.lock
+++ b/tests/mixed-package-kmdf-workspace/Cargo.lock
@@ -435,14 +435,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.5"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -456,13 +456,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -473,9 +473,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -735,6 +735,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/umdf-driver-workspace/Cargo.lock b/tests/umdf-driver-workspace/Cargo.lock
index 1dee849d..74a734b8 100644
--- a/tests/umdf-driver-workspace/Cargo.lock
+++ b/tests/umdf-driver-workspace/Cargo.lock
@@ -438,14 +438,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.5"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -459,13 +459,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -476,9 +476,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -728,6 +728,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/wdk-sys-tests/Cargo.lock b/tests/wdk-sys-tests/Cargo.lock
index 3b4cd777..0b5327b5 100644
--- a/tests/wdk-sys-tests/Cargo.lock
+++ b/tests/wdk-sys-tests/Cargo.lock
@@ -423,14 +423,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.6"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.7",
- "regex-syntax 0.8.4",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -444,13 +444,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.7"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.4",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -461,9 +461,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -703,6 +703,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",

From d515c39c177eb2ff8d947d15430d8565a76dbe1d Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Sat, 16 Nov 2024 08:57:17 -0800
Subject: [PATCH 06/14] refactor: update error messages for unsupported driver
 configurations and adjust README instructions for null driver installation

---
 crates/wdk-build/src/lib.rs                     | 15 +++++++--------
 examples/Makefile.toml                          |  2 +-
 examples/sample-null-driver-workspace/README.md | 14 ++------------
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index 5e25ba33..eedf5656 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -127,10 +127,9 @@ rustflags = [\"-C\", \"target-feature=+crt-static\"]
     #[error(transparent)]
     SerdeError(#[from] metadata::Error),
 
-
     /// Error returned when wdk build runs for [`metadata::driver_settings::DriverConfig::Package`]
-    #[error("Package driver type does not support building binaries. It should be used for null drivers and extension infs only.")]
-    PackageDriverTypeBuildNotSupported,
+    #[error("Package driver model does not support building binaries. It should be used for Inf only drivers.")]
+    UnsupportedDriverConfig,
 }
 
 impl Default for Config {
@@ -294,7 +293,7 @@ impl Config {
             DriverConfig::Wdm | DriverConfig::Kmdf(_) => "km",
             DriverConfig::Umdf(_) => "um",
             DriverConfig::Package => {
-                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+                return Err(ConfigError::UnsupportedDriverConfig);
             },
         });
         if !km_or_um_include_path.is_dir() {
@@ -356,7 +355,7 @@ impl Config {
                 );
             },
             DriverConfig::Package => {
-                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+                return Err(ConfigError::UnsupportedDriverConfig);
             },
         }
 
@@ -392,7 +391,7 @@ impl Config {
                         format!("um/{}", self.cpu_architecture.as_windows_str(),)
                     }
                     DriverConfig::Package => {
-                        return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+                        return Err(ConfigError::UnsupportedDriverConfig);
                     },
                 });
         if !windows_sdk_library_path.is_dir() {
@@ -446,7 +445,7 @@ impl Config {
                 );
             },
             DriverConfig::Package => {
-                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+                return Err(ConfigError::UnsupportedDriverConfig);
             },
         }
 
@@ -702,7 +701,7 @@ impl Config {
                 println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:WINDOWS");
             }
             DriverConfig::Package => {
-                return Err(ConfigError::PackageDriverTypeBuildNotSupported);
+                return Err(ConfigError::UnsupportedDriverConfig);
             },
         }
 
diff --git a/examples/Makefile.toml b/examples/Makefile.toml
index b1c360ef..c2cb62d3 100644
--- a/examples/Makefile.toml
+++ b/examples/Makefile.toml
@@ -4,7 +4,7 @@ extend = "../crates/wdk-build/rust-driver-makefile.toml"
 CARGO_MAKE_WORKSPACE_EMULATION = true
 CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = [
   "sample-kmdf-driver",
+  "sample-null-driver-workspace",
   "sample-umdf-driver",
   "sample-wdm-driver",
-  "sample-null-driver",
 ]
diff --git a/examples/sample-null-driver-workspace/README.md b/examples/sample-null-driver-workspace/README.md
index a6a6e79e..391464b3 100644
--- a/examples/sample-null-driver-workspace/README.md
+++ b/examples/sample-null-driver-workspace/README.md
@@ -26,16 +26,6 @@
    5. Repeat 2-4 for Store -> Browse -> Trusted Publishers -> Ok -> Next
    6. Finish
 3. Install the driver:
-   * In the package directory, run: `pnputil.exe /add-driver sample_kmdf_driver.inf /install`
+   * In the package directory, run: `pnputil.exe /add-driver sample_null_driver.inf /install`
 4. Create a software device:
-   * In the directory that `devgen.exe` was copied to, run: `devgen.exe /add /hardwareid "root\SAMPLE_KMDF_HW_ID"`
-
-## Test
-
-* To capture prints:
-  * Start [DebugView](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview)
-    1. Enable `Capture Kernel`
-    2. Enable `Enable Verbose Kernel Output`
-  * Alternatively, you can see prints in an active Windbg session.
-    1. Attach WinDBG
-    2. `ed nt!Kd_DEFAULT_Mask 0xFFFFFFFF`
+   * In the directory that `devgen.exe` was copied to, run: `devgen.exe /add /hardwareid "root\SAMPLE_NULL_HW_ID"`
\ No newline at end of file

From 70c641d82daaf58c5f107125d8328378568759c9 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 10:23:57 -0800
Subject: [PATCH 07/14] refactor: reorganize imports and improve code
 formatting

---
 crates/wdk-build/src/cargo_make.rs            | 64 ++++++++-----
 crates/wdk-build/src/lib.rs                   | 47 +++++-----
 .../wdk-build/src/metadata/driver_settings.rs | 16 ++--
 crates/wdk-build/src/metadata/mod.rs          |  9 +-
 crates/wdk-build/src/metadata/ser.rs          | 91 +++++++++++--------
 crates/wdk-sys/build.rs                       |  2 +-
 .../sample-null-driver-workspace/Cargo.toml   |  7 +-
 .../crates/driver/Cargo.toml                  |  2 +-
 8 files changed, 136 insertions(+), 102 deletions(-)

diff --git a/crates/wdk-build/src/cargo_make.rs b/crates/wdk-build/src/cargo_make.rs
index aaa6f1fa..b9322b33 100644
--- a/crates/wdk-build/src/cargo_make.rs
+++ b/crates/wdk-build/src/cargo_make.rs
@@ -66,10 +66,13 @@ const CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY_ENV_VAR: &str =
 const CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR: &str = "CARGO_MAKE_CURRENT_TASK_NAME";
 
 /// The environment variable that cargo-make uses to store driver model type
-const WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR: &str = "WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE";
+const WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR: &str =
+    "WDK_BUILD_METADATA-DRIVER_MODEL-DRIVER_TYPE";
 
-/// The environment variable that cargo-make uses to store additional files to be pacakaged with the driver
-const WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR: &str = "WDK_BUILD_METADATA-DRIVER_INSTALL-PACKAGE_FILES";
+/// The environment variable that cargo-make uses to store additional files to
+/// be pacakaged with the driver
+const WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR: &str =
+    "WDK_BUILD_METADATA-DRIVER_INSTALL-PACKAGE_FILES";
 
 /// `clap` uses an exit code of 2 for usage errors: <https://github.com/clap-rs/clap/blob/14fd853fb9c5b94e371170bbd0ca2bf28ef3abff/clap_builder/src/util/mod.rs#L30C18-L30C28>
 const CLAP_USAGE_EXIT_CODE: i32 = 2;
@@ -731,7 +734,7 @@ pub fn copy_to_driver_package_folder<P: AsRef<Path>>(path_to_copy: P) -> Result<
         std::fs::create_dir(&package_folder_path)?;
     }
 
-    eprintln!("Copying {:?} to {:?}", path_to_copy, package_folder_path);
+    eprintln!("Copying {path_to_copy:?} to {package_folder_path:?}");
     let destination_path = package_folder_path.join(
         path_to_copy
             .file_name()
@@ -1124,50 +1127,61 @@ pub fn driver_sample_infverif_condition_script() -> anyhow::Result<()> {
 /// # Panics
 ///
 /// Panics if `CARGO_MAKE_CURRENT_TASK_NAME` is not set in the environment
-/// Panics if `WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE` is not set in the environment
+/// Panics if `WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE` is not set in the
+/// environment
 pub fn driver_model_is_not_package_condition_script() -> anyhow::Result<()> {
     condition_script(|| {
-        let driver_type = env::var(WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR).expect("A driver type should exist in the WDK build metadata");
+        let driver_type = env::var(WDK_BUILD_METADATA_DRIVER_MODEL_DRIVER_TYPE_ENV_VAR)
+            .expect("A driver type should exist in the WDK build metadata");
         if driver_type == "PACKAGE" {
             // cargo_make will interpret returning an error from the rust-script
             // condition_script as skipping the task
             return Err::<(), anyhow::Error>(anyhow::Error::msg(format!(
                 "Skipping {}  task The driver model is a package.",
-                env::var(CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR).expect("CARGO_MAKE_CURRENT_TASK_NAME should be set by cargo-make")
+                env::var(CARGO_MAKE_CURRENT_TASK_NAME_ENV_VAR)
+                    .expect("CARGO_MAKE_CURRENT_TASK_NAME should be set by cargo-make")
             )));
         }
         Ok(())
     })
 }
 
-/// Copy the addition files specified in the wdk metadata to the  Driver Package folder
+/// Copy the addition files specified in the wdk metadata to the  Driver Package
+/// folder
+///
+///  # Errors
+///
+/// This function returns an error if the package files specified in the
+/// metadata are not found.
 ///
 /// # Panics
-/// 
-/// Panics if `WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES` is not set in the environment
+///
+/// Panics if `WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES` is not set in
+/// the environment
 pub fn copy_package_files_to_driver_package_folder() -> Result<(), ConfigError> {
-    let package_files: Vec<String>  = env::var(WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR)
-        .expect("The package files should be set by the wdk-build-init task")
-        .split_terminator(metadata::ser::SEQ_ELEMENT_SEPARATOR)
-        .map(String::from)
-        .collect();
+    let package_files: Vec<String> =
+        env::var(WDK_BUILD_METADATA_DRIVER_INSTALL_PACKAGE_FILES_ENV_VAR)
+            .expect("The package files should be set by the wdk-build-init task")
+            .split_terminator(metadata::ser::SEQ_ELEMENT_SEPARATOR)
+            .map(String::from)
+            .collect();
 
     let env_variable_regex = regex::Regex::new(r"\$\{(\w+)\}").unwrap();
-    package_files
-        .iter()
-        .try_for_each(|package_file|{
-            // Evaluate environment variables in the package file path.
-            let package_file_evaluated = env_variable_regex.replace_all(package_file, |captures: &regex::Captures| {
+    package_files.iter().try_for_each(|package_file| {
+        // Evaluate environment variables in the package file path.
+        let package_file_evaluated = env_variable_regex
+            .replace_all(package_file, |captures: &regex::Captures| {
                 print!("Evaluating environment variable {}", &captures[1]);
                 env::var(&captures[1]).unwrap_or_else(|_| {
                     panic!("The environment variable {} should be set", &captures[1])
                 })
-            }).to_string();
+            })
+            .to_string();
+
+        let package_file_path = Path::new(&package_file_evaluated);
+        copy_to_driver_package_folder(package_file_path)
+    })?;
 
-            let package_file_path = Path::new(&package_file_evaluated);
-            copy_to_driver_package_folder(package_file_path)
-        })?;
-    
     Ok(())
 }
 
diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index eedf5656..7484b7b6 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -13,9 +13,11 @@
 #![cfg_attr(nightly_toolchain, feature(assert_matches))]
 
 pub use bindgen::BuilderExt;
-use metadata::TryFromCargoMetadataError;
-use metadata::driver_install::DriverInstall;
-use metadata::driver_settings::DriverConfig;
+use metadata::{
+    driver_install::DriverInstall,
+    driver_settings::DriverConfig,
+    TryFromCargoMetadataError,
+};
 
 pub mod cargo_make;
 pub mod metadata;
@@ -42,7 +44,7 @@ pub struct Config {
     /// Build configuration of driver
     pub driver_config: DriverConfig,
     /// Driver installation settings
-    pub driver_install: Option<DriverInstall>
+    pub driver_install: Option<DriverInstall>,
 }
 
 /// The CPU architecture that's configured to be compiled for
@@ -127,8 +129,12 @@ rustflags = [\"-C\", \"target-feature=+crt-static\"]
     #[error(transparent)]
     SerdeError(#[from] metadata::Error),
 
-    /// Error returned when wdk build runs for [`metadata::driver_settings::DriverConfig::Package`]
-    #[error("Package driver model does not support building binaries. It should be used for Inf only drivers.")]
+    /// Error returned when wdk build runs for
+    /// [`metadata::driver_settings::DriverConfig::Package`]
+    #[error(
+        "Package driver model does not support building binaries. It should be used for Inf only \
+         drivers."
+    )]
     UnsupportedDriverConfig,
 }
 
@@ -294,7 +300,7 @@ impl Config {
             DriverConfig::Umdf(_) => "um",
             DriverConfig::Package => {
                 return Err(ConfigError::UnsupportedDriverConfig);
-            },
+            }
         });
         if !km_or_um_include_path.is_dir() {
             return Err(ConfigError::DirectoryNotFound {
@@ -353,10 +359,10 @@ impl Config {
                         .canonicalize()?
                         .strip_extended_length_path_prefix()?,
                 );
-            },
+            }
             DriverConfig::Package => {
                 return Err(ConfigError::UnsupportedDriverConfig);
-            },
+            }
         }
 
         Ok(include_paths)
@@ -392,7 +398,7 @@ impl Config {
                     }
                     DriverConfig::Package => {
                         return Err(ConfigError::UnsupportedDriverConfig);
-                    },
+                    }
                 });
         if !windows_sdk_library_path.is_dir() {
             return Err(ConfigError::DirectoryNotFound {
@@ -443,10 +449,10 @@ impl Config {
                         .canonicalize()?
                         .strip_extended_length_path_prefix()?,
                 );
-            },
+            }
             DriverConfig::Package => {
                 return Err(ConfigError::UnsupportedDriverConfig);
-            },
+            }
         }
 
         // Reverse order of library paths so that paths pushed later into the vec take
@@ -543,7 +549,7 @@ impl Config {
 
                     umdf_definitions
                 }
-                DriverConfig::Package => unreachable!()
+                DriverConfig::Package => unreachable!("Package driver should not be running binary build"),
             }
             .into_iter()
             .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))),
@@ -605,7 +611,7 @@ impl Config {
                 (config.umdf_version_major, config.target_umdf_version_minor)
             }
             DriverConfig::Wdm => return None,
-            DriverConfig::Package => unreachable!(),
+            DriverConfig::Package => unreachable!("Package driver should not be running binary build"),
         };
 
         Some(format!(
@@ -702,7 +708,7 @@ impl Config {
             }
             DriverConfig::Package => {
                 return Err(ConfigError::UnsupportedDriverConfig);
-            },
+            }
         }
 
         // Emit linker arguments common to all configs
@@ -907,6 +913,7 @@ mod tests {
     #[cfg(nightly_toolchain)]
     use std::assert_matches::assert_matches;
     use std::{collections::HashMap, ffi::OsStr, sync::Mutex};
+
     use metadata::driver_settings::{KmdfConfig, UmdfConfig};
 
     use super::*;
@@ -1078,10 +1085,7 @@ mod tests {
         });
 
         #[cfg(nightly_toolchain)]
-        assert_matches!(
-            config.driver_config,
-            DriverConfig::Package
-        );
+        assert_matches!(config.driver_config, DriverConfig::Package);
         assert_eq!(config.cpu_architecture, CpuArchitecture::Arm64);
     }
 
@@ -1099,9 +1103,10 @@ mod tests {
     }
 
     mod compute_wdffunctions_symbol_name {
-        use super::*;
         use metadata::driver_settings::{KmdfConfig, UmdfConfig};
 
+        use super::*;
+
         #[test]
         fn kmdf() {
             let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config {
@@ -1147,7 +1152,7 @@ mod tests {
         }
 
         #[test]
-        #[should_panic]
+        #[should_panic = "Package driver should not be running binary build"]
         fn package() {
             let config = with_env(&[("CARGO_CFG_TARGET_ARCH", "x86_64")], || Config {
                 driver_config: DriverConfig::Package,
diff --git a/crates/wdk-build/src/metadata/driver_settings.rs b/crates/wdk-build/src/metadata/driver_settings.rs
index bcd0256a..144f3b15 100644
--- a/crates/wdk-build/src/metadata/driver_settings.rs
+++ b/crates/wdk-build/src/metadata/driver_settings.rs
@@ -1,10 +1,12 @@
 // Copyright (c) Microsoft Corporation
 // License: MIT OR Apache-2.0
 
-//! Types for the `DriverConfig` section of the `metadata.wdk` section of the `Cargo.toml`
-//! 
-//! This section is used to specify the driver type and its associated configuration parameters.
-//! This corresponds with the settings in the `Driver Model` property pages
+//! Types for the `DriverConfig` section of the `metadata.wdk` section of the
+//! `Cargo.toml`
+//!
+//! This section is used to specify the driver type and its associated
+//! configuration parameters. This corresponds with the settings in the `Driver
+//! Model` property pages
 
 use serde::{Deserialize, Serialize};
 
@@ -24,7 +26,7 @@ pub enum DriverConfig {
     /// User Mode Driver Framework
     Umdf(UmdfConfig),
     /// INF only drivers e.g. null drivers and extension INFs
-    Package
+    Package,
 }
 
 /// Private enum identical to [`DriverConfig`] but with different tag name to
@@ -44,7 +46,7 @@ enum DeserializableDriverConfig {
     Wdm,
     Kmdf(KmdfConfig),
     Umdf(UmdfConfig),
-    Package
+    Package,
 }
 
 /// The configuration parameters for KMDF drivers
@@ -126,4 +128,4 @@ impl UmdfConfig {
     pub fn new() -> Self {
         Self::default()
     }
-}
\ No newline at end of file
+}
diff --git a/crates/wdk-build/src/metadata/mod.rs b/crates/wdk-build/src/metadata/mod.rs
index 4a3ea21e..c250e18d 100644
--- a/crates/wdk-build/src/metadata/mod.rs
+++ b/crates/wdk-build/src/metadata/mod.rs
@@ -13,9 +13,9 @@ pub use error::{Error, Result};
 pub use map::Map;
 pub use ser::{to_map, to_map_with_prefix, Serializer};
 
-pub(crate) mod ser;
 pub mod driver_install;
 pub mod driver_settings;
+pub(crate) mod ser;
 
 mod error;
 mod map;
@@ -24,12 +24,11 @@ use std::collections::HashSet;
 
 use camino::Utf8PathBuf;
 use cargo_metadata::Metadata;
+use driver_install::DriverInstall;
+use driver_settings::DriverConfig;
 use serde::{Deserialize, Serialize};
 use thiserror::Error;
 
-use driver_settings::DriverConfig;
-use driver_install::DriverInstall;
-
 /// Metadata specified in the `metadata.wdk` section of the `Cargo.toml`
 /// of a crate that depends on the WDK, or in a cargo workspace.
 ///
@@ -44,7 +43,7 @@ pub struct Wdk {
     /// Metadata corresponding to the `Driver Model` property page in the WDK
     pub driver_model: DriverConfig,
     /// Metadata corresponding to the `Driver Install` property page in the WDK
-    pub driver_install: Option<DriverInstall>
+    pub driver_install: Option<DriverInstall>,
 }
 
 /// Errors that could result from trying to construct a
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index e253bf21..e336d271 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -2,7 +2,8 @@
 // License: MIT OR Apache-2.0
 
 use serde::{
-    ser::{self, Impossible}, Serialize
+    ser::{self, Impossible},
+    Serialize,
 };
 
 use super::{
@@ -34,7 +35,7 @@ pub const SEQ_ELEMENT_SEPARATOR: char = ';';
 /// use std::collections::BTreeMap;
 ///
 /// use wdk_build::{
-///     metadata::{self, to_map, driver_settings::{ DriverConfig, KmdfConfig },
+///     metadata::{self, to_map, driver_settings::{ DriverConfig, KmdfConfig }},
 /// };
 ///
 /// let wdk_metadata = metadata::Wdk {
@@ -43,7 +44,7 @@ pub const SEQ_ELEMENT_SEPARATOR: char = ';';
 ///         target_kmdf_version_minor: 23,
 ///         minimum_kmdf_version_minor: None,
 ///     }),
-///     driver_install: Default::default(),
+///     driver_install: None,
 /// };
 ///
 /// let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -80,7 +81,7 @@ where
 /// use std::collections::BTreeMap;
 ///
 /// use wdk_build::{
-///     metadata::{self, to_map, driver_settings::{ DriverConfig, KmdfConfig },
+///     metadata::{self, to_map_with_prefix, driver_settings::{ DriverConfig, KmdfConfig }},
 /// };
 ///
 /// let wdk_metadata = metadata::Wdk {
@@ -89,7 +90,7 @@ where
 ///         target_kmdf_version_minor: 33,
 ///         minimum_kmdf_version_minor: Some(31),
 ///     }),
-///     driver_install: Default::default(),
+///     driver_install: None,
 /// };
 ///
 /// let output = to_map_with_prefix::<BTreeMap<_, _>>("WDK_BUILD_METADATA", &wdk_metadata).unwrap();
@@ -156,8 +157,8 @@ impl<'a> ser::Serializer for &'a mut Serializer<'a> {
     type Error = Error;
     type Ok = Option<String>;
     type SerializeMap = Impossible<Self::Ok, Self::Error>;
-    type SerializeStruct = Self;
     type SerializeSeq = SerializerSeq<'a>;
+    type SerializeStruct = Self;
     type SerializeStructVariant = Impossible<Self::Ok, Self::Error>;
     type SerializeTuple = Impossible<Self::Ok, Self::Error>;
     type SerializeTupleStruct = Impossible<Self::Ok, Self::Error>;
@@ -242,10 +243,7 @@ impl<'a> ser::Serializer for &'a mut Serializer<'a> {
     }
 
     fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq> {
-        Ok(SerializerSeq::new(
-            self.root_key_name.clone(),
-            self.dst,
-        ))
+        Ok(SerializerSeq::new(self.root_key_name.clone(), self.dst))
     }
 }
 
@@ -257,20 +255,16 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer<'a> {
     where
         T: ?Sized + Serialize,
     {
-        
         let new_root_key_name = self.root_key_name.clone().map_or_else(
             || key.to_string(),
             |root_key_name| format!("{root_key_name}{KEY_NAME_SEPARATOR}{key}"),
         );
 
         let mut serializer = Serializer::with_prefix(new_root_key_name.clone(), self.dst);
-        let value_string  = value.serialize(&mut serializer)?;
-       
+        let value_string = value.serialize(&mut serializer)?;
+
         if let Some(value_string) = value_string {
-            self.dst.push((
-                new_root_key_name,
-                value_string,
-            ));
+            self.dst.push((new_root_key_name, value_string));
         }
 
         Ok(())
@@ -284,20 +278,20 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer<'a> {
 pub struct SerializerSeq<'a> {
     root_key_name: Option<String>,
     dst: &'a mut Vec<(String, String)>,
-    delimited_string: String
+    delimited_string: String,
 }
 
-impl <'a> ser::SerializeSeq for SerializerSeq<'a> {
+impl<'a> ser::SerializeSeq for SerializerSeq<'a> {
     type Error = Error;
     type Ok = Option<String>;
 
     fn serialize_element<T>(&mut self, value: &T) -> Result<()>
     where
-        T: ? Sized + Serialize,
+        T: ?Sized + Serialize,
     {
         let root_key_name = self.root_key_name.clone().unwrap();
         let mut serializer = Serializer::with_prefix(root_key_name, self.dst);
-        let value_string  = value.serialize(&mut serializer)?.unwrap_or_else(|| {
+        let value_string = value.serialize(&mut serializer)?.unwrap_or_else(|| {
             unimplemented!(
                 "Sequence serializer for elements of type {} is not suppoted",
                 std::any::type_name::<T>(),
@@ -308,7 +302,7 @@ impl <'a> ser::SerializeSeq for SerializerSeq<'a> {
         self.delimited_string.push(SEQ_ELEMENT_SEPARATOR);
         Ok(())
     }
-    
+
     fn end(self) -> Result<Self::Ok> {
         // Remove the trailing delimiter.
         let delimited_string = if self.delimited_string.is_empty() {
@@ -317,10 +311,8 @@ impl <'a> ser::SerializeSeq for SerializerSeq<'a> {
             self.delimited_string[..self.delimited_string.len() - 1].to_string()
         };
 
-        self.dst.push((
-            self.root_key_name.unwrap(),
-            delimited_string,
-        ));
+        self.dst
+            .push((self.root_key_name.unwrap(), delimited_string));
         Ok(None)
     }
 }
@@ -350,7 +342,7 @@ impl<'a> SerializerSeq<'a> {
         Self {
             root_key_name,
             dst,
-            delimited_string: String::new()
+            delimited_string: String::new(),
         }
     }
 }
@@ -555,7 +547,11 @@ mod tests {
     };
 
     use super::*;
-    use crate::metadata::{self, driver_install::DriverInstall, driver_settings::{DriverConfig, KmdfConfig, UmdfConfig}};
+    use crate::metadata::{
+        self,
+        driver_install::DriverInstall,
+        driver_settings::{DriverConfig, KmdfConfig, UmdfConfig},
+    };
 
     #[test]
     fn test_kmdf() {
@@ -565,7 +561,7 @@ mod tests {
                 target_kmdf_version_minor: 23,
                 minimum_kmdf_version_minor: Some(21),
             }),
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -584,7 +580,7 @@ mod tests {
                 target_kmdf_version_minor: 23,
                 minimum_kmdf_version_minor: None,
             }),
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -605,7 +601,7 @@ mod tests {
                 target_kmdf_version_minor: 33,
                 minimum_kmdf_version_minor: Some(31),
             }),
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output =
@@ -637,7 +633,7 @@ mod tests {
                 target_kmdf_version_minor: 33,
                 minimum_kmdf_version_minor: Some(31),
             }),
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output = to_map::<HashMap<_, _>>(&wdk_metadata).unwrap();
@@ -656,7 +652,7 @@ mod tests {
                 target_umdf_version_minor: 23,
                 minimum_umdf_version_minor: Some(21),
             }),
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -675,7 +671,7 @@ mod tests {
                 target_umdf_version_minor: 23,
                 minimum_umdf_version_minor: None,
             }),
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -692,7 +688,7 @@ mod tests {
     fn test_wdm() {
         let wdk_metadata = metadata::Wdk {
             driver_model: DriverConfig::Wdm,
-            driver_install: Default::default(),
+            driver_install: None,
         };
 
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
@@ -737,7 +733,10 @@ mod tests {
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
 
         assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
-        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";"));
+        assert_eq!(
+            output["DRIVER_INSTALL-PACKAGE_FILES"],
+            package_files.join(";")
+        );
     }
 
     #[test]
@@ -759,7 +758,10 @@ mod tests {
         let output = to_map::<BTreeMap<_, _>>(&wdk_metadata).unwrap();
 
         assert_eq!(output["DRIVER_MODEL-DRIVER_TYPE"], "WDM");
-        assert_eq!(output["DRIVER_INSTALL-PACKAGE_FILES"], package_files.join(";"));
+        assert_eq!(
+            output["DRIVER_INSTALL-PACKAGE_FILES"],
+            package_files.join(";")
+        );
     }
 
     #[test]
@@ -787,12 +789,21 @@ mod tests {
         sequence: Vec<UnsupportedSequenceStruct>,
     }
     #[test]
-    #[should_panic(expected = "not implemented: Sequence serializer for elements of type &wdk_build::metadata::ser::tests::UnsupportedSequenceStruct is not suppoted")]
+    #[should_panic(
+        expected = "not implemented: Sequence serializer for elements of type \
+                    &wdk_build::metadata::ser::tests::UnsupportedSequenceStruct is not suppoted"
+    )]
     fn test_unsupported_seq() {
         let unsuppoted_struct = UnsupportedSequenceParentStruct {
             sequence: vec![
-                UnsupportedSequenceStruct { field1: 1, field2: 2 },
-                UnsupportedSequenceStruct { field1: 3, field2: 4 },
+                UnsupportedSequenceStruct {
+                    field1: 1,
+                    field2: 2,
+                },
+                UnsupportedSequenceStruct {
+                    field1: 3,
+                    field2: 4,
+                },
             ],
         };
 
diff --git a/crates/wdk-sys/build.rs b/crates/wdk-sys/build.rs
index 1ee0a391..e181d6d5 100644
--- a/crates/wdk-sys/build.rs
+++ b/crates/wdk-sys/build.rs
@@ -23,10 +23,10 @@ use tracing_subscriber::{
 };
 use wdk_build::{
     configure_wdk_library_build_and_then,
+    metadata::driver_settings::{DriverConfig, KmdfConfig, UmdfConfig},
     BuilderExt,
     Config,
     ConfigError,
-    metadata::driver_settings::{DriverConfig, KmdfConfig, UmdfConfig},
 };
 
 const NUM_WDF_FUNCTIONS_PLACEHOLDER: &str =
diff --git a/examples/sample-null-driver-workspace/Cargo.toml b/examples/sample-null-driver-workspace/Cargo.toml
index 8b6061bb..740c817d 100644
--- a/examples/sample-null-driver-workspace/Cargo.toml
+++ b/examples/sample-null-driver-workspace/Cargo.toml
@@ -17,7 +17,10 @@ publish = false
 driver-type = "PACKAGE"
 
 [workspace.metadata.wdk.driver-install]
-package-files = ["${WDK_BUILD_OUTPUT_DIRECTORY}/sample_app.exe", "${WDK_BUILD_OUTPUT_DIRECTORY}/sample_app.pdb"]
+package-files = [
+  "${WDK_BUILD_OUTPUT_DIRECTORY}/sample_app.exe",
+  "${WDK_BUILD_OUTPUT_DIRECTORY}/sample_app.pdb",
+]
 
 [workspace.dependencies]
 
@@ -27,4 +30,4 @@ lto = true
 
 [profile.release]
 panic = "abort"
-lto = true
\ No newline at end of file
+lto = true
diff --git a/examples/sample-null-driver-workspace/crates/driver/Cargo.toml b/examples/sample-null-driver-workspace/crates/driver/Cargo.toml
index 0019a933..8d256445 100644
--- a/examples/sample-null-driver-workspace/crates/driver/Cargo.toml
+++ b/examples/sample-null-driver-workspace/crates/driver/Cargo.toml
@@ -9,4 +9,4 @@ edition.workspace = true
 [lib]
 crate-type = ["cdylib"]
 # Tests from root driver crates must be excluded since there's no way to prevent linker args from being passed to their unit tests: https://github.com/rust-lang/cargo/issues/12663
-test = false
\ No newline at end of file
+test = false

From e5855e9444fdb1e8244566c64e87d34214ed47fa Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 10:58:51 -0800
Subject: [PATCH 08/14] refactor: improve code formatting

---
 crates/wdk-build/src/lib.rs                   |  8 ++++++--
 .../wdk-build/src/metadata/driver_install.rs  | 19 +++++++++++--------
 crates/wdk-build/src/metadata/ser.rs          | 12 ++++++++----
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs
index 7484b7b6..b8f0a6eb 100644
--- a/crates/wdk-build/src/lib.rs
+++ b/crates/wdk-build/src/lib.rs
@@ -549,7 +549,9 @@ impl Config {
 
                     umdf_definitions
                 }
-                DriverConfig::Package => unreachable!("Package driver should not be running binary build"),
+                DriverConfig::Package => {
+                    unreachable!("Package driver should not be running binary build")
+                }
             }
             .into_iter()
             .map(|(key, value)| (key.to_string(), value.map(|v| v.to_string()))),
@@ -611,7 +613,9 @@ impl Config {
                 (config.umdf_version_major, config.target_umdf_version_minor)
             }
             DriverConfig::Wdm => return None,
-            DriverConfig::Package => unreachable!("Package driver should not be running binary build"),
+            DriverConfig::Package => {
+                unreachable!("Package driver should not be running binary build")
+            }
         };
 
         Some(format!(
diff --git a/crates/wdk-build/src/metadata/driver_install.rs b/crates/wdk-build/src/metadata/driver_install.rs
index b48677d2..eed47759 100644
--- a/crates/wdk-build/src/metadata/driver_install.rs
+++ b/crates/wdk-build/src/metadata/driver_install.rs
@@ -1,14 +1,17 @@
 // Copyright (c) Microsoft Corporation
 // License: MIT OR Apache-2.0
 
-//! Types for the `DriverInstall` section of the `metadata.wdk` section of the `Cargo.toml`
+//! Types for the `DriverInstall` section of the `metadata.wdk` section of the
+//! `Cargo.toml`
 //!
-//! This section is used to specify files to be installed with the driver package.
-//! This corresponds with the settings in the `Driver Install` property pages
+//! This section is used to specify files to be installed with the driver
+//! package. This corresponds with the settings in the `Driver Install` property
+//! pages
 
 use serde::{Deserialize, Serialize};
 
-/// The `DRIVER_INSTALL` section of the `metadata.wdk` section of the `Cargo.toml`
+/// The `DRIVER_INSTALL` section of the `metadata.wdk` section of the
+/// `Cargo.toml`
 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Default)]
 #[serde(
     deny_unknown_fields,
@@ -16,13 +19,13 @@ use serde::{Deserialize, Serialize};
 )]
 pub struct DriverInstall {
     /// List of files to be installed with the driver package.
-    pub package_files: Vec<String>
+    pub package_files: Vec<String>,
 }
 
 impl DriverInstall {
-   /// Creates a new [`DriverInstall`] with default values
-   #[must_use]
+    /// Creates a new [`DriverInstall`] with default values
+    #[must_use]
     pub fn new() -> Self {
         Self::default()
     }
-}
\ No newline at end of file
+}
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index e336d271..1194da77 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -34,8 +34,10 @@ pub const SEQ_ELEMENT_SEPARATOR: char = ';';
 /// ```rust
 /// use std::collections::BTreeMap;
 ///
-/// use wdk_build::{
-///     metadata::{self, to_map, driver_settings::{ DriverConfig, KmdfConfig }},
+/// use wdk_build::metadata::{
+///     self,
+///     driver_settings::{DriverConfig, KmdfConfig},
+///     to_map,
 /// };
 ///
 /// let wdk_metadata = metadata::Wdk {
@@ -80,8 +82,10 @@ where
 /// ```rust
 /// use std::collections::BTreeMap;
 ///
-/// use wdk_build::{
-///     metadata::{self, to_map_with_prefix, driver_settings::{ DriverConfig, KmdfConfig }},
+/// use wdk_build::metadata::{
+///     self,
+///     driver_settings::{DriverConfig, KmdfConfig},
+///     to_map_with_prefix,
 /// };
 ///
 /// let wdk_metadata = metadata::Wdk {

From 6ec6d409d63070d1ec56e525d161912908b0bceb Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 11:27:04 -0800
Subject: [PATCH 09/14] fix: downgrade regex version to 1.10.5 and update
 lifetime annotation in SerializerSeq implementation

---
 Cargo.toml                           | 2 +-
 crates/wdk-build/src/metadata/ser.rs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index e700477d..87d55b47 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -59,7 +59,7 @@ thiserror = "1.0.62"
 tracing = "0.1.40"
 tracing-subscriber = "0.3.18"
 windows = "0.58.0"
-regex = "1.11.1"
+regex = "1.10.5"
 
 # The following workspace.metadata.wdk sections can be uncommented to configure the workspace for a specific WDK configuration (ex. for rust-analyzer to resolve things for a specific configuration)
 
diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs
index 1194da77..a517ef8c 100644
--- a/crates/wdk-build/src/metadata/ser.rs
+++ b/crates/wdk-build/src/metadata/ser.rs
@@ -285,7 +285,7 @@ pub struct SerializerSeq<'a> {
     delimited_string: String,
 }
 
-impl<'a> ser::SerializeSeq for SerializerSeq<'a> {
+impl ser::SerializeSeq for SerializerSeq<'_> {
     type Error = Error;
     type Ok = Option<String>;
 

From a1fd802621a53a445a92fea9996669020a0e75cf Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 12:04:39 -0800
Subject: [PATCH 10/14] feat: add condition for package file copying based on
 environment variable

---
 crates/wdk-build/rust-driver-makefile.toml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crates/wdk-build/rust-driver-makefile.toml b/crates/wdk-build/rust-driver-makefile.toml
index 44e711c6..5473a9a3 100644
--- a/crates/wdk-build/rust-driver-makefile.toml
+++ b/crates/wdk-build/rust-driver-makefile.toml
@@ -449,6 +449,7 @@ wdk_build::cargo_make::copy_to_driver_package_folder(
 
 [tasks.copy-package-files-to-package]
 private = true
+condition = { env_set = ["WDK_BUILD_METADATA-DRIVER_INSTALL-PACKAGE_FILES"] }
 script_runner = "@rust"
 script_runner_args = [
   "--base-path",

From c82c7bc38164231fb74d7117af3e3810748f37e2 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 12:06:58 -0800
Subject: [PATCH 11/14] fix: Revert Cargo.lock files.

---
 examples/sample-kmdf-driver/Cargo.lock        | 19 +++++++++----------
 examples/sample-umdf-driver/Cargo.lock        | 19 +++++++++----------
 examples/sample-wdm-driver/Cargo.lock         | 19 +++++++++----------
 tests/config-kmdf/Cargo.lock                  | 19 +++++++++----------
 tests/config-umdf/Cargo.lock                  | 19 +++++++++----------
 tests/mixed-package-kmdf-workspace/Cargo.lock | 19 +++++++++----------
 tests/umdf-driver-workspace/Cargo.lock        | 19 +++++++++----------
 tests/wdk-sys-tests/Cargo.lock                | 19 +++++++++----------
 8 files changed, 72 insertions(+), 80 deletions(-)

diff --git a/examples/sample-kmdf-driver/Cargo.lock b/examples/sample-kmdf-driver/Cargo.lock
index 917a0613..68afe172 100644
--- a/examples/sample-kmdf-driver/Cargo.lock
+++ b/examples/sample-kmdf-driver/Cargo.lock
@@ -420,14 +420,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -441,13 +441,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -458,9 +458,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -730,7 +730,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-umdf-driver/Cargo.lock b/examples/sample-umdf-driver/Cargo.lock
index 3ca9aeaf..d95db0be 100644
--- a/examples/sample-umdf-driver/Cargo.lock
+++ b/examples/sample-umdf-driver/Cargo.lock
@@ -420,14 +420,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -441,13 +441,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -458,9 +458,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -718,7 +718,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-wdm-driver/Cargo.lock b/examples/sample-wdm-driver/Cargo.lock
index 5e6bd925..a79d27fb 100644
--- a/examples/sample-wdm-driver/Cargo.lock
+++ b/examples/sample-wdm-driver/Cargo.lock
@@ -420,14 +420,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -441,13 +441,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -458,9 +458,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -730,7 +730,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-kmdf/Cargo.lock b/tests/config-kmdf/Cargo.lock
index 33861e80..af8a88c1 100644
--- a/tests/config-kmdf/Cargo.lock
+++ b/tests/config-kmdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.6",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
 
 [[package]]
 name = "rustc-hash"
@@ -848,7 +848,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-umdf/Cargo.lock b/tests/config-umdf/Cargo.lock
index c57a1707..99a963cd 100644
--- a/tests/config-umdf/Cargo.lock
+++ b/tests/config-umdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.6",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
 
 [[package]]
 name = "rustc-hash"
@@ -848,7 +848,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/mixed-package-kmdf-workspace/Cargo.lock b/tests/mixed-package-kmdf-workspace/Cargo.lock
index a7ee6cb3..93f31b48 100644
--- a/tests/mixed-package-kmdf-workspace/Cargo.lock
+++ b/tests/mixed-package-kmdf-workspace/Cargo.lock
@@ -435,14 +435,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -456,13 +456,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -473,9 +473,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -735,7 +735,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/umdf-driver-workspace/Cargo.lock b/tests/umdf-driver-workspace/Cargo.lock
index 74a734b8..1dee849d 100644
--- a/tests/umdf-driver-workspace/Cargo.lock
+++ b/tests/umdf-driver-workspace/Cargo.lock
@@ -438,14 +438,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -459,13 +459,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -476,9 +476,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -728,7 +728,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/wdk-sys-tests/Cargo.lock b/tests/wdk-sys-tests/Cargo.lock
index 0b5327b5..3b4cd777 100644
--- a/tests/wdk-sys-tests/Cargo.lock
+++ b/tests/wdk-sys-tests/Cargo.lock
@@ -423,14 +423,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -444,13 +444,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -461,9 +461,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -703,7 +703,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",

From 0c24cda0a19c91b1c0bf2f3847b40908424d63f3 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 12:09:57 -0800
Subject: [PATCH 12/14] fix: Revert root Cargo.lock

---
 Cargo.lock | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index caf140f9..7d521a67 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -436,14 +436,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -457,13 +457,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.4",
 ]
 
 [[package]]
@@ -474,9 +474,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
 name = "rustc-hash"
@@ -736,7 +736,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",

From 23e48cefb64092ce56141538fe56374a44008759 Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 12:19:51 -0800
Subject: [PATCH 13/14] feat: add regex dependency to multiple Cargo.lock files
 and update its version

---
 Cargo.lock                                    |  1 +
 examples/sample-kmdf-driver/Cargo.lock        |  1 +
 examples/sample-umdf-driver/Cargo.lock        |  1 +
 examples/sample-wdm-driver/Cargo.lock         |  1 +
 tests/config-kmdf/Cargo.lock                  | 19 ++++++++++---------
 tests/config-umdf/Cargo.lock                  | 19 ++++++++++---------
 tests/mixed-package-kmdf-workspace/Cargo.lock |  1 +
 tests/umdf-driver-workspace/Cargo.lock        |  1 +
 tests/wdk-sys-tests/Cargo.lock                |  1 +
 9 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 7d521a67..cd42a4d2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -736,6 +736,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-kmdf-driver/Cargo.lock b/examples/sample-kmdf-driver/Cargo.lock
index 68afe172..3b88cd0c 100644
--- a/examples/sample-kmdf-driver/Cargo.lock
+++ b/examples/sample-kmdf-driver/Cargo.lock
@@ -730,6 +730,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-umdf-driver/Cargo.lock b/examples/sample-umdf-driver/Cargo.lock
index d95db0be..e4471495 100644
--- a/examples/sample-umdf-driver/Cargo.lock
+++ b/examples/sample-umdf-driver/Cargo.lock
@@ -718,6 +718,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/examples/sample-wdm-driver/Cargo.lock b/examples/sample-wdm-driver/Cargo.lock
index a79d27fb..4e9ccbe1 100644
--- a/examples/sample-wdm-driver/Cargo.lock
+++ b/examples/sample-wdm-driver/Cargo.lock
@@ -730,6 +730,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-kmdf/Cargo.lock b/tests/config-kmdf/Cargo.lock
index af8a88c1..33861e80 100644
--- a/tests/config-kmdf/Cargo.lock
+++ b/tests/config-kmdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.4"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.6",
- "regex-syntax 0.8.3",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.6"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.3",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.3"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -848,6 +848,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-umdf/Cargo.lock b/tests/config-umdf/Cargo.lock
index 99a963cd..c57a1707 100644
--- a/tests/config-umdf/Cargo.lock
+++ b/tests/config-umdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.4"
+version = "1.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.6",
- "regex-syntax 0.8.3",
+ "regex-automata 0.4.9",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.6"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.3",
+ "regex-syntax 0.8.5",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.3"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
 
 [[package]]
 name = "rustc-hash"
@@ -848,6 +848,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/mixed-package-kmdf-workspace/Cargo.lock b/tests/mixed-package-kmdf-workspace/Cargo.lock
index 93f31b48..6a73287e 100644
--- a/tests/mixed-package-kmdf-workspace/Cargo.lock
+++ b/tests/mixed-package-kmdf-workspace/Cargo.lock
@@ -735,6 +735,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/umdf-driver-workspace/Cargo.lock b/tests/umdf-driver-workspace/Cargo.lock
index 1dee849d..bd2d7479 100644
--- a/tests/umdf-driver-workspace/Cargo.lock
+++ b/tests/umdf-driver-workspace/Cargo.lock
@@ -728,6 +728,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/wdk-sys-tests/Cargo.lock b/tests/wdk-sys-tests/Cargo.lock
index 3b4cd777..54bbea4d 100644
--- a/tests/wdk-sys-tests/Cargo.lock
+++ b/tests/wdk-sys-tests/Cargo.lock
@@ -703,6 +703,7 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
+ "regex",
  "rustversion",
  "serde",
  "serde_json",

From 062467e33a2d9ae5c882eb8c30422c37f9446bbc Mon Sep 17 00:00:00 2001
From: Ayodeji Ige <ayige@microsoft.com>
Date: Wed, 27 Nov 2024 13:31:33 -0800
Subject: [PATCH 14/14] fix: revert Cargo.lock for tests

---
 tests/config-kmdf/Cargo.lock | 19 +++++++++----------
 tests/config-umdf/Cargo.lock | 19 +++++++++----------
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/tests/config-kmdf/Cargo.lock b/tests/config-kmdf/Cargo.lock
index 33861e80..af8a88c1 100644
--- a/tests/config-kmdf/Cargo.lock
+++ b/tests/config-kmdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.6",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
 
 [[package]]
 name = "rustc-hash"
@@ -848,7 +848,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",
diff --git a/tests/config-umdf/Cargo.lock b/tests/config-umdf/Cargo.lock
index c57a1707..99a963cd 100644
--- a/tests/config-umdf/Cargo.lock
+++ b/tests/config-umdf/Cargo.lock
@@ -503,14 +503,14 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.11.1"
+version = "1.10.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.9",
- "regex-syntax 0.8.5",
+ "regex-automata 0.4.6",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -524,13 +524,13 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.9"
+version = "0.4.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.3",
 ]
 
 [[package]]
@@ -541,9 +541,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
 
 [[package]]
 name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
 
 [[package]]
 name = "rustc-hash"
@@ -848,7 +848,6 @@ dependencies = [
  "clap-cargo",
  "lazy_static",
  "paste",
- "regex",
  "rustversion",
  "serde",
  "serde_json",