1 | /* $Id: MediumImpl.h 76562 2019-01-01 03:22:50Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef MAIN_INCLUDED_MediumImpl_h
|
---|
19 | #define MAIN_INCLUDED_MediumImpl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <VBox/vd.h>
|
---|
25 | #include "MediumWrap.h"
|
---|
26 | #include "VirtualBoxBase.h"
|
---|
27 | #include "AutoCaller.h"
|
---|
28 | #include "SecretKeyStore.h"
|
---|
29 | class Progress;
|
---|
30 | class MediumFormat;
|
---|
31 | class MediumLockList;
|
---|
32 | struct MediumCryptoFilterSettings;
|
---|
33 |
|
---|
34 | namespace settings
|
---|
35 | {
|
---|
36 | struct Medium;
|
---|
37 | }
|
---|
38 |
|
---|
39 | ////////////////////////////////////////////////////////////////////////////////
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Medium component class for all media types.
|
---|
43 | */
|
---|
44 | class ATL_NO_VTABLE Medium :
|
---|
45 | public MediumWrap
|
---|
46 | {
|
---|
47 | public:
|
---|
48 | DECLARE_EMPTY_CTOR_DTOR(Medium)
|
---|
49 |
|
---|
50 | HRESULT FinalConstruct();
|
---|
51 | void FinalRelease();
|
---|
52 |
|
---|
53 | enum HDDOpenMode { OpenReadWrite, OpenReadOnly };
|
---|
54 | // have to use a special enum for the overloaded init() below;
|
---|
55 | // can't use AccessMode_T from XIDL because that's mapped to an int
|
---|
56 | // and would be ambiguous
|
---|
57 |
|
---|
58 | // public initializer/uninitializer for internal purposes only
|
---|
59 |
|
---|
60 | // initializer to create empty medium (VirtualBox::CreateMedium())
|
---|
61 | HRESULT init(VirtualBox *aVirtualBox,
|
---|
62 | const Utf8Str &aFormat,
|
---|
63 | const Utf8Str &aLocation,
|
---|
64 | const Guid &uuidMachineRegistry,
|
---|
65 | const DeviceType_T aDeviceType);
|
---|
66 |
|
---|
67 | // initializer for opening existing media
|
---|
68 | // (VirtualBox::OpenMedium(); Machine::AttachDevice())
|
---|
69 | HRESULT init(VirtualBox *aVirtualBox,
|
---|
70 | const Utf8Str &aLocation,
|
---|
71 | HDDOpenMode enOpenMode,
|
---|
72 | bool fForceNewUuid,
|
---|
73 | DeviceType_T aDeviceType);
|
---|
74 |
|
---|
75 | // initializer used when loading settings
|
---|
76 | HRESULT initOne(Medium *aParent,
|
---|
77 | DeviceType_T aDeviceType,
|
---|
78 | const Guid &uuidMachineRegistry,
|
---|
79 | const settings::Medium &data,
|
---|
80 | const Utf8Str &strMachineFolder);
|
---|
81 | HRESULT init(VirtualBox *aVirtualBox,
|
---|
82 | Medium *aParent,
|
---|
83 | DeviceType_T aDeviceType,
|
---|
84 | const Guid &uuidMachineRegistry,
|
---|
85 | const settings::Medium &data,
|
---|
86 | const Utf8Str &strMachineFolder,
|
---|
87 | AutoWriteLock &mediaTreeLock);
|
---|
88 |
|
---|
89 | // initializer for host floppy/DVD
|
---|
90 | HRESULT init(VirtualBox *aVirtualBox,
|
---|
91 | DeviceType_T aDeviceType,
|
---|
92 | const Utf8Str &aLocation,
|
---|
93 | const Utf8Str &aDescription = Utf8Str::Empty);
|
---|
94 |
|
---|
95 | void uninit();
|
---|
96 |
|
---|
97 | void i_deparent();
|
---|
98 | void i_setParent(const ComObjPtr<Medium> &pParent);
|
---|
99 |
|
---|
100 | // unsafe methods for internal purposes only (ensure there is
|
---|
101 | // a caller and a read lock before calling them!)
|
---|
102 | const ComObjPtr<Medium>& i_getParent() const;
|
---|
103 | const MediaList& i_getChildren() const;
|
---|
104 |
|
---|
105 | const Guid& i_getId() const;
|
---|
106 | MediumState_T i_getState() const;
|
---|
107 | MediumVariant_T i_getVariant() const;
|
---|
108 | bool i_isHostDrive() const;
|
---|
109 | const Utf8Str& i_getLocationFull() const;
|
---|
110 | const Utf8Str& i_getFormat() const;
|
---|
111 | const ComObjPtr<MediumFormat> & i_getMediumFormat() const;
|
---|
112 | bool i_isMediumFormatFile() const;
|
---|
113 | uint64_t i_getSize() const;
|
---|
114 | uint64_t i_getLogicalSize() const;
|
---|
115 | DeviceType_T i_getDeviceType() const;
|
---|
116 | MediumType_T i_getType() const;
|
---|
117 | Utf8Str i_getName();
|
---|
118 |
|
---|
119 | /* handles caller/locking itself */
|
---|
120 | bool i_addRegistry(const Guid &id);
|
---|
121 | /* handles caller/locking itself, caller is responsible for tree lock */
|
---|
122 | bool i_addRegistryRecursive(const Guid &id);
|
---|
123 | /* handles caller/locking itself */
|
---|
124 | bool i_removeRegistry(const Guid& id);
|
---|
125 | /* handles caller/locking itself, caller is responsible for tree lock */
|
---|
126 | bool i_removeRegistryRecursive(const Guid& id);
|
---|
127 | bool i_isInRegistry(const Guid& id);
|
---|
128 | bool i_getFirstRegistryMachineId(Guid &uuid) const;
|
---|
129 | void i_markRegistriesModified();
|
---|
130 |
|
---|
131 | HRESULT i_setPropertyDirect(const Utf8Str &aName, const Utf8Str &aValue);
|
---|
132 |
|
---|
133 | HRESULT i_addBackReference(const Guid &aMachineId,
|
---|
134 | const Guid &aSnapshotId = Guid::Empty);
|
---|
135 | HRESULT i_removeBackReference(const Guid &aMachineId,
|
---|
136 | const Guid &aSnapshotId = Guid::Empty);
|
---|
137 |
|
---|
138 |
|
---|
139 | const Guid* i_getFirstMachineBackrefId() const;
|
---|
140 | const Guid* i_getAnyMachineBackref() const;
|
---|
141 | const Guid* i_getFirstMachineBackrefSnapshotId() const;
|
---|
142 | size_t i_getMachineBackRefCount() const;
|
---|
143 |
|
---|
144 | #ifdef DEBUG
|
---|
145 | void i_dumpBackRefs();
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | HRESULT i_updatePath(const Utf8Str &strOldPath, const Utf8Str &strNewPath);
|
---|
149 |
|
---|
150 | /* handles caller/locking itself */
|
---|
151 | ComObjPtr<Medium> i_getBase(uint32_t *aLevel = NULL);
|
---|
152 | /* handles caller/locking itself */
|
---|
153 | uint32_t i_getDepth();
|
---|
154 |
|
---|
155 | bool i_isReadOnly();
|
---|
156 | void i_updateId(const Guid &id);
|
---|
157 |
|
---|
158 | void i_saveSettingsOne(settings::Medium &data,
|
---|
159 | const Utf8Str &strHardDiskFolder);
|
---|
160 | HRESULT i_saveSettings(settings::Medium &data,
|
---|
161 | const Utf8Str &strHardDiskFolder);
|
---|
162 |
|
---|
163 | HRESULT i_createMediumLockList(bool fFailIfInaccessible,
|
---|
164 | Medium *pToLock,
|
---|
165 | bool fMediumLockWriteAll,
|
---|
166 | Medium *pToBeParent,
|
---|
167 | MediumLockList &mediumLockList);
|
---|
168 |
|
---|
169 | HRESULT i_createDiffStorage(ComObjPtr<Medium> &aTarget,
|
---|
170 | MediumVariant_T aVariant,
|
---|
171 | MediumLockList *pMediumLockList,
|
---|
172 | ComObjPtr<Progress> *aProgress,
|
---|
173 | bool aWait,
|
---|
174 | bool aNotify);
|
---|
175 | Utf8Str i_getPreferredDiffFormat();
|
---|
176 | MediumVariant_T i_getPreferredDiffVariant();
|
---|
177 |
|
---|
178 | HRESULT i_close(AutoCaller &autoCaller);
|
---|
179 | HRESULT i_unlockRead(MediumState_T *aState);
|
---|
180 | HRESULT i_unlockWrite(MediumState_T *aState);
|
---|
181 | HRESULT i_deleteStorage(ComObjPtr<Progress> *aProgress, bool aWait, bool aNotify);
|
---|
182 | HRESULT i_markForDeletion();
|
---|
183 | HRESULT i_unmarkForDeletion();
|
---|
184 | HRESULT i_markLockedForDeletion();
|
---|
185 | HRESULT i_unmarkLockedForDeletion();
|
---|
186 |
|
---|
187 | HRESULT i_queryPreferredMergeDirection(const ComObjPtr<Medium> &pOther,
|
---|
188 | bool &fMergeForward);
|
---|
189 |
|
---|
190 | HRESULT i_prepareMergeTo(const ComObjPtr<Medium> &pTarget,
|
---|
191 | const Guid *aMachineId,
|
---|
192 | const Guid *aSnapshotId,
|
---|
193 | bool fLockMedia,
|
---|
194 | bool &fMergeForward,
|
---|
195 | ComObjPtr<Medium> &pParentForTarget,
|
---|
196 | MediumLockList * &aChildrenToReparent,
|
---|
197 | MediumLockList * &aMediumLockList);
|
---|
198 | HRESULT i_mergeTo(const ComObjPtr<Medium> &pTarget,
|
---|
199 | bool fMergeForward,
|
---|
200 | const ComObjPtr<Medium> &pParentForTarget,
|
---|
201 | MediumLockList *aChildrenToReparent,
|
---|
202 | MediumLockList *aMediumLockList,
|
---|
203 | ComObjPtr<Progress> *aProgress,
|
---|
204 | bool aWait,
|
---|
205 | bool aNotify);
|
---|
206 | void i_cancelMergeTo(MediumLockList *aChildrenToReparent,
|
---|
207 | MediumLockList *aMediumLockList);
|
---|
208 |
|
---|
209 | HRESULT i_resize(LONG64 aLogicalSize,
|
---|
210 | MediumLockList *aMediumLockList,
|
---|
211 | ComObjPtr<Progress> *aProgress,
|
---|
212 | bool aWait,
|
---|
213 | bool aNotify);
|
---|
214 |
|
---|
215 | HRESULT i_fixParentUuidOfChildren(MediumLockList *pChildrenToReparent);
|
---|
216 |
|
---|
217 | HRESULT i_addRawToFss(const char *aFilename, SecretKeyStore *pKeyStore, RTVFSFSSTREAM hVfsFssDst,
|
---|
218 | const ComObjPtr<Progress> &aProgress, bool fSparse);
|
---|
219 |
|
---|
220 | HRESULT i_exportFile(const char *aFilename,
|
---|
221 | const ComObjPtr<MediumFormat> &aFormat,
|
---|
222 | MediumVariant_T aVariant,
|
---|
223 | SecretKeyStore *pKeyStore,
|
---|
224 | RTVFSIOSTREAM hVfsIosDst,
|
---|
225 | const ComObjPtr<Progress> &aProgress);
|
---|
226 | HRESULT i_importFile(const char *aFilename,
|
---|
227 | const ComObjPtr<MediumFormat> &aFormat,
|
---|
228 | MediumVariant_T aVariant,
|
---|
229 | RTVFSIOSTREAM hVfsIosSrc,
|
---|
230 | const ComObjPtr<Medium> &aParent,
|
---|
231 | const ComObjPtr<Progress> &aProgress,
|
---|
232 | bool aNotify);
|
---|
233 |
|
---|
234 | HRESULT i_cloneToEx(const ComObjPtr<Medium> &aTarget, MediumVariant_T aVariant,
|
---|
235 | const ComObjPtr<Medium> &aParent, IProgress **aProgress,
|
---|
236 | uint32_t idxSrcImageSame, uint32_t idxDstImageSame, bool aNotify);
|
---|
237 |
|
---|
238 | const Utf8Str& i_getKeyId();
|
---|
239 |
|
---|
240 | HRESULT i_openForIO(bool fWritable, SecretKeyStore *pKeyStore, PVDISK *ppHdd, MediumLockList *pMediumLockList,
|
---|
241 | struct MediumCryptoFilterSettings *pCryptoSettings);
|
---|
242 |
|
---|
243 | private:
|
---|
244 |
|
---|
245 | // wrapped IMedium properties
|
---|
246 | HRESULT getId(com::Guid &aId);
|
---|
247 | HRESULT getDescription(AutoCaller &autoCaller, com::Utf8Str &aDescription);
|
---|
248 | HRESULT setDescription(AutoCaller &autoCaller, const com::Utf8Str &aDescription);
|
---|
249 | HRESULT getState(MediumState_T *aState);
|
---|
250 | HRESULT getVariant(std::vector<MediumVariant_T> &aVariant);
|
---|
251 | HRESULT getLocation(com::Utf8Str &aLocation);
|
---|
252 | HRESULT setLocation(const com::Utf8Str &aLocation);
|
---|
253 | HRESULT getName(com::Utf8Str &aName);
|
---|
254 | HRESULT getDeviceType(DeviceType_T *aDeviceType);
|
---|
255 | HRESULT getHostDrive(BOOL *aHostDrive);
|
---|
256 | HRESULT getSize(LONG64 *aSize);
|
---|
257 | HRESULT getFormat(com::Utf8Str &aFormat);
|
---|
258 | HRESULT getMediumFormat(ComPtr<IMediumFormat> &aMediumFormat);
|
---|
259 | HRESULT getType(AutoCaller &autoCaller, MediumType_T *aType);
|
---|
260 | HRESULT setType(AutoCaller &autoCaller, MediumType_T aType);
|
---|
261 | HRESULT getAllowedTypes(std::vector<MediumType_T> &aAllowedTypes);
|
---|
262 | HRESULT getParent(AutoCaller &autoCaller, ComPtr<IMedium> &aParent);
|
---|
263 | HRESULT getChildren(AutoCaller &autoCaller, std::vector<ComPtr<IMedium> > &aChildren);
|
---|
264 | HRESULT getBase(AutoCaller &autoCaller, ComPtr<IMedium> &aBase);
|
---|
265 | HRESULT getReadOnly(AutoCaller &autoCaller, BOOL *aReadOnly);
|
---|
266 | HRESULT getLogicalSize(LONG64 *aLogicalSize);
|
---|
267 | HRESULT getAutoReset(BOOL *aAutoReset);
|
---|
268 | HRESULT setAutoReset(BOOL aAutoReset);
|
---|
269 | HRESULT getLastAccessError(com::Utf8Str &aLastAccessError);
|
---|
270 | HRESULT getMachineIds(std::vector<com::Guid> &aMachineIds);
|
---|
271 |
|
---|
272 | // wrapped IMedium methods
|
---|
273 | HRESULT setIds(AutoCaller &aAutoCaller,
|
---|
274 | BOOL aSetImageId,
|
---|
275 | const com::Guid &aImageId,
|
---|
276 | BOOL aSetParentId,
|
---|
277 | const com::Guid &aParentId);
|
---|
278 | HRESULT refreshState(AutoCaller &aAutoCaller,
|
---|
279 | MediumState_T *aState);
|
---|
280 | HRESULT getSnapshotIds(const com::Guid &aMachineId,
|
---|
281 | std::vector<com::Guid> &aSnapshotIds);
|
---|
282 | HRESULT lockRead(ComPtr<IToken> &aToken);
|
---|
283 | HRESULT lockWrite(ComPtr<IToken> &aToken);
|
---|
284 | HRESULT close(AutoCaller &aAutoCaller);
|
---|
285 | HRESULT getProperty(const com::Utf8Str &aName,
|
---|
286 | com::Utf8Str &aValue);
|
---|
287 | HRESULT setProperty(const com::Utf8Str &aName,
|
---|
288 | const com::Utf8Str &aValue);
|
---|
289 | HRESULT getProperties(const com::Utf8Str &aNames,
|
---|
290 | std::vector<com::Utf8Str> &aReturnNames,
|
---|
291 | std::vector<com::Utf8Str> &aReturnValues);
|
---|
292 | HRESULT setProperties(const std::vector<com::Utf8Str> &aNames,
|
---|
293 | const std::vector<com::Utf8Str> &aValues);
|
---|
294 | HRESULT createBaseStorage(LONG64 aLogicalSize,
|
---|
295 | const std::vector<MediumVariant_T> &aVariant,
|
---|
296 | ComPtr<IProgress> &aProgress);
|
---|
297 | HRESULT deleteStorage(ComPtr<IProgress> &aProgress);
|
---|
298 | HRESULT createDiffStorage(AutoCaller &autoCaller,
|
---|
299 | const ComPtr<IMedium> &aTarget,
|
---|
300 | const std::vector<MediumVariant_T> &aVariant,
|
---|
301 | ComPtr<IProgress> &aProgress);
|
---|
302 | HRESULT mergeTo(const ComPtr<IMedium> &aTarget,
|
---|
303 | ComPtr<IProgress> &aProgress);
|
---|
304 | HRESULT cloneTo(const ComPtr<IMedium> &aTarget,
|
---|
305 | const std::vector<MediumVariant_T> &aVariant,
|
---|
306 | const ComPtr<IMedium> &aParent,
|
---|
307 | ComPtr<IProgress> &aProgress);
|
---|
308 | HRESULT cloneToBase(const ComPtr<IMedium> &aTarget,
|
---|
309 | const std::vector<MediumVariant_T> &aVariant,
|
---|
310 | ComPtr<IProgress> &aProgress);
|
---|
311 | HRESULT moveTo(AutoCaller &autoCaller,
|
---|
312 | const com::Utf8Str &aLocation,
|
---|
313 | ComPtr<IProgress> &aProgress);
|
---|
314 | HRESULT compact(ComPtr<IProgress> &aProgress);
|
---|
315 | HRESULT resize(LONG64 aLogicalSize,
|
---|
316 | ComPtr<IProgress> &aProgress);
|
---|
317 | HRESULT reset(AutoCaller &autoCaller, ComPtr<IProgress> &aProgress);
|
---|
318 | HRESULT changeEncryption(const com::Utf8Str &aCurrentPassword, const com::Utf8Str &aCipher,
|
---|
319 | const com::Utf8Str &aNewPassword, const com::Utf8Str &aNewPasswordId,
|
---|
320 | ComPtr<IProgress> &aProgress);
|
---|
321 | HRESULT getEncryptionSettings(AutoCaller &autoCaller, com::Utf8Str &aCipher, com::Utf8Str &aPasswordId);
|
---|
322 | HRESULT checkEncryptionPassword(const com::Utf8Str &aPassword);
|
---|
323 | HRESULT openForIO(BOOL aWritable, com::Utf8Str const &aPassword, ComPtr<IMediumIO> &aMediumIO);
|
---|
324 |
|
---|
325 | // Private internal nmethods
|
---|
326 | HRESULT i_queryInfo(bool fSetImageId, bool fSetParentId, AutoCaller &autoCaller);
|
---|
327 | HRESULT i_canClose();
|
---|
328 | HRESULT i_unregisterWithVirtualBox();
|
---|
329 | HRESULT i_setStateError();
|
---|
330 | HRESULT i_setLocation(const Utf8Str &aLocation, const Utf8Str &aFormat = Utf8Str::Empty);
|
---|
331 | HRESULT i_setFormat(const Utf8Str &aFormat);
|
---|
332 | VDTYPE i_convertDeviceType();
|
---|
333 | DeviceType_T i_convertToDeviceType(VDTYPE enmType);
|
---|
334 | Utf8Str i_vdError(int aVRC);
|
---|
335 |
|
---|
336 | bool i_isPropertyForFilter(const com::Utf8Str &aName);
|
---|
337 |
|
---|
338 | HRESULT i_getFilterProperties(std::vector<com::Utf8Str> &aReturnNames,
|
---|
339 | std::vector<com::Utf8Str> &aReturnValues);
|
---|
340 |
|
---|
341 | HRESULT i_preparationForMoving(const Utf8Str &aLocation);
|
---|
342 | bool i_isMoveOperation(const ComObjPtr<Medium> &pTarget) const;
|
---|
343 | bool i_resetMoveOperationData();
|
---|
344 | Utf8Str i_getNewLocationForMoving() const;
|
---|
345 |
|
---|
346 | static DECLCALLBACK(void) i_vdErrorCall(void *pvUser, int rc, RT_SRC_POS_DECL,
|
---|
347 | const char *pszFormat, va_list va);
|
---|
348 | static DECLCALLBACK(bool) i_vdConfigAreKeysValid(void *pvUser,
|
---|
349 | const char *pszzValid);
|
---|
350 | static DECLCALLBACK(int) i_vdConfigQuerySize(void *pvUser, const char *pszName,
|
---|
351 | size_t *pcbValue);
|
---|
352 | static DECLCALLBACK(int) i_vdConfigQuery(void *pvUser, const char *pszName,
|
---|
353 | char *pszValue, size_t cchValue);
|
---|
354 | static DECLCALLBACK(int) i_vdTcpSocketCreate(uint32_t fFlags, PVDSOCKET pSock);
|
---|
355 | static DECLCALLBACK(int) i_vdTcpSocketDestroy(VDSOCKET Sock);
|
---|
356 | static DECLCALLBACK(int) i_vdTcpClientConnect(VDSOCKET Sock, const char *pszAddress, uint32_t uPort,
|
---|
357 | RTMSINTERVAL cMillies);
|
---|
358 | static DECLCALLBACK(int) i_vdTcpClientClose(VDSOCKET Sock);
|
---|
359 | static DECLCALLBACK(bool) i_vdTcpIsClientConnected(VDSOCKET Sock);
|
---|
360 | static DECLCALLBACK(int) i_vdTcpSelectOne(VDSOCKET Sock, RTMSINTERVAL cMillies);
|
---|
361 | static DECLCALLBACK(int) i_vdTcpRead(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead);
|
---|
362 | static DECLCALLBACK(int) i_vdTcpWrite(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer);
|
---|
363 | static DECLCALLBACK(int) i_vdTcpSgWrite(VDSOCKET Sock, PCRTSGBUF pSgBuf);
|
---|
364 | static DECLCALLBACK(int) i_vdTcpFlush(VDSOCKET Sock);
|
---|
365 | static DECLCALLBACK(int) i_vdTcpSetSendCoalescing(VDSOCKET Sock, bool fEnable);
|
---|
366 | static DECLCALLBACK(int) i_vdTcpGetLocalAddress(VDSOCKET Sock, PRTNETADDR pAddr);
|
---|
367 | static DECLCALLBACK(int) i_vdTcpGetPeerAddress(VDSOCKET Sock, PRTNETADDR pAddr);
|
---|
368 |
|
---|
369 | static DECLCALLBACK(bool) i_vdCryptoConfigAreKeysValid(void *pvUser,
|
---|
370 | const char *pszzValid);
|
---|
371 | static DECLCALLBACK(int) i_vdCryptoConfigQuerySize(void *pvUser, const char *pszName,
|
---|
372 | size_t *pcbValue);
|
---|
373 | static DECLCALLBACK(int) i_vdCryptoConfigQuery(void *pvUser, const char *pszName,
|
---|
374 | char *pszValue, size_t cchValue);
|
---|
375 |
|
---|
376 | static DECLCALLBACK(int) i_vdCryptoKeyRetain(void *pvUser, const char *pszId,
|
---|
377 | const uint8_t **ppbKey, size_t *pcbKey);
|
---|
378 | static DECLCALLBACK(int) i_vdCryptoKeyRelease(void *pvUser, const char *pszId);
|
---|
379 | static DECLCALLBACK(int) i_vdCryptoKeyStorePasswordRetain(void *pvUser, const char *pszId, const char **ppszPassword);
|
---|
380 | static DECLCALLBACK(int) i_vdCryptoKeyStorePasswordRelease(void *pvUser, const char *pszId);
|
---|
381 | static DECLCALLBACK(int) i_vdCryptoKeyStoreSave(void *pvUser, const void *pvKeyStore, size_t cbKeyStore);
|
---|
382 | static DECLCALLBACK(int) i_vdCryptoKeyStoreReturnParameters(void *pvUser, const char *pszCipher,
|
---|
383 | const uint8_t *pbDek, size_t cbDek);
|
---|
384 |
|
---|
385 | class Task;
|
---|
386 | class CreateBaseTask;
|
---|
387 | class CreateDiffTask;
|
---|
388 | class CloneTask;
|
---|
389 | class MoveTask;
|
---|
390 | class CompactTask;
|
---|
391 | class ResizeTask;
|
---|
392 | class ResetTask;
|
---|
393 | class DeleteTask;
|
---|
394 | class MergeTask;
|
---|
395 | class ImportTask;
|
---|
396 | class EncryptTask;
|
---|
397 | friend class Task;
|
---|
398 | friend class CreateBaseTask;
|
---|
399 | friend class CreateDiffTask;
|
---|
400 | friend class CloneTask;
|
---|
401 | friend class MoveTask;
|
---|
402 | friend class CompactTask;
|
---|
403 | friend class ResizeTask;
|
---|
404 | friend class ResetTask;
|
---|
405 | friend class DeleteTask;
|
---|
406 | friend class MergeTask;
|
---|
407 | friend class ImportTask;
|
---|
408 | friend class EncryptTask;
|
---|
409 |
|
---|
410 | HRESULT i_taskCreateBaseHandler(Medium::CreateBaseTask &task);
|
---|
411 | HRESULT i_taskCreateDiffHandler(Medium::CreateDiffTask &task);
|
---|
412 | HRESULT i_taskMergeHandler(Medium::MergeTask &task);
|
---|
413 | HRESULT i_taskCloneHandler(Medium::CloneTask &task);
|
---|
414 | HRESULT i_taskMoveHandler(Medium::MoveTask &task);
|
---|
415 | HRESULT i_taskDeleteHandler(Medium::DeleteTask &task);
|
---|
416 | HRESULT i_taskResetHandler(Medium::ResetTask &task);
|
---|
417 | HRESULT i_taskCompactHandler(Medium::CompactTask &task);
|
---|
418 | HRESULT i_taskResizeHandler(Medium::ResizeTask &task);
|
---|
419 | HRESULT i_taskImportHandler(Medium::ImportTask &task);
|
---|
420 | HRESULT i_taskEncryptHandler(Medium::EncryptTask &task);
|
---|
421 |
|
---|
422 | void i_taskEncryptSettingsSetup(struct MediumCryptoFilterSettings *pSettings, const char *pszCipher,
|
---|
423 | const char *pszKeyStore, const char *pszPassword,
|
---|
424 | bool fCreateKeyStore);
|
---|
425 |
|
---|
426 | struct Data; // opaque data struct, defined in MediumImpl.cpp
|
---|
427 | Data *m;
|
---|
428 | };
|
---|
429 |
|
---|
430 |
|
---|
431 | /**
|
---|
432 | * Settings for a crypto filter instance.
|
---|
433 | */
|
---|
434 | struct MediumCryptoFilterSettings
|
---|
435 | {
|
---|
436 | MediumCryptoFilterSettings()
|
---|
437 | : fCreateKeyStore(false),
|
---|
438 | pszPassword(NULL),
|
---|
439 | pszKeyStore(NULL),
|
---|
440 | pszKeyStoreLoad(NULL),
|
---|
441 | pbDek(NULL),
|
---|
442 | cbDek(0),
|
---|
443 | pszCipher(NULL),
|
---|
444 | pszCipherReturned(NULL)
|
---|
445 | { }
|
---|
446 |
|
---|
447 | bool fCreateKeyStore;
|
---|
448 | const char *pszPassword;
|
---|
449 | char *pszKeyStore;
|
---|
450 | const char *pszKeyStoreLoad;
|
---|
451 |
|
---|
452 | const uint8_t *pbDek;
|
---|
453 | size_t cbDek;
|
---|
454 | const char *pszCipher;
|
---|
455 |
|
---|
456 | /** The cipher returned by the crypto filter. */
|
---|
457 | char *pszCipherReturned;
|
---|
458 |
|
---|
459 | PVDINTERFACE vdFilterIfaces;
|
---|
460 |
|
---|
461 | VDINTERFACECONFIG vdIfCfg;
|
---|
462 | VDINTERFACECRYPTO vdIfCrypto;
|
---|
463 | };
|
---|
464 |
|
---|
465 |
|
---|
466 |
|
---|
467 | #endif /* !MAIN_INCLUDED_MediumImpl_h */
|
---|
468 |
|
---|