Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dism): reload imaging session when needed #460

Merged
merged 3 commits into from
Jan 10, 2022

Conversation

lippertmarkus
Copy link
Contributor

@lippertmarkus lippertmarkus commented Dec 12, 2021

When DISM API returns DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED (0x00000001) the session should automatically be reloaded. I looked at how the .NET library handles this, and have oriented the code to it:
https://github.com/jeffkl/ManagedDism/blob/main/src/Microsoft.Dism/DismUtilities.cs#L304-L315
with the reload just closing the old and opening a new session without calling DismInitialize again: https://github.com/jeffkl/ManagedDism/blob/main/src/Microsoft.Dism/DismSession.cs#L57-L72

To support this here, I needed to extend the session struct and also change the Handle to a pointer so that the call defer dismSession.Close() on the caller side doesn't close the initial handle again (already closed if a session reload happend) but instead closes the new handle (the new one created by the reload).

This fixes #459 and it now works on Windows Server 2019/2022 and also Windows 10.

cc: @ItsMattL

@lippertmarkus
Copy link
Contributor Author

lippertmarkus commented Dec 12, 2021

signed the CLA, please re-run CI

@lippertmarkus
Copy link
Contributor Author

@ItsMattL what do you think? :)

@TsekNet
Copy link
Contributor

TsekNet commented Dec 20, 2021

Just wanted to jump on this thread to keep you updated.

@ItsMattL has begun reworking our internal automation to make it such that we can accept PRs again for this repo. #470 as an example.

@ItsMattL is also out until the new year, so I wouldn't expect movement until then at the very least.

@lippertmarkus
Copy link
Contributor Author

Understood, thanks for the update!
Wishing you both a calm Christmas and new year.

Copy link
Collaborator

@ItsMattL ItsMattL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this!

go/dism/dism.go Show resolved Hide resolved
go/dism/dism.go Outdated Show resolved Hide resolved
go/dism/dism.go Show resolved Hide resolved
go/dism/dism.go Show resolved Hide resolved
@copybara-service copybara-service bot merged commit 8a7f3da into google:master Jan 10, 2022
@lippertmarkus lippertmarkus deleted the fix-session-reloading branch January 11, 2022 07:12
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.

DISM: EnableFeature returns error on Windows Server 2019 although enablement works
3 participants