]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Core/Pei/Image/Image.c
Fix Buger in this file to process the ffs file that only contain one compressed section.
[mirror_edk2.git] / EdkModulePkg / Core / Pei / Image / Image.c
index 74286cff3112f209f8e5918073a7a48eea97671c..5edc8479eb04ca4aadd31c43ca684952f07a8a88 100644 (file)
@@ -50,10 +50,6 @@ Returns:
   EFI_STATUS                  Status;\r
   VOID                        *Pe32Data;\r
   EFI_PEI_FV_FILE_LOADER_PPI  *FvLoadFilePpi;\r
-//#ifdef EFI_NT_EMULATOR\r
-//  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
-//  NT_PEI_LOAD_FILE_PPI        *PeiNtService;\r
-//#endif\r
   EFI_PHYSICAL_ADDRESS        ImageAddress;\r
   UINT64                      ImageSize;\r
   EFI_PHYSICAL_ADDRESS        ImageEntryPoint;\r
@@ -65,7 +61,7 @@ Returns:
   //\r
   // Try to find a PE32 section.\r
   //\r
-  Status = PeiCoreFfsFindSectionData (\r
+  Status = PeiServicesFfsFindSectionData (\r
              EFI_SECTION_PE32,\r
              PeimFileHeader,\r
              &Pe32Data\r
@@ -74,7 +70,7 @@ Returns:
   // If we didn't find a PE32 section, try to find a TE section.\r
   //\r
   if (EFI_ERROR (Status)) {\r
-    Status = PeiCoreFfsFindSectionData (\r
+    Status = PeiServicesFfsFindSectionData (\r
                EFI_SECTION_TE,\r
                PeimFileHeader,\r
                (VOID **) &TEImageHeader\r
@@ -84,7 +80,7 @@ Returns:
       // There was not a PE32 or a TE section, so assume that it's a Compressed section\r
       // and use the LoadFile\r
       //\r
-      Status = PeiCoreLocatePpi (\r
+      Status = PeiServicesLocatePpi (\r
                 &gEfiPeiFvFileLoaderPpiGuid,\r
                 0,\r
                 NULL,\r
@@ -107,12 +103,10 @@ Returns:
       }\r
 \r
       //\r
-      // Retrieve the entry point from the PE/COFF image header\r
+      // Got the entry point from ImageEntryPoint\r
       //\r
-      Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)ImageAddress, EntryPoint);\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
+      *EntryPoint = (VOID *) ((UINTN) ImageEntryPoint);\r
+      return EFI_SUCCESS;\r
     } else {\r
       //\r
       // Retrieve the entry point from the TE image header\r
@@ -150,17 +144,23 @@ Returns:
     EFI_IMAGE_DOS_HEADER  *DosHeader;\r
     EFI_IMAGE_NT_HEADERS  *PeHeader;\r
 \r
-    DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
-    if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
-      //\r
-      // DOS image header is present, so read the PE header after the DOS image header\r
-      //\r
-      PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));\r
-    } else {\r
-      //\r
-      // DOS image header is not present, so PE header is at the image base\r
-      //\r
-      PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data;\r
+    //\r
+    // Pe32Data is NULL when load TE image \r
+    //    \r
+    PeHeader = NULL;\r
+    if (TEImageHeader == NULL) {\r
+      DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+      if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+        //\r
+        // DOS image header is present, so read the PE header after the DOS image header\r
+        //\r
+        PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));\r
+      } else {\r
+        //\r
+        // DOS image header is not present, so PE header is at the image base\r
+        //\r
+        PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data;\r
+      }\r
     }\r
 \r
     //\r