From 359253a847ecff9efca855501ec69fdb3e40d1b8 Mon Sep 17 00:00:00 2001 From: Darbin Reyes Date: Mon, 25 Nov 2024 14:13:16 -0800 Subject: [PATCH] Pkg-Module: Features/VirtualKeyboardDxe The Keyboard.c driver did not include ScanCodes like F1,F2,F12,etc. and UnicodeChars like Backspace, Tab in VK_NOTIFY NotifyList which is why these keys were not getting registered and not getting pushed in the KeyBuffer stack which resulted in undefined behavior of continuous backspace and not recognizing the relevant key push after the buffer overflow condition Signed-off-by: Contributor Name --- .../VirtualKeyboardDxe/Keyboard.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Features/Intel/UserInterface/VirtualKeyboardFeaturePkg/VirtualKeyboardDxe/Keyboard.c b/Features/Intel/UserInterface/VirtualKeyboardFeaturePkg/VirtualKeyboardDxe/Keyboard.c index 9c9b585ae2f..0c7d1ccfee6 100644 --- a/Features/Intel/UserInterface/VirtualKeyboardFeaturePkg/VirtualKeyboardDxe/Keyboard.c +++ b/Features/Intel/UserInterface/VirtualKeyboardFeaturePkg/VirtualKeyboardDxe/Keyboard.c @@ -897,9 +897,44 @@ VkApiStart ( goto Error; } + for (KeyData.Key.ScanCode = SCAN_UP; KeyData.Key.ScanCode <= SCAN_F12; KeyData.Key.ScanCode++) { + Status = SimpleEx->RegisterKeyNotify ( + SimpleEx, + &KeyData, + VkNotifyKeyCallback, + &NotifyHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_VK_ROUTINE_ENTRY_EXIT | DEBUG_ERROR, + "ERROR - Failed to register '%c', Status: %r\n", + KeyData.Key.ScanCode, + Status + )); + break; + } + } + KeyData.KeyState.KeyToggleState = 0; KeyData.KeyState.KeyShiftState = 0; KeyData.Key.ScanCode = SCAN_NULL; + for (KeyData.Key.UnicodeChar = CHAR_BACKSPACE; KeyData.Key.UnicodeChar <= CHAR_LINEFEED; KeyData.Key.UnicodeChar++) { + Status = SimpleEx->RegisterKeyNotify ( + SimpleEx, + &KeyData, + VkNotifyKeyCallback, + &NotifyHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_VK_ROUTINE_ENTRY_EXIT | DEBUG_ERROR, + "ERROR - Failed to register '%c', Status: %r\n", + KeyData.Key.UnicodeChar, + Status + )); + break; + } + } KeyData.Key.UnicodeChar = CHAR_CARRIAGE_RETURN; Status = SimpleEx->RegisterKeyNotify ( SimpleEx,