using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using Vanara.Collections; namespace Vanara.PInvoke.VssApi { /// /// The VSS_MGMT_OBJECT_TYPE enumeration type is a discriminant for the VSS_MGMT_OBJECT_UNION union within the /// VSS_MGMT_OBJECT_PROP structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/ne-vsmgmt-vss_mgmt_object_type typedef enum _VSS_MGMT_OBJECT_TYPE { // VSS_MGMT_OBJECT_UNKNOWN, VSS_MGMT_OBJECT_VOLUME, VSS_MGMT_OBJECT_DIFF_VOLUME, VSS_MGMT_OBJECT_DIFF_AREA } VSS_MGMT_OBJECT_TYPE, *PVSS_MGMT_OBJECT_TYPE; [PInvokeData("vsmgmt.h", MSDNShortId = "NE:vsmgmt._VSS_MGMT_OBJECT_TYPE")] public enum VSS_MGMT_OBJECT_TYPE { /// The object type is unknown. VSS_MGMT_OBJECT_UNKNOWN = 0, /// The object is a volume to be shadow copied. VSS_MGMT_OBJECT_VOLUME, /// The object is a volume to hold a shadow copy storage area. VSS_MGMT_OBJECT_DIFF_VOLUME, /// The object is an association between a volume to be shadow copied and a volume to hold the shadow copy storage area. VSS_MGMT_OBJECT_DIFF_AREA, } /// /// Defines the set of shadow copy protection faults. A shadow copy protection fault occurs when the VSS service is unable to perform a /// copy-on-write operation to the shadow copy storage area (also called the diff area). /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/ne-vsmgmt-vss_protection_fault typedef enum _VSS_PROTECTION_FAULT { // VSS_PROTECTION_FAULT_NONE, VSS_PROTECTION_FAULT_DIFF_AREA_MISSING, VSS_PROTECTION_FAULT_IO_FAILURE_DURING_ONLINE, // VSS_PROTECTION_FAULT_META_DATA_CORRUPTION, VSS_PROTECTION_FAULT_MEMORY_ALLOCATION_FAILURE, // VSS_PROTECTION_FAULT_MAPPED_MEMORY_FAILURE, VSS_PROTECTION_FAULT_COW_READ_FAILURE, VSS_PROTECTION_FAULT_COW_WRITE_FAILURE, // VSS_PROTECTION_FAULT_DIFF_AREA_FULL, VSS_PROTECTION_FAULT_GROW_TOO_SLOW, VSS_PROTECTION_FAULT_GROW_FAILED, // VSS_PROTECTION_FAULT_DESTROY_ALL_SNAPSHOTS, VSS_PROTECTION_FAULT_FILE_SYSTEM_FAILURE, VSS_PROTECTION_FAULT_IO_FAILURE, // VSS_PROTECTION_FAULT_DIFF_AREA_REMOVED, VSS_PROTECTION_FAULT_EXTERNAL_WRITER_TO_DIFF_AREA, // VSS_PROTECTION_FAULT_MOUNT_DURING_CLUSTER_OFFLINE } VSS_PROTECTION_FAULT, *PVSS_PROTECTION_FAULT; [PInvokeData("vsmgmt.h", MSDNShortId = "NE:vsmgmt._VSS_PROTECTION_FAULT")] public enum VSS_PROTECTION_FAULT { /// No shadow copy protection fault has occurred. VSS_PROTECTION_FAULT_NONE = 0, /// /// The volume that contains the shadow copy storage area could not be found. Usually this fault means that the volume has not yet /// arrived in the system. /// VSS_PROTECTION_FAULT_DIFF_AREA_MISSING, /// The volume that contains the shadow copy storage area could not be brought online because an I/O failure occurred. VSS_PROTECTION_FAULT_IO_FAILURE_DURING_ONLINE, /// The shadow copy metadata for the shadow copy storage area has been corrupted. VSS_PROTECTION_FAULT_META_DATA_CORRUPTION, /// /// A memory allocation failure occurred. This could be caused by a temporary low-memory condition that does not happen again after /// you clear the fault and restart the shadow copy operation. /// VSS_PROTECTION_FAULT_MEMORY_ALLOCATION_FAILURE, /// /// A memory mapping failure occurred. This fault could mean that the page file is too small, or it could be caused by a low-memory condition. /// VSS_PROTECTION_FAULT_MAPPED_MEMORY_FAILURE, /// /// A read failure occurred during the copy-on-write operation when data was being copied from the live volume to the shadow copy /// storage area volume. /// VSS_PROTECTION_FAULT_COW_READ_FAILURE, /// /// A read or write failure occurred during the copy-on-write operation when data was being copied from the live volume to the /// shadow copy storage area volume. One possible reason is that the shadow copy storage area volume has been removed from the system. /// VSS_PROTECTION_FAULT_COW_WRITE_FAILURE, /// /// /// This failure means that either the shadow copy storage area is full or the shadow copy storage area volume is full. After /// clearing the protection fault, you can do one of the following: /// /// /// /// Delete unused shadow copy storage areas by calling the IVssDifferentialSoftwareSnapshotMgmt3::DeleteUnusedDiffAreas method. /// /// /// /// Increase the shadow copy storage area maximum size for the volume by calling the /// IVssDifferentialSoftwareSnapshotMgmt::ChangeDiffAreaMaximumSize method or the /// IVssDifferentialSoftwareSnapshotMgmt2::ChangeDiffAreaMaximumSizeEx method. /// /// /// /// VSS_PROTECTION_FAULT_DIFF_AREA_FULL, /// /// The size of the shadow copy storage area could not be increased because there was no longer enough space on the shadow copy /// storage area volume. /// VSS_PROTECTION_FAULT_GROW_TOO_SLOW, /// The size of the shadow copy storage area could not be increased. VSS_PROTECTION_FAULT_GROW_FAILED, /// An unexpected error occurred. VSS_PROTECTION_FAULT_DESTROY_ALL_SNAPSHOTS, /// /// Either the shadow copy storage area files could not be opened or the shadow copy storage area volume could not be mounted /// because of a file system operation failure. /// VSS_PROTECTION_FAULT_FILE_SYSTEM_FAILURE, /// A read or write failure occurred on the shadow copy storage area volume. VSS_PROTECTION_FAULT_IO_FAILURE, /// The shadow copy storage area volume was removed from the system or could not be accessed for some other reason. VSS_PROTECTION_FAULT_DIFF_AREA_REMOVED, /// Another application attempted to write to the shadow copy storage area. VSS_PROTECTION_FAULT_EXTERNAL_WRITER_TO_DIFF_AREA, /// VSS_PROTECTION_FAULT_MOUNT_DURING_CLUSTER_OFFLINE, } /// Defines the set of volume shadow copy protection levels. /// /// When a volume is in shadow copy protection mode, requesters must set shadow copy storage area (diff area) associations using the /// IVssDifferentialSoftwareSnapshotMgmt::AddDiffArea method. /// // https://docs.microsoft.com/en-us/windows/win32/api/VsMgmt/ne-vsmgmt-vss_protection_level typedef enum _VSS_PROTECTION_LEVEL { // VSS_PROTECTION_LEVEL_ORIGINAL_VOLUME, VSS_PROTECTION_LEVEL_SNAPSHOT } VSS_PROTECTION_LEVEL, *PVSS_PROTECTION_LEVEL; [PInvokeData("vsmgmt.h", MSDNShortId = "NE:vsmgmt._VSS_PROTECTION_LEVEL")] public enum VSS_PROTECTION_LEVEL { /// /// /// Specifies that I/O to the original volume must be maintained at the expense of shadow copies. This is the default protection /// level. Shadow copies might be deleted if both of the following conditions occur: /// /// /// /// A write to the original volume occurs. /// /// /// /// The integrity of the shadow copy cannot be maintained for some reason, such as a failure to write to the shadow copy storage /// area or a failure to allocate sufficient memory. /// /// /// /// VSS_PROTECTION_LEVEL_ORIGINAL_VOLUME = 0, /// /// /// Specifies that shadow copies must be maintained at the expense of I/O to the original volume. This protection level is called /// "shadow copy protection mode." All I/O to the original volume will fail if both of the following conditions occur: /// /// /// /// A write to the original volume occurs. /// /// /// /// The corresponding write to the shadow copy storage area cannot be completed for some reason, such as a failure to write to the /// shadow copy storage area or a failure to allocate sufficient memory. /// /// /// /// VSS_PROTECTION_LEVEL_SNAPSHOT, } /// /// The IVssDifferentialSoftwareSnapshotMgmt interface contains methods that allow applications to query and manage shadow copy /// storage areas generated by the system shadow copy provider. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nn-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt [PInvokeData("vsmgmt.h", MSDNShortId = "NN:vsmgmt.IVssDifferentialSoftwareSnapshotMgmt")] [ComImport, Guid("214A0F28-B737-4026-B847-4F9E37D79529"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssDifferentialSoftwareSnapshotMgmt { /// /// The AddDiffArea method adds a shadow copy storage area association for the specified volume. If the association is not /// supported, an error code will be returned. /// /// /// /// The name of the volume that will be the source of shadow copies. This volume is associated with a shadow copy storage area on /// the pwszDiffAreaVolumeName volume. /// /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The name of the volume that will contain the shadow copy storage area to be associated with the pwszVolumeName volume. /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// /// The maximum size, in bytes, of the shadow copy storage area on the volume. This value must be at least 320 MB, up to the /// system-wide limit. If this value is –1, the maximum size is unlimited. /// /// /// Windows Server 2003: Prior to Windows Server 2003 with SP1, the shadow copy storage area size was fixed at 100 MB. /// /// /// /// /// A shadow copy storage area association cannot be created if any shadow copies already exist for the pwszVolumeName volume or if /// there is already a shadow copy storage area association for that volume. /// /// /// The shadow copy storage area for a virtual hard disk (VHD) source volume must reside on the same volume. Likewise, a shadow copy /// storage area can only be created on a VHD volume if the source volume is the same for both volumes. /// /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: VHDs are not supported. /// /// To change the size of a shadow copy storage area, use the IVssDifferentialSoftwareSnapshotMgmt::ChangeDiffAreaMaximumSize or /// IVssDifferentialSoftwareSnapshotMgmt2::ChangeDiffAreaMaximumSizeEx method. You can delete a shadow copy storage area by changing /// its size to zero. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt-adddiffarea HRESULT // AddDiffArea( [in] VSS_PWSZ pwszVolumeName, [in] VSS_PWSZ pwszDiffAreaVolumeName, [in] LONGLONG llMaximumDiffSpace ); void AddDiffArea([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string pwszDiffAreaVolumeName, long llMaximumDiffSpace); /// /// The ChangeDiffAreaMaximumSize method updates the shadow copy storage area maximum size for a certain volume. This may not /// have an immediate effect. /// /// /// /// Name of the volume that is the source of shadow copies. This volume is associated with a shadow copy storage area on the /// pwszDiffAreaVolumeName volume. /// /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// Name of the volume that contains the shadow copy storage area associated with the pwszVolumeName volume. /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// Specifies the maximum size, in bytes, for the shadow copy storage area to use for the volume. If this value is zero, the shadow /// copy storage area will be deleted. If this value is –1, the maximum size is unlimited. /// /// /// /// The ChangeDiffAreaMaximumSize method makes the shadow copy storage area explicit, which means that it is not deleted /// automatically when all shadow copies are deleted. /// /// If the shadow copy storage area does not exist, this method creates it. /// /// Windows Server 2008, Windows Vista and Windows Server 2003: If the shadow copy storage area does not exist, this method /// does not create it. /// /// To create a shadow copy storage area, use the IVssDifferentialSoftwareSnapshotMgmt::AddDiffArea method. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt-changediffareamaximumsize // HRESULT ChangeDiffAreaMaximumSize( [in] VSS_PWSZ pwszVolumeName, [in] VSS_PWSZ pwszDiffAreaVolumeName, [in] LONGLONG // llMaximumDiffSpace ); void ChangeDiffAreaMaximumSize([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string pwszDiffAreaVolumeName, long llMaximumDiffSpace); /// /// The QueryVolumesSupportedForDiffAreas method queries volumes that support shadow copy storage areas (including volumes /// with disabled shadow copy storage areas). /// /// /// /// Name of the original volume that is the source of the shadow copies. The name of the volume must be in one of the following /// formats and must include a trailing backslash (\): /// /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The address of an IVssEnumMgmtObject interface pointer, which is initialized on return. Callers must release the interface. /// /// /// The returned IVssEnumMgmtObject enumerator object will contain VSS_DIFF_VOLUME_PROP structures inside the VSS_MGMT_OBJECT_UNION /// union inside the VSS_MGMT_OBJECT_PROP structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt-queryvolumessupportedfordiffareas // HRESULT QueryVolumesSupportedForDiffAreas( [in] VSS_PWSZ pwszOriginalVolumeName, [out] IVssEnumMgmtObject **ppEnum ); IVssEnumMgmtObject QueryVolumesSupportedForDiffAreas([MarshalAs(UnmanagedType.LPWStr)] string pwszOriginalVolumeName); /// The QueryDiffAreasForVolume method queries shadow copy storage areas in use by the volume. /// /// Name of the volume that contains shadow copy storage areas. /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The address of an IVssEnumMgmtObject interface pointer, which is initialized on return. Callers must release the interface. /// /// /// The returned IVssEnumMgmtObject enumerator object will contain VSS_DIFF_AREA_PROP structures inside the VSS_MGMT_OBJECT_UNION /// union inside the VSS_MGMT_OBJECT_PROP structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt-querydiffareasforvolume // HRESULT QueryDiffAreasForVolume( [in] VSS_PWSZ pwszVolumeName, [out] IVssEnumMgmtObject **ppEnum ); IVssEnumMgmtObject QueryDiffAreasForVolume([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName); /// The QueryDiffAreasOnVolume method queries shadow copy storage areas that physically reside on the given volume. /// /// Name of the volume that contains shadow copy storage areas. /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The address of an IVssEnumMgmtObject interface pointer, which is initialized on return. Callers must release the interface. /// /// /// The returned IVssEnumMgmtObject enumerator object will contain VSS_DIFF_AREA_PROP structures inside the VSS_MGMT_OBJECT_UNION /// union inside the VSS_MGMT_OBJECT_PROP structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt-querydiffareasonvolume // HRESULT QueryDiffAreasOnVolume( [in] VSS_PWSZ pwszVolumeName, [out] IVssEnumMgmtObject **ppEnum ); IVssEnumMgmtObject QueryDiffAreasOnVolume([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName); /// /// The QueryDiffAreasForSnapshot method queries shadow copy storage areas in use by the original volume associated with the /// input shadow copy. /// /// The VSS_ID of a shadow copy. /// /// The address of an IVssEnumMgmtObject interface pointer, which is initialized on return. Callers must release the interface. /// /// /// The returned IVssEnumMgmtObject enumerator object will contain VSS_DIFF_AREA_PROP structures inside the VSS_MGMT_OBJECT_UNION /// union inside the VSS_MGMT_OBJECT_PROP structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt-querydiffareasforsnapshot // HRESULT QueryDiffAreasForSnapshot( [in] VSS_ID SnapshotId, [out] IVssEnumMgmtObject **ppEnum ); IVssEnumMgmtObject QueryDiffAreasForSnapshot(Guid SnapshotId); } /// /// /// Defines additional methods that allow applications to query and manage shadow copy storage areas generated by the system shadow copy provider. /// /// /// To obtain an instance of the IVssDifferentialSoftwareSnapshotMgmt2 interface, call the QueryInterface method of the /// IVssDifferentialSoftwareSnapshotMgmt interface, and pass the IID_IVssDifferentialSoftwareSnapshotMgmt2 constant as the /// interface identifier (IID) parameter. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nn-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt2 [PInvokeData("vsmgmt.h", MSDNShortId = "NN:vsmgmt.IVssDifferentialSoftwareSnapshotMgmt2")] [ComImport, Guid("949d7353-675f-4275-8969-f044c6277815"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssDifferentialSoftwareSnapshotMgmt2 : IVssDifferentialSoftwareSnapshotMgmt { /// /// Updates the shadow copy storage area maximum size for a certain volume. This may not have an immediate effect. If the bVolatile /// parameter is FALSE, the change continues even if the computer is rebooted. /// /// /// /// The name of the volume that is the source of shadow copies. This volume is associated with a shadow copy storage area on the /// pwszDiffAreaVolumeName volume. /// /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The name of the volume that contains the shadow copy storage area that is associated with the pwszVolumeName volume. /// The name of the volume must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder /// /// /// A drive letter with, for example, D:\ /// /// /// A volume GUID path of the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// Specifies the maximum size, in bytes, for the shadow copy storage area to use for the volume. If this value is zero, the shadow /// copy storage area will be deleted. If this value is –1, the maximum size is unlimited. /// /// /// /// TRUE to indicate that the effect of calling the ChangeDiffAreaMaximumSizeEx method should not continue if the computer is /// rebooted; otherwise, FALSE. /// /// The default value is FALSE. /// If the llMaximumDiffSpace parameter is zero, the bVolatile parameter must be FALSE. /// /// /// /// The ChangeDiffAreaMaximumSizeEx method is identical to the /// IVssDifferentialSoftwareSnapshotMgmt::ChangeDiffAreaMaximumSize method except for the bVolatile parameter. /// /// /// Calling the ChangeDiffAreaMaximumSizeEx method with the bVolatile parameter set to FALSE is the same as calling /// the ChangeDiffAreaMaximumSize method. /// /// /// ChangeDiffAreaMaximumSizeEx makes the shadow copy storage area explicit, which means that it is not deleted automatically /// when all shadow copies are deleted. /// /// If the shadow copy storage area does not exist, this method creates it. /// /// Windows Server 2008, Windows Vista and Windows Server 2003: If the shadow copy storage area does not exist, this method /// does not create it. /// /// To create a shadow copy storage area, use the IVssDifferentialSoftwareSnapshotMgmt::AddDiffArea method. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt2-changediffareamaximumsizeex // HRESULT ChangeDiffAreaMaximumSizeEx( [in] VSS_PWSZ pwszVolumeName, [in] VSS_PWSZ pwszDiffAreaVolumeName, [in] LONGLONG // llMaximumDiffSpace, [in] BOOL bVolatile ); void ChangeDiffAreaMaximumSizeEx([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string pwszDiffAreaVolumeName, long llMaximumDiffSpace, [MarshalAs(UnmanagedType.Bool)] bool bVolatile); /// /// Not supported. /// This method is reserved for future use. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt2-migratediffareas // HRESULT MigrateDiffAreas( [in] VSS_PWSZ pwszVolumeName, [in] VSS_PWSZ pwszDiffAreaVolumeName, [in] VSS_PWSZ // pwszNewDiffAreaVolumeName ); void MigrateDiffAreas([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string pwszDiffAreaVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string pwszNewDiffAreaVolumeName); /// /// Not supported. /// This method is reserved for future use. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt2-querymigrationstatus // HRESULT QueryMigrationStatus( [in] VSS_PWSZ pwszVolumeName, [in] VSS_PWSZ pwszDiffAreaVolumeName, [out] IVssAsync **ppAsync ); IVssAsync QueryMigrationStatus([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string pwszDiffAreaVolumeName); /// /// Not supported. /// This method is reserved for future use. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt2-setsnapshotpriority // HRESULT SetSnapshotPriority( [in] VSS_ID idSnapshot, [in] BYTE priority ); void SetSnapshotPriority(Guid idSnapshot, byte priority); } /// /// Defines methods that allow applications to use the shadow copy protection feature of VSS. /// /// To obtain an instance of the IVssDifferentialSoftwareSnapshotMgmt3 interface, call the QueryInterface method of the /// IVssDifferentialSoftwareSnapshotMgmt interface and pass the IID_IVssDifferentialSoftwareSnapshotMgmt3 constant as the /// interface identifier (IID) parameter. /// /// /// /// /// An application with administrator privilege can use the SetVolumeProtectLevel method to specify a shadow copy protection level for a /// volume and the separate volume that contains its shadow copy storage area. The same protection level should be set for both volumes. /// The possible protection levels are defined by the VSS_PROTECTION_LEVEL enumeration. /// /// /// When a volume protection fault occurs, the application must call the GetVolumeProtectLevel method for the volume to identify the /// cause of the fault. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nn-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt3 [PInvokeData("vsmgmt.h", MSDNShortId = "NN:vsmgmt.IVssDifferentialSoftwareSnapshotMgmt3")] [ComImport, Guid("383f7e71-a4c5-401f-b27f-f826289f8458"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssDifferentialSoftwareSnapshotMgmt3 : IVssDifferentialSoftwareSnapshotMgmt2 { /// Sets the shadow copy protection level for an original volume or a shadow copy storage area volume. /// /// The name of the volume. This parameter is required and cannot be NULL. /// The name must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path in the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// A value from the VSS_PROTECTION_LEVEL enumeration that specifies the shadow copy protection level. /// /// /// The SetVolumeProtectLevel method checks the current shadow copy protection level of the volume. If the volume is in a /// faulted state and VSS_PROTECTION_LEVEL_ORIGINAL_VOLUME is specified for the protectionLevel parameter, /// SetVolumeProtectLevel dismounts the volume before setting the protection level. /// /// /// If the current protection level of the volume is the same as the value of the protectionLevel parameter, /// SetVolumeProtectLevel does nothing. /// /// /// If the value of the protectionLevel parameter is VSS_PROTECTION_LEVEL_SNAPSHOT, requesters must set shadow copy storage /// area (diff area) associations using the IVssDifferentialSoftwareSnapshotMgmt::AddDiffArea method. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt3-setvolumeprotectlevel // HRESULT SetVolumeProtectLevel( [in] VSS_PWSZ pwszVolumeName, [in] VSS_PROTECTION_LEVEL protectionLevel ); void SetVolumeProtectLevel([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, VSS_PROTECTION_LEVEL protectionLevel); /// Gets the shadow copy protection level and status for the specified volume. /// /// The name of the volume. This parameter is required and cannot be NULL. /// The name must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path in the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The address of a caller-allocated buffer that receives a VSS_VOLUME_PROTECTION_INFO structure containing information about the /// volume's shadow copy protection level. /// /// /// /// The GetVolumeProtectLevel method gets information about the volume's current protection level. If the volume is in a /// faulted state, the m_protectionFault member of the VSS_VOLUME_PROTECTION_INFO structure contains the current protection /// fault, and the m_failureStatus member contains the reason why the volume is in a faulted state. If the volume is not in a /// faulted state, the m_protectionFault and m_failureStatus members will be zero. /// /// /// If the value of the protectionLevel parameter is VSS_PROTECTION_LEVEL_SNAPSHOT, requesters must set shadow copy storage /// area (diff area) associations using the IVssDifferentialSoftwareSnapshotMgmt::AddDiffArea method. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt3-getvolumeprotectlevel // HRESULT GetVolumeProtectLevel( [in] VSS_PWSZ pwszVolumeName, [out] VSS_VOLUME_PROTECTION_INFO *protectionLevel ); VSS_VOLUME_PROTECTION_INFO GetVolumeProtectLevel([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName); /// Clears the protection fault state for the specified volume. /// /// The name of the volume. This parameter is required and cannot be NULL. /// The name must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path in the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// The ClearVolumeProtectFault method dismounts the volume and resets the volume's protection fault member to FALSE /// to allow normal I/O to continue on the volume. If the volume is not in a faulted state, this method does nothing. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt3-clearvolumeprotectfault // HRESULT ClearVolumeProtectFault( [in] VSS_PWSZ pwszVolumeName ); void ClearVolumeProtectFault([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName); /// Deletes all shadow copy storage areas (also called diff areas) on the specified volume that are not in use. /// /// The name of the volume. This parameter is required and cannot be NULL. /// The name must be in one of the following formats and must include a trailing backslash (\): /// /// /// The path of a mounted folder, for example, Y:\MountX\ /// /// /// A drive letter, for example, D:\ /// /// /// A volume GUID path in the form \\?\Volume{GUID}\ (where GUID identifies the volume) /// /// /// /// /// Unused shadow copy storage area files are found on storage area volumes when the associated original volume is offline due to a /// protection fault. In certain cases, the original volume may be permanently lost, and calling the DeleteUnusedDiffAreas /// method is the only way to recover the abandoned storage area space. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt3-deleteunuseddiffareas // HRESULT DeleteUnusedDiffAreas( [in] VSS_PWSZ pwszDiffAreaVolumeName ); void DeleteUnusedDiffAreas([MarshalAs(UnmanagedType.LPWStr)] string pwszDiffAreaVolumeName); /// /// Not supported. /// This method is reserved for future use. /// /// /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssdifferentialsoftwaresnapshotmgmt3-querysnapshotdeltabitmap // HRESULT QuerySnapshotDeltaBitmap( [in] VSS_ID idSnapshotOlder, [in] VSS_ID idSnapshotYounger, [out] ULONG *pcBlockSizePerBit, // [out] ULONG *pcBitmapLength, [out] BYTE **ppbBitmap ); void QuerySnapshotDeltaBitmap(Guid idSnapshotOlder, Guid idSnapshotYounger, out uint pcBlockSizePerBit, out uint pcBitmapLength, out IntPtr ppbBitmap); } /// /// /// The IVssEnumMgmtObject interface contains methods to iterate over and perform other operations on a list of enumerated objects. /// /// /// The IVssDifferentialSoftwareSnapshotMgmt::QueryDiffAreasForSnapshot, IVssDifferentialSoftwareSnapshotMgmt::QueryDiffAreasForVolume, /// IVssDifferentialSoftwareSnapshotMgmt::QueryDiffAreasOnVolume, and /// IVssDifferentialSoftwareSnapshotMgmt::QueryVolumesSupportedForDiffAreas methods return an IVssEnumMgmtObject object. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nn-vsmgmt-ivssenummgmtobject [PInvokeData("vsmgmt.h", MSDNShortId = "NN:vsmgmt.IVssEnumMgmtObject")] [ComImport, Guid("01954E6B-9254-4e6e-808C-C9E05D007696"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssEnumMgmtObject : ICOMEnum { /// The Next method returns the specified number of objects from the specified list of enumerated objects. /// The number of elements to be read from the list of enumerated objects into the rgelt buffer. /// /// The address of a caller-allocated buffer that receives celt VSS_MGMT_OBJECT_PROP structures that contain the returned objects. /// This parameter is required and cannot be NULL. /// /// The number of elements that were returned in the rgelt buffer. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssenummgmtobject-next HRESULT Next( [in] ULONG celt, [out] // VSS_MGMT_OBJECT_PROP *rgelt, [out] ULONG *pceltFetched ); [PreserveSig] HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] VSS_MGMT_OBJECT_PROP[] rgelt, out uint pceltFetched); /// The Skip method skips the specified number of objects. /// Number of elements to be skipped in the list of enumerated objects. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssenummgmtobject-skip HRESULT Skip( [in] ULONG celt ); [PreserveSig] HRESULT Skip(uint celt); /// The Reset method resets the enumerator so that IVssEnumMgmtObject starts at the first enumerated object. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssenummgmtobject-reset HRESULT Reset(); void Reset(); /// /// The Clone method creates a copy of the specified list of enumerated elements by creating a copy of the IVssEnumMgmtObject /// enumerator object. /// /// /// Address of an IVssEnumMgmtObject interface pointer. Set the value of this parameter to NULL before calling this method. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivssenummgmtobject-clone HRESULT Clone( [in, out] // IVssEnumMgmtObject **ppenum ); IVssEnumMgmtObject Clone(); } /// /// The IVssSnapshotMgmt interface provides a method that returns an interface to further configure a shadow copy provider. /// /// /// /// The IVssSnapshotMgmt interface can be invoked remotely using DCOM. The caller must be a member of the local administrators /// group on the remote machine. /// /// Examples /// /// ///GetProviderMgmtInterface(ProviderId, IID_IVssDifferentialSoftwareSnapshotMgmt, (IUnknown**)&pDiffMgmt); /// if (FAILED(hr)) /// { /// pMgmt->Release(); /// } /// /// // processing code /// pDiffMgmt->Release(); /// pMgmt->Release(); ///}]]> /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nn-vsmgmt-ivsssnapshotmgmt [PInvokeData("vsmgmt.h", MSDNShortId = "NN:vsmgmt.IVssSnapshotMgmt")] [ComImport, Guid("FA7DF749-66E7-4986-A27F-E2F04AE53772"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(VssSnapshotMgmt))] public interface IVssSnapshotMgmt { /// The GetProviderMgmtInterface method returns an interface to further configure the system provider. /// /// This must be the system provider. The VSS_ID for the system provider /// {b5946137-7b9f-4925-af80-51abd60b20d5} /// . /// /// /// Must be IID_IVssDifferentialSoftwareSnapshotMgmt, which represents the IVssDifferentialSoftwareSnapshotMgmt interface. /// /// Address of an interface pointer that is filled in with the returned interface pointer. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivsssnapshotmgmt-getprovidermgmtinterface HRESULT // GetProviderMgmtInterface( [in] VSS_ID ProviderId, [in] REFIID InterfaceId, [out] IUnknown **ppItf ); [return: MarshalAs(UnmanagedType.IUnknown)] object GetProviderMgmtInterface(Guid ProviderId, in Guid InterfaceId); /// /// Not supported. /// The QueryVolumesSupportedForSnapshots method is reserved for system use. /// /// Reserved for system use. Do not use. /// Reserved for system use. Do not use. /// Reserved for system use. Do not use. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivsssnapshotmgmt-queryvolumessupportedforsnapshots HRESULT // QueryVolumesSupportedForSnapshots( [in] VSS_ID ProviderId, [in] LONG lContext, [out] IVssEnumMgmtObject **ppEnum ); IVssEnumMgmtObject QueryVolumesSupportedForSnapshots(Guid ProviderId, int lContext); /// /// Not supported. /// The QuerySnapshotsByVolume method is reserved for system use. /// /// Reserved for system use. Do not use. /// Reserved for system use. Do not use. /// Reserved for system use. Do not use. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivsssnapshotmgmt-querysnapshotsbyvolume HRESULT // QuerySnapshotsByVolume( [in] VSS_PWSZ pwszVolumeName, [in] VSS_ID ProviderId, [out] IVssEnumObject **ppEnum ); IVssEnumObject QuerySnapshotsByVolume([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, Guid ProviderId); } /// The IVssSnapshotMgmt2 interface provides a method to retrieve the minimum size of the shadow copy storage area. /// /// To obtain an instance of the IVssSnapshotMgmt2 interface, call the QueryInterface method of the IVssSnapshotMgmt interface, /// passing IID_IVssSnapshotMgmt2 as the riid parameter. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nn-vsmgmt-ivsssnapshotmgmt2 [PInvokeData("vsmgmt.h", MSDNShortId = "NN:vsmgmt.IVssSnapshotMgmt2")] [ComImport, Guid("0f61ec39-fe82-45f2-a3f0-768b5d427102"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(VssSnapshotMgmt))] public interface IVssSnapshotMgmt2 { /// Returns the current minimum size of the shadow copy storage area. /// A pointer to a variable that receives the minimum size, in bytes, of the shadow copy storage area. /// /// The shadow copy storage area minimum size is a per-computer setting that is specified by the MinDiffAreaFileSize registry /// key. For more information, see the entry for MinDiffAreaFileSize in Registry Keys and Values for Backup and Restore. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/nf-vsmgmt-ivsssnapshotmgmt2-getmindiffareasize HRESULT // GetMinDiffAreaSize( [out] LONGLONG *pllMinDiffAreaSize ); long GetMinDiffAreaSize(); } /// /// The VSS_DIFF_AREA_PROP structure describes associations between volumes containing the original file data and volumes /// containing the shadow copy storage area (also known as the diff area). /// /// /// The m_llMaximumDiffSpace member is passed as a parameter to the IVssDifferentialSoftwareSnapshotMgmt::AddDiffArea, /// IVssDifferentialSoftwareSnapshotMgmt::ChangeDiffAreaMaximumSize, and /// IVssDifferentialSoftwareSnapshotMgmt2::ChangeDiffAreaMaximumSizeEx methods. /// // https://docs.microsoft.com/en-us/windows/win32/api/VsMgmt/ns-vsmgmt-vss_diff_area_prop typedef struct _VSS_DIFF_AREA_PROP { VSS_PWSZ // m_pwszVolumeName; VSS_PWSZ m_pwszDiffAreaVolumeName; LONGLONG m_llMaximumDiffSpace; LONGLONG m_llAllocatedDiffSpace; LONGLONG // m_llUsedDiffSpace; } VSS_DIFF_AREA_PROP, *PVSS_DIFF_AREA_PROP; [PInvokeData("vsmgmt.h", MSDNShortId = "NS:vsmgmt._VSS_DIFF_AREA_PROP")] [StructLayout(LayoutKind.Sequential)] public struct VSS_DIFF_AREA_PROP { /// The original volume name. [MarshalAs(UnmanagedType.LPWStr)] public string m_pwszVolumeName; /// The shadow copy storage area volume name. [MarshalAs(UnmanagedType.LPWStr)] public string m_pwszDiffAreaVolumeName; /// Maximum space used on the shadow copy storage area volume for this association. public long m_llMaximumDiffSpace; /// Allocated space on the shadow copy storage area volume by this association. This must be less than or equal to m_llMaximumDiffSpace. public long m_llAllocatedDiffSpace; /// Used space from the allocated area above. This must be less than or equal to m_llAllocatedDiffSpace. public long m_llUsedDiffSpace; } /// The VSS_DIFF_VOLUME_PROP structure describes a shadow copy storage area volume. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/ns-vsmgmt-vss_diff_volume_prop typedef struct _VSS_DIFF_VOLUME_PROP { // VSS_PWSZ m_pwszVolumeName; VSS_PWSZ m_pwszVolumeDisplayName; LONGLONG m_llVolumeFreeSpace; LONGLONG m_llVolumeTotalSpace; } // VSS_DIFF_VOLUME_PROP, *PVSS_DIFF_VOLUME_PROP; [PInvokeData("vsmgmt.h", MSDNShortId = "NS:vsmgmt._VSS_DIFF_VOLUME_PROP")] [StructLayout(LayoutKind.Sequential)] public struct VSS_DIFF_VOLUME_PROP { /// The shadow copy storage area volume name, in \\?\ Volume { GUID }\ format. [MarshalAs(UnmanagedType.LPWStr)] public string m_pwszVolumeName; /// /// Points to a null-terminated Unicode string that can be displayed to a user, for example C :\, for the shadow copy storage /// area volume. /// [MarshalAs(UnmanagedType.LPWStr)] public string m_pwszVolumeDisplayName; /// Free space, in bytes, on the shadow copy storage area volume. public long m_llVolumeFreeSpace; /// Total space, in bytes, on the shadow copy storage area volume. public long m_llVolumeTotalSpace; } /// /// The VSS_MGMT_OBJECT_PROP structure defines the properties of a volume, shadow copy storage volume, or a shadow copy storage area. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/ns-vsmgmt-vss_mgmt_object_prop typedef struct _VSS_MGMT_OBJECT_PROP { // VSS_MGMT_OBJECT_TYPE Type; VSS_MGMT_OBJECT_UNION Obj; } VSS_MGMT_OBJECT_PROP, *PVSS_MGMT_OBJECT_PROP; [PInvokeData("vsmgmt.h", MSDNShortId = "NS:vsmgmt._VSS_MGMT_OBJECT_PROP")] [StructLayout(LayoutKind.Sequential)] public class VSS_MGMT_OBJECT_PROP : IDisposable { /// Object type. For more information, see VSS_MGMT_OBJECT_TYPE. public VSS_MGMT_OBJECT_TYPE Type; /// /// /// Management object properties: a union of VSS_VOLUME_PROP, VSS_DIFF_VOLUME_PROP, and VSS_DIFF_AREA_PROP structures. (For more /// information, see VSS_MGMT_OBJECT_UNION.) /// /// /// It contains information for an object of the type specified by the Type member. Management objects can be volumes, shadow /// copy storage volumes, or shadow copy storage areas. /// /// public VSS_MGMT_OBJECT_UNION Obj; /// Frees the allocated memory for the strings in this structure. public void Dispose() { Marshal.FreeCoTaskMem((IntPtr)Obj.szOne); Marshal.FreeCoTaskMem((IntPtr)Obj.szTwo); Obj.szOne = Obj.szTwo = IntPtr.Zero; } } /// /// The VSS_MGMT_OBJECT_UNION specifies the union of object types that can be defined by the VSS_MGMT_OBJECT_PROP structure (section 2.2.3.6). /// [PInvokeData("vsmgmt.h", MSDNShortId = "NS:vsmgmt._VSS_MGMT_OBJECT_PROP")] [StructLayout(LayoutKind.Sequential)] public struct VSS_MGMT_OBJECT_UNION { internal InteropServices.StrPtrUni szOne; internal InteropServices.StrPtrUni szTwo; internal long lOne; internal long lTwo; internal long lThree; /// The structure specifies an original volume object as a VSS_VOLUME_PROP structure (section 2.2.3.7). public VSS_VOLUME_PROP Vol => new() { m_pwszVolumeName = szOne, m_pwszVolumeDisplayName = szTwo }; /// The structure specifies a shadow copy storage volume as a VSS_DIFF_VOLUME_PROP structure. public VSS_DIFF_VOLUME_PROP DiffVol => new() { m_pwszVolumeName = szOne, m_pwszVolumeDisplayName = szTwo, m_llVolumeFreeSpace = lOne, m_llVolumeTotalSpace = lTwo }; /// The structure specifies a shadow copy storage object as a VSS_DIFF_AREA_PROP. public VSS_DIFF_AREA_PROP DiffArea => new() { m_pwszVolumeName = szOne, m_pwszDiffAreaVolumeName = szTwo, m_llMaximumDiffSpace = lOne, m_llAllocatedDiffSpace = lTwo, m_llUsedDiffSpace = lThree }; } /// The VSS_VOLUME_PROP structure contains the properties of a shadow copy source volume. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/ns-vsmgmt-vss_volume_prop typedef struct _VSS_VOLUME_PROP { VSS_PWSZ // m_pwszVolumeName; VSS_PWSZ m_pwszVolumeDisplayName; } VSS_VOLUME_PROP, *PVSS_VOLUME_PROP; [PInvokeData("vsmgmt.h", MSDNShortId = "NS:vsmgmt._VSS_VOLUME_PROP")] [StructLayout(LayoutKind.Sequential)] public struct VSS_VOLUME_PROP { /// The volume name, in \?\Volume{GUID}\ format. [MarshalAs(UnmanagedType.LPWStr)] public string m_pwszVolumeName; /// /// A pointer to a null-terminated Unicode string that contains the shortest mount point that can be displayed to the user. The /// mount point can be a drive letter, for example, C:, or a mounted folder, for example, C:\WriterData\Archive. /// [MarshalAs(UnmanagedType.LPWStr)] public string m_pwszVolumeDisplayName; } /// Contains information about a volume's shadow copy protection level. // https://docs.microsoft.com/en-us/windows/win32/api/vsmgmt/ns-vsmgmt-vss_volume_protection_info typedef struct // _VSS_VOLUME_PROTECTION_INFO { VSS_PROTECTION_LEVEL m_protectionLevel; BOOL m_volumeIsOfflineForProtection; VSS_PROTECTION_FAULT // m_protectionFault; LONG m_failureStatus; BOOL m_volumeHasUnusedDiffArea; DWORD m_reserved; } VSS_VOLUME_PROTECTION_INFO, *PVSS_VOLUME_PROTECTION_INFO; [PInvokeData("vsmgmt.h", MSDNShortId = "NS:vsmgmt._VSS_VOLUME_PROTECTION_INFO")] [StructLayout(LayoutKind.Sequential)] public struct VSS_VOLUME_PROTECTION_INFO { /// A value from the VSS_PROTECTION_LEVEL enumeration that specifies the target protection level for the volume. public VSS_PROTECTION_LEVEL m_protectionLevel; /// TRUE if the volume is offline due to a protection fault, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool m_volumeIsOfflineForProtection; /// /// A value from the VSS_PROTECTION_FAULT enumeration that describes the shadow copy protection fault that caused the volume to go offline. /// public VSS_PROTECTION_FAULT m_protectionFault; /// The internal failure status code. public int m_failureStatus; /// TRUE if the volume has unused shadow copy storage area files, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool m_volumeHasUnusedDiffArea; /// Reserved for system use. public uint m_reserved; } /// VSS extension methods. public static partial class Extensions { /// Enumerates the instances provided by an . /// The instance. /// A sequence of structures. public static IEnumerable Enumerate(this IVssEnumMgmtObject emo) => new IEnumFromCom(emo.Next, emo.Reset, () => new VSS_MGMT_OBJECT_PROP()); /// The GetProviderMgmtInterface method returns an interface to further configure the system provider. /// The instance. /// /// This must be the system provider. The VSS_ID for the system provider /// {b5946137-7b9f-4925-af80-51abd60b20d5} /// . /// /// A IVssDifferentialSoftwareSnapshotMgmt interface instance. public static IVssDifferentialSoftwareSnapshotMgmt GetProviderMgmtInterface(this IVssSnapshotMgmt sm, Guid ProviderId) => sm.GetProviderMgmtInterface(ProviderId); /// The GetProviderMgmtInterface method returns an interface to further configure the system provider. /// /// Must be IID_IVssDifferentialSoftwareSnapshotMgmt, which represents the IVssDifferentialSoftwareSnapshotMgmt interface. /// /// The instance. /// /// This must be the system provider. The VSS_ID for the system provider {b5946137-7b9f-4925-af80-51abd60b20d5} . /// /// An interface pointer that is filled in with the returned interface pointer. public static T GetProviderMgmtInterface(this IVssSnapshotMgmt sm, Guid ProviderId) where T : class => (T)sm.GetProviderMgmtInterface(ProviderId, typeof(T).GUID); } /// CLSID_VssSnapshotMgmt [ComImport, Guid("0B5A2C52-3EB9-470a-96E2-6C6D4570E40F"), ClassInterface(ClassInterfaceType.None)] public class VssSnapshotMgmt { } }