]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Image/Image.c
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.c
index 16fc91056a2f927a189ef9352efd6180bc22c5cf..5b441f03fbbf089edb78a32a83d3fe63eb661d2a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Core image handling services to load and unload PeImage.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, 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
@@ -389,7 +389,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
      if (EFI_ERROR (Status)) {\r
        return Status;\r
      }\r
-     \r
+     if (Size != sizeof (EFI_IMAGE_SECTION_HEADER)) {\r
+       return EFI_NOT_FOUND;\r
+     }\r
+\r
      Status = EFI_NOT_FOUND;\r
      \r
      if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {\r
@@ -851,6 +854,9 @@ CoreUnloadAndCloseImage (
   UINTN                               OpenInfoCount;\r
   UINTN                               OpenInfoIndex;\r
 \r
+  HandleBuffer = NULL;\r
+  ProtocolGuidArray = NULL;\r
+\r
   if (Image->Ebc != NULL) {\r
     //\r
     // If EBC protocol exists we must perform cleanups for this image.\r
@@ -1128,11 +1134,9 @@ CoreLoadImageCommon (
     }\r
   }\r
 \r
-  if (Status == EFI_ALREADY_STARTED) {\r
+  if (EFI_ERROR (Status)) {\r
     Image = NULL;\r
     goto Done;\r
-  } else if (EFI_ERROR (Status)) {\r
-    return Status;\r
   }\r
 \r
   if (gSecurity2 != NULL) {\r
@@ -1194,7 +1198,8 @@ CoreLoadImageCommon (
   //\r
   Image = AllocateZeroPool (sizeof(LOADED_IMAGE_PRIVATE_DATA));\r
   if (Image == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Done;\r
   }\r
 \r
   //\r
@@ -1621,6 +1626,7 @@ CoreStartImage (
   // Subsequent calls to LongJump() cause a non-zero value to be returned by SetJump().\r
   //\r
   if (SetJumpFlag == 0) {\r
+    RegisterMemoryProfileImage (Image, (Image->ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION ? EFI_FV_FILETYPE_APPLICATION : EFI_FV_FILETYPE_DRIVER));\r
     //\r
     // Call the image's entry point\r
     //\r
@@ -1846,6 +1852,7 @@ CoreUnloadImage (
     Status = EFI_INVALID_PARAMETER;\r
     goto Done;\r
   }\r
+  UnregisterMemoryProfileImage (Image);\r
 \r
   if (Image->Started) {\r
     //\r