Fix offreg false-negative (stale cached type) and manifest-fix NRE - #143
Merged
Conversation
Both reproduced by Invoke-MsixInvestigation on a real package on a Win11 host that HAS offreg.dll: 1. offreg probe false-negative. _MsixTestOffregAvailable probed via LoadLibraryW, a method added to the MsixOffReg type in 0.73.3. A .NET type can't be redefined once loaded, so a session that imported an OLDER module version first keeps the old type; [MsixOffReg]::LoadLibraryW then throws method-not- found, is caught, and reports offreg.dll missing even though it is present - silently dropping every registry-derived finding (ShellExt etc.). Probe now uses ORCreateHive (present in every version of the wrapper): it tests the exact P/Invoke binding the scanners use and survives a stale cached type. DllNotFoundException => unavailable; any other error => bound => available. 2. Manifest-fix NRE. The manifest block called .SelectSingleNode on $mf.Package.Properties (null when no <Properties>) and iterated @($mf.Package.Extensions.Extension) which is @($null) when there is no package-level <Extensions>. Both NRE'd and aborted the block, dropping ALL manifest-fix findings for those (very common) shapes. Guard Properties; null-strip the extension lists. Regression tests in MSIX.ScannerError.Tests.ps1 (manifest with neither element). Folded into the still-unreleased 0.73.4 notes/CHANGELOG. Full suite 713/0/1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Both reproduced by running
Invoke-MsixInvestigationon a real package (7-Zip wix MSIX) on a Win11 host that has offreg.dll — reported as "broke things" after 0.73.3/0.73.4.1. offreg probe false-negative (regression from 0.73.3)
_MsixTestOffregAvailableprobed viaLoadLibraryW, a method added to theMsixOffRegtype in 0.73.3. A .NET type can't be redefined once loaded, so a session that had already imported an older module version keeps the oldMsixOffReg(noLoadLibraryW).[MsixOffReg]::LoadLibraryWthen throws method-not-found → caught → reports offreg.dll missing on a host that has it, silently dropping every registry-derived finding (ShellExt, services, …). It fails closed.Fix: probe via
ORCreateHive(present in every version of the wrapper). It tests the exact P/Invoke binding the scanners use and survives a stale cached type.DllNotFoundException⇒ unavailable; any other error ⇒ the DLL bound ⇒ available.2. Manifest-fix NRE (pre-existing, surfaced by #140)
The manifest-level block in
Get-MsixHeuristicFindingcalled.SelectSingleNodeon$mf.Package.Properties(null when a package has no<Properties>) and iterated@($mf.Package.Extensions.Extension), which is@($null)— an array holding one$null— when there is no package-level<Extensions>. Both NRE'd and aborted the whole block, dropping every manifest-fix finding for those very common shapes.Fix: guard the
<Properties>access; null-strip the extension lists.Verified on the real package
Invoke-MsixInvestigationon the 7-Zip package now: no offreg warning, no ManifestFix error, and ShellExt is detected again (it was missing in the broken run because offreg was wrongly reported unavailable).Tests
MSIX.ScannerError.Tests.ps1: a manifest with neither<Properties>nor package<Extensions>produces noManifestFixScannerError.Folded into the still-unreleased 0.73.4 notes/CHANGELOG (the probe fix corrects the 0.73.3 regression). No release cut.
Note for anyone hitting the warning on a live session today: it's the stale-type case — a fresh PowerShell session with the fixed module is clean.
🤖 Generated with Claude Code