microsoft / windows-drivers-rs

Platform that enables Windows driver development in Rust. Developed by Surface.
Apache License 2.0
1.49k stars 65 forks source link

fix: skip infverif task for sample drivers built with certain GE WDK versions #143

Closed NateD-MSFT closed 4 months ago

NateD-MSFT commented 5 months ago

We expect that drivers built for Windows pass InfVerif. However, the driver samples provided by Microsoft generally have settings that do not pass the default InfVerif ruleset.

In the current (E)WDK, this can be alleviated by setting /msft when calling InfVerif.exe, but in the upcoming release's WDK this syntax is no longer available. While we wait for the InfVerif team to enable a new "/samples" flag for us, this change updates the cargo make logic to:

Note that with this change, samples should extend the makefile with

[tasks.infverif]
dependencies = ["wdk-samples-setup"]
condition = { env_not_set = ["WDK_INF_USING_NEW_VERSION"] }

When testing on one machine, I did see an issue where a ; was incorrectly appended to the /msft flag. I haven't been able to repro this on other machines yet.

wmmc88 commented 5 months ago
  • move the sample-specific infverif version mitigation logic to a script block in sample-kmdf-driver/Makefile.toml (and the same makefiles in the samples repo). It can be refactored to update WDK_BUILD_ADDITIONAL_INFVERIF_FLAGS by printing to stdout and using the rust-env-update plugin I wrote.

On 2nd thought, given that this is to work around issues in production WDKs and will be needed in all msft samples, I think we can keep a public function in wdk_build::cargo_make like setup_wdk_samples_infverif that contains workarounds like this. I still would like to keep it outside of wdk-build-init that every driver build goes thru. One approach is creating a new wdk-samples-setup task in rust-driver-makefile.toml and overriding the dependencies of infverif task to add the wdk-samples-setup in the samples (both in this repo and in sample repo). The wdk-samples-setup would call setup_wdk_samples_infverif and would update the executing task using the rust-env-update plugin

NateD-MSFT commented 5 months ago

I did one more quick refactor to clean things up, go ahead and review when you have time.

NateD-MSFT commented 4 months ago

Could you also spin up an accompanying pr for the samples repo? It won't merge until we do another crates.io release for WDR, but you can test the changes using git or path deps in cargo

Created here: https://github.com/microsoft/Windows-rust-driver-samples/pull/18