Skip to content

Remove dead code and some duplication - #487

Merged
lostindark merged 4 commits into
lostindark:masterfrom
indep-arg:pr-dead-code
Nov 1, 2026
Merged

lostindark merged 4 commits into
lostindark:masterfrom
indep-arg:pr-dead-code

Conversation

@indep-arg

Copy link
Copy Markdown
Contributor

No behavior change, one commit each:

  • SetupAPI.GetDeviceDriverInfo and everything only it used (the SetupDi* imports, the 32/64-bit SP_DRVINFO structs, the property helpers) had no callers. Device info comes from ConfigManager. About 500 lines.
  • DSEFormHelper.RunAsAdmin, which read and wrote the AppCompatFlags registry value, wasn't used.
  • The online add/delete code was identical in DismUtil and NativeDriverStore. It's now SetupAPI.TryAddDriver / TryDeleteDriver.
  • Filled in the six "<Pending>" analyzer suppression justifications.

SetupAPI.GetDeviceDriverInfo and everything only it used (the SetupDi*
imports, the 32/64-bit SP_DRVINFO structs, registry and device property
helpers) have no callers; device information comes from ConfigManager
(cfgmgr32). SetupAPI keeps the signer lookup and the add/delete calls.
It read and wrote the AppCompatFlags RUNASADMIN registry flag for the
executable, but nothing calls it. The app requests elevation through its
manifest instead.
DismUtil and NativeDriverStore both handle the online case by calling
SetupAPI and turning a Win32Exception into false, with identical blocks
in each. Move that into SetupAPI.TryAddDriver and TryDeleteDriver.
Six SuppressMessage attributes still had the "<Pending>" placeholder.
The CA1031 ones are UI handlers that log and report any failure; the
IDE1006 ones keep the DismApi.dll export name.
@indep-arg
indep-arg marked this pull request as ready for review October 28, 2026 01:06
@indep-arg

Copy link
Copy Markdown
Contributor Author

Tested the build from this PR: deleting and re-adding a driver package works with both the native and DISM stores.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the driver-store utility cleanup and consolidation.

No open issues 🎉

What changed in this PR

This PR simplifies DriverStoreExplorer’s driver-store utilities by removing unused code and consolidating online add/delete handling, with no intended behavior change.

Changes:

  • Removes unused SetupAPI device-enumeration code and the registry-backed RunAsAdmin property.
  • Shares online driver add/delete wrappers between the DISM and native backends.
  • Replaces six placeholder analyzer suppression justifications with explanations.
File Description
Rapr/​Utils/​SetupAPI.cs Removes unused device-enumeration infrastructure and adds shared add/delete wrappers.
Rapr/​Utils/​NativeDriverStore.cs Delegates online add/delete operations to the shared wrappers.
Rapr/​Utils/​DismUtil.cs Uses shared wrappers and explains native-function naming suppressions.
Rapr/​DSEFormHelper.cs Removes the unused AppCompat registry property and related declarations.
Rapr/​DSEForm.cs Explains four general-exception suppression justifications; no logic changes.

Review effort: Balanced

@lostindark
lostindark merged commit 4778e63 into lostindark:master Nov 1, 2026
2 checks passed
@indep-arg
indep-arg deleted the pr-dead-code branch November 1, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants