VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/DcsBml
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2017-06-14 12:49:40 +0300
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-06-18 15:52:10 +0200
commitaede42a840cc6e3509048182eb204b5ce8f3187c (patch)
tree49623debea5bda47325e71850a32506209ab9aec /DcsBml
parent37c62bedd36ae255a036fb9e77f529a1021abb9a (diff)
downloadVeraCrypt-DCS-aede42a840cc6e3509048182eb204b5ce8f3187c.tar.gz
VeraCrypt-DCS-aede42a840cc6e3509048182eb204b5ce8f3187c.zip
BML update to sort "BootOrder"
Diffstat (limited to 'DcsBml')
-rw-r--r--DcsBml/DcsBml.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/DcsBml/DcsBml.c b/DcsBml/DcsBml.c
index f5aaf3a..3a5406f 100644
--- a/DcsBml/DcsBml.c
+++ b/DcsBml/DcsBml.c
@@ -33,7 +33,7 @@ typedef struct _BML_GLOBALS {
} BML_GLOBALS, *PBML_GLOBALS;
STATIC PBML_GLOBALS gBmlData = NULL;
-STATIC BOOLEAN BootMenuLocked = FALSE;
+STATIC BOOLEAN BootMenuLocked = TRUE;
EFI_EVENT mBmlVirtualAddrChangeEvent;
EFI_SET_VARIABLE orgSetVariable = NULL;
@@ -138,6 +138,32 @@ DcsBmlUnload(
return EFI_SUCCESS;
}
+//////////////////////////////////////////////////////////////////////////
+// Boot order
+//////////////////////////////////////////////////////////////////////////
+EFI_STATUS
+UpdateBootOrder()
+{
+ EFI_STATUS res;
+ UINT16 DcsBootNum = 0x0DC5B;
+ UINTN boIndex = 1;
+ UINTN len;
+ UINT32 attr;
+ CHAR16* tmp = NULL;
+ res = EfiGetVar(L"BootDC5B", &gEfiGlobalVariableGuid, &tmp, &len, &attr);
+ if (EFI_ERROR(res)) {
+ InitFS();
+ res = BootMenuItemCreate(L"BootDC5B", sDcsBootEfiDesc, gFileRootHandle, sDcsBootEfi, TRUE);
+ res = BootOrderInsert(L"BootOrder", 0, 0x0DC5B);
+ } else {
+ if (EFI_ERROR(BootOrderPresent(L"BootOrder", 0x0DC5B, &boIndex) || boIndex != 0)) {
+ res = BootOrderInsert(L"BootOrder", 0, 0x0DC5B);
+ }
+ }
+ res = EfiSetVar(L"BootNext", &gEfiGlobalVariableGuid, &DcsBootNum, sizeof(DcsBootNum), EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS);
+ MEM_FREE(tmp);
+ return res;
+}
/**
The actual entry point for the application.
@@ -173,7 +199,7 @@ DcsBmlMain(
ASSERT_EFI_ERROR(res);
if (EFI_ERROR(res)) {
- Print(L"Install protocol %r\n", res);
+ ERR_PRINT(L"Install protocol %r\n", res);
return res;
}
@@ -185,7 +211,7 @@ DcsBmlMain(
);
if (EFI_ERROR(res)) {
- Print(L"Allocate runtime globals %r\n", res);
+ ERR_PRINT(L"Allocate runtime globals %r\n", res);
return res;
}
@@ -202,29 +228,15 @@ DcsBmlMain(
);
if (EFI_ERROR(res)) {
- Print(L"Register notify %r\n", res);
+ ERR_PRINT(L"Register notify %r\n", res);
return res;
}
+ UpdateBootOrder();
+
orgSetVariable = gST->RuntimeServices->SetVariable;
gST->RuntimeServices->SetVariable = BmlSetVaribale;
- // select boot next
- {
- UINT16 DcsBootNum = 0x0DC5B;
- UINTN len;
- UINT32 attr;
- CHAR16* tmp = NULL;
- res = EfiGetVar(L"BootDC5B", &gEfiGlobalVariableGuid, &tmp, &len, &attr);
- if (EFI_ERROR(res)) {
- InitFS();
- res = BootMenuItemCreate(L"BootDC5B", sDcsBootEfiDesc, gFileRootHandle, sDcsBootEfi, TRUE);
- res = BootOrderInsert(L"BootOrder", 0, 0x0DC5B);
- }
- res = EfiSetVar(L"BootNext", &gEfiGlobalVariableGuid, &DcsBootNum, sizeof(DcsBootNum), EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS);
- MEM_FREE(tmp);
- }
-
// Prepare BootDC5B
return EFI_SUCCESS;
}