]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c
ShellPkg/for: Fix potential null pointer deference
[mirror_edk2.git] / ShellPkg / Library / UefiShellInstall1CommandsLib / UefiShellInstall1CommandsLib.c
index e524e7f50a21c44b07556dccfe20f1460de04e3c..e26a86283e86fc266ff691ef5d7f44507dfb3b59 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for NULL named library for install1 shell command functions.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 \r
 **/\r
 \r
-#include "UefiShellInstall1CommandsLib.h"\r
-\r
-STATIC CONST CHAR16 mFileName[] = L"ShellCommands";\r
-EFI_HANDLE gShellInstall1HiiHandle = NULL;\r
-CONST EFI_GUID gShellInstall1HiiGuid = \\r
-  { \\r
-    0x7d574d54, 0xd364, 0x4d4a, { 0x95, 0xe3, 0x49, 0x45, 0xdb, 0x7a, 0xd3, 0xee } \\r
-  };\r
-\r
-CONST CHAR16*\r
-EFIAPI\r
-ShellCommandGetManFileNameInstall1 (\r
-  VOID\r
-  )\r
-{\r
-  return (mFileName);\r
-}\r
+#include <Library/BcfgCommandLib.h>\r
 \r
 /**\r
   Constructor for the Shell Level 1 Commands library.\r
@@ -52,24 +36,17 @@ ShellInstall1CommandsLibConstructor (
   // check our bit of the profiles mask\r
   //\r
   if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {\r
-    return (EFI_UNSUPPORTED);\r
+    return (EFI_SUCCESS);\r
   }\r
 \r
-  gShellInstall1HiiHandle = HiiAddPackages (&gShellInstall1HiiGuid, gImageHandle, UefiShellInstall1CommandsLibStrings, NULL);\r
-  if (gShellInstall1HiiHandle == NULL) {\r
-    return (EFI_DEVICE_ERROR);\r
-  }\r
-\r
-  //\r
-  // install our shell command handlers that are always installed\r
-  //\r
-  ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfgInstall , ShellCommandGetManFileNameInstall1, 0, L"Install", FALSE, gShellInstall1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG));\r
-\r
-  return (EFI_SUCCESS);\r
+  return (BcfgLibraryRegisterBcfgCommand(ImageHandle, SystemTable, L"Install1"));\r
 }\r
 \r
 /**\r
   Destructor for the library.  free any resources.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+  @param SystemTable            The EFI System Table pointer.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -78,8 +55,5 @@ ShellInstall1CommandsLibDestructor (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  if (gShellInstall1HiiHandle != NULL) {\r
-    HiiRemovePackages(gShellInstall1HiiHandle);\r
-  }\r
-  return (EFI_SUCCESS);\r
+  return (BcfgLibraryUnregisterBcfgCommand(ImageHandle, SystemTable));\r
 }\r