4 * Definitions for Windows Overlay File System Filter (WOF) ioctls. See
5 * http://msdn.microsoft.com/en-us/library/windows/hardware/ff540367(v=vs.85).aspx
6 * for more information.
8 * The author dedicates this file to the public domain.
9 * You can do whatever you want with this file.
15 #include "wimlib/types.h"
16 #include "wimlib/compiler.h"
18 #define WOF_CURRENT_VERSION 1
19 #define WOF_PROVIDER_WIM 1
20 #define WIM_PROVIDER_CURRENT_VERSION 1
22 /* Identifies a backing provider for a specific overlay service version. */
23 struct wof_external_info {
25 /* Version of the overlay service supported by the backing provider.
26 * Set to WOF_CURRENT_VERSION. */
29 /* Identifier for the backing provider. Example value:
30 * WOF_PROVIDER_WIM. */
34 /* On Windows, WOF reparse points can only be directly created when the WOF
35 * driver is NOT running on the volume. Otherwise, the WOF ioctl
36 * (FSCTL_SET_EXTERNAL_BACKING, FSCTL_GET_EXTERNAL_BACKING,
37 * FSCTL_DELETE_EXTERNAL_BACKING) must be used instead. */
40 * Format of the reparse data of WoF (Windows Overlay File System Filter)
41 * reparse points. These include WIMBoot "pointer files".
43 * This is not documented by Microsoft!!!
46 * - 'struct wim_provider_rpdata' must be preceded by
47 * 'struct wof_external_info'.
48 * - Reparse tag is 0x80000017
49 * - Don't make these if the file has no unnamed data stream, has an empty
50 * unnamed data stream, or already is a reparse point.
51 * - There is nowhere to put named data streams. They have to copied
52 * literally to the reparse point file.
54 struct wim_provider_rpdata {
55 /* Set to 2. Uncertain meaning. */
58 /* 0 when WIM provider active, otherwise
59 * WIM_PROVIDER_EXTERNAL_FLAG_NOT_ACTIVE or
60 * WIM_PROVIDER_EXTERNAL_FLAG_SUSPENDED. */
63 /* Integer ID that identifies the WIM. */
66 /* SHA1 message digest of the file's unnamed data stream. */
69 /* SHA1 message digest of the WIM's lookup table. */
70 u8 wim_lookup_table_hash[20];
72 /* Uncompressed size of the file's unnamed data stream, in bytes. */
73 le64 stream_uncompressed_size;
75 /* Compressed size of the file's unnamed data stream, in bytes. If
76 * stream is stored uncompressed, set this the same as the uncompressed
78 le64 stream_compressed_size;
80 /* Byte offset of the file's unnamed data stream in the WIM. */
81 le64 stream_offset_in_wim;
84 /* WIM-specific information about a WIM data source */
85 struct WimOverlay_dat_entry_1 {
87 /* Identifier for the WIM data source, (normally allocated by
88 * FSCTL_ADD_OVERLAY). Every 'WimOverlay_dat_entry_1' should have a
89 * different value for this. */
92 /* Byte offset, from the beginning of the file, of the corresponding
93 * 'struct WimOverlay_dat_entry_2' for this WIM data source. */
96 /* Size, in bytes, of the corresponding 'struct WimOverlay_dat_entry_2
97 * for this WIM data source, including wim_file_name and its null
101 /* Type of the WIM file: WIM_BOOT_OS_WIM or WIM_BOOT_NOT_OS_WIM. */
104 /* Index of the image in the WIM to use??? (This doesn't really make
105 * sense, since WIM files combine streams for all images into a single
106 * table. Set to 1 if unsure...) */
109 /* GUID of the WIM file (copied from the WIM header, offset +0x18). */
114 * Format of file: "\System Volume Information\WimOverlay.dat"
116 * Not documented by Microsoft.
118 * The file consists of a 'struct WimOverlay_dat_header' followed by one or more
119 * 'struct WimOverlay_dat_entry_1', followed by the same number of 'struct
120 * WimOverlay_dat_entry_2'. Note that 'struct WimOverlay_dat_entry_1' is of
121 * fixed length, whereas 'struct WimOverlay_dat_entry_2' is of variable length.
123 struct WimOverlay_dat_header {
124 /* Set to WIMOVERLAY_DAT_MAGIC */
126 #define WIMOVERLAY_DAT_MAGIC 0x66436F57
128 /* Set to 1 (WIM_PROVIDER_CURRENT_VERSION) */
129 le32 wim_provider_version;
131 /* Set to 0x00000028 */
134 /* Set to number of WIMs registered;
135 * also the number of 'struct WimOverlay_dat_entry_1' that follow. */
138 /* Set to number of WIMs registered;
139 * also the number of 'struct WimOverlay_dat_entry_2' that follow. */
145 struct WimOverlay_dat_entry_1 entry_1s[];
148 /* Location information about a WIM data source */
149 struct WimOverlay_dat_entry_2 {
156 /* Size, in bytes, of this 'struct WimOverlay_dat_entry_2', including
157 * wim_file_name and its null terminator. */
170 /* Size of this inner structure, in bytes. */
171 le32 inner_struct_size;
188 /*************************
189 * Partition information
190 ************************/
192 /* Partition identifier */
194 /* (For MBR-formatted disks) */
196 /* Offset, in bytes, of the MBR partition, from
197 * the beginning of the disk. */
198 le64 part_start_offset;
204 /* (For GPT-formatted disks) */
206 /* Unique GUID of the GPT partition */
207 u8 part_unique_guid[16];
214 /***********************
216 **********************/
218 /* 1 for MBR, 0 for GPT */
219 le32 partition_table_type;
220 #define WIMOVERLAY_PARTITION_TYPE_MBR 1
221 #define WIMOVERLAY_PARTITION_TYPE_GPT 0
223 /* Disk identifier */
225 /* (For MBR-formatted disks) */
227 /* 4-byte ID of the MBR disk */
234 /* (For GPT-formatted disks) */
236 /* GUID of the GPT disk */
241 /* Set to 0. (This is the right size for some sort of optional
243 le32 unknown_0x58[4];
245 /**************************
246 * Location in filesystem
247 *************************/
249 /* Null-terminated path to WIM file. Begins with \ but does
250 * *not* include drive letter! */
251 utf16lechar wim_file_name[];
256 wof_check_structs(void)
258 BUILD_BUG_ON(sizeof(struct WimOverlay_dat_header) != 24);
259 BUILD_BUG_ON(sizeof(struct WimOverlay_dat_entry_1) != 40);
260 BUILD_BUG_ON(sizeof(struct WimOverlay_dat_entry_2) != 104);
263 /*****************************************************************************
265 * --- FSCTL_SET_EXTERNAL_BACKING ---
267 * Sets the backing source of a file.
269 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
270 * Access: 0 (FILE_ANY_ACCESS)
272 * Method: 0 (METHOD_BUFFERED)
274 * Input buffer: 'struct wof_external_info' followed by provider-specific data
275 * ('struct wim_provider_external_info' in the case of WIM).
277 * Output buffer: None
279 #define FSCTL_SET_EXTERNAL_BACKING 0x9030C
281 struct wim_provider_external_info {
283 /* Set to WIM_PROVIDER_CURRENT_VERSION. */
286 /* 0 when WIM provider active, otherwise
287 * WIM_PROVIDER_EXTERNAL_FLAG_NOT_ACTIVE or
288 * WIM_PROVIDER_EXTERNAL_FLAG_SUSPENDED. */
291 /* Integer ID that identifies the WIM. Get this with the
292 * FSCTL_ADD_OVERLAY ioctl. */
295 /* SHA1 message digest of the file's unnamed data stream. */
296 u8 resource_hash[20];
299 /*****************************************************************************
301 * --- FSCTL_GET_EXTERNAL_BACKING ---
303 * Get external backing information for the specified file.
305 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
306 * Access: 0 (FILE_ANY_ACCESS)
308 * Method: 0 (METHOD_BUFFERED)
311 * Output buffer: 'struct wof_external_info' followed by provider-specific data
312 * ('struct wim_provider_external_info' in the case of WIM).
314 #define FSCTL_GET_EXTERNAL_BACKING 0x90310
316 /*****************************************************************************
318 * --- FSCTL_DELETE_EXTERNAL_BACKING ---
320 * Copy a file from its backing source to its volume, then disassociate it from
321 * its backing provider.
323 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
324 * Access: 0 (FILE_ANY_ACCESS)
326 * Method: 0 (METHOD_BUFFERED)
329 * Output buffer: None
331 #define FSCTL_DELETE_EXTERNAL_BACKING 0x90314
333 /*****************************************************************************
335 * --- FSCTL_ENUM_EXTERNAL_BACKING ---
337 * Enumerate externally backed files on a volume.
339 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
340 * Access: 0 (FILE_ANY_ACCESS)
342 * Method: 0 (METHOD_BUFFERED)
345 * Output buffer: A 16-byte buffer that receives the 128-bit file ID for the
346 * next externally backed file.
348 * The handle used may be either the volume handle or the handle for any file or
349 * directory on the volume.
351 * When all externally backed files on the volume have been enumerated, the
352 * function fails with ERROR_NO_MORE_FILES.
354 #define FSCTL_ENUM_EXTERNAL_BACKING 0x90318
356 /*****************************************************************************
358 * --- FSCTL_ENUM_OVERLAY ---
360 * Enumerates the volume's overlay sources from the specified provider.
362 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
363 * Access: 0 (FILE_ANY_ACCESS)
365 * Method: 3 (METHOD_NEITHER)
367 * Input buffer: 'struct wof_external_info' to specify the provider for which
368 * to enumerate the overlay sources.
370 * Output buffer: Provider-specific data. For the WIM provider, an array of
371 * 'struct wim_provider_overlay_entry'.
373 * This ioctl must be performed on the volume handle, such as \\.\C:
375 #define FSCTL_ENUM_OVERLAY 0x9031F
377 struct wim_provider_overlay_entry {
378 /* Byte offset of the next entry from the beginning of this structure,
379 * or 0 if there are no more entries. */
380 uint32_t next_entry_offset;
384 /* Identifier for the WIM file. */
385 uint64_t data_source_id;
387 /* GUID of the WIM file. */
390 /* Byte offset of the WIM's file name from the beginning of this
392 uint32_t wim_file_name_offset;
394 /* Type of WIM file: WIM_BOOT_OS_WIM or WIM_BOOT_NOT_OS_WIM. */
397 /* Index of the backing image in the WIM??? (This doesn't really make
398 * sense, since WIM files combine streams for all images into a single
402 /* 0 when WIM provider active, otherwise
403 * WIM_PROVIDER_EXTERNAL_FLAG_NOT_ACTIVE or
404 * WIM_PROVIDER_EXTERNAL_FLAG_SUSPENDED. */
407 /* Full path to the WIM in the NT device namespace, e.g.
408 * "\Device\HardDiskVolume2\test.wim". Seems to be null-terminated,
409 * although you probably shouldn't assume so. */
410 wchar_t wim_file_name[];
414 /*****************************************************************************
416 * --- FSCTL_ADD_OVERLAY ---
418 * Adds a new external backing source to a volume.
420 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
421 * Access: 2 (FILE_WRITE_ACCESS)
423 * Method: 0 (METHOD_BUFFERED)
425 * Input buffer: 'struct wof_external_info' followed by provider-specific data
426 * ('struct wim_provider_add_overlay_input' in the case of WIM).
428 * Output buffer: Buffer large enough to receive any information resulting from
429 * the add operation. For the WIM provider, this must be an 8 byte buffer that
430 * receives the 64-bit WIM file ID.
432 * This ioctl must be performed on the volume handle, such as \\.\C:
434 #define FSCTL_ADD_OVERLAY 0x98330
436 struct wim_provider_add_overlay_input {
438 /* Type of WIM file. */
440 #define WIM_BOOT_OS_WIM 0
441 #define WIM_BOOT_NOT_OS_WIM 1
443 /* Index of the image in the WIM to use??? (This doesn't really make
444 * sense, since WIM files combine streams for all images into a single
445 * table. Set to 1 if unsure...) */
448 /* Byte offset of wim_file_name in this buffer, not including the
449 * preceding 'struct wof_external_info' (should be 16). */
450 u32 wim_file_name_offset;
452 /* Number of bytes in wim_file_name. */
453 u32 wim_file_name_length;
455 /* Full path to the WIM, e.g. "\??\C:\test-wimboot.wim".
456 * Does NOT need to be null terminated (MS docs claim otherwise). */
457 wchar_t wim_file_name[];
460 /*****************************************************************************
462 * --- FSCTL_REMOVE_OVERLAY ---
464 * Removes an external backing source from a volume.
466 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
467 * Access: 2 (FILE_WRITE_ACCESS)
469 * Method: 0 (METHOD_BUFFERED)
471 * Input buffer: 'struct wof_external_info' followed by provider-specific data
472 * ('struct wim_provider_remove_overlay_input' in the case of WIM).
474 * Output buffer: None
476 * This ioctl must be performed on the volume handle, such as \\.\C:
478 #define FSCTL_REMOVE_OVERLAY 0x98334
480 struct wim_provider_remove_overlay_input {
481 /* Integer ID that identifies the WIM. */
486 /*****************************************************************************
488 * --- FSCTL_UPDATE_OVERLAY ---
490 * Updates an overlay source for a volume.
492 * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
493 * Access: 2 (FILE_WRITE_ACCESS)
495 * Method: 0 (METHOD_BUFFERED)
497 * Input buffer: 'struct wof_external_info' followed by provider-specific data
498 * ('struct wim_provider_update_overlay_input' in the case of WIM).
500 * Output buffer: None
502 * This ioctl must be performed on the volume handle, such as \\.\C:
504 #define FSCTL_UPDATE_OVERLAY 0x98338
506 struct wim_provider_update_overlay_input {
507 /* Integer ID that identifies the WIM data source. */
510 /* Byte offset of wim_file_name in this buffer, not including the
511 * preceding 'struct wof_external_info' (should be 16). */
512 u32 wim_file_name_offset;
514 /* Number of bytes in wim_file_name. */
515 u32 wim_file_name_length;
517 /* Full path to the WIM, e.g. "\??\C:\test-wimboot.wim".
518 * Does NOT need to be null terminated (MS docs claim otherwise).
519 * This WIM must be renamed from the original WIM, or at least be an
520 * identical copy of it! (Maybe the WIM's GUID field is checked.) */
521 wchar_t wim_file_name[];