ifndef VIRT_DISK_API_DEF
define VIRT_DISK_API_DEF

.pragma comment(lib, virtdisk)

include winapifamily.inc

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

if ((WINVER GE _WIN32_WINNT_WIN7) OR defined(VIRTDISK_DEFINE_FLAGS))

ifndef _VIRTUAL_STORAGE_TYPE_DEFINED
define _VIRTUAL_STORAGE_TYPE_DEFINED
VIRTUAL_STORAGE_TYPE	STRUC
DeviceId		ULONG ?
VendorId		GUID <>
VIRTUAL_STORAGE_TYPE	ENDS
PVIRTUAL_STORAGE_TYPE	typedef ptr VIRTUAL_STORAGE_TYPE
endif

ifdef DEFINE_GUID
DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT, 0xec984aec, 0xa0f9, 0x47e9, 0x90, 0x1f, 0x71, 0x41, 0x5a, 0x66, 0x34, 0x5b)
endif


VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN equ 0
VIRTUAL_STORAGE_TYPE_DEVICE_ISO	    equ 1
VIRTUAL_STORAGE_TYPE_DEVICE_VHD	    equ 2
VIRTUAL_STORAGE_TYPE_DEVICE_VHDX    equ 3
VIRTUAL_STORAGE_TYPE_DEVICE_VHDSET  equ 4

if NOT defined(VIRTDISK_DEFINE_FLAGS)

OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT equ 1

.enum OPEN_VIRTUAL_DISK_VERSION {
    OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
    OPEN_VIRTUAL_DISK_VERSION_1		  = 1,
    OPEN_VIRTUAL_DISK_VERSION_2		  = 2,
    OPEN_VIRTUAL_DISK_VERSION_3		  = 3,
    }

OPEN_VIRTUAL_DISK_PARAMETERS STRUC
Version			OPEN_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  RWDepth		ULONG ?
 ENDS
 STRUC Version2
  GetInfoOnly		BOOL ?
  ReadOnly		BOOL ?
  ResiliencyGuid	GUID <>
 ENDS
 STRUC Version3
  GetInfoOnly		BOOL ?
  ReadOnly		BOOL ?
  ResiliencyGuid	GUID <>
  SnapshotId		GUID <>
 ENDS
ENDS
OPEN_VIRTUAL_DISK_PARAMETERS ENDS
POPEN_VIRTUAL_DISK_PARAMETERS typedef ptr OPEN_VIRTUAL_DISK_PARAMETERS

endif

.enum VIRTUAL_DISK_ACCESS_MASK {
    VIRTUAL_DISK_ACCESS_NONE		    = 0x00000000,
    VIRTUAL_DISK_ACCESS_ATTACH_RO	    = 0x00010000,
    VIRTUAL_DISK_ACCESS_ATTACH_RW	    = 0x00020000,
    VIRTUAL_DISK_ACCESS_DETACH		    = 0x00040000,
    VIRTUAL_DISK_ACCESS_GET_INFO	    = 0x00080000,
    VIRTUAL_DISK_ACCESS_CREATE		    = 0x00100000,
    VIRTUAL_DISK_ACCESS_METAOPS		    = 0x00200000,
    VIRTUAL_DISK_ACCESS_READ		    = 0x000d0000,
    VIRTUAL_DISK_ACCESS_ALL		    = 0x003f0000,
    VIRTUAL_DISK_ACCESS_WRITABLE	    = 0x00320000
    }

.enum OPEN_VIRTUAL_DISK_FLAG {
    OPEN_VIRTUAL_DISK_FLAG_NONE		       = 0x00000000,
    OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS	       = 0x00000001,
    OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE	       = 0x00000002,
    OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE	       = 0x00000004,
    OPEN_VIRTUAL_DISK_FLAG_CACHED_IO	       = 0x00000008,
    OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN   = 0x00000010,
    OPEN_VIRTUAL_DISK_FLAG_PARENT_CACHED_IO    = 0x00000020,
    OPEN_VIRTUAL_DISK_FLAG_VHDSET_FILE_ONLY    = 0x00000040,
    OPEN_VIRTUAL_DISK_FLAG_IGNORE_RELATIVE_PARENT_LOCATOR = 0x00000080,
    OPEN_VIRTUAL_DISK_FLAG_NO_WRITE_HARDENING = 0x00000100,
    }

if NOT defined(VIRTDISK_DEFINE_FLAGS)

OpenVirtualDisk proto WINAPI :PVIRTUAL_STORAGE_TYPE, :PCWSTR, :VIRTUAL_DISK_ACCESS_MASK, :OPEN_VIRTUAL_DISK_FLAG, :POPEN_VIRTUAL_DISK_PARAMETERS, :PHANDLE

CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE equ 0

CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_SECTOR_SIZE equ 0

.enum CREATE_VIRTUAL_DISK_VERSION {
    CREATE_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
    CREATE_VIRTUAL_DISK_VERSION_1	    = 1,
    CREATE_VIRTUAL_DISK_VERSION_2	    = 2,
    CREATE_VIRTUAL_DISK_VERSION_3	    = 3,
    CREATE_VIRTUAL_DISK_VERSION_4	    = 4,
    }

CREATE_VIRTUAL_DISK_PARAMETERS STRUC
Version			CREATE_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  UniqueId		 GUID <>
  MaximumSize		 dq ?
  BlockSizeInBytes	 dd ?
  SectorSizeInBytes	 dd ?
  ParentPath		 PCWSTR ?
  SourcePath		 PCWSTR ?
 ENDS
 STRUC Version2
  UniqueId		 GUID <>
  MaximumSize		 dq ?
  BlockSizeInBytes	 dd ?
  SectorSizeInBytes	 dd ?
  PhysicalSectorSizeInBytes dd ?
  ParentPath		 PCWSTR ?
  SourcePath		 PCWSTR ?
  OpenFlags		 OPEN_VIRTUAL_DISK_FLAG ?
  ParentVirtualStorageType VIRTUAL_STORAGE_TYPE <>
  SourceVirtualStorageType VIRTUAL_STORAGE_TYPE <>
  ResiliencyGuid	 GUID <>
 ENDS
 STRUC Version3
  UniqueId		 GUID <>
  MaximumSize		 dq ?
  BlockSizeInBytes	 dd ?
  SectorSizeInBytes	 dd ?
  PhysicalSectorSizeInBytes ULONG ?
  ParentPath		 PCWSTR ?
  SourcePath		 PCWSTR ?
  OpenFlags		 OPEN_VIRTUAL_DISK_FLAG ?
  ParentVirtualStorageType VIRTUAL_STORAGE_TYPE <>
  SourceVirtualStorageType VIRTUAL_STORAGE_TYPE <>
  ResiliencyGuid	 GUID <>
  SourceLimitPath	 PCWSTR ?
  BackingStorageType	 VIRTUAL_STORAGE_TYPE <>
 ENDS
 STRUC Version4
  UniqueId		 GUID <>
  MaximumSize		 dq ?
  BlockSizeInBytes	 dd ?
  SectorSizeInBytes	 dd ?
  PhysicalSectorSizeInBytes dd ?
  ParentPath		 PCWSTR ?
  SourcePath		 PCWSTR ?
  OpenFlags		 OPEN_VIRTUAL_DISK_FLAG ?
  ParentVirtualStorageType VIRTUAL_STORAGE_TYPE <>
  SourceVirtualStorageType VIRTUAL_STORAGE_TYPE <>
  ResiliencyGuid	 GUID <>
  SourceLimitPath	 PCWSTR ?
  BackingStorageType	 VIRTUAL_STORAGE_TYPE <>
  PmemAddressAbstractionType GUID <>
  DataAlignment		 dq ?
 ENDS
ENDS
CREATE_VIRTUAL_DISK_PARAMETERS ENDS
PCREATE_VIRTUAL_DISK_PARAMETERS typedef ptr CREATE_VIRTUAL_DISK_PARAMETERS

.enum CREATE_VIRTUAL_DISK_FLAG {
    CREATE_VIRTUAL_DISK_FLAG_NONE			   = 0x0,
    CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION	   = 0x1,
    CREATE_VIRTUAL_DISK_FLAG_PREVENT_WRITES_TO_SOURCE_DISK = 0x2,
    CREATE_VIRTUAL_DISK_FLAG_DO_NOT_COPY_METADATA_FROM_PARENT = 0x4,
    CREATE_VIRTUAL_DISK_FLAG_CREATE_BACKING_STORAGE = 0x8,
    CREATE_VIRTUAL_DISK_FLAG_USE_CHANGE_TRACKING_SOURCE_LIMIT = 0x10,
    CREATE_VIRTUAL_DISK_FLAG_PRESERVE_PARENT_CHANGE_TRACKING_STATE = 0x20,
    CREATE_VIRTUAL_DISK_FLAG_VHD_SET_USE_ORIGINAL_BACKING_STORAGE = 0x40,
    CREATE_VIRTUAL_DISK_FLAG_SPARSE_FILE = 0x80,
    CREATE_VIRTUAL_DISK_FLAG_PMEM_COMPATIBLE = 0x100,
    }

CreateVirtualDisk proto WINAPI :PVIRTUAL_STORAGE_TYPE, :PCWSTR, :VIRTUAL_DISK_ACCESS_MASK, :PSECURITY_DESCRIPTOR, :CREATE_VIRTUAL_DISK_FLAG, :ULONG, :PCREATE_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED, :PHANDLE

.enum ATTACH_VIRTUAL_DISK_VERSION {
    ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
    ATTACH_VIRTUAL_DISK_VERSION_1	    = 1,
    ATTACH_VIRTUAL_DISK_VERSION_2	    = 2,
    }

ATTACH_VIRTUAL_DISK_PARAMETERS STRUC
Version			ATTACH_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  Reserved		dd ?
 ENDS
 STRUC Version2
  RestrictedOffset	dq ?
  RestrictedLength	dq ?
 ENDS
ENDS
ATTACH_VIRTUAL_DISK_PARAMETERS ENDS
PATTACH_VIRTUAL_DISK_PARAMETERS typedef ptr ATTACH_VIRTUAL_DISK_PARAMETERS

endif ;; VIRTDISK_DEFINE_FLAGS

.enum ATTACH_VIRTUAL_DISK_FLAG {
    ATTACH_VIRTUAL_DISK_FLAG_NONE			    = 0x00000000,
    ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY			    = 0x00000001,
    ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER		    = 0x00000002,
    ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME		    = 0x00000004,
    ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST		    = 0x00000008,
    ATTACH_VIRTUAL_DISK_FLAG_NO_SECURITY_DESCRIPTOR	    = 0x00000010,
    ATTACH_VIRTUAL_DISK_FLAG_BYPASS_DEFAULT_ENCRYPTION_POLICY = 0x00000020,
    ATTACH_VIRTUAL_DISK_FLAG_NON_PNP			    = 0x00000040,
    ATTACH_VIRTUAL_DISK_FLAG_RESTRICTED_RANGE		    = 0x00000080,
    ATTACH_VIRTUAL_DISK_FLAG_SINGLE_PARTITION		    = 0x00000100,
    ATTACH_VIRTUAL_DISK_FLAG_REGISTER_VOLUME		    = 0x00000200,
    }

if NOT defined(VIRTDISK_DEFINE_FLAGS)
AttachVirtualDisk proto WINAPI :HANDLE, :PSECURITY_DESCRIPTOR, :ATTACH_VIRTUAL_DISK_FLAG, :ULONG, :PATTACH_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED
endif

.enum DETACH_VIRTUAL_DISK_FLAG {
    DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
    }

if NOT defined(VIRTDISK_DEFINE_FLAGS)
DetachVirtualDisk proto WINAPI :HANDLE, :DETACH_VIRTUAL_DISK_FLAG, :ULONG
GetVirtualDiskPhysicalPath proto WINAPI :HANDLE, :PULONG, :PWSTR
GetAllAttachedVirtualDiskPhysicalPaths proto WINAPI :PULONG, :PWSTR
endif

.enum DEPENDENT_DISK_FLAG {
    DEPENDENT_DISK_FLAG_NONE		     = 0x00000000,
    DEPENDENT_DISK_FLAG_MULT_BACKING_FILES   = 0x00000001,
    DEPENDENT_DISK_FLAG_FULLY_ALLOCATED	     = 0x00000002,
    DEPENDENT_DISK_FLAG_READ_ONLY	     = 0x00000004,
    DEPENDENT_DISK_FLAG_REMOTE		     = 0x00000008,
    DEPENDENT_DISK_FLAG_SYSTEM_VOLUME	     = 0x00000010,
    DEPENDENT_DISK_FLAG_SYSTEM_VOLUME_PARENT = 0x00000020,
    DEPENDENT_DISK_FLAG_REMOVABLE	     = 0x00000040,
    DEPENDENT_DISK_FLAG_NO_DRIVE_LETTER	     = 0x00000080,
    DEPENDENT_DISK_FLAG_PARENT		     = 0x00000100,
    DEPENDENT_DISK_FLAG_NO_HOST_DISK	     = 0x00000200,
    DEPENDENT_DISK_FLAG_PERMANENT_LIFETIME   = 0x00000400,
    }

if NOT defined(VIRTDISK_DEFINE_FLAGS)

.enum STORAGE_DEPENDENCY_INFO_VERSION {
    STORAGE_DEPENDENCY_INFO_VERSION_UNSPECIFIED = 0,
    STORAGE_DEPENDENCY_INFO_VERSION_1		= 1,
    STORAGE_DEPENDENCY_INFO_VERSION_2		= 2,
    }

STORAGE_DEPENDENCY_INFO_TYPE_1 STRUC
DependencyTypeFlags	DEPENDENT_DISK_FLAG ?
ProviderSpecificFlags	ULONG ?
VirtualStorageType	VIRTUAL_STORAGE_TYPE <>
STORAGE_DEPENDENCY_INFO_TYPE_1 ENDS
PSTORAGE_DEPENDENCY_INFO_TYPE_1 typedef ptr STORAGE_DEPENDENCY_INFO_TYPE_1

STORAGE_DEPENDENCY_INFO_TYPE_2 STRUC
DependencyTypeFlags	DEPENDENT_DISK_FLAG ?
ProviderSpecificFlags	ULONG ?
VirtualStorageType	VIRTUAL_STORAGE_TYPE <>
AncestorLevel		ULONG ?
DependencyDeviceName	PWSTR ?
HostVolumeName		PWSTR ?
DependentVolumeName	PWSTR ?
DependentVolumeRelativePath PWSTR ?
STORAGE_DEPENDENCY_INFO_TYPE_2 ENDS
PSTORAGE_DEPENDENCY_INFO_TYPE_2 typedef ptr STORAGE_DEPENDENCY_INFO_TYPE_2

STORAGE_DEPENDENCY_INFO STRUC
Version			STORAGE_DEPENDENCY_INFO_VERSION ?
NumberEntries		ULONG ?
UNION
 Version1Entries	STORAGE_DEPENDENCY_INFO_TYPE_1 1 dup(<>)
 Version2Entries	STORAGE_DEPENDENCY_INFO_TYPE_2 1 dup(<>)
ENDS
STORAGE_DEPENDENCY_INFO ENDS
PSTORAGE_DEPENDENCY_INFO typedef ptr STORAGE_DEPENDENCY_INFO

endif ;; VIRTDISK_DEFINE_FLAGS

.enum GET_STORAGE_DEPENDENCY_FLAG {
    GET_STORAGE_DEPENDENCY_FLAG_NONE	     = 0x00000000,
    GET_STORAGE_DEPENDENCY_FLAG_HOST_VOLUMES = 0x00000001,
    GET_STORAGE_DEPENDENCY_FLAG_DISK_HANDLE  = 0x00000002,
    }

GET_STORAGE_DEPENDENCY_FLAG_PARENTS equ GET_STORAGE_DEPENDENCY_FLAG_HOST_VOLUMES

if NOT defined(VIRTDISK_DEFINE_FLAGS)
GetStorageDependencyInformation proto WINAPI :HANDLE, :GET_STORAGE_DEPENDENCY_FLAG, :ULONG, :PSTORAGE_DEPENDENCY_INFO, :PULONG

.enum GET_VIRTUAL_DISK_INFO_VERSION {
    GET_VIRTUAL_DISK_INFO_UNSPECIFIED			= 0,
    GET_VIRTUAL_DISK_INFO_SIZE				= 1,
    GET_VIRTUAL_DISK_INFO_IDENTIFIER			= 2,
    GET_VIRTUAL_DISK_INFO_PARENT_LOCATION		= 3,
    GET_VIRTUAL_DISK_INFO_PARENT_IDENTIFIER		= 4,
    GET_VIRTUAL_DISK_INFO_PARENT_TIMESTAMP		= 5,
    GET_VIRTUAL_DISK_INFO_VIRTUAL_STORAGE_TYPE		= 6,
    GET_VIRTUAL_DISK_INFO_PROVIDER_SUBTYPE		= 7,
    GET_VIRTUAL_DISK_INFO_IS_4K_ALIGNED			= 8,
    GET_VIRTUAL_DISK_INFO_PHYSICAL_DISK			= 9,
    GET_VIRTUAL_DISK_INFO_VHD_PHYSICAL_SECTOR_SIZE	= 10,
    GET_VIRTUAL_DISK_INFO_SMALLEST_SAFE_VIRTUAL_SIZE	= 11,
    GET_VIRTUAL_DISK_INFO_FRAGMENTATION			= 12,
    GET_VIRTUAL_DISK_INFO_IS_LOADED			= 13,
    GET_VIRTUAL_DISK_INFO_VIRTUAL_DISK_ID		= 14,
    GET_VIRTUAL_DISK_INFO_CHANGE_TRACKING_STATE		= 15,
    }


GET_VIRTUAL_DISK_INFO	STRUC
Version			GET_VIRTUAL_DISK_INFO_VERSION ?
UNION
 STRUC Size
  VirtualSize		ULONGLONG ?
  PhysicalSize		ULONGLONG ?
  BlockSize		ULONG ?
  SectorSize		ULONG ?
 ENDS
 Identifier		GUID <>
 STRUC ParentLocation
  ParentResolved	BOOL ?
  ParentLocationBuffer	WCHAR 1 dup(?) ;; MultiSz string
 ENDS
 ParentIdentifier	GUID <>
 ParentTimestamp	ULONG ?
 VirtualStorageType	VIRTUAL_STORAGE_TYPE <>
 ProviderSubtype	ULONG ?
 Is4kAligned		BOOL ?
 IsLoaded		BOOL ?
 STRUC PhysicalDisk
  LogicalSectorSize	 ULONG ?
  PhysicalSectorSize	 ULONG ?
  IsRemote		 BOOL ?
 ENDS
 VhdPhysicalSectorSize	 ULONG ?
 SmallestSafeVirtualSize ULONGLONG ?
 FragmentationPercentage ULONG ?
 VirtualDiskId		 GUID <>
ENDS
GET_VIRTUAL_DISK_INFO	ENDS
PGET_VIRTUAL_DISK_INFO	typedef ptr GET_VIRTUAL_DISK_INFO

GetVirtualDiskInformation proto WINAPI :HANDLE, :PULONG, :PGET_VIRTUAL_DISK_INFO, :PULONG

.enum SET_VIRTUAL_DISK_INFO_VERSION {
    SET_VIRTUAL_DISK_INFO_UNSPECIFIED		 = 0,
    SET_VIRTUAL_DISK_INFO_PARENT_PATH		 = 1,
    SET_VIRTUAL_DISK_INFO_IDENTIFIER		 = 2,
    SET_VIRTUAL_DISK_INFO_PARENT_PATH_WITH_DEPTH = 3,
    SET_VIRTUAL_DISK_INFO_PHYSICAL_SECTOR_SIZE	 = 4,
    SET_VIRTUAL_DISK_INFO_VIRTUAL_DISK_ID	 = 5,
    SET_VIRTUAL_DISK_INFO_CHANGE_TRACKING_STATE	 = 6,
    SET_VIRTUAL_DISK_INFO_PARENT_LOCATOR	 = 7,
    }


SET_VIRTUAL_DISK_INFO	STRUC
Version			SET_VIRTUAL_DISK_INFO_VERSION ?
UNION
 ParentFilePath		PCWSTR ?
 UniqueIdentifier	GUID <>
 STRUC ParentPathWithDepthInfo
  ChildDepth		ULONG ?
  ParentFilePath	PCWSTR ?
 ENDS
 VhdPhysicalSectorSize	ULONG ?
 VirtualDiskId		GUID <>
ENDS
SET_VIRTUAL_DISK_INFO	ENDS
PSET_VIRTUAL_DISK_INFO	typedef ptr SET_VIRTUAL_DISK_INFO


SetVirtualDiskInformation proto WINAPI :HANDLE, :PSET_VIRTUAL_DISK_INFO

if (NTDDI_VERSION GE NTDDI_WIN8)
EnumerateVirtualDiskMetadata proto WINAPI :HANDLE, :PULONG, :ptr
GetVirtualDiskMetadata proto WINAPI :HANDLE, :ptr, :PULONG, :ptr
SetVirtualDiskMetadata proto WINAPI :HANDLE, :ptr, :ULONG, :ptr
DeleteVirtualDiskMetadata proto WINAPI :HANDLE, :ptr
endif

VIRTUAL_DISK_PROGRESS	STRUC
OperationStatus		dd ?
CurrentValue		ULONGLONG ?
CompletionValue		ULONGLONG ?
VIRTUAL_DISK_PROGRESS	ENDS
PVIRTUAL_DISK_PROGRESS	typedef ptr VIRTUAL_DISK_PROGRESS

GetVirtualDiskOperationProgress proto WINAPI :HANDLE, :LPOVERLAPPED, :PVIRTUAL_DISK_PROGRESS

.enum COMPACT_VIRTUAL_DISK_VERSION {
    COMPACT_VIRTUAL_DISK_VERSION_UNSPECIFIED	= 0,
    COMPACT_VIRTUAL_DISK_VERSION_1		= 1,
    }

COMPACT_VIRTUAL_DISK_PARAMETERS STRUC
Version			COMPACT_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  Reserved		dd ?
 ENDS
ENDS
COMPACT_VIRTUAL_DISK_PARAMETERS ENDS
PCOMPACT_VIRTUAL_DISK_PARAMETERS typedef ptr COMPACT_VIRTUAL_DISK_PARAMETERS

.enum COMPACT_VIRTUAL_DISK_FLAG {
    COMPACT_VIRTUAL_DISK_FLAG_NONE		   = 0x00000000,
    COMPACT_VIRTUAL_DISK_FLAG_NO_ZERO_SCAN	   = 0x00000001,
    COMPACT_VIRTUAL_DISK_FLAG_NO_BLOCK_MOVES	   = 0x00000002,
    }

CompactVirtualDisk proto WINAPI :HANDLE, :COMPACT_VIRTUAL_DISK_FLAG, :PCOMPACT_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED

.enum MERGE_VIRTUAL_DISK_VERSION {
    MERGE_VIRTUAL_DISK_VERSION_UNSPECIFIED    = 0,
    MERGE_VIRTUAL_DISK_VERSION_1	      = 1,
    MERGE_VIRTUAL_DISK_VERSION_2	      = 2,
    }

MERGE_VIRTUAL_DISK_DEFAULT_MERGE_DEPTH equ 1

MERGE_VIRTUAL_DISK_PARAMETERS STRUC
Version			MERGE_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  MergeDepth		ULONG ?
 ENDS
 STRUC Version2
  MergeSourceDepth	ULONG ?
  MergeTargetDepth	ULONG ?
 ENDS
ENDS
MERGE_VIRTUAL_DISK_PARAMETERS ENDS
PMERGE_VIRTUAL_DISK_PARAMETERS typedef ptr MERGE_VIRTUAL_DISK_PARAMETERS

MERGE_VIRTUAL_DISK_FLAG typedef SDWORD
MERGE_VIRTUAL_DISK_FLAG_NONE equ 0x00000000

MergeVirtualDisk proto WINAPI :HANDLE, :MERGE_VIRTUAL_DISK_FLAG, :PMERGE_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED

.enum EXPAND_VIRTUAL_DISK_VERSION {
    EXPAND_VIRTUAL_DISK_VERSION_UNSPECIFIED    = 0,
    EXPAND_VIRTUAL_DISK_VERSION_1	       = 1,
    }

EXPAND_VIRTUAL_DISK_PARAMETERS STRUC
Version			EXPAND_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  NewSize		ULONGLONG ?
 ENDS
ENDS
EXPAND_VIRTUAL_DISK_PARAMETERS ENDS
PEXPAND_VIRTUAL_DISK_PARAMETERS typedef ptr EXPAND_VIRTUAL_DISK_PARAMETERS

.enum EXPAND_VIRTUAL_DISK_FLAG {
    EXPAND_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
    }

ExpandVirtualDisk proto WINAPI :HANDLE, :EXPAND_VIRTUAL_DISK_FLAG, :PEXPAND_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED

.enum RESIZE_VIRTUAL_DISK_VERSION {
    RESIZE_VIRTUAL_DISK_VERSION_UNSPECIFIED    = 0,
    RESIZE_VIRTUAL_DISK_VERSION_1	       = 1,
    }

RESIZE_VIRTUAL_DISK_PARAMETERS STRUC
Version			RESIZE_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  NewSize		ULONGLONG ?
 ENDS
ENDS
RESIZE_VIRTUAL_DISK_PARAMETERS ENDS
PRESIZE_VIRTUAL_DISK_PARAMETERS typedef ptr RESIZE_VIRTUAL_DISK_PARAMETERS

.enum RESIZE_VIRTUAL_DISK_FLAG {
    RESIZE_VIRTUAL_DISK_FLAG_NONE				  = 0x0,
    RESIZE_VIRTUAL_DISK_FLAG_ALLOW_UNSAFE_VIRTUAL_SIZE		  = 0x1,
    RESIZE_VIRTUAL_DISK_FLAG_RESIZE_TO_SMALLEST_SAFE_VIRTUAL_SIZE = 0x2,
    }

if (NTDDI_VERSION GE NTDDI_WIN8)
ResizeVirtualDisk proto WINAPI :HANDLE, :RESIZE_VIRTUAL_DISK_FLAG, :PRESIZE_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED
endif

.enum MIRROR_VIRTUAL_DISK_VERSION {
    MIRROR_VIRTUAL_DISK_VERSION_UNSPECIFIED    = 0,
    MIRROR_VIRTUAL_DISK_VERSION_1	       = 1,
    }

MIRROR_VIRTUAL_DISK_PARAMETERS STRUC
Version			MIRROR_VIRTUAL_DISK_VERSION ?
UNION
 STRUC Version1
  MirrorVirtualDiskPath PCWSTR ?
 ENDS
ENDS
MIRROR_VIRTUAL_DISK_PARAMETERS ENDS
PMIRROR_VIRTUAL_DISK_PARAMETERS typedef ptr MIRROR_VIRTUAL_DISK_PARAMETERS

.enum MIRROR_VIRTUAL_DISK_FLAG {
    MIRROR_VIRTUAL_DISK_FLAG_NONE		    = 0x00000000,
    MIRROR_VIRTUAL_DISK_FLAG_EXISTING_FILE	    = 0x00000001,
    MIRROR_VIRTUAL_DISK_FLAG_SKIP_MIRROR_ACTIVATION = 0x00000002
    }

if (NTDDI_VERSION GE NTDDI_WIN8)
MirrorVirtualDisk proto WINAPI :HANDLE, :MIRROR_VIRTUAL_DISK_FLAG, :PMIRROR_VIRTUAL_DISK_PARAMETERS, :LPOVERLAPPED
endif
if (NTDDI_VERSION GE NTDDI_WIN8)
BreakMirrorVirtualDisk proto WINAPI :HANDLE
endif
if (NTDDI_VERSION GE NTDDI_WIN8)
AddVirtualDiskParent proto WINAPI :HANDLE, :PCWSTR
endif
endif ;; VIRTDISK_DEFINE_FLAGS


SurfaceVirtualDisk	equ <AttachVirtualDisk>
UnsurfaceVirtualDisk	equ <DetachVirtualDisk>
VIRTUAL_DISK_ACCESS_SURFACE_RO equ VIRTUAL_DISK_ACCESS_ATTACH_RO
VIRTUAL_DISK_ACCESS_SURFACE_RW equ <VIRTUAL_DISK_ACCESS_ATTACH_RW>
VIRTUAL_DISK_ACCESS_UNSURFACE equ VIRTUAL_DISK_ACCESS_DETACH
SURFACE_VIRTUAL_DISK_VERSION_UNSPECIFIED equ ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED
SURFACE_VIRTUAL_DISK_VERSION_1 equ ATTACH_VIRTUAL_DISK_VERSION_1
SURFACE_VIRTUAL_DISK_VERSION equ ATTACH_VIRTUAL_DISK_VERSION
_SURFACE_VIRTUAL_DISK_VERSION equ _ATTACH_VIRTUAL_DISK_VERSION
SURFACE_VIRTUAL_DISK_PARAMETERS equ ATTACH_VIRTUAL_DISK_PARAMETERS
PSURFACE_VIRTUAL_DISK_PARAMETERS equ PATTACH_VIRTUAL_DISK_PARAMETERS
_SURFACE_VIRTUAL_DISK_PARAMETERS equ _ATTACH_VIRTUAL_DISK_PARAMETERS

if NOT defined(__midl)

_SURFACE_VIRTUAL_DISK_FLAG equ _ATTACH_VIRTUAL_DISK_FLAG
SURFACE_VIRTUAL_DISK_FLAG_NONE equ ATTACH_VIRTUAL_DISK_FLAG_NONE
SURFACE_VIRTUAL_DISK_FLAG_READ_ONLY equ ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY
SURFACE_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER equ ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER
SURFACE_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME equ ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME
SURFACE_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST equ ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST
SURFACE_VIRTUAL_DISK_FLAG equ ATTACH_VIRTUAL_DISK_FLAG
_UNSURFACE_VIRTUAL_DISK_FLAG equ _DETACH_VIRTUAL_DISK_FLAG
UNSURFACE_VIRTUAL_DISK_FLAG_NONE equ DETACH_VIRTUAL_DISK_FLAG_NONE
UNSURFACE_VIRTUAL_DISK_FLAG equ DETACH_VIRTUAL_DISK_FLAG

else

SURFACE_VIRTUAL_DISK_FLAG typedef SDWORD
SURFACE_VIRTUAL_DISK_FLAG_NONE equ 0x00000000
SURFACE_VIRTUAL_DISK_FLAG_READ_ONLY equ 0x00000001
SURFACE_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER equ 0x00000002
SURFACE_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME equ 0x00000004
SURFACE_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST equ 0x00000008

UNSURFACE_VIRTUAL_DISK_FLAG typedef SDWORD
UNSURFACE_VIRTUAL_DISK_FLAG_NONE equ 0x00000000

endif
endif ;; WIN32_WINNT_WIN7
endif ;; WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
endif ;; VIRT_DISK_API_DEF

