summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2016-04-25 10:08:30 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-13 20:43:03 +0800
commitb0465d483b5b1d5fabc5e2e6d1783a163f6a7380 (patch)
tree90dbbcd43470531d70f9fa545cd31c06dd8aec56 /ShellPkg
parent56cacefbfaa180a91bf6e82e2fb208d83ac7feb2 (diff)
downloadedk2-platforms-b0465d483b5b1d5fabc5e2e6d1783a163f6a7380.tar.xz
ShellPkg: Fix Shell treats every .EFI file as an executable application.
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> (cherry picked from commit 91a92220f75c15950e5ba913c1f204ec73f2c2e9)
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/Shell.uni5
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/ShellPkg/Application/Shell/Shell.uni b/ShellPkg/Application/Shell/Shell.uni
index 301d8797ff..3947d01b53 100644
--- a/ShellPkg/Application/Shell/Shell.uni
+++ b/ShellPkg/Application/Shell/Shell.uni
@@ -1,7 +1,7 @@
// *++
//
// (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
-// Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>
+// Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved. <BR>
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at
@@ -52,3 +52,6 @@
#string STR_VER_OUTPUT_MAIN_UEFI #language en-US "UEFI v%d.%02d (%s, 0x%08x)\r\n"
#string STR_SHELL_NO_IN_EX #language en-US "No SimpleTextInputEx was found. CTRL-based features are not usable.\r\n"
+
+#string STR_SHELL_IMAGE_NOT_APP #language en-US "The image is not an application.\r\n"
+
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 17c30029e4..dc65b7d09a 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -1441,6 +1441,7 @@ InternalShellExecuteDevicePath(
}
InitializeListHead(&OrigEnvs);
+ ZeroMem(&ShellParamsProtocol, sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));
NewHandle = NULL;
@@ -1483,6 +1484,20 @@ InternalShellExecuteDevicePath(
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
+ //
+ // If the image is not an app abort it.
+ //
+ if (LoadedImage->ImageCodeType != EfiLoaderCode){
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SHELL_IMAGE_NOT_APP),
+ ShellInfoObject.HiiHandle
+ );
+ goto UnloadImage;
+ }
+
ASSERT(LoadedImage->LoadOptionsSize == 0);
if (NewCmdLine != NULL) {
LoadedImage->LoadOptionsSize = (UINT32)StrSize(NewCmdLine);