using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke.VssApi { /// Contains the methods used by VSS to manage shadow copy volumes. // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nn-vsprov-ivssfilesharesnapshotprovider [PInvokeData("vsprov.h", MSDNShortId = "NN:vsprov.IVssFileShareSnapshotProvider")] [ComImport, Guid("c8636060-7c2e-11df-8c4a-0800200c9a66"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssFileShareSnapshotProvider { /// Sets the context for the subsequent shadow copy-related operations. /// /// The context to be set. The context must be one of the supported values of _VSS_SNAPSHOT_CONTEXT or a supported combination of /// _VSS_VOLUME_SNAPSHOT_ATTRIBUTES and _VSS_SNAPSHOT_CONTEXT values. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The context was set successfully. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_BAD_STATE /// The context is frozen and cannot be changed. /// /// /// /// /// The default context for VSS shadow copies is VSS_CTX_BACKUP. /// /// Windows XP: The only supported context is the default context, VSS_CTX_BACKUP. Therefore, calling SetContext under /// Windows XP returns E_NOTIMPL. /// /// /// For more information about how the context that is set by SetContext affects how a shadow copy is created and managed, see /// Implementation Details for Creating Shadow Copies. /// /// For a complete discussion of the permitted shadow copy contexts, see _VSS_SNAPSHOT_CONTEXT and _VSS_VOLUME_SNAPSHOT_ATTRIBUTES. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-setcontext HRESULT SetContext( // [in] LONG lContext ); [PreserveSig] HRESULT SetContext(VSS_SNAPSHOT_CONTEXT lContext); /// Gets the VSS_SNAPSHOT_PROP structure for a file share snapshot. /// Shadow copy identifier. /// /// The address of a caller-allocated VSS_SNAPSHOT_PROP structure that receives the shadow copy properties. The provider is /// responsible for setting the members of this structure. All members are required except m_pwszExposedName and /// m_pwszExposedPath, which the provider can set to NULL. The provider allocates memory for all string members that /// it sets in the structure. When the structure is no longer needed, the caller is responsible for freeing these strings by calling /// the VssFreeSnapshotProperties function. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The requested information was successfully returned. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// /// /// /// /// /// /// The caller should set the contents of the VSS_SNAPSHOT_PROP structure to zero before calling the GetSnapshotProperties method. /// /// The provider is responsible for allocating and freeing the strings in the VSS_SNAPSHOT_PROP structure. /// /// The VSS coordinator calls this method during the PostSnapshot phase of snapshot creation in order to retrieve the snapshot /// access path (UNC path for file share snapshots). The coordinator calls this method after PreFinalCommitSnapshots and before it /// invokes PostSnapshot in the writers. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-getsnapshotproperties HRESULT // GetSnapshotProperties( [in] VSS_ID SnapshotId, [out] VSS_SNAPSHOT_PROP *pProp ); [PreserveSig] HRESULT GetSnapshotProperties(Guid SnapshotId, out VSS_SNAPSHOT_PROP pProp); /// /// Gets an enumeration of VSS_SNAPSHOT_PROP structures for all file share snapshots that are available to the application server. /// /// Reserved for system use. The value of this parameter must be GUID_NULL. /// Reserved for system use. The value of this parameter must be VSS_OBJECT_NONE. /// Reserved for system use. The value of this parameter must be VSS_OBJECT_SNAPSHOT. /// /// The address of an IVssEnumObject interface pointer, which is initialized on return. Callers must release the interface. This /// parameter is required and cannot be null. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The query operation was successful. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// /// /// This method is typically called in response to requester generated snapshot query operations. /// /// Calling the IVssEnumObject::Next method on the IVssEnumObject interface that is returned though the ppEnum parameter will /// return VSS_OBJECT_PROP structures containing a VSS_SNAPSHOT_PROP structure for each shadow copy. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-query HRESULT Query( [in] // VSS_ID QueriedObjectId, [in] VSS_OBJECT_TYPE eQueriedObjectType, [in] VSS_OBJECT_TYPE eReturnedObjectsType, [out] IVssEnumObject // **ppEnum ); [PreserveSig] HRESULT Query(Guid QueriedObjectId, VSS_OBJECT_TYPE eQueriedObjectType, VSS_OBJECT_TYPE eReturnedObjectsType, out IVssEnumObject ppEnum); /// Deletes specific snapshots, or all snapshots in a specified snapshot set. /// Identifier of the shadow copy or shadow copy set to be deleted. /// Type of the object to be deleted. The value of this parameter is VSS_OBJECT_SNAPSHOT or VSS_OBJECT_SNAPSHOT_SET. /// /// If the value of this parameter is TRUE, the provider will do everything possible to delete the shadow copy or shadow /// copies in a shadow copy set. If it is FALSE, no additional effort will be made. /// /// Pointer to a variable that receives the number of shadow copies that were deleted. /// /// If an error occurs, this parameter receives a pointer to the identifier of the first shadow copy that could not be deleted. /// Otherwise, it points to GUID_NULL. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The shadow copies were successfully deleted. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified shadow copies were not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// /// /// The VSS coordinator calls this method as part of the snapshot auto-release process. The method is also called in response to /// requester driven delete operations. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-deletesnapshots HRESULT // DeleteSnapshots( [in] VSS_ID SourceObjectId, [in] VSS_OBJECT_TYPE eSourceObjectType, [in] BOOL bForceDelete, [out] LONG // *plDeletedSnapshots, [out] VSS_ID *pNondeletedSnapshotID ); [PreserveSig] HRESULT DeleteSnapshots(Guid SourceObjectId, VSS_OBJECT_TYPE eSourceObjectType, [MarshalAs(UnmanagedType.Bool)] bool bForceDelete, out int plDeletedSnapshots, out Guid pNondeletedSnapshotID); /// VSS calls this method for each shadow copy that is added to the shadow copy set. /// Shadow copy set identifier. /// Identifier of the shadow copy to be created. /// The file share path. /// /// The context for the shadow copy set. This context consists of a bitmask of _VSS_VOLUME_SNAPSHOT_ATTRIBUTES values. /// /// The provider ID. /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The shadow copy was successfully created. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNSUPPORTED_CONTEXT /// The specified context is not supported. /// /// /// VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER /// The provider does not support the specified volume. /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-beginpreparesnapshot HRESULT // BeginPrepareSnapshot( [in] VSS_ID SnapshotSetId, [in] VSS_ID SnapshotId, [in] VSS_PWSZ pwszSharePath, [in] LONG lNewContext, [in] // VSS_ID ProviderId ); [PreserveSig] HRESULT BeginPrepareSnapshot(Guid SnapshotSetId, Guid SnapshotId, [MarshalAs(UnmanagedType.LPWStr)] string pwszSharePath, VSS_VOLUME_SNAPSHOT_ATTRIBUTES lNewContext, Guid ProviderId); /// Determines whether the given Universal Naming Convention (UNC) path is supported by this provider. /// The path to the file share. /// /// This parameter receives TRUE if shadow copies are supported on the specified volume, otherwise FALSE. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The requested information was successfully returned. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// VSS_E_NESTED_VOLUME_LIMIT /// /// The specified volume is nested too deeply to participate in the VSS operation. Windows Server 2008, Windows Vista, Windows /// Server 2003 and Windows XP: This return code is not supported. /// /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// /// /// The VSS coordinator calls this method as part of AddToSnapshotSet to determine which provider to use for snapshot creation. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-ispathsupported HRESULT // IsPathSupported( [in] VSS_PWSZ pwszSharePath, [out] BOOL *pbSupportedByThisProvider ); [PreserveSig] HRESULT IsPathSupported([MarshalAs(UnmanagedType.LPWStr)] string pwszSharePath, [MarshalAs(UnmanagedType.Bool)] out bool pbSupportedByThisProvider); /// Determines whether the given Universal Naming Convention (UNC) path currently has any snapshots. /// The path to the file share. /// /// This parameter receives TRUE if the volume has a shadow copy, or FALSE if the volume does not have a shadow copy. /// /// /// A bitmask of VSS_SNAPSHOT_COMPATIBILITY values that indicate whether certain volume control or file I/O operations are disabled /// for the given volume, if the volume has a shadow copy. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The requested information was successfully returned. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-ispathsnapshotted HRESULT // IsPathSnapshotted( [in] VSS_PWSZ pwszSharePath, [out] BOOL *pbSnapshotsPresent, [out] LONG *plSnapshotCompatibility ); [PreserveSig] HRESULT IsPathSnapshotted([MarshalAs(UnmanagedType.LPWStr)] string pwszSharePath, [MarshalAs(UnmanagedType.Bool)] out bool pbSnapshotsPresent, out VSS_SNAPSHOT_COMPATIBILITY plSnapshotCompatibility); /// Requests the provider to set a property value for the specified snapshot. /// Shadow copy identifier. This parameter is required and cannot be GUID_NULL. /// A VSS_SNAPSHOT_PROPERTY_ID value that specifies the property to be set for the shadow copy. /// /// The value to be set for the property. See the VSS_SNAPSHOT_PROP structure for valid data types and descriptions of the /// properties that can be set for a shadow copy. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The property was set successfully. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified shadow copy was not found. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssfilesharesnapshotprovider-setsnapshotproperty HRESULT // SetSnapshotProperty( [in] VSS_ID SnapshotId, [in] VSS_SNAPSHOT_PROPERTY_ID eSnapshotPropertyId, [in] VARIANT vProperty ); [PreserveSig] HRESULT SetSnapshotProperty(Guid SnapshotId, VSS_SNAPSHOT_PROPERTY_ID eSnapshotPropertyId, object vProperty); } /// /// /// The IVssHardwareSnapshotProvider interface contains the methods used by VSS to map volumes to LUNs, discover LUNs created /// during the shadow copy process, and transport LUNs on a SAN. All hardware providers must support this interface. /// /// Note Hardware providers are only supported on Windows Server operating systems. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nn-vsprov-ivsshardwaresnapshotprovider [PInvokeData("vsprov.h", MSDNShortId = "NN:vsprov.IVssHardwareSnapshotProvider")] [ComImport, Guid("9593A157-44E9-4344-BBEB-44FBF9B06B10"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssHardwareSnapshotProvider { /// /// /// The AreLunsSupported method determines whether the hardware provider supports shadow copy creation for all LUNs that /// contribute to the volume. VSS calls the AreLunsSupported method for each volume that is added to the shadow copy set. /// Before calling this method, VSS determines the LUNs that contribute to the volume. /// /// For a specific volume, each LUN can contribute only once. A specific LUN may contribute to multiple volumes. /// Note Hardware providers are only supported on Windows Server operating systems. /// /// Count of LUNs contributing to this shadow copy volume. /// /// Shadow copy context for the current shadow copy set as enumerated by a bitmask of flags from the _VSS_VOLUME_SNAPSHOT_ATTRIBUTES /// enumeration. If the VSS_VOLSNAP_ATTR_TRANSPORTABLE flag is set, the shadow copy set is transportable. /// /// List of devices corresponding to the LUNs to be shadow copied. /// /// Array of lLunCount VDS_LUN_INFORMATION structures, one for each LUN contributing to this shadow copy volume. /// /// /// Pointer to a BOOL value. If all devices are supported for shadow copy, the provider should store a TRUE value at /// the location pointed to by pbIsSupported. /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. The provider must report an event in the application event log providing the user with /// information on how to resolve the problem. /// /// /// /// /// /// /// If the hardware subsystem supports the SCSI Inquiry Data and Vital Product Data page 80 (device serial number) and page 83 /// (device identity) guidelines, the provider should not need to modify the structures in the pLunInformation array. /// /// /// In any case, the AreLunsSupported method should not modify the value of the m_rgInterconnects member of any /// VDS_LUN_INFORMATION structure in the pLunInformation array. /// /// /// If the provider supports hardware shadow copy creation for all of the LUNs in the pLunInformation array, it should return /// TRUE in the BOOL value that the pbIsSupported parameter points to. If the provider does not support /// hardware shadow copies for one or more LUNs, it must set this BOOL value to FALSE. /// /// /// The provider must never agree to create shadow copies if it cannot, even if the problem is only temporary. If a transient /// condition, such as low resources, makes it impossible for the provider to create a shadow copy using one or more LUNs when /// AreLunsSupported is called, the provider must set the BOOL value to FALSE. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotprovider-arelunssupported HRESULT // AreLunsSupported( [in] LONG lLunCount, [in] LONG lContext, [in] VSS_PWSZ *rgwszDevices, [in, out] VDS_LUN_INFORMATION // *pLunInformation, [out] BOOL *pbIsSupported ); [PreserveSig] HRESULT AreLunsSupported(int lLunCount, VSS_VOLUME_SNAPSHOT_ATTRIBUTES lContext, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0)] string[] rgwszDevices, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] VDS_LUN_INFORMATION[] pLunInformation, [MarshalAs(UnmanagedType.Bool)] out bool pbIsSupported); /// /// /// The FillInLunInfo method prompts the hardware provider to indicate whether it supports the corresponding disk device and /// correct any omissions in the VDS_LUN_INFORMATION structure. VSS calls the FillInLunInfo method after the /// IVssHardwareSnapshotProvider::LocateLuns method or before the IVssHardwareSnapshotProvider::OnLunEmpty method to obtain the /// VDS_LUN_INFORMATION structure associated with a shadow copy LUN. VSS will compare the VDS_LUN_INFORMATION structure /// received in the IVssHardwareSnapshotProvider::GetTargetLuns method to identify shadow copy LUNs. If the structures do not match, /// the requester will receive VSS_S_SOME_SNAPSHOTS_NOT_IMPORTED, which indicates a mismatch. /// /// Note Hardware providers are only supported on Windows Server operating systems. /// /// Device corresponding to the shadow copy LUN. /// The VDS_LUN_INFORMATION structure for the shadow copy LUN. /// /// The provider must return TRUE in the location pointed to by the pbIsSupported parameter if the device is supported. /// /// /// VSS ignores this method's return value. /// Windows Server 2003: VSS does not ignore the return value, which can be one of the following values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error has occurred. The provider must report an event in the application event log providing the user /// with information on how to resolve the problem. /// /// /// /// /// /// /// VSS calls the FillInLunInfo method for each VDS_LUN_INFORMATION structure that the provider previously initialized in its /// GetTargetLuns method. VSS also calls the FillInLunInfo method for each new disk device that arrives in the system during /// the import process. /// /// /// The provider can correct any omissions in the VDS_LUN_INFORMATION structure received in the pLunInfo parameter. However, /// the provider should not modify the value of the m_rgInterconnects member of this structure. /// /// /// The members of the VDS_LUN_INFORMATION structure correspond to the SCSI Inquiry Data and Vital Product Data page 80 (device /// serial number) information, with the following exceptions: /// /// /// /// The m_version member must be set to VER_VDS_LUN_INFORMATION. /// /// /// /// The m_BusType member is ignored in comparisons during import. This value depends on the PnP storage stack on the /// corresponding disk device. Usually this is VDSBusTypeScsi. /// /// /// /// The m_diskSignature member is ignored in comparisons during import. The provider must set this member to GUID_NULL. /// /// /// /// The members of the VDS_STORAGE_DEVICE_ID_DESCRIPTOR structure (in the m_deviceIdDescriptor member of the /// VDS_LUN_INFORMATION structure) correspond to the page 83 information. In this structure, each VDS_STORAGE_IDENTIFIER structure /// corresponds to the STORAGE_IDENTIFIER structure for a device identifier (that is, a storage identifier with an association type /// of zero). For more information about the STORAGE_IDENTIFIER structure, see the Windows Driver Kit (WDK) documentation. /// /// /// If the FillInLunInfo method is called for a LUN that is unknown to the provider, the provider should not return an error. /// Instead, it should return FALSE in the BOOL value that the pbIsSupported parameter points to and return /// success. If the provider recognizes the LUN, it should set the BOOL value to TRUE. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotprovider-fillinluninfo HRESULT // FillInLunInfo( [in] VSS_PWSZ wszDeviceName, [in, out] VDS_LUN_INFORMATION *pLunInfo, [out] BOOL *pbIsSupported ); [PreserveSig] HRESULT FillInLunInfo([MarshalAs(UnmanagedType.LPWStr)] string wszDeviceName, ref VDS_LUN_INFORMATION pLunInfo, [MarshalAs(UnmanagedType.Bool)] out bool pbIsSupported); /// /// The BeginPrepareSnapshot method is called for each shadow copy that is added to the shadow copy set. /// Note Hardware providers are only supported on Windows Server operating systems. /// /// Shadow copy set identifier. /// Identifier of the shadow copy to be created. /// Shadow copy context for current shadow copy set as enumerated by _VSS_VOLUME_SNAPSHOT_ATTRIBUTES. /// Count of LUNs contributing to this shadow copy volume. /// /// Pointer to array of lLunCount pointers to strings, each string containing the name of a LUN to be shadow copied. /// /// /// Pointer to array of lLunCount VDS_LUN_INFORMATION structures, one for each LUN contributing to this shadow copy volume. /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED 0x80042312L /// The provider has reached the maximum number of volumes it can support. /// /// /// VSS_E_NESTED_VOLUME_LIMIT /// /// The specified volume is nested too deeply to participate in the VSS operation. Windows Server 2008, Windows Vista, Windows /// Server 2003 and Windows XP: This return code is not supported. /// /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. The provider must report an event in the application event log providing the user with /// information on how to resolve the problem. /// /// /// /// VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER 0x8004230EL /// The provider does not support this volume. /// /// /// VSS_E_UNSUPPORTED_CONTEXT 0x8004231BL /// The context specified by lContext is not supported. /// /// /// /// /// This method cannot be called for a virtual hard disk (VHD) that is nested inside another VHD. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: VHDs are not supported. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotprovider-beginpreparesnapshot HRESULT // BeginPrepareSnapshot( [in] VSS_ID SnapshotSetId, [in] VSS_ID SnapshotId, [in] LONG lContext, [in] LONG lLunCount, [in] VSS_PWSZ // *rgDeviceNames, [in, out] VDS_LUN_INFORMATION *rgLunInformation ); [PreserveSig] HRESULT BeginPrepareSnapshot(Guid SnapshotSetId, Guid SnapshotId, VSS_VOLUME_SNAPSHOT_ATTRIBUTES lContext, int lLunCount, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 3)] string[] rgDeviceNames, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] VDS_LUN_INFORMATION[] rgLunInformation); /// /// /// The GetTargetLuns method prompts the hardware provider to initialize the VDS_LUN_INFORMATION structures for the newly /// created shadow copy LUNs. The GetTargetLuns method is called after the IVssProviderCreateSnapshotSet::PostCommitSnapshots /// method. Identifying information for each newly created LUN is returned to VSS through VDS_LUN_INFORMATION structures. /// /// Note Hardware providers are only supported on Windows Server operating systems. /// /// Count of LUNs that contribute to the original volume. /// /// Pointer to an array of lLunCount pointers to strings. Each string contains the name of an original LUN to be shadow copied. /// /// /// Pointer to an array of lLunCount VDS_LUN_INFORMATION structures, one for each LUN that contributes to the original volume. /// /// /// Pointer to an array of lLunCount VDS_LUN_INFORMATION structures, one for each new shadow copy LUN created during shadow /// copy processing. There should be a one-to-one correspondence between the elements of the rgSourceLuns and /// rgDestinationLuns arrays. /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. The provider must report an event in the application event log providing the user with /// information on how to resolve the problem. /// /// /// /// /// /// /// In the rgDestinationLuns parameter, VSS supplies an empty VDS_LUN_INFORMATION structure for each newly created shadow /// copy LUN. The shadow copy LUNs are not surfaced or visible to the system. The provider should initialize the members of the /// VDS_LUN_INFORMATION structure with the appropriate SCSI Inquiry Data and Vital Product Data page 80 (device serial /// number) and page 83 (device identity) information. The structure should contain correct member values such that the shadow copy /// LUNs can be located by Windows from the original computer or any other computer connected to the SAN. /// /// The members of the VDS_LUN_INFORMATION structure correspond to the page 80 information, with the following exceptions: /// /// /// The m_version member must be set to VER_VDS_LUN_INFORMATION. /// /// /// /// The m_BusType member is ignored in comparisons during import. This value depends on the PnP storage stack on the /// corresponding disk device. Usually this is VDSBusTypeScsi. /// /// /// /// The m_diskSignature member is ignored in comparisons during import. The provider must set this member to GUID_NULL. /// /// /// /// The members of the VDS_STORAGE_DEVICE_ID_DESCRIPTOR structure (in the m_deviceIdDescriptor member of the /// VDS_LUN_INFORMATION structure) correspond to the page 83 information. In this structure, each VDS_STORAGE_IDENTIFIER structure /// corresponds to the STORAGE_IDENTIFIER structure for a device identifier (that is, a storage identifier with an association type /// of zero). For more information about the STORAGE_IDENTIFIER structure, see the Windows Driver Kit (WDK) documentation. /// /// /// The VDS_LUN_INFORMATION structures returned here must be the same as the structures provided in the /// IVssHardwareSnapshotProvider::FillInLunInfo method during import so that VSS can use this information to identify the newly /// arriving shadow copy LUNs at import. These same structures will be passed to the provider in the /// IVssHardwareSnapshotProvider::LocateLuns method. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotprovider-gettargetluns HRESULT // GetTargetLuns( [in] LONG lLunCount, [in] VSS_PWSZ *rgDeviceNames, [in] VDS_LUN_INFORMATION *rgSourceLuns, [in, out] // VDS_LUN_INFORMATION *rgDestinationLuns ); [PreserveSig] HRESULT GetTargetLuns(int lLunCount, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0)] string[] rgDeviceNames, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] VDS_LUN_INFORMATION[] rgSourceLuns, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] VDS_LUN_INFORMATION[] rgDestinationLuns); /// /// /// The LocateLuns method prompts the hardware provider to make the shadow copy LUNs visible to the computer. The /// LocateLuns method is called by VSS when a hardware shadow copy set is imported to a computer. The provider is responsible /// for any unmasking (or "surfacing") at the hardware level. /// /// Note Hardware providers are only supported on Windows Server operating systems. /// /// Number of LUNs that contribute to this shadow copy set. /// /// Pointer to an array of iLunCount VDS_LUN_INFORMATION structures, one for each LUN that is part of the shadow copy set to /// be imported. /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. The provider must report an event in the application event log providing the user with /// information on how to resolve the problem. /// /// /// /// /// /// /// In the rgSourceLuns parameter, VSS supplies the same array of VDS_LUN_INFORMATION structures that the provider previously /// initialized in its IVssHardwareSnapshotProvider::GetTargetLuns method. For each VDS_LUN_INFORMATION structure in the /// array, the provider should unmask (or "surface") the corresponding shadow copy LUN to the computer. /// /// /// Immediately after this method returns, VSS will perform a rescan and enumeration to detect any arrived devices. This causes any /// exposed LUNs to be discovered by the PnP manager. In parallel with listening for disk arrivals, VSS will also listen for hidden /// volume arrivals. VSS will stop listening after all volumes that contribute to a shadow copy set appear in the system or a /// time-out occurs. If some disk or volume devices fail to appear in this window, the requester will be told that only some of the /// shadow copies were imported by VSS returning VSS_S_SOME_SNAPSHOTS_NOT_IMPORTED to the requester. The requester will also /// receive the same error from VSS if the VDS_LUN_INFORMATION structures received from the GetTargetLuns and /// IVssHardwareSnapshotProvider::FillInLunInfo methods do not match. /// /// This method cannot be used to map shadow copy LUNs as read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotprovider-locateluns HRESULT LocateLuns( // [in] LONG lLunCount, [in] VDS_LUN_INFORMATION *rgSourceLuns ); [PreserveSig] HRESULT LocateLuns(int lLunCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] VDS_LUN_INFORMATION[] rgSourceLuns); /// /// /// The OnLunEmpty method is called whenever VSS determines that a shadow copy LUN contains no interesting data. All shadow /// copies have been deleted (which also causes deletion of the LUN.) The LUN resources may be reclaimed by the provider and reused /// for another purpose. VSS will dismount any affected volumes. A provider should not issue a rescan during OnLunEmpty. VSS /// will handle this cleanup. /// /// Note Hardware providers are only supported on Windows Server operating systems. /// /// Device corresponding to the LUN that contains the shadow copy to be deleted. /// /// Pointer to a VDS_LUN_INFORMATION structure containing information about the LUN containing the shadow copy to be deleted. /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. The provider must report an event in the application event log providing the user with /// information on how to resolve the problem. /// /// /// /// /// /// /// Hardware providers should delete a shadow copy and reclaim the LUN if and only if OnLunEmpty is being called. A hardware /// shadow copy may be used as the backup media itself, therefore the LUNs should be treated with the same care the storage array /// treats LUNs used for regular disks. Reclaiming LUNs outside of processing for OnLunEmpty should be limited to emergency /// or an administrator performing explicit action manually. /// /// /// In the case of persistent shadow copies, the requester deletes the shadow copy when it is no longer needed. In the case of /// nonpersistent non-auto-release shadow copies, the VSS service deletes the shadow copy when the computer is restarted. In all /// cases, the VSS service calls the provider's OnLunEmpty method as needed for each shadow copy LUN. /// /// /// Note that OnLunEmpty is called on a best effort basis. VSS invokes the method only when the LUN is guaranteed to be /// empty. There may be many cases where the LUN is empty but VSS is unable to detect this due to errors or external circumstances. /// In this case, the user should use storage management software to clear this state. /// /// Some examples: /// /// /// /// When a shadow copy LUN is moved to a different host but not actually transported or imported through VSS, then that LUN appears /// as any other LUN, and volumes can be simply deleted without any notification of VSS. /// /// /// /// A crash or unexpected reboot in the middle of a shadow copy creation. /// /// /// A canceled import. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotprovider-onlunempty HRESULT OnLunEmpty( // [in] VSS_PWSZ wszDeviceName, [in] VDS_LUN_INFORMATION *pInformation ); [PreserveSig] HRESULT OnLunEmpty([MarshalAs(UnmanagedType.LPWStr)] string wszDeviceName, in VDS_LUN_INFORMATION pInformation); } /// /// /// Provides an additional method used by VSS to notify hardware providers of LUN state changes. All hardware providers must support /// this interface. /// /// Note Hardware providers are only supported on Windows Server operating systems. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nn-vsprov-ivsshardwaresnapshotproviderex [PInvokeData("vsprov.h", MSDNShortId = "NN:vsprov.IVssHardwareSnapshotProviderEx")] [ComImport, Guid("7F5BA925-CDB1-4d11-A71F-339EB7E709FD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssHardwareSnapshotProviderEx : IVssHardwareSnapshotProvider { /// /// Not supported. /// This method is reserved for future use. /// /// This parameter is reserved for future use. /// None // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotproviderex-getprovidercapabilities // HRESULT GetProviderCapabilities( ULONGLONG *pllOriginalCapabilityMask ); [PreserveSig] HRESULT GetProviderCapabilities(out ulong pllOriginalCapabilityMask); /// /// The VSS service calls this method to notify hardware providers of a LUN state change. /// Note Hardware providers are only supported on Windows Server operating systems. /// /// /// A pointer to an array of dwCount VDS_LUN_INFORMATION structures, one for each LUN that contributes to the shadow copy volume. /// /// /// A pointer to an array of dwCount VDS_LUN_INFORMATION structures, one for each LUN that contributes to the original volume. /// /// /// Number of elements in the pSnapshotLuns array. This is also the number of elements in the pOriginalLuns array. /// /// /// /// A bitmask of _VSS_HARDWARE_OPTIONS flags that provide information about the state change that the shadow copy LUNs have /// undergone. The following table describes how each flag is used in this parameter. /// /// /// /// Value /// Meaning /// /// /// VSS_ONLUNSTATECHANGE_NOTIFY_READ_WRITE 0x00000100 /// The shadow copy LUN will be converted permanently to read-write. /// /// /// VSS_ONLUNSTATECHANGE_NOTIFY_LUN_PRE_RECOVERY 0x00000200 /// The shadow copy LUNs will be converted temporarily to read-write and are about to undergo TxF recovery or VSS auto-recovery. /// /// /// VSS_ONLUNSTATECHANGE_NOTIFY_LUN_POST_RECOVERY 0x00000400 /// The shadow copy LUNs have just undergone TxF recovery or VSS auto-recovery and have been converted back to read-only. /// /// /// VSS_ONLUNSTATECHANGE_DO_MASK_LUNS 0x00000800 /// The shadow copy LUNs must be masked from the current machine but not deleted. /// /// /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotproviderex-onlunstatechange HRESULT // OnLunStateChange( [in] VDS_LUN_INFORMATION *pSnapshotLuns, [in] VDS_LUN_INFORMATION *pOriginalLuns, [in] DWORD dwCount, [in] // DWORD dwFlags ); [PreserveSig] HRESULT OnLunStateChange([In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] VDS_LUN_INFORMATION[] pSnapshotLuns, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] VDS_LUN_INFORMATION[] pOriginalLuns, uint dwCount, VSS_HARDWARE_OPTIONS dwFlags); /// The VSS service calls this method to notify hardware providers that a LUN resynchronization is needed. /// /// A pointer to an array of dwCount VDS_LUN_INFORMATION structures, one for each LUN that contributes to the shadow copy volume. /// /// /// A pointer to an array of dwCount VDS_LUN_INFORMATION structures, one for each LUN that contributes to the destination /// volume where the contents of the shadow copy volume are to be copied. /// /// /// The number of elements in the pSourceLuns array. This is also the number of elements in the pTargetLuns array. /// /// /// A pointer to a location that will receive an IVssAsync interface pointer that can be used to retrieve the status of the /// resynchronization operation. /// /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this error code is returned, the error must be described in an entry in the /// application event log, giving the user information on how to resolve the problem. /// /// /// /// VSS_E_INSUFFICIENT_STORAGE 0x8004231FL /// The provider cannot perform the operation because there is not enough disk space. /// /// /// /// /// /// The destination LUNs can be the LUNs that contribute to the original production volume from which the shadow copy was created, /// or they can be new or existing LUNs that are used to replace an original volume that is removed from production. /// /// /// The provider must perform the resynchronization by copying data at the LUN array level, not at the host level. This means that /// the provider cannot implement LUN resynchronization by simply copying the contents of the source LUN to the destination LUN. The /// I/O that is required to perform the LUN resynchronization must be performed in the hardware, through the disk devices of the /// resynchronized LUNs, and not through the host computer. This I/O should be completely transparent to the host computer. /// /// When the resynchronization is complete, the LUNs are fully functional and are available for I/O operations. /// The underlying disk hardware must support unique page 83 device identifiers. /// /// If the destination LUN is larger than the source LUN, the provider must resize the destination LUN if necessary to ensure that /// it matches the source LUN after resynchronization. /// /// /// This method cannot be called in WinPE, and it cannot be called in Safe mode. Before calling this method, the caller must use the /// IVssBackupComponents::InitializeForRestore method to prepare for the resynchronization. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotproviderex-resyncluns HRESULT ResyncLuns( // [in] VDS_LUN_INFORMATION *pSourceLuns, [in] VDS_LUN_INFORMATION *pTargetLuns, [in] DWORD dwCount, [out] IVssAsync **ppAsync ); [PreserveSig] HRESULT ResyncLuns([In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] VDS_LUN_INFORMATION[] pSourceLuns, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] VDS_LUN_INFORMATION[] pTargetLuns, uint dwCount, out IVssAsync ppAsync); /// /// Not supported. /// This method is reserved for future use. /// /// This parameter is reserved for future use. /// This parameter is reserved for future use. /// This parameter is reserved for future use. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsshardwaresnapshotproviderex-onreuseluns HRESULT // OnReuseLuns( VDS_LUN_INFORMATION *pSnapshotLuns, VDS_LUN_INFORMATION *pOriginalLuns, DWORD dwCount ); [PreserveSig] HRESULT OnReuseLuns([In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] VDS_LUN_INFORMATION[] pSnapshotLuns, [In, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] VDS_LUN_INFORMATION[] pOriginalLuns, uint dwCount); } /// The IVssProviderCreateSnapshotSet interface contains the methods used during shadow copy creation. // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nn-vsprov-ivssprovidercreatesnapshotset [PInvokeData("vsprov.h", MSDNShortId = "NN:vsprov.IVssProviderCreateSnapshotSet")] [ComImport, Guid("5F894E5B-1E39-4778-8E23-9ABAD9F0E08C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssProviderCreateSnapshotSet { /// /// The EndPrepareSnapshots method is called once for the complete shadow copy set, after the last /// IVssHardwareSnapshotProvider::BeginPrepareSnapshot call. This method is intended as a point where the provider can wait for any /// shadow copy preparation work to complete. Because EndPrepareSnapshots may take a long time to complete, a provider should /// be prepared to accept an AbortSnapshots method call at any time and immediately end the preparation work. /// /// The VSS_ID of the shadow copy set. /// /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_INSUFFICIENT_STORAGE 0x8004231FL /// /// There is not enough disk storage to create a shadow copy. Insufficient disk space can also generate VSS_E_PROVIDER_VETO /// or VSS_E_OBJECT_NOT_FOUND error return values. /// /// /// /// VSS_E_OBJECT_NOT_FOUND 0x80042308L /// The SnapshotSetId parameter refers to an object that was not found. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// If any other value is returned, VSS will write an event to the event log and convert the error to VSS_E_UNEXPECTED_PROVIDER_ERROR. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-endpreparesnapshots HRESULT // EndPrepareSnapshots( [in] VSS_ID SnapshotSetId ); [PreserveSig] HRESULT EndPrepareSnapshots(Guid SnapshotSetId); /// /// The PreCommitSnapshots method ensures the provider is ready to quickly commit the prepared LUNs. This happens immediately /// before the flush-and-hold writes, but while applications are in a frozen state. During this call the provider should prepare all /// shadow copies in the shadow copy set indicated by SnapshotSetId for committing by the CommitSnapshots method call that /// will follow. While the provider is processing this method, the applications have been frozen, so the time spent in this method /// should be minimized. /// /// The VSS_ID that identifies the shadow copy set. /// /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_OBJECT_NOT_FOUND 0x80042308L /// The SnapshotSetId parameter refers to an object that was not found. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// If any other value is returned, VSS will write an event to the event log and convert the error to VSS_E_UNEXPECTED_PROVIDER_ERROR. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-precommitsnapshots HRESULT // PreCommitSnapshots( [in] VSS_ID SnapshotSetId ); [PreserveSig] HRESULT PreCommitSnapshots(Guid SnapshotSetId); /// The CommitSnapshots method quickly commits all LUNs in this provider. /// The VSS_ID that identifies the shadow copy set. /// /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_OBJECT_NOT_FOUND 0x80042308L /// The SnapshotSetId parameter refers to an object that was not found. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// An unexpected provider error occurred. The provider must log the details of this error in the application event log. /// /// /// If any other value is returned, VSS will write an event to the event log and convert the error to VSS_E_UNEXPECTED_PROVIDER_ERROR. /// /// /// /// This method is called at the defined time at which the shadow copies should be taken. For each prepared LUN in this shadow copy /// set, the provider will perform the work required to persist the point-in-time LUN contents. While this method is executing, both /// applications and the I/O subsystem are largely quiescent. The provider must minimize the amount of time spent in this method. As /// a general rule, this method should take less than one second to complete. This method is called during the Flush and Hold /// window, and VSS Kernel Support will cancel the Flush and Hold if the release is not received within 10 seconds, which would /// cause VSS to fail the shadow copy creation process. If each provider takes more than a second or two to complete this call, /// there is a high probability that the entire shadow copy creation will fail. /// /// /// Because the I/O system is quiescent, the provider must take care to not initiate any I/O as it could deadlock the system - for /// example debug or tracing I/O by this method or any calls made from this method. Memory mapped files and paging I/O will not be /// frozen at this time. /// /// /// Note that the I/O system is quiescent only while this method is executing. Immediately after the last provider's /// CommitSnapshots method returns, the VSS service releases all pending writes on the source LUNs. If the provider performs /// any synchronization of the source and shadow copy LUNs, this synchronization must be completed before the provider's /// CommitSnapshots method returns; it cannot be performed asynchronously. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-commitsnapshots HRESULT // CommitSnapshots( [in] VSS_ID SnapshotSetId ); [PreserveSig] HRESULT CommitSnapshots(Guid SnapshotSetId); /// /// The PostCommitSnapshots method is called after all providers involved in the shadow copy set have succeeded with /// CommitSnapshots. The lock on the I/O system has been lifted, but the applications have not yet been unfrozen. This is an /// opportunity for the provider to perform additional cleanup work after the shadow copy commit. /// /// The VSS_ID that identifies the shadow copy set. /// Count of shadow copies in the shadow copy set. /// /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_OBJECT_NOT_FOUND 0x80042308L /// The SnapshotSetId parameter refers to an object that was not found. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// If any other value is returned, VSS will write an event to the event log and convert the error to VSS_E_UNEXPECTED_PROVIDER_ERROR. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-postcommitsnapshots HRESULT // PostCommitSnapshots( [in] VSS_ID SnapshotSetId, [in] LONG lSnapshotsCount ); [PreserveSig] HRESULT PostCommitSnapshots(Guid SnapshotSetId, int lSnapshotsCount); /// /// The PreFinalCommitSnapshots method enables providers to support auto-recover shadow copies. If the shadow copy has the /// VSS_VOLSNAP_ATTR_AUTORECOVER flag set in the context, the volume can receive a large number of writes during the /// auto-recovery operation. /// /// The VSS_ID that identifies the shadow copy set. /// /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// If any other value is returned, VSS will write an event to the event log and convert the error to VSS_E_UNEXPECTED_PROVIDER_ERROR. /// /// /// /// This method was added to enable binary compatibility when the auto-recover feature was introduced in Windows Server 2003 with /// Service Pack 1 (SP1). /// /// /// Note For Windows Server 2003, it is recommended that hardware providers implement this method using the following example: /// /// /// HRESULT PreFinalCommitSnapshots( VSS_ID /* SnapshotSetId */ ) { return S_OK; } /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-prefinalcommitsnapshots HRESULT // PreFinalCommitSnapshots( [in] VSS_ID SnapshotSetId ); [PreserveSig] HRESULT PreFinalCommitSnapshots(Guid SnapshotSetId); /// /// The PostFinalCommitSnapshots method supports auto-recover shadow copies. VSS calls this method to notify the provider /// that the volume will now be read-only until a requester calls IVssBackupComponents::BreakSnapshotSet. /// /// The VSS_ID that identifies the shadow copy set. /// /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// If any other value is returned, VSS will write an event to the event log and convert the error to VSS_E_UNEXPECTED_PROVIDER_ERROR. /// /// /// /// This method was added in Windows Server 2003 to enable binary compatibility when the auto-recover feature was introduced in /// Windows Server 2003 with Service Pack 1 (SP1). /// /// /// Note For Windows Server 2003, it is recommended that hardware providers implement this method using the following example: /// /// /// HRESULT PostFinalCommitSnapshots( VSS_ID /* SnapshotSetId */ ) { return S_OK; } /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-postfinalcommitsnapshots // HRESULT PostFinalCommitSnapshots( [in] VSS_ID SnapshotSetId ); [PreserveSig] HRESULT PostFinalCommitSnapshots(Guid SnapshotSetId); /// /// The AbortSnapshots method aborts prepared shadow copies in this provider. This includes all non-committed shadow copies /// and pre-committed ones. /// /// The VSS_ID that identifies the shadow copy set. /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_OBJECT_NOT_FOUND 0x80042308L /// The SnapshotSetId parameter refers to an object that was not found. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. The provider must log a message in the application event log providing the user with /// information on how to resolve the problem. /// /// /// /// /// /// VSS will only call AbortSnapshots after the requester has called IVssBackupComponents::DoSnapshotSet, even if the shadow /// copy fails or is aborted before this point. This means that a provider will not receive an AbortSnapshots call until /// after EndPrepareSnapshots has been called. If a shadow copy is aborted or fails before this point, the provider is not given any /// indication until a new shadow copy is started. For this reason, the provider must be prepared to handle an out-of-sequence /// IVssHardwareSnapshotProvider::BeginPrepareSnapshot call at any point. This out-of-sequence call represents the start of a new /// shadow copy creation sequence and will have a new shadow copy set ID. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidercreatesnapshotset-abortsnapshots HRESULT // AbortSnapshots( [in] VSS_ID SnapshotSetId ); [PreserveSig] HRESULT AbortSnapshots(Guid SnapshotSetId); } /// The IVssProviderNotifications interface manages providers registered with VSS. // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nn-vsprov-ivssprovidernotifications [PInvokeData("vsprov.h", MSDNShortId = "NN:vsprov.IVssProviderNotifications")] [ComImport, Guid("E561901F-03A5-4afe-86D0-72BAEECE7004"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssProviderNotifications { /// The OnLoad method notifies a provider that it was loaded. /// This parameter is reserved. /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// The operation was successfully completed. /// /// /// E_OUTOFMEMORY 0x8007000EL /// Out of memory or other system resources. /// /// /// E_INVALIDARG 0x80070057L /// One of the parameter values is not valid. /// /// /// VSS_E_PROVIDER_VETO 0x80042306L /// /// An unexpected provider error occurred. If this is returned, the error must be described in an entry in the application event /// log, giving the user information on how to resolve the problem. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidernotifications-onload HRESULT OnLoad( [in] // IUnknown *pCallback ); [PreserveSig] HRESULT OnLoad([In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pCallback); /// The OnUnload method notifies the provider to prepare to be unloaded. /// If TRUE, the provider must prepare to be released. /// /// This method can return one of these values. /// /// /// Return code/value /// Description /// /// /// S_OK 0x00000000L /// There are no pending operations and the provider is ready to be released. /// /// /// S_FALSE 0x00000001L /// The provider should not be unloaded. This value can only be returned if bForceUnload is FALSE. /// /// /// /// If bForceUnload is TRUE, the return value must be S_OK. // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivssprovidernotifications-onunload HRESULT OnUnload( [in] // BOOL bForceUnload ); [PreserveSig] HRESULT OnUnload([MarshalAs(UnmanagedType.Bool)] bool bForceUnload); } /// Contains the methods used by VSS to manage shadow copy volumes. All software providers must support this interface. // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nn-vsprov-ivsssoftwaresnapshotprovider [PInvokeData("vsprov.h", MSDNShortId = "NN:vsprov.IVssSoftwareSnapshotProvider")] [ComImport, Guid("609e123e-2c5a-44d3-8f01-0b1d9a47d1ff"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVssSoftwareSnapshotProvider { /// Sets the context for subsequent shadow copy-related operations. /// /// The context to be set. The context must be one of the supported values of _VSS_SNAPSHOT_CONTEXT or a supported combination of /// _VSS_VOLUME_SNAPSHOT_ATTRIBUTES and _VSS_SNAPSHOT_CONTEXT values. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The context was set successfully. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_BAD_STATE /// The context is frozen and cannot be changed. /// /// /// /// /// The default context for VSS shadow copies is VSS_CTX_BACKUP. /// /// Windows XP: The only supported context is the default context, VSS_CTX_BACKUP. Therefore, calling SetContext under /// Windows XP returns E_NOTIMPL. /// /// /// For more information about how the context that is set by SetContext affects how a shadow copy is created and managed, /// see Implementation Details for Creating Shadow Copies. /// /// For a complete discussion of the permitted shadow copy contexts, see _VSS_SNAPSHOT_CONTEXT and _VSS_VOLUME_SNAPSHOT_ATTRIBUTES. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-setcontext HRESULT SetContext( // [in] LONG lContext ); [PreserveSig] HRESULT SetContext(VSS_SNAPSHOT_CONTEXT lContext); /// Gets the properties of the specified shadow copy. /// Shadow copy identifier. /// /// The address of a caller-allocated VSS_SNAPSHOT_PROP structure that receives the shadow copy properties. The provider is /// responsible for setting the members of this structure. All members are required except m_pwszExposedName and /// m_pwszExposedPath, which the provider can set to NULL. The provider allocates memory for all string members that /// it sets in the structure. When the structure is no longer needed, the caller is responsible for freeing these strings by calling /// the VssFreeSnapshotProperties function. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The requested information was successfully returned. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// /// /// /// The caller should set the contents of the VSS_SNAPSHOT_PROP structure to zero before calling the GetSnapshotProperties method. /// /// The provider is responsible for allocating and freeing the strings in the VSS_SNAPSHOT_PROP structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-getsnapshotproperties HRESULT // GetSnapshotProperties( [in] VSS_ID SnapshotId, [out] VSS_SNAPSHOT_PROP *pProp ); [PreserveSig] HRESULT GetSnapshotProperties(Guid SnapshotId, out VSS_SNAPSHOT_PROP pProp); /// Queries the provider for information about the shadow copies that the provider has completed. /// Reserved for system use. The value of this parameter must be GUID_NULL. /// Reserved for system use. The value of this parameter must be VSS_OBJECT_NONE. /// Reserved for system use. The value of this parameter must be VSS_OBJECT_SNAPSHOT. /// /// The address of an IVssEnumObject interface pointer, which is initialized on return. Callers must release the interface. This /// parameter is required and cannot be null. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The query operation was successful. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// /// /// Calling the IVssEnumObject::Next method on the IVssEnumObject interface that is returned though the ppEnum parameter will /// return VSS_OBJECT_PROP structures containing a VSS_SNAPSHOT_PROP structure for each shadow copy. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-query HRESULT Query( [in] VSS_ID // QueriedObjectId, [in] VSS_OBJECT_TYPE eQueriedObjectType, [in] VSS_OBJECT_TYPE eReturnedObjectsType, [out] IVssEnumObject // **ppEnum ); [PreserveSig] HRESULT Query(Guid QueriedObjectId, VSS_OBJECT_TYPE eQueriedObjectType, VSS_OBJECT_TYPE eReturnedObjectsType, out IVssEnumObject ppEnum); /// Deletes one or more shadow copies or a shadow copy set. /// Identifier of the shadow copy or shadow copy set to be deleted. /// Type of the object to be deleted. The value of this parameter is VSS_OBJECT_SNAPSHOT or VSS_OBJECT_SNAPSHOT_SET. /// /// If the value of this parameter is TRUE, the provider will do everything possible to delete the shadow copy or shadow /// copies in a shadow copy set. If it is FALSE, no additional effort will be made. /// /// Pointer to a variable that receives the number of shadow copies that were deleted. /// /// If an error occurs, this parameter receives a pointer to the identifier of the first shadow copy that could not be deleted. /// Otherwise, it points to GUID_NULL. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The shadow copies were successfully deleted. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified shadow copies were not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// /// /// Multiple shadow copies in a shadow copy set are deleted sequentially. If an error occurs during one of these individual /// deletions, DeleteSnapshots will return immediately; no attempt will be made to delete any remaining shadow copies. The /// VSS_ID of the undeleted shadow copy is returned in pNondeletedSnapshotID. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-deletesnapshots HRESULT // DeleteSnapshots( [in] VSS_ID SourceObjectId, [in] VSS_OBJECT_TYPE eSourceObjectType, [in] BOOL bForceDelete, [out] LONG // *plDeletedSnapshots, [out] VSS_ID *pNondeletedSnapshotID ); [PreserveSig] HRESULT DeleteSnapshots(Guid SourceObjectId, VSS_OBJECT_TYPE eSourceObjectType, [MarshalAs(UnmanagedType.Bool)] bool bForceDelete, out int plDeletedSnapshots, out Guid pNondeletedSnapshotID); /// VSS calls this method for each shadow copy that is added to the shadow copy set. /// Shadow copy set identifier. /// Identifier of the shadow copy to be created. /// /// /// Null-terminated wide character string containing the volume name. 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 of the form \\?\ Volume{ GUID}\ (where GUID identifies the volume) /// /// /// /// /// The context for the shadow copy set. This context consists of a bitmask of _VSS_VOLUME_SNAPSHOT_ATTRIBUTES values. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The shadow copy was successfully created. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNSUPPORTED_CONTEXT /// The specified context is not supported. /// /// /// VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER /// The provider does not support the specified volume. /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-beginpreparesnapshot HRESULT // BeginPrepareSnapshot( [in] VSS_ID SnapshotSetId, [in] VSS_ID SnapshotId, [in] VSS_PWSZ pwszVolumeName, [in] LONG lNewContext ); [PreserveSig] HRESULT BeginPrepareSnapshot(Guid SnapshotSetId, Guid SnapshotId, [MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, VSS_VOLUME_SNAPSHOT_ATTRIBUTES lNewContext); /// Determines whether the provider supports shadow copies on the specified volume. /// /// /// Null-terminated wide character string containing the volume name. 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 of the form \\?\ Volume{ GUID}\ (where GUID identifies the volume) /// /// /// /// /// This parameter receives TRUE if shadow copies are supported on the specified volume, otherwise FALSE. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The requested information was successfully returned. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// VSS_E_NESTED_VOLUME_LIMIT /// /// The specified volume is nested too deeply to participate in the VSS operation. Windows Server 2008, Windows Vista, Windows /// Server 2003 and Windows XP: This return code is not supported. /// /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// /// /// /// The IsVolumeSupported method will return TRUE if it is possible to create shadow copies on the given volume, even /// if the current configuration does not allow the creation of shadow copies on that volume at the present time. /// /// /// For example, if the maximum number of shadow copies has been reached on a given volume (and therefore no more shadow copies can /// be created on that volume), the method will still indicate that the volume can be shadow copied. /// /// This method cannot be called for a virtual hard disk (VHD) that is nested inside another VHD. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: VHDs are not supported. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-isvolumesupported HRESULT // IsVolumeSupported( [in] VSS_PWSZ pwszVolumeName, [out] BOOL *pbSupportedByThisProvider ); [PreserveSig] HRESULT IsVolumeSupported([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.Bool)] out bool pbSupportedByThisProvider); /// Determines whether any shadow copies exist for the specified volume. /// /// /// Null-terminated wide character string containing the volume name. 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 of the form \\?\ Volume{ GUID}\ (where GUID identifies the volume) /// /// /// /// /// This parameter receives TRUE if the volume has a shadow copy, or FALSE if the volume does not have a shadow copy. /// /// /// A bitmask of VSS_SNAPSHOT_COMPATIBILITY values that indicate whether certain volume control or file I/O operations are disabled /// for the given volume, if the volume has a shadow copy. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The requested information was successfully returned. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified volume was not found. /// /// /// VSS_E_PROVIDER_VETO /// /// Provider error. The provider logged the error in the event log. For more information, see Event and Error Handling Under VSS. /// /// /// /// VSS_E_UNEXPECTED /// /// Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported until Windows Server /// 2008 R2 and Windows 7. E_UNEXPECTED is used instead. /// /// /// /// /// /// If no volume control or file I/O operations are disabled for the selected volume, then the shadow copy capability of the /// selected volume returned by plSnapshotCapability will be zero. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-isvolumesnapshotted HRESULT // IsVolumeSnapshotted( [in] VSS_PWSZ pwszVolumeName, [out] BOOL *pbSnapshotsPresent, [out] LONG *plSnapshotCompatibility ); [PreserveSig] HRESULT IsVolumeSnapshotted([MarshalAs(UnmanagedType.LPWStr)] string pwszVolumeName, [MarshalAs(UnmanagedType.Bool)] out bool pbSnapshotsPresent, out VSS_SNAPSHOT_COMPATIBILITY plSnapshotCompatibility); /// Sets a property for a shadow copy. /// Shadow copy identifier. This parameter is required and cannot be GUID_NULL. /// A VSS_SNAPSHOT_PROPERTY_ID value that specifies the property to be set for the shadow copy. /// /// The value to be set for the property. See the VSS_SNAPSHOT_PROP structure for valid data types and descriptions of the /// properties that can be set for a shadow copy. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The property was set successfully. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The specified shadow copy was not found. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-setsnapshotproperty HRESULT // SetSnapshotProperty( [in] VSS_ID SnapshotId, [in] VSS_SNAPSHOT_PROPERTY_ID eSnapshotPropertyId, [in] VARIANT vProperty ); [PreserveSig] HRESULT SetSnapshotProperty(Guid SnapshotId, VSS_SNAPSHOT_PROPERTY_ID eSnapshotPropertyId, object vProperty); /// /// Reverts a volume to a previous shadow copy. Only shadow copies created with persistent contexts (VSS_CTX_APP_ROLLBACK, /// VSS_CTX_CLIENT_ACCESSIBLE, VSS_CTX_CLIENT_ACCESSIBLE_WRITERS, or VSS_CTX_NAS_ROLLBACK) are supported. /// /// Shadow copy identifier of the shadow copy to revert. /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The revert operation was successful. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_REVERT_IN_PROGRESS /// The volume already has a revert operation in process. /// /// /// /// /// This operation cannot be canceled, or undone once completed. If the computer is rebooted during the revert operation, the revert /// process will continue when the system is restarted. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-reverttosnapshot HRESULT // RevertToSnapshot( [in] VSS_ID SnapshotId ); [PreserveSig] HRESULT RevertToSnapshot(Guid SnapshotId); /// Returns an IVssAsync interface pointer that can be used to determine the status of the revert operation. /// /// /// Null-terminated wide character string containing the volume name. 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 of the form \\?\ Volume{ GUID}\ (where GUID identifies the volume) /// /// /// /// /// Pointer to a location that will receive an IVssAsync interface pointer that can be used to retrieve the status of the revert /// operation. /// /// /// The following are the valid return codes for this method. /// /// /// Value /// Meaning /// /// /// S_OK /// The status of the revert operation was successfully queried. /// /// /// E_ACCESSDENIED /// The caller does not have sufficient backup privileges or is not an administrator. /// /// /// E_INVALIDARG /// One of the parameter values is not valid. /// /// /// E_OUTOFMEMORY /// The caller is out of memory or other system resources. /// /// /// VSS_E_OBJECT_NOT_FOUND /// The pwszVolume parameter does not specify a valid volume. /// /// /// VSS_E_VOLUME_NOT_SUPPORTED /// The revert operation is not supported on this volume. /// /// /// /// /// The revert operation will continue even if the computer is rebooted, and cannot be canceled or undone, except by restoring a /// backup that was created using another method. The IVssAsync::QueryStatus method cannot return VSS_S_ASYNC_CANCELLED, because the /// revert operation cannot be canceled after it has started. /// // https://docs.microsoft.com/en-us/windows/win32/api/vsprov/nf-vsprov-ivsssoftwaresnapshotprovider-queryrevertstatus HRESULT // QueryRevertStatus( [in] VSS_PWSZ pwszVolume, [out] IVssAsync **ppAsync ); [PreserveSig] HRESULT QueryRevertStatus([MarshalAs(UnmanagedType.LPWStr)] string pwszVolume, out IVssAsync ppAsync); } }