Skip to content

Commit

Permalink
refactor: update error messages for unsupported driver configurations…
Browse files Browse the repository at this point in the history
… and adjust README instructions for null driver installation
  • Loading branch information
Ayodeji Ige committed Nov 27, 2024
1 parent e23a9e5 commit d515c39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
15 changes: 7 additions & 8 deletions crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -356,7 +355,7 @@ impl Config {
);
},
DriverConfig::Package => {
return Err(ConfigError::PackageDriverTypeBuildNotSupported);
return Err(ConfigError::UnsupportedDriverConfig);
},
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -446,7 +445,7 @@ impl Config {
);
},
DriverConfig::Package => {
return Err(ConfigError::PackageDriverTypeBuildNotSupported);
return Err(ConfigError::UnsupportedDriverConfig);
},
}

Expand Down Expand Up @@ -702,7 +701,7 @@ impl Config {
println!("cargo::rustc-cdylib-link-arg=/SUBSYSTEM:WINDOWS");
}
DriverConfig::Package => {
return Err(ConfigError::PackageDriverTypeBuildNotSupported);
return Err(ConfigError::UnsupportedDriverConfig);
},
}

Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
14 changes: 2 additions & 12 deletions examples/sample-null-driver-workspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

0 comments on commit d515c39

Please sign in to comment.