]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg/DebugAgent.c: Consume PeCoffSerachImageBase()
authorJeff Fan <jeff.fan@intel.com>
Sat, 1 Apr 2017 12:27:16 +0000 (20:27 +0800)
committerJeff Fan <jeff.fan@intel.com>
Fri, 7 Apr 2017 01:43:53 +0000 (09:43 +0800)
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c

index edd0de1ba29c0e97aa622208703f0a40ef6879e7..6f3c41933d92e30041c38fe6f499d6ba9ad78865 100644 (file)
@@ -4,7 +4,7 @@
   read/write debug packet to communication with HOST based on transfer\r
   protocol.\r
 \r
-  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2017, 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
@@ -201,55 +201,17 @@ FindAndReportModuleImageInfo (
   )\r
 {\r
   UINTN                                Pe32Data;\r
-  EFI_IMAGE_DOS_HEADER                 *DosHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;\r
   PE_COFF_LOADER_IMAGE_CONTEXT         ImageContext;\r
 \r
   //\r
   // Find Image Base\r
   //\r
-  Pe32Data = ((UINTN)mErrorMsgVersionAlert) & ~(AlignSize - 1);\r
-  while (Pe32Data != 0) {\r
-    DosHdr = (EFI_IMAGE_DOS_HEADER *) Pe32Data;\r
-    if (DosHdr->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
-      Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
-      //\r
-      // Make sure PE header address does not overflow and is less than the initial address.\r
-      //\r
-      if (((UINTN)Hdr.Pe32 > Pe32Data) && ((UINTN)Hdr.Pe32 < (UINTN)mErrorMsgVersionAlert)) {\r
-        if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
-          //\r
-          // It's PE image.\r
-          //\r
-          break;\r
-        }\r
-      }\r
-    } else {\r
-      //\r
-      // DOS image header is not present, TE header is at the image base.\r
-      //\r
-      Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
-      if ((Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) &&\r
-          ((Hdr.Te->Machine == IMAGE_FILE_MACHINE_I386) || Hdr.Te->Machine == IMAGE_FILE_MACHINE_X64)) {\r
-        //\r
-        // It's TE image, it TE header and Machine type match\r
-        //\r
-        break;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Not found the image base, check the previous aligned address\r
-    //\r
-    Pe32Data -= AlignSize;\r
+  Pe32Data = PeCoffSerachImageBase ((UINTN) mErrorMsgVersionAlert);\r
+  if (Pe32Data != 0) {\r
+    ImageContext.ImageAddress = Pe32Data;\r
+    ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);\r
+    PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
   }\r
-\r
-  ImageContext.ImageAddress = Pe32Data;\r
-  ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);\r
-  PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
 }\r
 \r
 /**\r