VirtualBox

source: vbox/trunk/src/VBox/Main/include/UefiVariableStoreImpl.h@ 91535

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

Main/{NvramStore,UefiVariableStore}: Always retain/releas the variable store reference in every externally accessible API to make sure the variable store is flushed to the NVRAM when saving avoiding data loss, bugref:9580

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UefiVariableStoreImpl.h 91535 2021-10-04 09:15:19Z vboxsync $ */
2/** @file
3 * VirtualBox COM UEFI variable store class implementation
4 */
5
6/*
7 * Copyright (C) 2021 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_UefiVariableStoreImpl_h
19#define MAIN_INCLUDED_UefiVariableStoreImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "UefiVariableStoreWrap.h"
25#include <iprt/types.h>
26
27#include <iprt/formats/efi-common.h>
28
29class NvramStore;
30class Machine;
31
32class ATL_NO_VTABLE UefiVariableStore :
33 public UefiVariableStoreWrap
34{
35public:
36
37 DECLARE_COMMON_CLASS_METHODS(UefiVariableStore)
38
39 HRESULT FinalConstruct();
40 void FinalRelease();
41
42 // public initializer/uninitializer for internal purposes only
43 HRESULT init(NvramStore *aParent, Machine *pMachine);
44 void uninit();
45
46 // public methods for internal purposes only
47
48private:
49
50 // Wrapped NVRAM store properties
51 HRESULT getSecureBootEnabled(BOOL *pfEnabled);
52 HRESULT setSecureBootEnabled(BOOL fEnabled);
53
54 // Wrapped NVRAM store members
55 HRESULT addVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, const std::vector<UefiVariableAttributes_T> &aAttributes,
56 const std::vector<BYTE> &aData);
57 HRESULT deleteVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid);
58 HRESULT changeVariable(const com::Utf8Str &aName, const std::vector<BYTE> &aData);
59 HRESULT queryVariableByName(const com::Utf8Str &aName, com::Guid &aOwnerUuid, std::vector<UefiVariableAttributes_T> &aAttributes,
60 std::vector<BYTE> &aData);
61 HRESULT queryVariables(std::vector<com::Utf8Str> &aNames, std::vector<com::Guid> &aOwnerUuids);
62 HRESULT enrollOraclePlatformKey(void);
63 HRESULT enrollPlatformKey(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid);
64 HRESULT addKek(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
65 HRESULT addSignatureToDb(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
66 HRESULT addSignatureToDbx(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
67 HRESULT enrollDefaultMsSignatures(void);
68
69 int i_uefiVarStoreSetVarAttr(const char *pszVar, uint32_t fAttr);
70 int i_uefiVarStoreQueryVarAttr(const char *pszVar, uint32_t *pfAttr);
71 int i_uefiVarStoreQueryVarSz(const char *pszVar, uint64_t *pcbVar);
72 int i_uefiVarStoreQueryVarOwnerUuid(const char *pszVar, PRTUUID pUuid);
73 uint32_t i_uefiVarAttrToMask(const std::vector<UefiVariableAttributes_T> &aAttributes);
74 void i_uefiAttrMaskToVec(uint32_t fAttr, std::vector<UefiVariableAttributes_T> &aAttributes);
75
76 HRESULT i_retainUefiVariableStore(bool fReadonly);
77 HRESULT i_releaseUefiVariableStore(void);
78
79 HRESULT i_uefiVarStoreAddVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, PRTVFSFILE phVfsFile);
80 HRESULT i_uefiVarStoreSetVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, const void *pvData, size_t cbData);
81 HRESULT i_uefiVarStoreQueryVar(const char *pszVar, void *pvData, size_t cbData);
82 HRESULT i_uefiSigDbAddSig(RTEFISIGDB hEfiSigDb, const void *pvData, size_t cbData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
83 HRESULT i_uefiVarStoreAddSignatureToDbVec(PCEFI_GUID pGuid, const char *pszDb, const std::vector<BYTE> &aData,
84 const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
85 HRESULT i_uefiVarStoreAddSignatureToDb(PCEFI_GUID pGuid, const char *pszDb, const void *pvData, size_t cbData,
86 const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
87
88 struct Data; // opaque data struct, defined in UefiVariableStoreImpl.cpp
89 Data *m;
90};
91
92#endif /* !MAIN_INCLUDED_UefiVariableStoreImpl_h */
93/* 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