Repository navigation
Apply qword, hex(2) and hex(7) reg values instead of throwing - #62
Merged
Merged
Conversation
Convert-RegOperationToValueKind, the PowerShell registry writer used when a reg file is applied into a mounted user hive (Sysprep and per-user) or as the fallback when reg import fails, only handled DWord, String and Binary. The reg file parser already produces QWord, Hex2 (REG_EXPAND_SZ) and Hex7 (REG_MULTI_SZ), and the applied-state verifier already maps all three, so the writer was the only part out of step: a reg file using one of those types would throw "Unsupported value type" through that path. Add the three cases, wrapping the qword through its bytes so a high-bit value keeps its bit pattern like the dword case does.
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.
The gap
Convert-RegOperationToValueKind(Scripts/Helpers/ApplyRegistryRegFile.ps1) is the PowerShell registry writer used when a reg file is applied into a mounted user hive (-Sysprep/-User, wherereg importcan't targetHKU\<mount>) or as the fallback whenreg importfails. It only handledDWord,String, andBinary, and threw "Unsupported value type" on anything else.But the reg-file parser (
Get-RegFileOperations) already emitsQWord,Hex2(REG_EXPAND_SZ), andHex7(REG_MULTI_SZ), and the applied-state verifier (Get-ExpectedRegistryValueKind) already maps all three. So the writer was the only part of the parse/apply/verify pipeline out of step: a reg file using one of those types would parse and verify fine but fail to apply through the hive/fallback path.Not a live bug today — no bundled reg file uses those types (
grepconfirms) — and it fails loudly (throws → rollback), not silently. This closes the asymmetry so it stays safe as reg files evolve.Change
Added
QWord,Hex2→ExpandString, andHex7→MultiStringcases, wrapping the qword through its bytes so a high-bit value keeps its bit pattern exactly as the dword case already does.Validation
Tests\Invoke-StaticValidation.ps1 -RequirePSScriptAnalyzerclean (126 files).Tests/Unit/Test-RegistryFiles.ps1: 12/12 (added 6 cases covering all value types, the high-bit dword/qword sign wrap, and the unsupported-type throw).