VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/Library
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2017-06-13 17:19:47 +0300
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-06-18 15:51:59 +0200
commit0ba0723c769f95d312835967c47e34e444fea368 (patch)
tree91672b6c6b8de151ddaf1ee62cd1daed781cdaad /Library
parent3058711f8b12cf11585e0eda2a1b573f0d871667 (diff)
downloadVeraCrypt-DCS-0ba0723c769f95d312835967c47e34e444fea368.tar.gz
VeraCrypt-DCS-0ba0723c769f95d312835967c47e34e444fea368.zip
solution of HP problem via DrverOrder and BML modified driver
Diffstat (limited to 'Library')
-rw-r--r--Library/CommonLib/CommonLib.inf1
-rw-r--r--Library/CommonLib/EfiBml.c57
-rw-r--r--Library/CommonLib/EfiVar.c27
3 files changed, 85 insertions, 0 deletions
diff --git a/Library/CommonLib/CommonLib.inf b/Library/CommonLib/CommonLib.inf
index dde5c61..ec658d7 100644
--- a/Library/CommonLib/CommonLib.inf
+++ b/Library/CommonLib/CommonLib.inf
@@ -39,6 +39,7 @@
EfiBluetooth.c
EfiTpm.c
GptRead.c
+ EfiBml.c
[Sources.IA32]
IA32/EfiCpuHalt.asm
diff --git a/Library/CommonLib/EfiBml.c b/Library/CommonLib/EfiBml.c
new file mode 100644
index 0000000..184ca75
--- /dev/null
+++ b/Library/CommonLib/EfiBml.c
@@ -0,0 +1,57 @@
+/** @file
+EFI DCS BML helpers routines/wrappers
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
+
+The full text of the license may be found at
+https://opensource.org/licenses/LGPL-3.0
+**/
+
+#include <Library/CommonLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/DcsBmlProto.h>
+
+//////////////////////////////////////////////////////////////////////////
+// BML
+//////////////////////////////////////////////////////////////////////////
+EFI_HANDLE* gBmlHandles = NULL;
+UINTN gBmlCount = 0;
+EFI_DCSBML_PROTOCOL* gBml = NULL;
+EFI_GUID gBmlGuid = EFI_DCSBML_INTERFACE_PROTOCOL_GUID;
+
+EFI_STATUS
+BmlSelect(
+ IN UINTN index) {
+ if (index < gBmlCount) {
+ return gBS->HandleProtocol(gBmlHandles[index], &gBmlGuid, (VOID**)&gBml);
+ }
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+InitBml() {
+ EFI_STATUS res;
+ // BML control if supported
+ res = EfiGetHandles(ByProtocol, &gBmlGuid, 0, &gBmlHandles, &gBmlCount);
+ if (gBmlCount > 0) {
+ return BmlSelect(gBmlCount - 1);
+ }
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+BmlLock(
+ IN BOOLEAN lock
+ )
+{
+ if (gBml != NULL) {
+ return gBml->BootMenuLock(gBml, lock);
+ }
+ return EFI_UNSUPPORTED;
+}
+
diff --git a/Library/CommonLib/EfiVar.c b/Library/CommonLib/EfiVar.c
index fad6eb5..e9c1082 100644
--- a/Library/CommonLib/EfiVar.c
+++ b/Library/CommonLib/EfiVar.c
@@ -146,6 +146,33 @@ BootOrderRemove(
}
EFI_STATUS
+BootOrderPresent(
+ IN CHAR16 *OrderVarName,
+ UINT16 value)
+{
+ EFI_STATUS res = EFI_NOT_READY;
+ UINT16* varBootOrder;
+ UINTN varBootOrderSize;
+ UINT32 varBootOrderAttr;
+ UINTN BootOrderCount;
+ UINTN i;
+ UINTN j;
+
+ res = EfiGetVar(OrderVarName, &gEfiGlobalVariableGuid, &varBootOrder, &varBootOrderSize, &varBootOrderAttr);
+ if (EFI_ERROR(res)) return res;
+ BootOrderCount = varBootOrderSize / sizeof(UINT16);
+ res = EFI_NOT_FOUND;
+ for (j = 0, i = 0; i < BootOrderCount; ++i) {
+ if (varBootOrder[i] == value) {
+ MEM_FREE(varBootOrder);
+ res = EFI_SUCCESS;
+ break;
+ }
+ }
+ return res;
+}
+
+EFI_STATUS
BootMenuItemRemove(
IN CHAR16 *VarName
)