VirtualBox

source: vbox/trunk/src/VBox/Main/include/NvramStoreImpl.h@ 107044

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: NvramStoreImpl.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VirtualBox COM NVRAM store class implementation
4 */
5
6/*
7 * Copyright (C) 2021-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_NvramStoreImpl_h
29#define MAIN_INCLUDED_NvramStoreImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "NvramStoreWrap.h"
35#include "SecretKeyStore.h"
36#include <VBox/vmm/pdmdrv.h>
37#include <VBox/VBoxCryptoIf.h>
38
39
40#ifdef VBOX_COM_INPROC
41class Console;
42struct DRVMAINNVRAMSTORE;
43#else
44class GuestOSType;
45
46namespace settings
47{
48 struct NvramSettings;
49}
50#endif
51
52class ATL_NO_VTABLE NvramStore :
53 public NvramStoreWrap
54{
55public:
56
57 DECLARE_COMMON_CLASS_METHODS(NvramStore)
58
59 HRESULT FinalConstruct();
60 void FinalRelease();
61
62 // public initializer/uninitializer for internal purposes only
63#ifdef VBOX_COM_INPROC
64 HRESULT init(Console *aParent, const com::Utf8Str &strNonVolatileStorageFile);
65#else
66 HRESULT init(Machine *parent);
67 HRESULT init(Machine *parent, NvramStore *that);
68 HRESULT initCopy(Machine *parent, NvramStore *that);
69#endif
70 void uninit();
71
72 // public methods for internal purposes only
73#ifndef VBOX_COM_INPROC
74 HRESULT i_loadSettings(const settings::NvramSettings &data);
75 HRESULT i_saveSettings(settings::NvramSettings &data);
76#endif
77
78#ifdef VBOX_COM_INPROC
79 static const PDMDRVREG DrvReg;
80#else
81 void i_rollback();
82 void i_commit();
83 void i_copyFrom(NvramStore *aThat);
84 HRESULT i_applyDefaults(GuestOSType *aOSType);
85#endif
86
87 int i_getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
88 com::Utf8Str i_getNonVolatileStorageFile();
89 void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile);
90
91 int i_loadStore(const char *pszPath);
92 int i_saveStore(void);
93
94#ifndef VBOX_COM_INPROC
95 HRESULT i_retainUefiVarStore(PRTVFS phVfs, bool fReadonly);
96 HRESULT i_releaseUefiVarStore(RTVFS hVfs);
97#endif
98
99#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
100 HRESULT i_updateEncryptionSettings(const com::Utf8Str &strKeyId,
101 const com::Utf8Str &strKeyStore);
102 HRESULT i_getEncryptionSettings(com::Utf8Str &strKeyId,
103 com::Utf8Str &strKeyStore);
104
105 int i_addPassword(const Utf8Str &strKeyId, const Utf8Str &strPassword);
106 int i_removePassword(const Utf8Str &strKeyId);
107 int i_removeAllPasswords();
108#endif
109
110private:
111
112 int initImpl(void);
113
114 // Wrapped NVRAM store properties
115 HRESULT getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
116 HRESULT getUefiVariableStore(ComPtr<IUefiVariableStore> &aUefiVarStore);
117 HRESULT getKeyId(com::Utf8Str &aKeyId);
118 HRESULT getKeyStore(com::Utf8Str &aKeyStore);
119
120 // Wrapped NVRAM store members
121 HRESULT initUefiVariableStore(ULONG aSize);
122
123 int i_loadStoreFromTar(RTVFSFSSTREAM hVfsFssTar);
124 int i_loadStoreFromDir(RTVFSDIR hVfsDir, const char *pszNamespace);
125 int i_saveStoreAsTar(const char *pszPath);
126 int i_saveStoreAsDir(const char *pszPath);
127
128 int i_retainCryptoIf(PCVBOXCRYPTOIF *ppCryptoIf);
129 int i_releaseCryptoIf(PCVBOXCRYPTOIF pCryptoIf);
130
131#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
132 int i_setupEncryptionOrDecryption(RTVFSIOSTREAM hVfsIosInOut, bool fEncrypt,
133 PCVBOXCRYPTOIF *ppCryptoIf, SecretKey **ppKey,
134 PRTVFSIOSTREAM phVfsIos);
135 void i_releaseEncryptionOrDecryptionResources(RTVFSIOSTREAM hVfsIos, PCVBOXCRYPTOIF pCryptoIf,
136 SecretKey *pKey);
137#endif
138
139#ifdef VBOX_COM_INPROC
140 static DECLCALLBACK(int) i_SsmSaveExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
141 static int i_SsmSaveExecInner(struct DRVMAINNVRAMSTORE *pThis, PCPDMDRVHLPR3 pHlp, PSSMHANDLE pSSM,
142 void **ppvData, size_t *pcbDataMax) RT_NOEXCEPT;
143 static DECLCALLBACK(int) i_SsmLoadExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
144 static int i_SsmLoadExecInner(struct DRVMAINNVRAMSTORE *pThis, PCPDMDRVHLPR3 pHlp, PSSMHANDLE pSSM,
145 uint32_t cEntries, void **ppvData, size_t *pcbDataMax) RT_NOEXCEPT;
146
147 static DECLCALLBACK(int) i_nvramStoreQuerySize(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
148 uint64_t *pcb);
149 static DECLCALLBACK(int) i_nvramStoreReadAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
150 void *pvBuf, size_t cbRead);
151 static DECLCALLBACK(int) i_nvramStoreWriteAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
152 const void *pvBuf, size_t cbWrite);
153 static DECLCALLBACK(int) i_nvramStoreDelete(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath);
154 static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
155 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
156 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
157#endif
158
159 struct Data; // opaque data struct, defined in NvramStoreImpl.cpp
160 Data *m;
161};
162
163#endif /* !MAIN_INCLUDED_NvramStoreImpl_h */
164/* 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