Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _INC_VIRTDISK
      7 #define _INC_VIRTDISK
      8 
      9 #if (_WIN32_WINNT >= 0x0601)
     10 #ifdef __cplusplus
     11 extern "C" {
     12 #endif
     13 
     14 #define VIRTDISKAPI DECLSPEC_IMPORT
     15 
     16 typedef enum _ATTACH_VIRTUAL_DISK_FLAG {
     17   ATTACH_VIRTUAL_DISK_FLAG_NONE                 = 0x00000000,
     18   ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY            = 0x00000001,
     19   ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER      = 0x00000002,
     20   ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME   = 0x00000004,
     21   ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST        = 0x00000008
     22 } ATTACH_VIRTUAL_DISK_FLAG;
     23 
     24 typedef enum _ATTACH_VIRTUAL_DISK_VERSION {
     25   ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED   = 0,
     26   ATTACH_VIRTUAL_DISK_VERSION_1             = 1
     27 } ATTACH_VIRTUAL_DISK_VERSION;
     28 
     29 typedef enum _COMPACT_VIRTUAL_DISK_FLAG {
     30   COMPACT_VIRTUAL_DISK_FLAG_NONE   = 0x00000000
     31 } COMPACT_VIRTUAL_DISK_FLAG;
     32 
     33 typedef enum _COMPACT_VIRTUAL_DISK_VERSION {
     34   COMPACT_VIRTUAL_DISK_VERSION_UNSPECIFIED   = 0,
     35   COMPACT_VIRTUAL_DISK_VERSION_1             = 1
     36 } COMPACT_VIRTUAL_DISK_VERSION;
     37 
     38 typedef enum _CREATE_VIRTUAL_DISK_FLAG {
     39   CREATE_VIRTUAL_DISK_FLAG_NONE                       = 0x00000000,
     40   CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION   = 0x00000001
     41 } CREATE_VIRTUAL_DISK_FLAG;
     42 
     43 typedef enum _CREATE_VIRTUAL_DISK_VERSION {
     44   CREATE_VIRTUAL_DISK_VERSION_UNSPECIFIED   = 0,
     45   CREATE_VIRTUAL_DISK_VERSION_1             = 1
     46 } CREATE_VIRTUAL_DISK_VERSION;
     47 
     48 typedef enum _DEPENDENT_DISK_FLAG {
     49   DEPENDENT_DISK_FLAG_NONE                   = 0x00000000,
     50   DEPENDENT_DISK_FLAG_MULT_BACKING_FILES     = 0x00000001,
     51   DEPENDENT_DISK_FLAG_FULLY_ALLOCATED        = 0x00000002,
     52   DEPENDENT_DISK_FLAG_READ_ONLY              = 0x00000004,
     53   DEPENDENT_DISK_FLAG_REMOTE                 = 0x00000008,
     54   DEPENDENT_DISK_FLAG_SYSTEM_VOLUME          = 0x00000010,
     55   DEPENDENT_DISK_FLAG_SYSTEM_VOLUME_PARENT   = 0x00000020,
     56   DEPENDENT_DISK_FLAG_REMOVABLE              = 0x00000040,
     57   DEPENDENT_DISK_FLAG_NO_DRIVE_LETTER        = 0x00000080,
     58   DEPENDENT_DISK_FLAG_PARENT                 = 0x00000100,
     59   DEPENDENT_DISK_FLAG_NO_HOST_DISK           = 0x00000200,
     60   DEPENDENT_DISK_FLAG_PERMANENT_LIFETIME     = 0x00000400
     61 } DEPENDENT_DISK_FLAG;
     62 
     63 typedef enum _EXPAND_VIRTUAL_DISK_VERSION {
     64   EXPAND_VIRTUAL_DISK_VERSION_UNSPECIFIED   = 0,
     65   EXPAND_VIRTUAL_DISK_VERSION_1             = 1
     66 } EXPAND_VIRTUAL_DISK_VERSION;
     67 
     68 typedef enum _DETACH_VIRTUAL_DISK_FLAG {
     69   DETACH_VIRTUAL_DISK_FLAG_NONE   = 0x00000000
     70 } DETACH_VIRTUAL_DISK_FLAG;
     71 
     72 typedef enum _EXPAND_VIRTUAL_DISK_FLAG {
     73   EXPAND_VIRTUAL_DISK_FLAG_NONE   = 0x00000000
     74 } EXPAND_VIRTUAL_DISK_FLAG;
     75 
     76 typedef enum _GET_STORAGE_DEPENDENCY_FLAG {
     77   GET_STORAGE_DEPENDENCY_FLAG_NONE           = 0x00000000,
     78   GET_STORAGE_DEPENDENCY_FLAG_HOST_VOLUMES   = 0x00000001,
     79   GET_STORAGE_DEPENDENCY_FLAG_DISK_HANDLE    = 0x00000002
     80 } GET_STORAGE_DEPENDENCY_FLAG;
     81 
     82 typedef enum _GET_VIRTUAL_DISK_INFO_VERSION {
     83   GET_VIRTUAL_DISK_INFO_UNSPECIFIED            = 0,
     84   GET_VIRTUAL_DISK_INFO_SIZE                   = 1,
     85   GET_VIRTUAL_DISK_INFO_IDENTIFIER             = 2,
     86   GET_VIRTUAL_DISK_INFO_PARENT_LOCATION        = 3,
     87   GET_VIRTUAL_DISK_INFO_PARENT_IDENTIFIER      = 4,
     88   GET_VIRTUAL_DISK_INFO_PARENT_TIMESTAMP       = 5,
     89   GET_VIRTUAL_DISK_INFO_VIRTUAL_STORAGE_TYPE   = 6,
     90   GET_VIRTUAL_DISK_INFO_PROVIDER_SUBTYPE       = 7
     91 } GET_VIRTUAL_DISK_INFO_VERSION;
     92 
     93 typedef enum _MERGE_VIRTUAL_DISK_FLAG {
     94   MERGE_VIRTUAL_DISK_FLAG_NONE   = 0x00000000
     95 } MERGE_VIRTUAL_DISK_FLAG;
     96 
     97 typedef enum _MERGE_VIRTUAL_DISK_VERSION {
     98   MERGE_VIRTUAL_DISK_VERSION_UNSPECIFIED   = 0,
     99   MERGE_VIRTUAL_DISK_VERSION_1             = 1
    100 } MERGE_VIRTUAL_DISK_VERSION;
    101 
    102 typedef enum _OPEN_VIRTUAL_DISK_FLAG {
    103   OPEN_VIRTUAL_DISK_FLAG_NONE         = 0x00000000,
    104   OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS   = 0x00000001,
    105   OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE   = 0x00000002,
    106   OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE   = 0x00000004
    107 } OPEN_VIRTUAL_DISK_FLAG;
    108 
    109 typedef enum _OPEN_VIRTUAL_DISK_VERSION {
    110   OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED   = 0,
    111   OPEN_VIRTUAL_DISK_VERSION_1             = 1
    112 } OPEN_VIRTUAL_DISK_VERSION;
    113 
    114 typedef enum _SET_VIRTUAL_DISK_INFO_VERSION {
    115   SET_VIRTUAL_DISK_INFO_UNSPECIFIED   = 0,
    116   SET_VIRTUAL_DISK_INFO_PARENT_PATH   = 1,
    117   SET_VIRTUAL_DISK_INFO_IDENTIFIER    = 2
    118 } SET_VIRTUAL_DISK_INFO_VERSION;
    119 
    120 typedef enum _STORAGE_DEPENDENCY_INFO_VERSION {
    121   STORAGE_DEPENDENCY_INFO_VERSION_UNSPECIFIED   = 0,
    122   STORAGE_DEPENDENCY_INFO_VERSION_1             = 1,
    123   STORAGE_DEPENDENCY_INFO_VERSION_2             = 2
    124 } STORAGE_DEPENDENCY_INFO_VERSION;
    125 
    126 typedef enum _VIRTUAL_DISK_ACCESS_MASK {
    127   VIRTUAL_DISK_ACCESS_ATTACH_RO   = 0x00010000,
    128   VIRTUAL_DISK_ACCESS_ATTACH_RW   = 0x00020000,
    129   VIRTUAL_DISK_ACCESS_DETACH      = 0x00040000,
    130   VIRTUAL_DISK_ACCESS_GET_INFO    = 0x00080000,
    131   VIRTUAL_DISK_ACCESS_CREATE      = 0x00100000,
    132   VIRTUAL_DISK_ACCESS_METAOPS     = 0x00200000,
    133   VIRTUAL_DISK_ACCESS_READ        = 0x000d0000,
    134   VIRTUAL_DISK_ACCESS_ALL         = 0x003f0000,
    135   VIRTUAL_DISK_ACCESS_WRITABLE    = 0x00320000
    136 } VIRTUAL_DISK_ACCESS_MASK;
    137 
    138 typedef struct _VIRTUAL_STORAGE_TYPE {
    139   ULONG DeviceId;
    140   GUID  VendorId;
    141 } VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE;
    142 
    143 typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS {
    144   ATTACH_VIRTUAL_DISK_VERSION Version;
    145   __C89_NAMELESS union {
    146     struct {
    147       ULONG Reserved;
    148     } Version1;
    149   } DUMMYUNIONNAME;
    150 } ATTACH_VIRTUAL_DISK_PARAMETERS, *PATTACH_VIRTUAL_DISK_PARAMETERS;
    151 
    152 typedef struct _COMPACT_VIRTUAL_DISK_PARAMETERS {
    153   COMPACT_VIRTUAL_DISK_VERSION Version;
    154   __C89_NAMELESS union {
    155     struct {
    156       ULONG Reserved;
    157     } Version1;
    158   } DUMMYUNIONNAME;
    159 } COMPACT_VIRTUAL_DISK_PARAMETERS, *PCOMPACT_VIRTUAL_DISK_PARAMETERS;
    160 
    161 typedef struct _CREATE_VIRTUAL_DISK_PARAMETERS {
    162   CREATE_VIRTUAL_DISK_VERSION Version;
    163   __C89_NAMELESS union {
    164     struct {
    165       GUID      UniqueId;
    166       ULONGLONG MaximumSize;
    167       ULONG     BlockSizeInBytes;
    168       ULONG     SectorSizeInBytes;
    169       PCWSTR    ParentPath;
    170       PCWSTR    SourcePath;
    171     } Version1;
    172   } DUMMYUNIONNAME;
    173 } CREATE_VIRTUAL_DISK_PARAMETERS, *PCREATE_VIRTUAL_DISK_PARAMETERS;
    174 
    175 typedef struct _EXPAND_VIRTUAL_DISK_PARAMETERS {
    176   EXPAND_VIRTUAL_DISK_VERSION Version;
    177   __C89_NAMELESS union {
    178     struct {
    179       ULONGLONG NewSize;
    180     } Version1;
    181   } DUMMYUNIONNAME;
    182 } EXPAND_VIRTUAL_DISK_PARAMETERS, *PEXPAND_VIRTUAL_DISK_PARAMETERS;
    183 
    184 typedef struct _GET_VIRTUAL_DISK_INFO {
    185   GET_VIRTUAL_DISK_INFO_VERSION Version;
    186   __C89_NAMELESS union {
    187     struct {
    188       ULONGLONG VirtualSize;
    189       ULONGLONG PhysicalSize;
    190       ULONG     BlockSize;
    191       ULONG     SectorSize;
    192     } Size;
    193     GUID                 Identifier;
    194     struct {
    195       BOOL  ParentResolved;
    196       WCHAR ParentLocationBuffer[1];
    197     } ParentLocation;
    198     GUID                 ParentIdentifier;
    199     ULONG                ParentTimestamp;
    200     VIRTUAL_STORAGE_TYPE VirtualStorageType;
    201     ULONG                ProviderSubtype;
    202   } DUMMYUNIONNAME;
    203 } GET_VIRTUAL_DISK_INFO, *PGET_VIRTUAL_DISK_INFO;
    204 
    205 typedef struct _MERGE_VIRTUAL_DISK_PARAMETERS {
    206   MERGE_VIRTUAL_DISK_VERSION Version;
    207   __C89_NAMELESS union {
    208     struct {
    209       ULONG MergeDepth;
    210     } Version1;
    211   } DUMMYUNIONNAME;
    212 } MERGE_VIRTUAL_DISK_PARAMETERS, *PMERGE_VIRTUAL_DISK_PARAMETERS;
    213 
    214 typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS {
    215   OPEN_VIRTUAL_DISK_VERSION Version;
    216   __C89_NAMELESS union {
    217     struct {
    218       ULONG RWDepth;
    219     } Version1;
    220   } DUMMYUNIONNAME;
    221 } OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS;
    222 
    223 typedef struct _SET_VIRTUAL_DISK_INFO {
    224   SET_VIRTUAL_DISK_INFO_VERSION Version;
    225   __C89_NAMELESS union {
    226     PCWSTR ParentFilePath;
    227     GUID   UniqueIdentifier;
    228   } DUMMYUNIONNAME;
    229 } SET_VIRTUAL_DISK_INFO, *PSET_VIRTUAL_DISK_INFO;
    230 
    231 typedef struct _STORAGE_DEPENDENCY_INFO_TYPE_1 {
    232   DEPENDENT_DISK_FLAG  DependencyTypeFlags;
    233   ULONG                ProviderSpecificFlags;
    234   VIRTUAL_STORAGE_TYPE VirtualStorageType;
    235 } STORAGE_DEPENDENCY_INFO_TYPE_1, *PSTORAGE_DEPENDENCY_INFO_TYPE_1;
    236 
    237 typedef struct _STORAGE_DEPENDENCY_INFO_TYPE_2 {
    238   DEPENDENT_DISK_FLAG  DependencyTypeFlags;
    239   ULONG                ProviderSpecificFlags;
    240   VIRTUAL_STORAGE_TYPE VirtualStorageType;
    241   ULONG                AncestorLevel;
    242   PWSTR                DependencyDeviceName;
    243   PWSTR                HostVolumeName;
    244   PWSTR                DependentVolumeName;
    245   PWSTR                DependentVolumeRelativePath;
    246 } STORAGE_DEPENDENCY_INFO_TYPE_2, *PSTORAGE_DEPENDENCY_INFO_TYPE_2;
    247 
    248 /* Fixme: Suppress GCC errors about "error: flexible array member in union" */
    249 
    250 typedef struct _STORAGE_DEPENDENCY_INFO {
    251   STORAGE_DEPENDENCY_INFO_VERSION Version;
    252   ULONG                           NumberEntries;
    253   __C89_NAMELESS union {
    254     STORAGE_DEPENDENCY_INFO_TYPE_1 Version1Entries[1];
    255     STORAGE_DEPENDENCY_INFO_TYPE_2 Version2Entries[1];
    256   } DUMMYUNIONNAME;
    257 } STORAGE_DEPENDENCY_INFO, *PSTORAGE_DEPENDENCY_INFO;
    258 
    259 typedef struct _VIRTUAL_DISK_PROGRESS {
    260   DWORD     OperationStatus;
    261   ULONGLONG CurrentValue;
    262   ULONGLONG CompletionValue;
    263 } VIRTUAL_DISK_PROGRESS, *PVIRTUAL_DISK_PROGRESS;
    264 
    265 #define VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN 0
    266 #define VIRTUAL_STORAGE_TYPE_DEVICE_ISO 1
    267 #define VIRTUAL_STORAGE_TYPE_DEVICE_VHD 2
    268 
    269 DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT,0xEC984AEC,0xA0F9,0x47e9,0x90,0x1F,0x71,0x41,0x5A,0x66,0x34,0x5B);
    270 
    271 VIRTDISKAPI DWORD WINAPI AttachVirtualDisk(
    272   HANDLE VirtualDiskHandle,
    273   PSECURITY_DESCRIPTOR SecurityDescriptor,
    274   ATTACH_VIRTUAL_DISK_FLAG Flags,
    275   ULONG ProviderSpecificFlags,
    276   PATTACH_VIRTUAL_DISK_PARAMETERS Parameters,
    277   LPOVERLAPPED Overlapped
    278 );
    279 
    280 VIRTDISKAPI DWORD WINAPI CompactVirtualDisk(
    281   HANDLE VirtualDiskHandle,
    282   COMPACT_VIRTUAL_DISK_FLAG Flags,
    283   PCOMPACT_VIRTUAL_DISK_PARAMETERS Parameters,
    284   LPOVERLAPPED Overlapped
    285 );
    286 
    287 VIRTDISKAPI DWORD WINAPI CreateVirtualDisk(
    288   PVIRTUAL_STORAGE_TYPE VirtualStorageType,
    289   PCWSTR Path,
    290   VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask,
    291   PSECURITY_DESCRIPTOR SecurityDescriptor,
    292   CREATE_VIRTUAL_DISK_FLAG Flags,
    293   ULONG ProviderSpecificFlags,
    294   PCREATE_VIRTUAL_DISK_PARAMETERS Parameters,
    295   LPOVERLAPPED Overlapped,
    296   PHANDLE Handle
    297 );
    298 
    299 VIRTDISKAPI DWORD WINAPI DetachVirtualDisk(
    300   HANDLE VirtualDiskHandle,
    301   DETACH_VIRTUAL_DISK_FLAG Flags,
    302   ULONG ProviderSpecificFlags
    303 );
    304 
    305 VIRTDISKAPI DWORD WINAPI ExpandVirtualDisk(
    306   HANDLE VirtualDiskHandle,
    307   EXPAND_VIRTUAL_DISK_FLAG Flags,
    308   PEXPAND_VIRTUAL_DISK_PARAMETERS Parameters,
    309   LPOVERLAPPED Overlapped
    310 );
    311 
    312 VIRTDISKAPI DWORD WINAPI GetStorageDependencyInformation(
    313   HANDLE ObjectHandle,
    314   GET_STORAGE_DEPENDENCY_FLAG Flags,
    315   ULONG StorageDependencyInfoSize,
    316   PSTORAGE_DEPENDENCY_INFO StorageDependencyInfo,
    317   PULONG SizeUsed
    318 );
    319 
    320 VIRTDISKAPI DWORD WINAPI GetVirtualDiskInformation(
    321   HANDLE VirtualDiskHandle,
    322   PULONG VirtualDiskInfoSize,
    323   PGET_VIRTUAL_DISK_INFO VirtualDiskInfo,
    324   PULONG SizeUsed
    325 );
    326 
    327 VIRTDISKAPI DWORD WINAPI GetVirtualDiskOperationProgress(
    328   HANDLE VirtualDiskHandle,
    329   LPOVERLAPPED Overlapped,
    330   PVIRTUAL_DISK_PROGRESS Progress
    331 );
    332 
    333 DWORD WINAPI GetVirtualDiskPhysicalPath(
    334   HANDLE VirtualDiskHandle,
    335   PULONG DiskPathSizeInBytes,
    336   PWSTR DiskPath
    337 );
    338 
    339 VIRTDISKAPI DWORD WINAPI MergeVirtualDisk(
    340   HANDLE VirtualDiskHandle,
    341   MERGE_VIRTUAL_DISK_FLAG Flags,
    342   PMERGE_VIRTUAL_DISK_PARAMETERS Parameters,
    343   LPOVERLAPPED Overlapped
    344 );
    345 
    346 VIRTDISKAPI DWORD WINAPI OpenVirtualDisk(
    347   PVIRTUAL_STORAGE_TYPE VirtualStorageType,
    348   PCWSTR Path,
    349   VIRTUAL_DISK_ACCESS_MASK VirtualDiskAccessMask,
    350   OPEN_VIRTUAL_DISK_FLAG Flags,
    351   POPEN_VIRTUAL_DISK_PARAMETERS Parameters,
    352   PHANDLE Handle
    353 );
    354 
    355 VIRTDISKAPI DWORD WINAPI SetVirtualDiskInformation(
    356   HANDLE VirtualDiskHandle,
    357   PSET_VIRTUAL_DISK_INFO VirtualDiskInfo
    358 );
    359 
    360 #ifdef __cplusplus
    361 }
    362 #endif
    363 #endif /*(_WIN32_WINNT >= 0x0601)*/
    364 #endif /*_INC_VIRTDISK*/
    365