aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/DisplayHIIByGuid
diff options
context:
space:
mode:
Diffstat (limited to 'UefiLessonsPkg/DisplayHIIByGuid')
-rw-r--r--UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.c69
-rw-r--r--UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.inf29
2 files changed, 98 insertions, 0 deletions
diff --git a/UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.c b/UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.c
new file mode 100644
index 0000000..87e7efe
--- /dev/null
+++ b/UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Library/MemoryAllocationLib.h>
+#include <Library/HiiLib.h>
+#include <Protocol/FormBrowser2.h>
+
+INTN
+EFIAPI
+ShellAppMain (
+ IN UINTN Argc,
+ IN CHAR16 **Argv
+ )
+{
+ if (Argc != 2) {
+ Print(L"Usage:\n");
+ Print(L" DisplayHIIByGuid <GUID>\n");
+ return EFI_INVALID_PARAMETER;
+ }
+
+ GUID Guid;
+ EFI_STATUS Status = StrToGuid(Argv[1], &Guid);
+ if (Status != RETURN_SUCCESS) {
+ Print(L"Error! Can't convert input argument to GUID\n");
+ return EFI_INVALID_PARAMETER;
+ }
+
+
+ EFI_HII_HANDLE* HiiHandles = HiiGetHiiHandles(&Guid);
+
+ EFI_HII_HANDLE* HiiHandle = HiiHandles;
+ UINTN HandleCount=0;
+ while (*HiiHandle != NULL) {
+ HiiHandle++;
+ HandleCount++;
+ }
+
+ EFI_FORM_BROWSER2_PROTOCOL* FormBrowser2;
+ Status = gBS->LocateProtocol(&gEfiFormBrowser2ProtocolGuid, NULL, (VOID**)&FormBrowser2);
+ if (EFI_ERROR(Status)) {
+ Print(L"Error! Can't locate gEfiFormBrowser2Protocol\n");
+ FreePool(HiiHandles);
+ return Status;
+ }
+
+ Status = FormBrowser2->SendForm (
+ FormBrowser2,
+ HiiHandles,
+ HandleCount,
+ NULL,
+ 0,
+ NULL,
+ NULL
+ );
+
+ if (EFI_ERROR(Status)) {
+ Print(L"Error! SendForm returned %r\n", Status);
+ }
+
+ FreePool(HiiHandles);
+
+ return EFI_SUCCESS;
+}
diff --git a/UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.inf b/UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.inf
new file mode 100644
index 0000000..bb22a5e
--- /dev/null
+++ b/UefiLessonsPkg/DisplayHIIByGuid/DisplayHIIByGuid.inf
@@ -0,0 +1,29 @@
+##
+# Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+##
+
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = DisplayHIIByGuid
+ FILE_GUID = 1597e1d0-7f62-4631-a166-703f03bd7223
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ShellCEntryLib
+
+[Sources]
+ DisplayHIIByGuid.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+ ShellCEntryLib
+ HiiLib
+
+[Protocols]
+ gEfiFormBrowser2ProtocolGuid