Skip to content

Fix offreg false-negative (stale cached type) and manifest-fix NRE - #143

Merged
sanderdewit merged 1 commit into
mainfrom
fix/offreg-probe-and-manifestfix-nre
Jul 8, 2026
Merged

Fix offreg false-negative (stale cached type) and manifest-fix NRE#143
sanderdewit merged 1 commit into
mainfrom
fix/offreg-probe-and-manifestfix-nre

Conversation

@sanderdewit

Copy link
Copy Markdown
Owner

Both reproduced by running Invoke-MsixInvestigation on 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)

_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 had already imported an older module version keeps the old MsixOffReg (no LoadLibraryW). [MsixOffReg]::LoadLibraryW then 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-MsixHeuristicFinding called .SelectSingleNode on $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-MsixInvestigation on 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

  • New regression test in MSIX.ScannerError.Tests.ps1: a manifest with neither <Properties> nor package <Extensions> produces no ManifestFix ScannerError.
  • PSSA clean; full suite 713 passed / 0 failed / 1 skipped.

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

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>
@sanderdewit
sanderdewit merged commit 43cf50f into main Jul 8, 2026
6 checks passed
@sanderdewit
sanderdewit deleted the fix/offreg-probe-and-manifestfix-nre branch July 8, 2026 20:18
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.

1 participant