]> wimlib.net Git - wimlib/commitdiff
win32: update WOF ioctl definitions
authorEric Biggers <ebiggers3@gmail.com>
Tue, 29 Jun 2021 07:42:11 +0000 (00:42 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 29 Jun 2021 07:42:11 +0000 (00:42 -0700)
Use the "official" Microsoft struct and field names, and only define
things when they aren't already defined (since some of them were
recently added to MinGW's winioctl.h, causing build errors).

include/wimlib/wof.h
src/wimboot.c
src/win32_apply.c
src/win32_capture.c
tests/wlfuzz.c

index d0fcf03a3ca4797727846fa183a817bcaedcebed..4f28db75648811beb65ded05be8447aea2e75e66 100644 (file)
@@ -2,13 +2,11 @@
  * wof.h
  *
  * Definitions for the Windows Overlay Filesystem filter (WOF) ioctls, as well
- * some definitions for associated undocumented data structures.  See
- * http://msdn.microsoft.com/en-us/library/windows/hardware/ff540367(v=vs.85).aspx
- * for more information about the documented ioctls.
+ * some definitions for associated undocumented data structures.
  *
  * The following copying information applies to this specific source code file:
  *
- * Written in 2014-2016 by Eric Biggers <ebiggers3@gmail.com>
+ * Written in 2014-2021 by Eric Biggers <ebiggers3@gmail.com>
  *
  * To the extent possible under law, the author(s) have dedicated all copyright
  * and related and neighboring rights to this software to the public domain
  */
 
 
-/* Current version of the WOF driver/protocol  */
-#define WOF_CURRENT_VERSION            1
+/*----------------------------------------------------------------------------*
+ *                          WOF ioctl definitions                             *
+ *----------------------------------------------------------------------------*/
 
-/* Specifies the WIM backing provider  */
-#define WOF_PROVIDER_WIM               1
-
-/* Specifies the "file" backing provider (a.k.a. System Compression)  */
-#define WOF_PROVIDER_FILE              2
-
-/* The current version of the WIM backing provider  */
-#define WIM_PROVIDER_CURRENT_VERSION   1
-
-/* The current version of the file backing provider  */
-#define FILE_PROVIDER_CURRENT_VERSION  1
-
-/* Identifies a backing provider for a specific overlay service version.  */
-struct wof_external_info {
-
-       /* Version of the overlay service supported by the backing provider.
-        * Set to WOF_CURRENT_VERSION.  */
-       u32 version;
-
-       /* Identifier for the backing provider.  Example value:
-        * WOF_PROVIDER_WIM.  */
-       u32 provider;
-};
+#ifndef WOF_CURRENT_VERSION
+/* Identifies a file backing provider and the overlay service version it supports.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_wof_external_info */
+typedef struct _WOF_EXTERNAL_INFO {
+#define WOF_CURRENT_VERSION 1
+       DWORD Version;
+       DWORD Provider;
+} WOF_EXTERNAL_INFO, *PWOF_EXTERNAL_INFO;
+#endif /* WOF_CURRENT_VERSION */
 
+/* WIM provider ("WIMBoot") */
+#ifndef WOF_PROVIDER_WIM
+#define WOF_PROVIDER_WIM 1
+/*
+ * The identifier and status information for the Windows Image File (WIM)
+ * external backing provider.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_wim_provider_external_info
+ */
+typedef struct _WIM_PROVIDER_EXTERNAL_INFO {
+#define WIM_PROVIDER_CURRENT_VERSION 1
+       ULONG         Version;
+       ULONG         Flags;
+       LARGE_INTEGER DataSourceId;
+#define WIM_PROVIDER_HASH_SIZE 20
+       UCHAR         ResourceHash[WIM_PROVIDER_HASH_SIZE];
+} WIM_PROVIDER_EXTERNAL_INFO, *PWIM_PROVIDER_EXTERNAL_INFO;
+#endif /* WOF_PROVIDER_WIM */
+
+/* File provider ("system compression") */
+#ifndef WOF_PROVIDER_FILE
+#define WOF_PROVIDER_FILE 2
+/* Defines metadata specific to files provided by WOF_PROVIDER_FILE.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_provider_external_info_v1 */
+typedef struct _FILE_PROVIDER_EXTERNAL_INFO_V1 {
+#define FILE_PROVIDER_CURRENT_VERSION 1
+       DWORD Version;
+#define FILE_PROVIDER_COMPRESSION_XPRESS4K     0
+#define FILE_PROVIDER_COMPRESSION_LZX          1
+#define FILE_PROVIDER_COMPRESSION_XPRESS8K     2
+#define FILE_PROVIDER_COMPRESSION_XPRESS16K    3
+       DWORD Algorithm;
+       DWORD Flags;
+} FILE_PROVIDER_EXTERNAL_INFO_V1, *PFILE_PROVIDER_EXTERNAL_INFO_V1;
+#endif /* WOF_PROVIDER_FILE */
+
+/* Sets the backing source for a file.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-set-external-backing */
+#ifndef FSCTL_SET_EXTERNAL_BACKING
+#define FSCTL_SET_EXTERNAL_BACKING \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 195, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
+#endif
+
+/* Gets the backing information for a file from an external backing provider.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-get-external-backing */
+#ifndef FSCTL_GET_EXTERNAL_BACKING
+#define FSCTL_GET_EXTERNAL_BACKING \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 196, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#endif
+
+#ifndef STATUS_OBJECT_NOT_EXTERNALLY_BACKED
+#define STATUS_OBJECT_NOT_EXTERNALLY_BACKED    0xC000046D
+#endif
+
+/* Removes the association of a file with an external backing provider.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-delete-external-backing */
+#ifndef FSCTL_DELETE_EXTERNAL_BACKING
+#define FSCTL_DELETE_EXTERNAL_BACKING \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 197, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
+#endif
+
+/* Begins or continues an enumeration of files on a volume that have a backing source.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-enum-external-backing */
+#ifndef FSCTL_ENUM_EXTERNAL_BACKING
+#define FSCTL_ENUM_EXTERNAL_BACKING \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 198, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#endif
+
+/* Enumerates all the data sources from a backing provider for a specified volume.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-enum-overlay */
+#ifndef FSCTL_ENUM_OVERLAY
+#define FSCTL_ENUM_OVERLAY \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 199, METHOD_NEITHER, FILE_ANY_ACCESS)
+typedef struct _WIM_PROVIDER_OVERLAY_ENTRY {
+       ULONG NextEntryOffset;
+       LARGE_INTEGER DataSourceId;
+       GUID WimGuid;
+       ULONG WimFileNameOffset;
+       ULONG WimType;
+       ULONG WimIndex;
+       ULONG Flags;
+} WIM_PROVIDER_OVERLAY_ENTRY, *PWIM_PROVIDER_OVERLAY_ENTRY;
+#endif /* FSCTL_ENUM_OVERLAY */
+
+/* Add a new external backing source to a volume's namespace.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-add-overlay */
+#ifndef FSCTL_ADD_OVERLAY
+#define FSCTL_ADD_OVERLAY \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 204, METHOD_BUFFERED, FILE_WRITE_DATA)
+typedef struct _WIM_PROVIDER_ADD_OVERLAY_INPUT {
+#define WIM_BOOT_NOT_OS_WIM    0
+#define WIM_BOOT_OS_WIM                1
+       ULONG WimType;
+       ULONG WimIndex;
+       ULONG WimFileNameOffset;
+       ULONG WimFileNameLength;
+} WIM_PROVIDER_ADD_OVERLAY_INPUT, *PWIM_PROVIDER_ADD_OVERLAY_INPUT;
+#endif /* FSCTL_ADD_OVERLAY */
+
+/* Removes a backing source from a volume.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-remove-overlay */
+#ifndef FSCTL_REMOVE_OVERLAY
+#define FSCTL_REMOVE_OVERLAY \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 205, METHOD_BUFFERED, FILE_WRITE_DATA)
+typedef struct _WIM_PROVIDER_REMOVE_OVERLAY_INPUT {
+       LARGE_INTEGER DataSourceId;
+} WIM_PROVIDER_REMOVE_OVERLAY_INPUT, *PWIM_PROVIDER_REMOVE_OVERLAY_INPUT;
+#endif /* FSCTL_REMOVE_OVERLAY */
+
+/* Updates a new data source identifier for a backing source attached to a volume.
+ * Ref: https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/fsctl-update-overlay */
+#ifndef FSCTL_UPDATE_OVERLAY
+#define FSCTL_UPDATE_OVERLAY \
+       CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 206, METHOD_BUFFERED, FILE_WRITE_DATA)
+typedef struct _WIM_PROVIDER_UPDATE_OVERLAY_INPUT {
+       LARGE_INTEGER DataSourceId;
+       ULONG         WimFileNameOffset;
+       ULONG         WimFileNameLength;
+} WIM_PROVIDER_UPDATE_OVERLAY_INPUT, *PWIM_PROVIDER_UPDATE_OVERLAY_INPUT;
+#endif /* FSCTL_UPDATE_OVERLAY */
+
+/*----------------------------------------------------------------------------*
+ *        WOF reparse point and WimOverlay.dat structs (undocumented)         *
+ *----------------------------------------------------------------------------*/
 
 /*
  * Format of the WIM provider reparse data.  This is the data which follows the
  * portion of the reparse point common to WOF.  (The common portion consists of
- * a reparse point header where the reparse tag is 0x80000017, then a 'struct
- * wof_external_info' which specifies the provider.)
+ * a reparse point header where the reparse tag is 0x80000017, then a
+ * WOF_EXTERNAL_INFO struct which specifies the provider.)
  *
  * Note that Microsoft does not document any of the reparse point formats for
  * WOF, although they document the structures which must be passed into the
@@ -308,279 +416,4 @@ wof_check_structs(void)
        STATIC_ASSERT(sizeof(struct WimOverlay_dat_entry_2) == 104);
 }
 
-/*****************************************************************************
- *
- * --- FSCTL_SET_EXTERNAL_BACKING ---
- *
- * Sets the backing source of a file.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     0 (FILE_ANY_ACCESS)
- * Function:   195
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer:  'struct wof_external_info' followed by provider-specific data
- * ('struct wim_provider_external_info' in the case of WIM).
- *
- * Output buffer: None
- */
-#define FSCTL_SET_EXTERNAL_BACKING 0x9030C
-
-struct wim_provider_external_info {
-
-       /* Set to WIM_PROVIDER_CURRENT_VERSION.  */
-       u32 version;
-
-       /* 0 when WIM provider active, otherwise
-        * WIM_PROVIDER_EXTERNAL_FLAG_NOT_ACTIVE or
-        * WIM_PROVIDER_EXTERNAL_FLAG_SUSPENDED.  */
-       u32 flags;
-
-       /* Integer ID that identifies the WIM.  Get this with the
-        * FSCTL_ADD_OVERLAY ioctl.  */
-       u64 data_source_id;
-
-       /* SHA-1 message digest of the file's unnamed data stream.  */
-       u8 unnamed_data_stream_hash[20];
-};
-
-struct file_provider_external_info {
-
-       /* Set to FILE_PROVIDER_CURRENT_VERSION.  */
-       u32 version;
-
-       u32 compression_format;
-#define FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS4K      0
-#define FILE_PROVIDER_COMPRESSION_FORMAT_LZX           1
-#define FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS8K      2
-#define FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS16K     3
-};
-
-/*****************************************************************************
- *
- * --- FSCTL_GET_EXTERNAL_BACKING ---
- *
- * Get external backing information for the specified file.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     0 (FILE_ANY_ACCESS)
- * Function:   196
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer: None
- * Output buffer:  'struct wof_external_info' followed by provider-specific data
- * ('struct wim_provider_external_info' in the case of WIM).
- */
-#define FSCTL_GET_EXTERNAL_BACKING 0x90310
-
-#define STATUS_OBJECT_NOT_EXTERNALLY_BACKED    0xC000046D
-
-/*****************************************************************************
- *
- * --- FSCTL_DELETE_EXTERNAL_BACKING ---
- *
- * Copy a file from its backing source to its volume, then disassociate it from
- * its backing provider.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     0 (FILE_ANY_ACCESS)
- * Function:   197
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer: None
- * Output buffer: None
- */
-#define FSCTL_DELETE_EXTERNAL_BACKING 0x90314
-
-/*****************************************************************************
- *
- * --- FSCTL_ENUM_EXTERNAL_BACKING ---
- *
- * Enumerate externally backed files on a volume.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     0 (FILE_ANY_ACCESS)
- * Function:   198
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer: None
- * Output buffer: A 16-byte buffer that receives the 128-bit file ID for the
- * next externally backed file.
- *
- * The handle used may be either the volume handle or the handle for any file or
- * directory on the volume.
- *
- * When all externally backed files on the volume have been enumerated, the
- * function fails with ERROR_NO_MORE_FILES.
- */
-#define FSCTL_ENUM_EXTERNAL_BACKING 0x90318
-
-/*****************************************************************************
- *
- * --- FSCTL_ENUM_OVERLAY ---
- *
- * Enumerates the volume's overlay sources from the specified provider.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     0 (FILE_ANY_ACCESS)
- * Function:   199
- * Method:     3 (METHOD_NEITHER)
- *
- * Input buffer:  'struct wof_external_info' to specify the provider for which
- * to enumerate the overlay sources.
- *
- * Output buffer:  Provider-specific data.  For the WIM provider, an array of
- * 'struct wim_provider_overlay_entry'.
- *
- * This ioctl must be performed on the volume handle, such as \\.\C:
- */
-#define FSCTL_ENUM_OVERLAY 0x9031F
-
-struct wim_provider_overlay_entry {
-       /* Byte offset of the next entry from the beginning of this structure,
-        * or 0 if there are no more entries.  */
-       u32 next_entry_offset;
-
-       u32 padding;
-
-       /* Identifier for the WIM file.  */
-       u64 data_source_id;
-
-       /* GUID of the WIM file.  */
-       u8 guid[16];
-
-       /* Byte offset of the WIM's file name from the beginning of this
-        * structure.  */
-       u32 wim_file_name_offset;
-
-       /* Type of WIM file: WIM_BOOT_OS_WIM or WIM_BOOT_NOT_OS_WIM.  */
-       u32 wim_type;
-
-       /* Index of the image in the WIM to use??? (This doesn't really make
-        * sense, since WIM files combine file data "blobs" for all images into
-        * a single table.  Set to 1 if unsure...)  */
-       u32 wim_index;
-
-       /* 0 when WIM provider active, otherwise
-        * WIM_PROVIDER_EXTERNAL_FLAG_NOT_ACTIVE or
-        * WIM_PROVIDER_EXTERNAL_FLAG_SUSPENDED.  */
-       u32 flags;
-
-       /* Full path to the WIM in the NT device namespace, e.g.
-        * "\Device\HardDiskVolume2\test.wim".  Seems to be null-terminated,
-        * although you probably shouldn't assume so.  */
-       wchar_t wim_file_name[];
-};
-
-
-/*****************************************************************************
- *
- * --- FSCTL_ADD_OVERLAY ---
- *
- * Adds a new external backing source to a volume.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     2 (FILE_WRITE_ACCESS)
- * Function:   204
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer:  'struct wof_external_info' followed by provider-specific data
- * ('struct wim_provider_add_overlay_input' in the case of WIM).
- *
- * Output buffer:  Buffer large enough to receive any information resulting from
- * the add operation.  For the WIM provider, this must be an 8 byte buffer that
- * receives the 64-bit WIM file ID.
- *
- * This ioctl must be performed on the volume handle, such as \\.\C:
- */
-#define FSCTL_ADD_OVERLAY 0x98330
-
-struct wim_provider_add_overlay_input {
-
-       /* Type of WIM file.  */
-       u32 wim_type;
-#define WIM_BOOT_OS_WIM                0
-#define WIM_BOOT_NOT_OS_WIM    1
-
-       /* Index of the image in the WIM to use??? (This doesn't really make
-        * sense, since WIM files combine file data "blobs" for all images into
-        * a single table.  Set to 1 if unsure...)  */
-       u32 wim_index;
-
-       /* Byte offset of wim_file_name in this buffer, not including the
-        * preceding 'struct wof_external_info' (should be 16).  */
-       u32 wim_file_name_offset;
-
-       /* Number of bytes in wim_file_name.  */
-       u32 wim_file_name_length;
-
-       /* Full path to the WIM, e.g. "\??\C:\test-wimboot.wim".
-        * Does NOT need to be null terminated (MS docs claim otherwise).  */
-       wchar_t wim_file_name[];
-};
-
-/*****************************************************************************
- *
- * --- FSCTL_REMOVE_OVERLAY ---
- *
- * Removes an external backing source from a volume.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     2 (FILE_WRITE_ACCESS)
- * Function:   205
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer:  'struct wof_external_info' followed by provider-specific data
- * ('struct wim_provider_remove_overlay_input' in the case of WIM).
- *
- * Output buffer:  None
- *
- * This ioctl must be performed on the volume handle, such as \\.\C:
- */
-#define FSCTL_REMOVE_OVERLAY 0x98334
-
-struct wim_provider_remove_overlay_input {
-       /* Integer ID that identifies the WIM.  */
-       u64 data_source_id;
-};
-
-
-/*****************************************************************************
- *
- * --- FSCTL_UPDATE_OVERLAY ---
- *
- * Updates an overlay source for a volume.
- *
- * DeviceType: 9 (FILE_DEVICE_FILE_SYSTEM)
- * Access:     2 (FILE_WRITE_ACCESS)
- * Function:   206
- * Method:     0 (METHOD_BUFFERED)
- *
- * Input buffer:  'struct wof_external_info' followed by provider-specific data
- * ('struct wim_provider_update_overlay_input' in the case of WIM).
- *
- * Output buffer:  None
- *
- * This ioctl must be performed on the volume handle, such as \\.\C:
- */
-#define FSCTL_UPDATE_OVERLAY 0x98338
-
-struct wim_provider_update_overlay_input {
-       /* Integer ID that identifies the WIM data source.  */
-       u64 data_source_id;
-
-       /* Byte offset of wim_file_name in this buffer, not including the
-        * preceding 'struct wof_external_info' (should be 16).  */
-       u32 wim_file_name_offset;
-
-       /* Number of bytes in wim_file_name.  */
-       u32 wim_file_name_length;
-
-       /* Full path to the WIM, e.g. "\??\C:\test-wimboot.wim".
-        * Does NOT need to be null terminated (MS docs claim otherwise).
-        * This WIM must be renamed from the original WIM, or at least be an
-        * identical copy of it!  (Maybe the WIM's GUID field is checked.)  */
-       wchar_t wim_file_name[];
-};
-
 #endif /* _WOF_H_ */
index 47c4d3a4de40f23154ec7154cfda71ffd5152024..3943470c8f439d1e1b6e7ff65d7609da57df5fff 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 /*
- * Copyright (C) 2014-2016 Eric Biggers
+ * Copyright (C) 2014-2021 Eric Biggers
  *
  * This file is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -887,8 +887,9 @@ wimboot_alloc_data_source_id(const wchar_t *wim_path,
        size_t wim_file_name_length;
        void *in;
        size_t insize;
-       struct wof_external_info *wof_info;
-       struct wim_provider_add_overlay_input *wim_info;
+       WOF_EXTERNAL_INFO *wof_info;
+       WIM_PROVIDER_ADD_OVERLAY_INPUT *wim_info;
+       wchar_t *WimFileName;
        HANDLE h;
        u64 data_source_id;
        DWORD bytes_returned;
@@ -908,28 +909,25 @@ wimboot_alloc_data_source_id(const wchar_t *wim_path,
        wim_file_name_length = sizeof(wchar_t) *
                               (wim_path_nchars + prefix_nchars);
 
-       insize = sizeof(struct wof_external_info) +
-                sizeof(struct wim_provider_add_overlay_input) +
-                wim_file_name_length;
-
-       in = MALLOC(insize);
+       insize = sizeof(*wof_info) + sizeof(*wim_info) + wim_file_name_length;
+       in = CALLOC(1, insize);
        if (!in) {
                ret = WIMLIB_ERR_NOMEM;
                goto out;
        }
 
-       wof_info = (struct wof_external_info *)in;
-       wof_info->version = WOF_CURRENT_VERSION;
-       wof_info->provider = WOF_PROVIDER_WIM;
+       wof_info = (WOF_EXTERNAL_INFO *)in;
+       wof_info->Version = WOF_CURRENT_VERSION;
+       wof_info->Provider = WOF_PROVIDER_WIM;
 
-       wim_info = (struct wim_provider_add_overlay_input *)(wof_info + 1);
-       wim_info->wim_type = WIM_BOOT_NOT_OS_WIM;
-       wim_info->wim_index = image;
-       wim_info->wim_file_name_offset = offsetof(struct wim_provider_add_overlay_input,
-                                                 wim_file_name);
-       wim_info->wim_file_name_length = wim_file_name_length;
-       wmemcpy(&wim_info->wim_file_name[0], prefix, prefix_nchars);
-       wmemcpy(&wim_info->wim_file_name[prefix_nchars], wim_path, wim_path_nchars);
+       wim_info = (WIM_PROVIDER_ADD_OVERLAY_INPUT *)(wof_info + 1);
+       wim_info->WimType = WIM_BOOT_NOT_OS_WIM;
+       wim_info->WimIndex = image;
+       wim_info->WimFileNameOffset = sizeof(*wim_info);
+       wim_info->WimFileNameLength = wim_file_name_length;
+       WimFileName = (wchar_t *)(wim_info + 1);
+       wmemcpy(WimFileName, prefix, prefix_nchars);
+       wmemcpy(&WimFileName[prefix_nchars], wim_path, wim_path_nchars);
 
 retry_ioctl:
        h = open_file(drive_path, GENERIC_WRITE);
@@ -1027,20 +1025,20 @@ wimboot_set_pointer(HANDLE h,
                 * using FSCTL_SET_EXTERNAL_BACKING.  */
                unsigned int max_retries = 4;
                struct {
-                       struct wof_external_info wof_info;
-                       struct wim_provider_external_info wim_info;
+                       WOF_EXTERNAL_INFO wof_info;
+                       WIM_PROVIDER_EXTERNAL_INFO wim_info;
                } in;
 
        retry:
                memset(&in, 0, sizeof(in));
 
-               in.wof_info.version = WOF_CURRENT_VERSION;
-               in.wof_info.provider = WOF_PROVIDER_WIM;
+               in.wof_info.Version = WOF_CURRENT_VERSION;
+               in.wof_info.Provider = WOF_PROVIDER_WIM;
 
-               in.wim_info.version = WIM_PROVIDER_CURRENT_VERSION;
-               in.wim_info.flags = 0;
-               in.wim_info.data_source_id = data_source_id;
-               copy_hash(in.wim_info.unnamed_data_stream_hash, blob->hash);
+               in.wim_info.Version = WIM_PROVIDER_CURRENT_VERSION;
+               in.wim_info.Flags = 0;
+               in.wim_info.DataSourceId.QuadPart = data_source_id;
+               copy_hash(in.wim_info.ResourceHash, blob->hash);
 
                /* blob_table_hash is not necessary  */
 
@@ -1074,20 +1072,20 @@ wimboot_set_pointer(HANDLE h,
                                le16 rpdatalen;
                                le16 rpreserved;
                        } hdr;
-                       struct wof_external_info wof_info;
+                       WOF_EXTERNAL_INFO wof_info;
                        struct wim_provider_rpdata wim_info;
                } in;
 
                STATIC_ASSERT(sizeof(in) == 8 +
-                             sizeof(struct wof_external_info) +
+                             sizeof(WOF_EXTERNAL_INFO) +
                              sizeof(struct wim_provider_rpdata));
 
                in.hdr.rptag = WIM_IO_REPARSE_TAG_WOF;
                in.hdr.rpdatalen = sizeof(in) - sizeof(in.hdr);
                in.hdr.rpreserved = 0;
 
-               in.wof_info.version = WOF_CURRENT_VERSION;
-               in.wof_info.provider = WOF_PROVIDER_WIM;
+               in.wof_info.Version = WOF_CURRENT_VERSION;
+               in.wof_info.Provider = WOF_PROVIDER_WIM;
 
                in.wim_info.version = 2;
                in.wim_info.flags = 0;
index 6065976968a2d09801a9c0383e6476f4cc42511b..a1301d646290f4d8671428119698e3a41871e619 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 /*
- * Copyright (C) 2013-2020 Eric Biggers
+ * Copyright (C) 2013-2021 Eric Biggers
  *
  * This file is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -2424,15 +2424,15 @@ static int
 get_system_compression_format(int extract_flags)
 {
        if (extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K)
-               return FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS4K;
+               return FILE_PROVIDER_COMPRESSION_XPRESS4K;
 
        if (extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K)
-               return FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS8K;
+               return FILE_PROVIDER_COMPRESSION_XPRESS8K;
 
        if (extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K)
-               return FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS16K;
+               return FILE_PROVIDER_COMPRESSION_XPRESS16K;
 
-       return FILE_PROVIDER_COMPRESSION_FORMAT_LZX;
+       return FILE_PROVIDER_COMPRESSION_LZX;
 }
 
 
@@ -2440,11 +2440,11 @@ static const wchar_t *
 get_system_compression_format_string(int format)
 {
        switch (format) {
-       case FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS4K:
+       case FILE_PROVIDER_COMPRESSION_XPRESS4K:
                return L"XPRESS4K";
-       case FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS8K:
+       case FILE_PROVIDER_COMPRESSION_XPRESS8K:
                return L"XPRESS8K";
-       case FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS16K:
+       case FILE_PROVIDER_COMPRESSION_XPRESS16K:
                return L"XPRESS16K";
        default:
                return L"LZX";
@@ -2456,16 +2456,16 @@ set_system_compression(HANDLE h, int format)
 {
        NTSTATUS status;
        struct {
-               struct wof_external_info wof_info;
-               struct file_provider_external_info file_info;
+               WOF_EXTERNAL_INFO wof_info;
+               FILE_PROVIDER_EXTERNAL_INFO_V1 file_info;
        } in = {
                .wof_info = {
-                       .version = WOF_CURRENT_VERSION,
-                       .provider = WOF_PROVIDER_FILE,
+                       .Version = WOF_CURRENT_VERSION,
+                       .Provider = WOF_PROVIDER_FILE,
                },
                .file_info = {
-                       .version = FILE_PROVIDER_CURRENT_VERSION,
-                       .compression_format = format,
+                       .Version = FILE_PROVIDER_CURRENT_VERSION,
+                       .Algorithm = format,
                },
        };
 
@@ -2528,7 +2528,7 @@ static bool
 bootloader_supports_compression_format(struct win32_apply_ctx *ctx, int format)
 {
        /* Windows 10 and later support XPRESS4K */
-       if (format == FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS4K)
+       if (format == FILE_PROVIDER_COMPRESSION_XPRESS4K)
                return ctx->windows_build_number >= 10240;
 
        /*
@@ -2573,7 +2573,7 @@ set_system_compression_on_inode(struct wim_inode *inode, int format,
                        warned = (ctx->num_system_compression_exclusions++ > 0);
 
                        if (bootloader_supports_compression_format(ctx,
-                                  FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS4K))
+                                  FILE_PROVIDER_COMPRESSION_XPRESS4K))
                        {
                                /* Force to XPRESS4K  */
                                if (!warned) {
@@ -2586,7 +2586,7 @@ set_system_compression_on_inode(struct wim_inode *inode, int format,
                                                "          you requested.",
                                                get_system_compression_format_string(format));
                                }
-                               format = FILE_PROVIDER_COMPRESSION_FORMAT_XPRESS4K;
+                               format = FILE_PROVIDER_COMPRESSION_XPRESS4K;
                                break;
                        } else {
                                /* Force to uncompressed  */
index 1b088de959463e3aef96be15f4eafb4b5448c2b6..0298cf00e7de2bc70eba70bb62a47165ebe81228 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 /*
- * Copyright (C) 2013-2018 Eric Biggers
+ * Copyright (C) 2013-2021 Eric Biggers
  *
  * This file is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -1518,7 +1518,7 @@ try_to_use_wimboot_hash(HANDLE h, struct wim_inode *inode,
        if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT) {
                struct reparse_buffer_disk rpbuf;
                struct {
-                       struct wof_external_info wof_info;
+                       WOF_EXTERNAL_INFO wof_info;
                        struct wim_provider_rpdata wim_info;
                } *rpdata = (void *)rpbuf.rpdata;
                struct blob_descriptor *reparse_blob;
@@ -1536,8 +1536,8 @@ try_to_use_wimboot_hash(HANDLE h, struct wim_inode *inode,
                if (ret)
                        return ret;
 
-               if (rpdata->wof_info.version != WOF_CURRENT_VERSION ||
-                   rpdata->wof_info.provider != WOF_PROVIDER_WIM ||
+               if (rpdata->wof_info.Version != WOF_CURRENT_VERSION ||
+                   rpdata->wof_info.Provider != WOF_PROVIDER_WIM ||
                    rpdata->wim_info.version != 2)
                        return 0;  /* Not a WIM-backed file  */
 
@@ -1545,8 +1545,8 @@ try_to_use_wimboot_hash(HANDLE h, struct wim_inode *inode,
                copy_hash(hash, rpdata->wim_info.unnamed_data_stream_hash);
        } else {
                struct {
-                       struct wof_external_info wof_info;
-                       struct wim_provider_external_info wim_info;
+                       WOF_EXTERNAL_INFO wof_info;
+                       WIM_PROVIDER_EXTERNAL_INFO wim_info;
                } out;
                NTSTATUS status;
 
@@ -1580,13 +1580,13 @@ try_to_use_wimboot_hash(HANDLE h, struct wim_inode *inode,
                }
 
                /* Is this file backed by a WIM?  */
-               if (out.wof_info.version != WOF_CURRENT_VERSION ||
-                   out.wof_info.provider != WOF_PROVIDER_WIM ||
-                   out.wim_info.version != WIM_PROVIDER_CURRENT_VERSION)
+               if (out.wof_info.Version != WOF_CURRENT_VERSION ||
+                   out.wof_info.Provider != WOF_PROVIDER_WIM ||
+                   out.wim_info.Version != WIM_PROVIDER_CURRENT_VERSION)
                        return 0;
 
                /* Okay, this is a WIM backed file.  Get its SHA-1 hash.  */
-               copy_hash(hash, out.wim_info.unnamed_data_stream_hash);
+               copy_hash(hash, out.wim_info.ResourceHash);
        }
 
        /* If the file's unnamed data stream is nonempty, then fill in its hash
index 35cefbe5c3846d9fcaae2c4d5a8fb762f983dff0..7b3589b99e0fe4dc4e235c5375de35a07390ec18 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 /*
- * Copyright (C) 2015-2016 Eric Biggers
+ * Copyright (C) 2015-2021 Eric Biggers
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -820,10 +820,10 @@ unregister_all_backing_wims(const tchar drive_letter)
        HANDLE h;
        void *overlay_list;
        DWORD bytes_returned;
-       const struct wim_provider_overlay_entry *entry;
+       const WIM_PROVIDER_OVERLAY_ENTRY *entry;
        struct {
-               struct wof_external_info wof_info;
-               struct wim_provider_remove_overlay_input wim;
+               WOF_EXTERNAL_INFO wof_info;
+               WIM_PROVIDER_REMOVE_OVERLAY_INPUT wim;
        } in;
 
        wsprintf(volume, L"\\\\.\\%lc:", drive_letter);
@@ -837,11 +837,11 @@ unregister_all_backing_wims(const tchar drive_letter)
        overlay_list = malloc(32768);
        ASSERT(overlay_list != NULL, "out of memory");
 
-       in.wof_info.version = WOF_CURRENT_VERSION;
-       in.wof_info.provider = WOF_PROVIDER_WIM;
+       in.wof_info.Version = WOF_CURRENT_VERSION;
+       in.wof_info.Provider = WOF_PROVIDER_WIM;
 
        if (!DeviceIoControl(h, FSCTL_ENUM_OVERLAY,
-                            &in, sizeof(struct wof_external_info),
+                            &in, sizeof(WOF_EXTERNAL_INFO),
                             overlay_list, 32768, &bytes_returned, NULL))
        {
                ASSERT(GetLastError() == ERROR_INVALID_FUNCTION ||
@@ -854,16 +854,16 @@ unregister_all_backing_wims(const tchar drive_letter)
        entry = overlay_list;
        for (;;) {
                printf("Unregistering data source ID %"PRIu64"\n",
-                      entry->data_source_id);
-               in.wim.data_source_id = entry->data_source_id;
+                      entry->DataSourceId.QuadPart);
+               in.wim.DataSourceId = entry->DataSourceId;
                ASSERT(DeviceIoControl(h, FSCTL_REMOVE_OVERLAY, &in, sizeof(in),
                                       NULL, 0, &bytes_returned, NULL),
                       "FSCTL_REMOVE_OVERLAY failed; error=%u",
                       (unsigned )GetLastError());
-               if (entry->next_entry_offset == 0)
+               if (entry->NextEntryOffset == 0)
                        break;
-               entry = (const struct wim_provider_overlay_entry *)
-                       ((const uint8_t *)entry + entry->next_entry_offset);
+               entry = (const WIM_PROVIDER_OVERLAY_ENTRY *)
+                       ((const uint8_t *)entry + entry->NextEntryOffset);
        }
        free(overlay_list);
        CloseHandle(h);