Skip to content

support both cimfs and cimwriter dlls#2587

Open
anmaxvl wants to merge 3 commits intomicrosoft:mainfrom
anmaxvl:cimfs-backward-compat
Open

support both cimfs and cimwriter dlls#2587
anmaxvl wants to merge 3 commits intomicrosoft:mainfrom
anmaxvl:cimfs-backward-compat

Conversation

@anmaxvl
Copy link
Contributor

@anmaxvl anmaxvl commented Jan 13, 2026

The PR introducing cimwriter.dll was a breaking change, which is fixed in this PR.

Add both cimfs.dll and cimwriter.dll syscalls and only use cimwriter.dll when present.

Add logging to indicate which one is used:

cimwriter

@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch 3 times, most recently from 2ccfeab to 47570f0 Compare January 13, 2026 16:26
@anmaxvl anmaxvl marked this pull request as ready for review January 13, 2026 18:02
@anmaxvl anmaxvl requested a review from a team as a code owner January 13, 2026 18:02
@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch from 47570f0 to 36bea94 Compare January 13, 2026 18:04
Copy link
Contributor

@helsaawy helsaawy left a comment

Choose a reason for hiding this comment

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

nits in comments; but LGTM overall

@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch from 97f02b3 to 2589b91 Compare January 20, 2026 18:50
@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch 2 times, most recently from 6070070 to b61bbd6 Compare February 9, 2026 18:09
@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch from b61bbd6 to a9415b3 Compare February 11, 2026 00:23
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *CimFsImagePath, flags uint32, volumeID *g, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage
// pickSupported makes sure we use appropriate syscalls depending on which DLLs are present.
func pickSupported[F any](cimWriterFunc, cimfsFunc F) F {
if cimwriter.Supported() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to log which CIM dll gets used but not for each syscall?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added logging to the function used by snapshotter.

The PR introducing `cimwriter.dll` was a breaking change, which
is fixed in this PR.

Split CIM syscalls into separate packages for `cimfs.dll` and
`cimwriter.dll`, with shared types in `internal/winapi/types/`.

Add `pickSupported()` to prefer `cimwriter.dll` for write operations
and fall back to `cimfs.dll` when `cimwriter.dll` is not present.

Mount, dismount, and verification operations always use `cimfs.dll`.
Relax `CimFsSupported()` to only require cimfs.dll instead of
both DLLs (the breaking change).

Signed-off-by: Maksim An <maksiman@microsoft.com>
Regenerate zsyscall_windows.go files for the new cimfs and
cimwriter packages after PR feedback.

Signed-off-by: Maksim An <maksiman@microsoft.com>
Allow `cimwriter.dll` and `cimfs.dll` to be loaded from outside
the system directory.

Log the resolved DLL path on load using `GetModuleFileName`.

Add `LogCimDLLSupport()` to report which DLL is active for
write operations, called from `CreateBlockCIMWithOptions` on
every block CIM creation.

Add `TestMain` in `pkg/cimfs` to print DLL availability in
test output.

Signed-off-by: Maksim An <maksiman@microsoft.com>
@anmaxvl anmaxvl force-pushed the cimfs-backward-compat branch from 2224b12 to 32f979e Compare February 18, 2026 06:58
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.

3 participants