Advertisement
MagicAndre1981

VHD Set in #Windows10

Apr 4th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  1. #define VIRTUAL_STORAGE_TYPE_DEVICE_VHDSET 4
  2.  
  3. // This flag causes a Vhd Set file to be opened without any virtual disk.
  4. OPEN_VIRTUAL_DISK_FLAG_VHDSET_FILE_ONLY = 0x00000040,
  5. part of enum _OPEN_VIRTUAL_DISK_FLAG
  6.  
  7.  
  8. // Flags for CreateVirtualDisk
  9. typedef enum _CREATE_VIRTUAL_DISK_FLAG
  10. {
  11. CREATE_VIRTUAL_DISK_FLAG_NONE = 0x0,
  12.  
  13. // Pre-allocate all physical space necessary for the virtual
  14. // size of the disk (e.g. a fixed VHD).
  15. CREATE_VIRTUAL_DISK_FLAG_FULL_PHYSICAL_ALLOCATION = 0x1,
  16.  
  17. // Take ownership of the source disk during create from source disk, to
  18. // insure the source disk does not change during the create operation. The
  19. // source disk must also already be offline or read-only (or both).
  20. // Ownership is released when create is done. This also has a side-effect
  21. // of disallowing concurrent create from same source disk. Create will fail
  22. // if ownership cannot be obtained or if the source disk is not already
  23. // offline or read-only. This flag is optional, but highly recommended for
  24. // creates from source disk. No effect for other types of create (no effect
  25. // for create from source VHD; no effect for create without SourcePath).
  26. CREATE_VIRTUAL_DISK_FLAG_PREVENT_WRITES_TO_SOURCE_DISK = 0x2,
  27.  
  28. // Do not copy initial virtual disk metadata or block states from the
  29. // parent VHD; this is useful if the parent VHD is a stand-in file and the
  30. // real parent will be explicitly set later.
  31. CREATE_VIRTUAL_DISK_FLAG_DO_NOT_COPY_METADATA_FROM_PARENT = 0x4,
  32.  
  33. // Create the backing storage disk.
  34. CREATE_VIRTUAL_DISK_FLAG_CREATE_BACKING_STORAGE = 0x8,
  35.  
  36. // If set, the SourceLimitPath is an change tracking ID, and all data that has changed
  37. // since that change tracking ID will be copied from the source. If clear, the
  38. // SourceLimitPath is a VHD file path in the source VHD's chain, and
  39. // all data that is present in the children of that VHD in the chain
  40. // will be copied from the source.
  41. CREATE_VIRTUAL_DISK_FLAG_USE_CHANGE_TRACKING_SOURCE_LIMIT = 0x10,
  42.  
  43. // If set and the parent VHD has change tracking enabled, the child will
  44. // have change tracking enabled and will recognize all change tracking
  45. // IDs that currently exist in the parent. If clear or if the parent VHD
  46. // does not have change tracking available, then change tracking will
  47. // not be enabled in the new VHD.
  48. CREATE_VIRTUAL_DISK_FLAG_PRESERVE_PARENT_CHANGE_TRACKING_STATE = 0x20,
  49.  
  50. } CREATE_VIRTUAL_DISK_FLAG;
  51.  
  52. #define CREATE_VIRTUAL_DISK_FLAG_USE_RCT_SOURCE_LIMIT CREATE_VIRTUAL_DISK_FLAG_USE_CHANGE_TRACKING_SOURCE_LIMIT
  53.  
  54.  
  55.  
  56. typedef struct _QUERY_CHANGES_VIRTUAL_DISK_RANGE {
  57. ULONG64 ByteOffset;
  58. ULONG64 ByteLength;
  59. ULONG64 Reserved;
  60. } QUERY_CHANGES_VIRTUAL_DISK_RANGE, *PQUERY_CHANGES_VIRTUAL_DISK_RANGE;
  61.  
  62. // Flags for QueryChangesVirtualDisk
  63. typedef enum _QUERY_CHANGES_VIRTUAL_DISK_FLAG
  64. {
  65. QUERY_CHANGES_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
  66.  
  67. } QUERY_CHANGES_VIRTUAL_DISK_FLAG;
  68.  
  69. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  70. DEFINE_ENUM_FLAG_OPERATORS(QUERY_CHANGES_VIRTUAL_DISK_FLAG);
  71. #endif
  72.  
  73. typedef enum _TAKE_SNAPSHOT_VHDSET_FLAG
  74. {
  75. TAKE_SNAPSHOT_VHDSET_FLAG_NONE = 0x00000000,
  76.  
  77. } TAKE_SNAPSHOT_VHDSET_FLAG, *PTAKE_SNAPSHOT_VHDSET_FLAG;
  78.  
  79. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  80. DEFINE_ENUM_FLAG_OPERATORS(TAKE_SNAPSHOT_VHDSET_FLAG);
  81. #endif
  82.  
  83. typedef enum _TAKE_SNAPSHOT_VHDSET_VERSION
  84. {
  85. TAKE_SNAPSHOT_VHDSET_VERSION_UNSPECIFIED = 0,
  86. TAKE_SNAPSHOT_VHDSET_VERSION_1 = 1,
  87.  
  88. } TAKE_SNAPSHOT_VHDSET_VERSION;
  89.  
  90. typedef struct _TAKE_SNAPSHOT_VHDSET_PARAMETERS
  91. {
  92. TAKE_SNAPSHOT_VHDSET_VERSION Version;
  93.  
  94. union
  95. {
  96. struct
  97. {
  98. GUID SnapshotId;
  99. } Version1;
  100. };
  101. } TAKE_SNAPSHOT_VHDSET_PARAMETERS, *PTAKE_SNAPSHOT_VHDSET_PARAMETERS;
  102.  
  103. typedef enum _DELETE_SNAPSHOT_VHDSET_FLAG
  104. {
  105. DELETE_SNAPSHOT_VHDSET_FLAG_NONE = 0x00000000,
  106. DELETE_SNAPSHOT_VHDSET_FLAG_PERSIST_RCT = 0x00000001,
  107.  
  108. } DELETE_SNAPSHOT_VHDSET_FLAG, *PDELETE_SNAPSHOT_VHDSET_FLAG;
  109.  
  110. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  111. DEFINE_ENUM_FLAG_OPERATORS(DELETE_SNAPSHOT_VHDSET_FLAG);
  112. #endif
  113.  
  114. typedef enum _DELETE_SNAPSHOT_VHDSET_VERSION
  115. {
  116. DELETE_SNAPSHOT_VHDSET_VERSION_UNSPECIFIED = 0,
  117. DELETE_SNAPSHOT_VHDSET_VERSION_1 = 1,
  118.  
  119. } DELETE_SNAPSHOT_VHDSET_VERSION;
  120.  
  121. typedef struct _DELETE_SNAPSHOT_VHDSET_PARAMETERS
  122. {
  123. DELETE_SNAPSHOT_VHDSET_VERSION Version;
  124.  
  125. union
  126. {
  127. struct
  128. {
  129. GUID SnapshotId;
  130. } Version1;
  131. };
  132. } DELETE_SNAPSHOT_VHDSET_PARAMETERS, *PDELETE_SNAPSHOT_VHDSET_PARAMETERS;
  133.  
  134. #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
  135.  
  136. DWORD
  137. WINAPI
  138. QueryChangesVirtualDisk (
  139. _In_ HANDLE VirtualDiskHandle,
  140. _In_ PCWSTR ChangeTrackingId,
  141. _In_ ULONG64 ByteOffset,
  142. _In_ ULONG64 ByteLength,
  143. _In_ QUERY_CHANGES_VIRTUAL_DISK_FLAG Flags,
  144. _Out_writes_to_(*RangeCount, *RangeCount) PQUERY_CHANGES_VIRTUAL_DISK_RANGE Ranges,
  145. _Inout_ PULONG RangeCount,
  146. _Out_ PULONG64 ProcessedLength
  147. );
  148.  
  149. DWORD
  150. WINAPI
  151. TakeSnapshotVhdSet (
  152. _In_ HANDLE VirtualDiskHandle,
  153. _In_ const PTAKE_SNAPSHOT_VHDSET_PARAMETERS Parameters,
  154. _In_ TAKE_SNAPSHOT_VHDSET_FLAG Flags
  155. );
  156.  
  157. DWORD
  158. WINAPI
  159. DeleteSnapshotVhdSet (
  160. _In_ HANDLE VirtualDiskHandle,
  161. _In_ const PDELETE_SNAPSHOT_VHDSET_PARAMETERS Parameters,
  162. _In_ DELETE_SNAPSHOT_VHDSET_FLAG Flags
  163. );
  164.  
  165. #endif // NTDDI_VERSION >= NTDDI_WINTHRESHOLD
  166.  
  167. typedef enum _MODIFY_VHDSET_VERSION
  168. {
  169. MODIFY_VHDSET_UNSPECIFIED = 0,
  170. MODIFY_VHDSET_SNAPSHOT_PATH = 1,
  171. MODIFY_VHDSET_REMOVE_SNAPSHOT = 2,
  172. MODIFY_VHDSET_DEFAULT_SNAPSHOT_PATH = 3,
  173.  
  174. } MODIFY_VHDSET_VERSION, *PMODIFY_VHDSET_VERSION;
  175.  
  176. typedef enum _MODIFY_VHDSET_FLAG
  177. {
  178. MODIFY_VHDSET_FLAG_NONE = 0x00000000,
  179.  
  180. } MODIFY_VHDSET_FLAG, *PMODIFY_VHDSET_FLAG;
  181.  
  182. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  183. DEFINE_ENUM_FLAG_OPERATORS(MODIFY_VHDSET_FLAG);
  184. #endif
  185.  
  186. typedef struct _MODIFY_VHDSET_PARAMETERS
  187. {
  188. MODIFY_VHDSET_VERSION Version;
  189.  
  190. union
  191. {
  192. struct
  193. {
  194. GUID SnapshotId;
  195. PCWSTR SnapshotFilePath;
  196. } SnapshotPath;
  197.  
  198. GUID SnapshotId;
  199.  
  200. PCWSTR DefaultFilePath;
  201. };
  202. } MODIFY_VHDSET_PARAMETERS, *PMODIFY_VHDSET_PARAMETERS;
  203.  
  204. #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
  205.  
  206. DWORD
  207. WINAPI
  208. ModifyVhdSet (
  209. _In_ HANDLE VirtualDiskHandle,
  210. _In_ const PMODIFY_VHDSET_PARAMETERS Parameters,
  211. _In_ MODIFY_VHDSET_FLAG Flags
  212. );
  213.  
  214. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement