VirtualBox

source: vbox/trunk/src/VBox/Main/include/ExtPackManagerImpl.h@ 94751

Last change on this file since 94751 was 94714, checked in by vboxsync, 3 years ago

Main,Settings: Integrate the extension pack cryptographic module in the ExtPack manager etc., bugref:9955

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.0 KB
Line 
1/* $Id: ExtPackManagerImpl.h 94714 2022-04-27 07:41:12Z vboxsync $ */
2/** @file
3 * VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
4 */
5
6/*
7 * Copyright (C) 2010-2022 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_ExtPackManagerImpl_h
19#define MAIN_INCLUDED_ExtPackManagerImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "VirtualBoxBase.h"
25#include <VBox/ExtPack/ExtPack.h>
26#include "ExtPackWrap.h"
27#include "ExtPackFileWrap.h"
28#include "ExtPackManagerWrap.h"
29#include <iprt/fs.h>
30
31
32/** The name of the oracle extension back. */
33#define ORACLE_PUEL_EXTPACK_NAME "Oracle VM VirtualBox Extension Pack"
34
35
36#ifndef VBOX_COM_INPROC
37/**
38 * An extension pack file.
39 */
40class ATL_NO_VTABLE ExtPackFile :
41 public ExtPackFileWrap
42{
43public:
44 /** @name COM and internal init/term/mapping cruft.
45 * @{ */
46 DECLARE_COMMON_CLASS_METHODS(ExtPackFile)
47
48 HRESULT FinalConstruct();
49 void FinalRelease();
50 HRESULT initWithFile(const char *a_pszFile, const char *a_pszDigest, class ExtPackManager *a_pExtPackMgr, VirtualBox *a_pVirtualBox);
51 void uninit();
52 /** @} */
53
54private:
55 /** @name Misc init helpers
56 * @{ */
57 HRESULT initFailed(const char *a_pszWhyFmt, ...);
58 /** @} */
59
60private:
61
62 // wrapped IExtPackFile properties
63 HRESULT getName(com::Utf8Str &aName);
64 HRESULT getDescription(com::Utf8Str &aDescription);
65 HRESULT getVersion(com::Utf8Str &aVersion);
66 HRESULT getRevision(ULONG *aRevision);
67 HRESULT getEdition(com::Utf8Str &aEdition);
68 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
69 HRESULT getCryptoModule(com::Utf8Str &aCryptoModule);
70 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
71 HRESULT getUsable(BOOL *aUsable);
72 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
73 HRESULT getShowLicense(BOOL *aShowLicense);
74 HRESULT getLicense(com::Utf8Str &aLicense);
75 HRESULT getFilePath(com::Utf8Str &aFilePath);
76
77 // wrapped IExtPackFile methods
78 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
79 const com::Utf8Str &aPreferredLanguage,
80 const com::Utf8Str &aFormat,
81 com::Utf8Str &aLicenseText);
82 HRESULT install(BOOL aReplace,
83 const com::Utf8Str &aDisplayInfo,
84 ComPtr<IProgress> &aProgess);
85
86 struct Data;
87 /** Pointer to the private instance. */
88 Data *m;
89
90 friend class ExtPackManager;
91 friend class ExtPackInstallTask;
92};
93#endif /* !VBOX_COM_INPROC */
94
95
96/**
97 * An installed extension pack.
98 */
99class ATL_NO_VTABLE ExtPack :
100 public ExtPackWrap
101{
102public:
103 /** @name COM and internal init/term/mapping cruft.
104 * @{ */
105 DECLARE_COMMON_CLASS_METHODS(ExtPack)
106
107 HRESULT FinalConstruct();
108 void FinalRelease();
109 HRESULT initWithDir(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
110 void uninit();
111 RTMEMEF_NEW_AND_DELETE_OPERATORS();
112 /** @} */
113
114 /** @name Internal interfaces used by ExtPackManager.
115 * @{ */
116#ifndef VBOX_COM_INPROC
117 bool i_callInstalledHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock, PRTERRINFO pErrInfo);
118 HRESULT i_callUninstallHookAndClose(IVirtualBox *a_pVirtualBox, bool a_fForcedRemoval);
119 bool i_callVirtualBoxReadyHook(IVirtualBox *a_pVirtualBox, AutoWriteLock *a_pLock);
120#endif
121#ifdef VBOX_COM_INPROC
122 bool i_callConsoleReadyHook(IConsole *a_pConsole, AutoWriteLock *a_pLock);
123#endif
124#ifndef VBOX_COM_INPROC
125 bool i_callVmCreatedHook(IVirtualBox *a_pVirtualBox, IMachine *a_pMachine, AutoWriteLock *a_pLock);
126#endif
127#ifdef VBOX_COM_INPROC
128 bool i_callVmConfigureVmmHook(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM,
129 AutoWriteLock *a_pLock, int *a_pvrc);
130 bool i_callVmPowerOnHook(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM, AutoWriteLock *a_pLock, int *a_pvrc);
131 bool i_callVmPowerOffHook(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM, AutoWriteLock *a_pLock);
132#endif
133 HRESULT i_checkVrde(void);
134 HRESULT i_checkCrypto(void);
135 HRESULT i_getVrdpLibraryName(Utf8Str *a_pstrVrdeLibrary);
136 HRESULT i_getCryptoLibraryName(Utf8Str *a_pstrCryptoLibrary);
137 HRESULT i_getLibraryName(const char *a_pszModuleName, Utf8Str *a_pstrLibrary);
138 bool i_wantsToBeDefaultVrde(void) const;
139 bool i_wantsToBeDefaultCrypto(void) const;
140 HRESULT i_refresh(bool *pfCanDelete);
141#ifndef VBOX_COM_INPROC
142 bool i_areThereCloudProviderUninstallVetos();
143 void i_notifyCloudProviderManager();
144#endif
145 /** @} */
146
147protected:
148 /** @name Internal helper methods.
149 * @{ */
150 void i_probeAndLoad(void);
151 bool i_findModule(const char *a_pszName, const char *a_pszExt, VBOXEXTPACKMODKIND a_enmKind,
152 Utf8Str *a_ppStrFound, bool *a_pfNative, PRTFSOBJINFO a_pObjInfo) const;
153 static bool i_objinfoIsEqual(PCRTFSOBJINFO pObjInfo1, PCRTFSOBJINFO pObjInfo2);
154 /** @} */
155
156 /** @name Extension Pack Helpers
157 * @{ */
158 static DECLCALLBACK(int) i_hlpFindModule(PCVBOXEXTPACKHLP pHlp, const char *pszName, const char *pszExt,
159 VBOXEXTPACKMODKIND enmKind, char *pszFound, size_t cbFound, bool *pfNative);
160 static DECLCALLBACK(int) i_hlpGetFilePath(PCVBOXEXTPACKHLP pHlp, const char *pszFilename, char *pszPath, size_t cbPath);
161 static DECLCALLBACK(VBOXEXTPACKCTX) i_hlpGetContext(PCVBOXEXTPACKHLP pHlp);
162 static DECLCALLBACK(int) i_hlpLoadHGCMService(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IConsole) *pConsole, const char *pszServiceLibrary, const char *pszServiceName);
163 static DECLCALLBACK(int) i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
164 static DECLCALLBACK(int) i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary);
165 static DECLCALLBACK(uint32_t) i_hlpCreateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator,
166 const char *pcszDescription, uint32_t cOperations,
167 uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription,
168 uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut);
169 static DECLCALLBACK(uint32_t) i_hlpGetCanceledProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
170 bool *pfCanceled);
171 static DECLCALLBACK(uint32_t) i_hlpUpdateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
172 uint32_t uPercent);
173 static DECLCALLBACK(uint32_t) i_hlpNextOperationProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
174 const char *pcszNextOperationDescription,
175 uint32_t uNextOperationWeight);
176 static DECLCALLBACK(uint32_t) i_hlpWaitOtherProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
177 VBOXEXTPACK_IF_CS(IProgress) *pProgressOther,
178 uint32_t cTimeoutMS);
179 static DECLCALLBACK(uint32_t) i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress,
180 uint32_t uResultCode);
181 static DECLCALLBACK(uint32_t) i_hlpCreateEvent(PCVBOXEXTPACKHLP pHlp,
182 VBOXEXTPACK_IF_CS(IEventSource) *aSource,
183 /* VBoxEventType_T */ uint32_t aType, bool aWaitable,
184 VBOXEXTPACK_IF_CS(IEvent) **ppEventOut);
185 static DECLCALLBACK(uint32_t) i_hlpCreateVetoEvent(PCVBOXEXTPACKHLP pHlp,
186 VBOXEXTPACK_IF_CS(IEventSource) *aSource,
187 /* VBoxEventType_T */ uint32_t aType,
188 VBOXEXTPACK_IF_CS(IVetoEvent) **ppEventOut);
189 static DECLCALLBACK(const char *) i_hlpTranslate(PCVBOXEXTPACKHLP pHlp,
190 const char *pszComponent,
191 const char *pszSourceText,
192 const char *pszComment = NULL,
193 const size_t aNum = ~(size_t)0);
194 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp);
195 /** @} */
196
197private:
198
199 // wrapped IExtPack properties
200 HRESULT getName(com::Utf8Str &aName);
201 HRESULT getDescription(com::Utf8Str &aDescription);
202 HRESULT getVersion(com::Utf8Str &aVersion);
203 HRESULT getRevision(ULONG *aRevision);
204 HRESULT getEdition(com::Utf8Str &aEdition);
205 HRESULT getVRDEModule(com::Utf8Str &aVRDEModule);
206 HRESULT getCryptoModule(com::Utf8Str &aCryptoModule);
207 HRESULT getPlugIns(std::vector<ComPtr<IExtPackPlugIn> > &aPlugIns);
208 HRESULT getUsable(BOOL *aUsable);
209 HRESULT getWhyUnusable(com::Utf8Str &aWhyUnusable);
210 HRESULT getShowLicense(BOOL *aShowLicense);
211 HRESULT getLicense(com::Utf8Str &aLicense);
212
213 // wrapped IExtPack methods
214 HRESULT queryLicense(const com::Utf8Str &aPreferredLocale,
215 const com::Utf8Str &aPreferredLanguage,
216 const com::Utf8Str &aFormat,
217 com::Utf8Str &aLicenseText);
218 HRESULT queryObject(const com::Utf8Str &aObjUuid,
219 ComPtr<IUnknown> &aReturnInterface);
220
221
222 struct Data;
223 /** Pointer to the private instance. */
224 Data *m;
225
226 friend class ExtPackManager;
227};
228
229
230/**
231 * Extension pack manager.
232 */
233class ATL_NO_VTABLE ExtPackManager :
234 public ExtPackManagerWrap
235{
236public:
237 /** @name COM and internal init/term/mapping cruft.
238 * @{ */
239 DECLARE_COMMON_CLASS_METHODS(ExtPackManager)
240
241 HRESULT FinalConstruct();
242 void FinalRelease();
243 HRESULT initExtPackManager(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext);
244 void uninit();
245 /** @} */
246
247 /** @name Internal interfaces used by other Main classes.
248 * @{ */
249#ifndef VBOX_COM_INPROC
250 HRESULT i_doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo);
251 HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
252 void i_callAllVirtualBoxReadyHooks(void);
253 HRESULT i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
254#endif
255#ifdef VBOX_COM_INPROC
256 void i_callAllConsoleReadyHooks(IConsole *a_pConsole);
257#endif
258#ifndef VBOX_COM_INPROC
259 void i_callAllVmCreatedHooks(IMachine *a_pMachine);
260#endif
261#ifdef VBOX_COM_INPROC
262 int i_callAllVmConfigureVmmHooks(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM);
263 int i_callAllVmPowerOnHooks(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM);
264 void i_callAllVmPowerOffHooks(IConsole *a_pConsole, PVM a_pVM, PCVMMR3VTABLE a_pVMM);
265#endif
266 HRESULT i_checkVrdeExtPack(Utf8Str const *a_pstrExtPack);
267 int i_getVrdeLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
268 HRESULT i_checkCryptoExtPack(Utf8Str const *a_pstrExtPack);
269 int i_getCryptoLibraryPathForExtPack(Utf8Str const *a_pstrExtPack, Utf8Str *a_pstrVrdeLibrary);
270 HRESULT i_getLibraryPathForExtPack(const char *a_pszModuleName, const char *a_pszExtPack, Utf8Str *a_pstrLibrary);
271 HRESULT i_getDefaultVrdeExtPack(Utf8Str *a_pstrExtPack);
272 HRESULT i_getDefaultCryptoExtPack(Utf8Str *a_pstrExtPack);
273 bool i_isExtPackUsable(const char *a_pszExtPack);
274 void i_dumpAllToReleaseLog(void);
275 uint64_t i_getUpdateCounter(void);
276 /** @} */
277
278private:
279 // wrapped IExtPackManager properties
280 HRESULT getInstalledExtPacks(std::vector<ComPtr<IExtPack> > &aInstalledExtPacks);
281
282 // wrapped IExtPackManager methods
283 HRESULT find(const com::Utf8Str &aName,
284 ComPtr<IExtPack> &aReturnData);
285 HRESULT openExtPackFile(const com::Utf8Str &aPath,
286 ComPtr<IExtPackFile> &aFile);
287 HRESULT uninstall(const com::Utf8Str &aName,
288 BOOL aForcedRemoval,
289 const com::Utf8Str &aDisplayInfo,
290 ComPtr<IProgress> &aProgess);
291 HRESULT cleanup();
292 HRESULT queryAllPlugInsForFrontend(const com::Utf8Str &aFrontendName,
293 std::vector<com::Utf8Str> &aPlugInModules);
294 HRESULT isExtPackUsable(const com::Utf8Str &aName,
295 BOOL *aUsable);
296
297 bool i_areThereAnyRunningVMs(void) const;
298 HRESULT i_runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
299 ExtPack *i_findExtPack(const char *a_pszName);
300 void i_removeExtPack(const char *a_pszName);
301 HRESULT i_refreshExtPack(const char *a_pszName, bool a_fUnsuableIsError, ExtPack **a_ppExtPack);
302
303private:
304 struct Data;
305 /** Pointer to the private instance. */
306 Data *m;
307
308 friend class ExtPackUninstallTask;
309};
310
311#endif /* !MAIN_INCLUDED_ExtPackManagerImpl_h */
312/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette