Restore image edition metadata lost during export (fixes #583) - #628
Open
maged909 wants to merge 1 commit into
Open
Restore image edition metadata lost during export (fixes #583)#628maged909 wants to merge 1 commit into
maged909 wants to merge 1 commit into
Conversation
On some source images the exported install.wim loses the EDITIONID, INSTALLATIONTYPE, PRODUCTTYPE, PRODUCTSUITE and LANGUAGES elements from its XML metadata block. Windows Setup matches ei.cfg against EDITIONID, so without it the install fails with "Setup has failed to validate the product key" - both when a product key is supplied and when the user picks "I don't have a product key". Reported in ntdevlabs#583. Read the edition metadata off the source image before servicing, and restore it after the final export if it went missing. The XML block is written last in the WIM, so it can be rewritten in place and the file retruncated; the header's XML resource entry is repointed and the integrity table cleared. No-op when the metadata survived the export. Co-Authored-By: Claude Opus 5 <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.
The problem
On some source images the exported
install.wimcomes out missing theEDITIONID,INSTALLATIONTYPE,PRODUCTTYPE,PRODUCTSUITEandLANGUAGESelements from its XML metadata block.Windows Setup matches
ei.cfg'sEditionIDagainst the image'sEDITIONID. When that element is absent, no image matches, and Setup aborts with:This happens both when a product key is supplied (via
autounattend.xmlor typed in) and when the user clicks "I don't have a product key", which makes it look like a licensing problem when it is really an edition-resolution problem. Reported in #583.Diagnosis
Dumping the XML block out of a failing
install.wimshows the<WINDOWS>element reduced to:versus the same index in the untouched Microsoft ISO:
<FLAGS>Professional</FLAGS>does survive, which is presumably why this went unnoticed for a long time — that was the field older Setup versions matched on.The fix
/Export-Image, check the resulting WIM and restore the elements if they were dropped.The XML block is written last in the WIM, so it can be rewritten in place and the file retruncated; the header's XML resource entry is repointed and the integrity table cleared. The repair is a no-op when the metadata survived, so images that build fine today are unaffected.
Scope and caveats
This restores the metadata rather than preventing the loss — I could not determine what in the servicing pass drops it, and the repair is deliberately conservative: it bails out with a warning (rather than touching the file) if the XML block is not at EOF, and reports any failure without aborting the build.
Testing
Get-WindowsImagereportEditionId: Professional,InstallationType: Client,ProductType: WinNT,Languages: {en-US}, and Setup then installed to desktop without the error.TOTALBYTESconsistency, integrity-table clearing, idempotency on a second run, and the not-at-EOF refusal path.🤖 Generated with Claude Code