From: Andreas Reichel <[email protected]> Give the user a chance to override kernel arguments. EBG waits for 3 seconds and checks if user pressed the <a> key. This can help in unbricking a system.
Signed-off-by: Andreas Reichel <[email protected]> --- main.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 0d5f14b..f0fcaff 100644 --- a/main.c +++ b/main.c @@ -21,6 +21,7 @@ #include <bootguard.h> #include <configuration.h> #include "version.h" +#include "envdata.h" #include "color.h" extern const unsigned long init_array_start[]; @@ -108,6 +109,8 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) BG_STATUS bg_status; BG_LOADER_PARAMS bg_loader_params; CHAR16 *tmp; + EFI_INPUT_KEY key; + CHAR16 input_buffer[ENV_STRING_LENGTH]; ZeroMem(&bg_loader_params, sizeof(bg_loader_params)); @@ -198,11 +201,31 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) status); } + /* Give user a chance to change the boot parameters on the fly */ + Color(system_table, 15, 0); + Print(L"Press <a> to change kernel arguments\n"); + Color(system_table, 7, 0); + + /* Wait for key for 3 seconds */ + WaitForSingleEvent(system_table->ConIn->WaitForKey, 30000000); + + input_buffer[0] = L'\0'; + if (uefi_call_wrapper(system_table->ConIn->ReadKeyStroke, + 2, system_table->ConIn, &key) == EFI_SUCCESS) { + if (key.UnicodeChar == L'a') { + Input(L"\nInput kernel args (empty str to cancel): ", + input_buffer, ENV_STRING_LENGTH - 1); + } + } + if (StrLen(input_buffer) > 0) { + StrCpy(bg_loader_params.payload_options, input_buffer); + } + loaded_image->LoadOptions = bg_loader_params.payload_options; loaded_image->LoadOptionsSize = (StrLen(bg_loader_params.payload_options) + 1) * sizeof(CHAR16); - Print(L"Starting %s with watchdog set to %d seconds\n", + Print(L"\nStarting %s with watchdog set to %d seconds\n", bg_loader_params.payload_path, bg_loader_params.timeout); return uefi_call_wrapper(BS->StartImage, 3, payload_handle, 0, 0); -- 2.19.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20181025134409.1446-3-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
