Add open_options support to registry open_*_key helpers#643
Draft
benhillis wants to merge 1 commit into
Draft
Conversation
Adds a wil::reg::open_options flag enum (none / open_link / backup_restore / dont_virtualize) that maps to the ulOptions parameter of RegOpenKeyExW, and threads it through open_unique_key, open_shared_key, and their _nothrow variants as a trailing defaulted parameter. Previously these helpers hardcoded ulOptions to 0, so callers needing e.g. REG_OPTION_OPEN_LINK had to fall back to raw Win32. Includes [registry] tests covering option-to-ulOptions mapping (static_assert), default-open parity, and a symbolic-link round-trip proving open_link opens the link key itself rather than its target. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Adds open-with-options support to wil's registry
open_*_keyhelpers.Motivation
Today
open_unique_key/open_shared_key(and their_nothrowvariants) hardcodeulOptionsto0in theirRegOpenKeyExWcall. Callers that need a non-zero option — most notablyREG_OPTION_BACKUP_RESTOREandREG_OPTION_OPEN_LINK— have no choice but to drop down to raw Win32. This is the last remaining gap preventing WSL from replacing its in-house registry helper with wil (WSL opens keys withREG_OPTION_BACKUP_RESTORE).Change
wil::reg::open_optionsflag enum:none,open_link(REG_OPTION_OPEN_LINK),backup_restore(REG_OPTION_BACKUP_RESTORE),dont_virtualize(REG_OPTION_DONT_VIRTUALIZE), withDEFINE_ENUM_FLAG_OPERATORS.= open_options::none) throughopen_unique_key,open_shared_key,open_unique_key_nothrow,open_shared_key_nothrowand the internalreg_view::open_key. Source-compatible — existing callers are unaffected.key_optionsprecedent on the create side (kept separate because create/open option semantics differ).Tests
Added
BasicRegistryTests::open_options([registry]) covering:static_assertmapping of each enum value to itsREG_OPTION_*constant and flag-OR composition.nonebehaves like a plain open).open_linkreturns the link key itself while a plain open follows through to the target.Validated in both
normalandnoexceptconfigurations; full[registry]suite green.Opening as draft for review.