1 // Copyright © 2015, Brian Vincent
2 // Licensed under the MIT License <LICENSE.md>
3 //! VSS backup interfaces
4 DEFINE_GUID!(IID_IVssExamineWriterMetadata, 0x902fcf7f, 0xb7fd, 0x42f8,
5     0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd);
6 DEFINE_GUID!(IID_IVssExamineWriterMetadataEx, 0x0c0e5ec0, 0xca44, 0x472b,
7     0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51);
8 DEFINE_GUID!(IID_IVssBackupComponents, 0x665c1d5f, 0xc218, 0x414d,
9     0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86);
10 DEFINE_GUID!(IID_IVssBackupComponentsEx, 0x963f03ad, 0x9e4c, 0x4a34,
11     0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36);
12 STRUCT!{struct VSS_COMPONENTINFO {
13     type_: ::VSS_COMPONENT_TYPE, // type is a keyword in rust
14     bstrLogicalPath: ::BSTR,
15     bstrComponentName: ::BSTR,
16     bstrCaption: ::BSTR,
17     pbIcon: *mut ::BYTE,
18     cbIcon: ::UINT,
19     bRestoreMetadata: bool,
20     bNotifyOnBackupComplete: bool,
21     bSelectable: bool,
22     bSelectableForRestore: bool,
23     dwComponentFlags: ::DWORD,
24     cFileCount: ::UINT,
25     cDatabases: ::UINT,
26     cLogFiles: ::UINT,
27     cDependencies: ::UINT,
28 }}
29 pub type PVSSCOMPONENTINFO = *const ::VSS_COMPONENTINFO;
30 RIDL!(
31 interface IVssWMComponent(IVssWMComponentVtbl): IUnknown(IUnknownVtbl) {
32     fn GetComponentInfo(&mut self, ppInfo: *mut ::PVSSCOMPONENTINFO) -> ::HRESULT,
33     fn FreeComponentInfo(&mut self, pInfo: ::PVSSCOMPONENTINFO) -> ::HRESULT,
34     fn GetFile(&mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc) -> ::HRESULT,
35     fn GetDatabaseFile(
36         &mut self, iDBFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc
37     ) -> ::HRESULT,
38     fn GetDatabaseLogFile(
39         &mut self, iDbLogFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc
40     ) -> ::HRESULT,
41     fn GetDependency(
42         &mut self, iDependency: ::UINT, ppDependency: *mut *mut ::IVssWMDependency
43     ) -> ::HRESULT
44 }
45 );
46 RIDL!(
47 interface IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl): IUnknown(IUnknownVtbl) {
48     fn GetIdentity(
49         &mut self, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID,
50         pbstrWriterName: *mut ::BSTR, pUsage: *mut ::VSS_USAGE_TYPE,
51         pSource: *mut ::VSS_SOURCE_TYPE
52     ) -> ::HRESULT,
53     fn GetFileCounts(&mut self, pcIncludeFiles: *mut ::UINT, pcExcludeFiles: *mut ::UINT,
54         pcComponents: *mut ::UINT
55     ) -> ::HRESULT,
56     fn GetIncludeFile(
57         &mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc
58     ) -> ::HRESULT,
59     fn GetExcludeFile(
60         &mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc
61     ) -> ::HRESULT,
62     fn GetComponent(
63         &mut self, iComponent: ::UINT, ppComponent: *mut *mut ::IVssWMComponent
64     ) -> ::HRESULT,
65     fn GetRestoreMethod(
66         &mut self, pMethod: *mut ::VSS_RESTOREMETHOD_ENUM, pbstrService: *mut ::BSTR,
67         pbstrUserProcedure: *mut ::BSTR, pwriterRestore: *mut ::VSS_WRITERRESTORE_ENUM,
68         pbRebootRequired: *mut bool, pcMappings: *mut ::UINT
69     ) -> ::HRESULT,
70     fn GetAlternateLocationMapping(
71         &mut self, iMapping: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc
72     ) -> ::HRESULT,
73     fn GetBackupSchema(&mut self, pdwSchemaMask: *mut ::DWORD) -> ::HRESULT,
74     fn GetDocument(&mut self, pDoc: *mut ::c_void) -> ::HRESULT, //TODO IXMLDOMDocument
75     fn SaveAsXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT,
76     fn LoadFromXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT
77 }
78 );
79 RIDL!(
80 interface IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl):
81     IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl) {
82     fn GetIdentityEx(
83         &mut self, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID,
84         pbstrWriterName: *mut ::BSTR, pbstrInstanceName: *mut ::BSTR,
85         pUsage: *mut ::VSS_USAGE_TYPE, pSource: *mut ::VSS_SOURCE_TYPE
86     ) -> ::HRESULT
87 }
88 );
89 RIDL!(
90 interface IVssExamineWriterMetadataEx2(IVssExamineWriterMetadataEx2Vtbl):
91     IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl) {
92     fn GetVersion(
93         &mut self, pdwMajorVersion: *mut ::DWORD, pdwMinorVersion: *mut ::DWORD
94     ) -> ::HRESULT,
95     fn GetExcludeFromSnapshotCount(&mut self, pcExcludedFromSnapshot: *mut ::UINT) -> ::HRESULT,
96     fn GetExcludeFromSnapshotFile(
97         &mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc
98     ) -> ::HRESULT
99 }
100 );
101 #[repr(C)]
102 pub struct IVssWriterComponentsExt {
103     pub lpVtbl: *const IVssWriterComponentsExtVtbl,
104 }
105 #[repr(C)]
106 pub struct IVssWriterComponentsExtVtbl {
107     pub parent1: ::IVssWriterComponentsVtbl,
108     pub parent2: ::IUnknownVtbl,
109 }
110 RIDL!(
111 interface IVssBackupComponents(IVssBackupComponentsVtbl): IUnknown(IUnknownVtbl) {
112     fn GetWriterComponentsCount(&mut self, pcComponents: *mut ::UINT) -> ::HRESULT,
113     fn GetWriterComponents(
114         &mut self, iWriter: ::UINT, ppWriter: *mut *mut IVssWriterComponentsExt
115     ) -> ::HRESULT,
116     fn InitializeForBackup(&mut self, bstrXML: ::BSTR) -> ::HRESULT,
117     fn SetBackupState(
118         &mut self, bSelectComponents: bool, bBackupBootableSystemState: bool,
119         backupType: ::VSS_BACKUP_TYPE, bPartialFileSupport: bool
120     ) -> ::HRESULT,
121     fn InitializeForRestore(&mut self, bstrXML: ::BSTR) -> ::HRESULT,
122     fn SetRestoreState(&mut self, restoreType: ::VSS_RESTORE_TYPE) -> ::HRESULT,
123     fn GatherWriterMetadata(&mut self, pAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
124     fn GetWriterMetadataCount(&mut self, pcWriters: *mut ::UINT) -> ::HRESULT,
125     fn GetWriterMetadata(
126         &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID,
127         ppMetadata: *mut *mut IVssExamineWriterMetadata
128     ) -> ::HRESULT,
129     fn FreeWriterMetadata(&mut self) -> ::HRESULT,
130     fn AddComponent(
131         &mut self, instanceId: ::VSS_ID, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE,
132         wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR
133     ) -> ::HRESULT,
134     fn PrepareForBackup(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
135     fn AbortBackup(&mut self) -> ::HRESULT,
136     fn GatherWriterStatus(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
137     fn GetWriterStatusCount(&mut self, pcWriters: *mut ::UINT) -> ::HRESULT,
138     fn FreeWriterStatus(&mut self) -> ::HRESULT,
139     fn GetWriterStatus(
140         &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID,
141         pbstrWriter: *mut ::BSTR, pnStatus: *mut ::VSS_WRITER_STATE,
142         phResultFailure: *mut ::HRESULT
143     ) -> ::HRESULT,
144     fn SetBackupSucceeded(
145         &mut self, instanceId: ::VSS_ID, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE,
146         wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, bSucceded: bool
147     ) -> ::HRESULT,
148     fn SetBackupOptions(
149         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
150         wszComponentName: ::LPCWSTR, wszBackupOptions: ::LPCWSTR
151     ) -> ::HRESULT,
152     fn SetSelectedForRestore(
153         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
154         wszComponentName: ::LPCWSTR, bSelectedForRestore: bool
155     ) -> ::HRESULT,
156     fn SetRestoreOptions(
157         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
158         wszComponentName: ::LPCWSTR, wszRestoreOptions: ::LPCWSTR
159     ) -> ::HRESULT,
160     fn SetAdditionalRestores(
161         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
162         wszComponentName: ::LPCWSTR, bAdditionalRestores: bool
163     ) -> ::HRESULT,
164     fn SetPreviousBackupStamp(
165         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
166         wszComponentName: ::LPCWSTR, wszPreviousBackupStamp: ::LPCWSTR
167     ) -> ::HRESULT,
168     fn SaveAsXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT,
169     fn BackupComplete(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
170     fn AddAlternativeLocationMapping(
171         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
172         wszComponentName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: bool,
173         wszDestination: ::LPCWSTR
174     ) -> ::HRESULT,
175     fn AddRestoreSubcomponent(
176         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
177         wszComponentName: ::LPCWSTR, wszSubComponentLogicalPath: ::LPCWSTR,
178         wszSubComponentName: ::LPCWSTR, bRepair: bool
179     ) -> ::HRESULT,
180     fn SetFileRestoreStatus(
181         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
182         wszComponentName: ::LPCWSTR, status: ::VSS_FILE_RESTORE_STATUS
183     ) -> ::HRESULT,
184     fn AddNewTarget(
185         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
186         wszComponentName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFileName: ::LPCWSTR, bRecursive: bool,
187         wszAlternatePath: ::LPCWSTR
188     ) -> ::HRESULT,
189     fn SetRangesFilePath(
190         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
191         wszComponentName: ::LPCWSTR, iPartialFile: ::UINT, wszRangesFile: ::LPCWSTR
192     ) -> ::HRESULT,
193     fn PreRestore(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
194     fn PostRestore(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
195     fn SetContext(&mut self, lContext: ::LONG) -> ::HRESULT,
196     fn StartSnapshotSet(&mut self, pSnapshotSetId: *mut ::VSS_ID) -> ::HRESULT,
197     fn AddToSnapshotSet(
198         &mut self, pwszVolumeName: ::VSS_PWSZ, ProviderId: ::VSS_ID, pidSnapshot: *mut ::VSS_ID
199     ) -> ::HRESULT,
200     fn DoSnapshotSet(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
201     fn DeleteSnapshots(
202         &mut self, SourceObjectId: ::VSS_ID, eSourceObjectType: ::VSS_OBJECT_TYPE,
203         bForceDelete: ::BOOL, plDeletedSnapshots: *mut ::LONG, pNondeletedSnapshotID: *mut ::VSS_ID
204     ) -> ::HRESULT,
205     fn ImportSnapshots(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
206     fn BreakSnapshotSet(&mut self, SnapshotSetId: ::VSS_ID) -> ::HRESULT,
207     fn GetSnapshotProperties(
208         &mut self, SnapshotId: ::VSS_ID,
209         pProp: *mut ::VSS_SNAPSHOT_PROP
210     ) -> ::HRESULT,
211     fn Query(&mut self, QueriedObjectId: ::VSS_ID, eQueriedObjectType: ::VSS_OBJECT_TYPE,
212         eReturnedObjectsType: ::VSS_OBJECT_TYPE, ppEnum: *mut *mut ::IVssEnumObject) -> ::HRESULT,
213     fn IsVolumeSupported(
214         &mut self, ProviderId: ::VSS_ID, pwszVolumeName: ::VSS_PWSZ,
215         pbSupportedByThisProvider: *mut ::BOOL
216     ) -> ::HRESULT,
217     fn DisableWriterClasses(
218         &mut self, rgWriterClassId: *const ::VSS_ID, cClassId: ::UINT
219     ) -> ::HRESULT,
220     fn EnableWriterClasses(
221         &mut self, rgWriterClassId: *const ::VSS_ID, cClassId: ::UINT
222     ) -> ::HRESULT,
223     fn DisableWriterInstances(
224         &mut self, rgWriterInstanceId: *const ::VSS_ID, cInstanceId: ::UINT
225     ) -> ::HRESULT,
226     fn ExposeSnapshot(&mut self, SnapshotId: ::VSS_ID, wszPathFromRoot: ::VSS_PWSZ,
227         lAttributes: ::LONG, wszExpose: ::VSS_PWSZ, pwszExposed: ::VSS_PWSZ
228     ) -> ::HRESULT,
229     fn RevertToSnapshot(&mut self, SnapshotId: ::VSS_ID, bForceDismount: ::BOOL) -> ::HRESULT,
230     fn QueryRevertStatus(
231         &mut self, pwszVolume: ::VSS_PWSZ, ppAsync: *mut *mut ::IVssAsync
232     ) -> ::HRESULT
233 }
234 );
235 RIDL!(
236 interface IVssBackupComponentsEx(IVssBackupComponentsExVtbl):
237     IVssBackupComponents(IVssBackupComponentsVtbl) {
238     fn GetWriterMetadataEx(
239         &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID,
240         ppMetadata: *mut *mut ::IVssExamineWriterMetadataEx
241     ) -> ::HRESULT,
242     fn SetSelectedForRestoreEx(
243         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
244         wszComponentName: ::LPCWSTR, bSelectedForRestore: bool, instanceId: ::VSS_ID
245     ) -> ::HRESULT
246 }
247 );
248 RIDL!(
249 interface IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl):
250     IVssBackupComponentsEx(IVssBackupComponentsExVtbl) {
251     fn UnexposeSnapshot(&mut self, snapshotId: ::VSS_ID) -> ::HRESULT,
252     fn SetAuthoritativeRestore(
253         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
254         wszComponentName: ::LPCWSTR, bAuth: bool
255     ) -> ::HRESULT,
256     fn SetRollForward(
257         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
258         wszComponentName: ::LPCWSTR, rollType: ::VSS_ROLLFORWARD_TYPE,
259         wszRollForwardPoint: ::LPCWSTR
260     ) -> ::HRESULT,
261     fn SetRestoreName(
262         &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR,
263         wszComponentName: ::LPCWSTR, wszRestoreName: ::LPCWSTR
264     ) -> ::HRESULT,
265     fn BreakSnapshotSetEx(
266         &mut self, SnapshotSetID: ::VSS_ID, dwBreakFlags: ::DWORD, ppAsync: *mut *mut ::IVssAsync
267     ) -> ::HRESULT,
268     fn PreFastRecovery(
269         &mut self, SnapshotSetID: ::VSS_ID, dwPreFastRecoveryFlags: ::DWORD,
270         ppAsync: *mut *mut ::IVssAsync
271     ) -> ::HRESULT,
272     fn FastRecovery(
273         &mut self, SnapshotSetID: ::VSS_ID, dwFastRecoveryFlags: ::DWORD,
274         ppAsync: *mut *mut ::IVssAsync
275     ) -> ::HRESULT
276 }
277 );
278 RIDL!(
279 interface IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl):
280     IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl) {
281     fn GetWriterStatusEx(
282         &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID,
283         pbstrWriter: *mut ::BSTR, pnStatus: *mut ::VSS_WRITER_STATE,
284         phrFailureWriter: *mut ::HRESULT, phrApplication: *mut ::HRESULT,
285         pbstrApplicationMessage: *mut ::BSTR
286     ) -> ::HRESULT,
287     fn AddSnapshotToRecoverySet(
288         &mut self, snapshotId: ::VSS_ID, dwFlags: ::DWORD, pwszDestinationVolume: ::VSS_PWSZ
289     ) -> ::HRESULT,
290     fn RecoverSet(&mut self, dwFlags: ::DWORD, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT,
291     fn GetSessionId(&mut self, idSession: *mut ::VSS_ID) -> ::HRESULT
292 }
293 );
294 RIDL!(
295 interface IVssBackupComponentsEx4(IVssBackupComponentsEx4Vtbl):
296     IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl) {
297     fn GetRootAndLogicalPrefixPaths(
298         &mut self, pwszFilePath: ::VSS_PWSZ, ppwszRootPath: *mut ::VSS_PWSZ,
299         ppwszLogicalPrefix: *mut ::VSS_PWSZ, bNormalizeFQDNforRootPath: ::BOOL
300     ) -> ::HRESULT
301 }
302 );
303 pub const VSS_SW_BOOTABLE_STATE: ::DWORD = 1;
304