]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix Shell treats every .EFI file as an executable application.
authorQiu Shumin <shumin.qiu@intel.com>
Mon, 25 Apr 2016 02:08:30 +0000 (10:08 +0800)
committerQiu Shumin <shumin.qiu@intel.com>
Tue, 26 Apr 2016 06:37:50 +0000 (14:37 +0800)
UEFI Shell 2.x cannot recognize whether a .EFI file is an application or
a driver. This means when we typed in a driver image in Shell command
line, Shell will load the driver image and try to run the entry point
function of the driver.
This patch check the ImageCodeType to fix the issue.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
ShellPkg/Application/Shell/Shell.uni
ShellPkg/Application/Shell/ShellProtocol.c

index 301d8797ff460a944de3123c34d6edbdd423112b..3947d01b5316295a2ecf2ecb70956b4ecac7f792 100644 (file)
@@ -1,7 +1,7 @@
 // *++\r
 //\r
 // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-// Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>\r
+// Copyright (c) 2009 - 2016, 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
@@ -52,3 +52,6 @@
 #string STR_VER_OUTPUT_MAIN_UEFI      #language en-US "UEFI v%d.%02d (%s, 0x%08x)\r\n"\r
 \r
 #string STR_SHELL_NO_IN_EX            #language en-US "No SimpleTextInputEx was found. CTRL-based features are not usable.\r\n"\r
+\r
+#string STR_SHELL_IMAGE_NOT_APP       #language en-US "The image is not an application.\r\n"\r
+\r
index 17c30029e4201fea2e1df83072b62c25cb7211fe..dc65b7d09aa26dc2eeb85d38dcbe0f642333b385 100644 (file)
@@ -1441,6 +1441,7 @@ InternalShellExecuteDevicePath(
   }\r
 \r
   InitializeListHead(&OrigEnvs);\r
+  ZeroMem(&ShellParamsProtocol, sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));\r
 \r
   NewHandle = NULL;\r
   \r
@@ -1483,6 +1484,20 @@ InternalShellExecuteDevicePath(
     EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
 \r
   if (!EFI_ERROR(Status)) {\r
+    //\r
+    // If the image is not an app abort it.\r
+    //\r
+    if (LoadedImage->ImageCodeType != EfiLoaderCode){\r
+      ShellPrintHiiEx(\r
+        -1, \r
+        -1, \r
+        NULL,\r
+        STRING_TOKEN (STR_SHELL_IMAGE_NOT_APP),\r
+        ShellInfoObject.HiiHandle\r
+      );\r
+      goto UnloadImage;\r
+    }\r
+\r
     ASSERT(LoadedImage->LoadOptionsSize == 0);\r
     if (NewCmdLine != NULL) {\r
       LoadedImage->LoadOptionsSize  = (UINT32)StrSize(NewCmdLine);\r