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

ResilientChangeTrackingEnabled = true has no effect #356

Closed
picrap opened this issue Dec 20, 2022 · 8 comments
Closed

ResilientChangeTrackingEnabled = true has no effect #356

picrap opened this issue Dec 20, 2022 · 8 comments

Comments

@picrap
Copy link

picrap commented Dec 20, 2022

If RCT is not enabled, it can’t be enabled using the ResilientChangeTrackingEnabled property:

using var v = VirtualDisk.Open(@"F:\Hyper-V\Windows XP\Virtual Hard Disks\Windows XP.vhdx", false, false, true);
v.ResilientChangeTrackingEnabled = false;

Does nothing (And it does not throw any error).

From a C++ program, invoking the native function works:

HANDLE vhdHandle;
_VIRTUAL_STORAGE_TYPE storageType{};
DWORD res = OpenVirtualDisk(&storageType, L"F:\\Hyper-V\\Windows XP\\Virtual Hard Disks\\Windows XP.vhdx",
        VIRTUAL_DISK_ACCESS_ALL, OPEN_VIRTUAL_DISK_FLAG_NONE, NULL, &vhdHandle);

SET_VIRTUAL_DISK_INFO setDiskInfo{};
setDiskInfo.ChangeTrackingEnabled = true;
setDiskInfo.Version = SET_VIRTUAL_DISK_INFO_CHANGE_TRACKING_STATE;
SetVirtualDiskInformation(vhdHandle, &setDiskInfo);

Please note that ResilientChangeTrackingEnabled = false (disabling RCT) actually works 😅, so RCT can be disabled, but not enabled.

@dahall
Copy link
Owner

dahall commented Dec 20, 2022

Please try the other Open overload. I believe the issue is related to the mask.

using var v = VirtualDisk.Open(filename, mask: VIRTUAL_DISK_ACCESS_MASK.VIRTUAL_DISK_ACCESS_ALL);
v.ResilientChangeTrackingEnabled = false;

@picrap
Copy link
Author

picrap commented Dec 20, 2022

Please try the other Open overload. I believe the issue is related to the mask.

using var v = VirtualDisk.Open(filename, mask: VIRTUAL_DISK_ACCESS_MASK.VIRTUAL_DISK_ACCESS_ALL);
v.ResilientChangeTrackingEnabled = false;

Nope, it does not work either.

@dahall
Copy link
Owner

dahall commented Dec 20, 2022

Is your main application 64-bit?

@picrap
Copy link
Author

picrap commented Dec 21, 2022

The platform target is set to “Any CPU” and I can’t find any other option that could relate to platform.

@dahall
Copy link
Owner

dahall commented Dec 21, 2022

Are you able to build your EXE with the target of x86 and let me know if setting ResilientChangeTrackingEnabled = true still fails?

@picrap
Copy link
Author

picrap commented Dec 21, 2022

That’s a win! It works in x86, fails in x64 and Any CPU.
The fun fact it that ResilientChangeTrackingEnabled = false always succeeds.

@dahall
Copy link
Owner

dahall commented Dec 21, 2022

Yep. Under 32-bit builds the structure aligns correctly so setting the structure field to 1 works. I'll fix it so it works on both 32 and 64 bit. Thanks for your help.

@dahall
Copy link
Owner

dahall commented Dec 23, 2022

This is now fixed

@dahall dahall closed this as completed Dec 23, 2022
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

No branches or pull requests

2 participants