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