feat: add PE resource version + metadata generation#661
Open
Alan632 wants to merge 13 commits into
Open
Conversation
added 3 commits
May 19, 2026 21:09
… var as the same as an absent env var, update documentation, update and add unit tests
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic generation and compilation of Windows PE VERSIONINFO resources for driver binaries built with wdk-build, so that file version and descriptive metadata are embedded directly into the produced .sys / .dll artifacts (not just the .inf).
Changes:
- Introduces
resource_compilemodule to generate a.rc, compile it viarc.exeto a.res, and emit linker args to embed it into the driver binary. - Extends
ConfigErrorandConfig::configure_binary_buildto run the version-resource compilation step during build script configuration. - Updates WDK metadata parsing so
[package.metadata.wdk.*]sections (e.g.,version-resource) can coexist while still strictly validating thedriver-modelconfiguration, plus adds unit tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/wdk-build/src/resource_compile.rs | New module implementing version/metadata resolution, .rc generation, rc.exe invocation, and link-arg emission, with unit tests. |
| crates/wdk-build/src/metadata/mod.rs | Narrows WDK configuration deserialization to metadata.wdk.driver-model while permitting other metadata.wdk.* sections; adds tests. |
| crates/wdk-build/src/lib.rs | Exposes the new module, adds a ConfigError variant, and invokes resource compilation from configure_binary_build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #661 +/- ##
==========================================
+ Coverage 79.61% 81.37% +1.76%
==========================================
Files 26 27 +1
Lines 5544 6466 +922
Branches 5544 6466 +922
==========================================
+ Hits 4414 5262 +848
- Misses 1001 1048 +47
- Partials 129 156 +27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…tness for different dev environment setups
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Alan632 <aln.noda7@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Alan632 <aln.noda7@gmail.com>
added 2 commits
May 27, 2026 15:03
… typos.toml used in rc.exe args
…se crate only), fix lint issues
…ary rerun directive (CI builds are fresh), fix formatting in .typos.toml
…ourceCompileError by changing variant to use path aware IoError
Alan632
commented
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently driver PE resource metadata and versioning do not get populated (the version in the *.inf does) and makes issue and post-mortem troubleshooting/tracing difficult.
This PR adds the functionality to populate the PE resource metadata automatically.
wdk-build/src/lib.rsconfigure_binary_buildto initiate *.rc generation, compilation to *.res, and linker directive emissionwdk-build/src/resource_compile.rscompile_version_resourcecalled fromconfigure_binary_buildSTAMPINF_VERSION, falling back toCARGO_PKG_VERSIONset by Cargorc.exeto compile to a *.res and emits linker directiveswdk-build/src/metadata/mod.rs[package.metadata.wdk.version-resource]), keeps strict serde validation of Wdk/DriverConfig (eg.[package.metadata.wdk.driver-model])Validation
Local testing with in production driver in the following scenarios: missing version-resource metadata, populated version-resource metadata, and
STAMPINF_VERSIONset.Tested with sample drivers kmdf/wdm/umdf.
WDM sample driver with
[package.metadata.wdk.version-resource]info filled in:UMDF sample driver without
[package.metadata.wdk.version-resource]info: