From nobody Sat Nov 2 12:30:37 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1491527922071913.6120748221442; Thu, 6 Apr 2017 18:18:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 819DA20083182; Thu, 6 Apr 2017 18:18:33 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 124952008317E for ; Thu, 6 Apr 2017 18:18:32 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP; 06 Apr 2017 18:18:32 -0700 Received: from jfan12-desk.ccr.corp.intel.com ([10.239.158.57]) by orsmga004.jf.intel.com with ESMTP; 06 Apr 2017 18:18:30 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,162,1488873600"; d="scan'208";a="74765750" From: Jeff Fan To: edk2-devel@lists.01.org Date: Fri, 7 Apr 2017 09:18:23 +0800 Message-Id: <20170407011823.12664-6-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20170407011823.12664-1-jeff.fan@intel.com> References: <20170407011823.12664-1-jeff.fan@intel.com> Subject: [edk2] [PATCH v2 5/5] SourceLevelDebugPkg/DebugAgent.c: Consume PeCoffSerachImageBase() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , Feng Tian , Jiewen Yao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Jiewen Yao Cc: Michael Kinney Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- .../DebugAgent/DebugAgentCommon/DebugAgent.c | 50 +++---------------= ---- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugA= gent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent= .c index edd0de1..6f3c419 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c @@ -4,7 +4,7 @@ read/write debug packet to communication with HOST based on transfer protocol. =20 - Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -201,55 +201,17 @@ FindAndReportModuleImageInfo ( ) { UINTN Pe32Data; - EFI_IMAGE_DOS_HEADER *DosHdr; - EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; =20 // // Find Image Base // - Pe32Data =3D ((UINTN)mErrorMsgVersionAlert) & ~(AlignSize - 1); - while (Pe32Data !=3D 0) { - DosHdr =3D (EFI_IMAGE_DOS_HEADER *) Pe32Data; - if (DosHdr->e_magic =3D=3D EFI_IMAGE_DOS_SIGNATURE) { - // - // DOS image header is present, so read the PE header after the DOS = image header. - // - Hdr.Pe32 =3D (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data + (UINTN) ((DosHdr-= >e_lfanew) & 0x0ffff)); - // - // Make sure PE header address does not overflow and is less than th= e initial address. - // - if (((UINTN)Hdr.Pe32 > Pe32Data) && ((UINTN)Hdr.Pe32 < (UINTN)mError= MsgVersionAlert)) { - if (Hdr.Pe32->Signature =3D=3D EFI_IMAGE_NT_SIGNATURE) { - // - // It's PE image. - // - break; - } - } - } else { - // - // DOS image header is not present, TE header is at the image base. - // - Hdr.Pe32 =3D (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; - if ((Hdr.Te->Signature =3D=3D EFI_TE_IMAGE_HEADER_SIGNATURE) && - ((Hdr.Te->Machine =3D=3D IMAGE_FILE_MACHINE_I386) || Hdr.Te->Mac= hine =3D=3D IMAGE_FILE_MACHINE_X64)) { - // - // It's TE image, it TE header and Machine type match - // - break; - } - } - - // - // Not found the image base, check the previous aligned address - // - Pe32Data -=3D AlignSize; + Pe32Data =3D PeCoffSerachImageBase ((UINTN) mErrorMsgVersionAlert); + if (Pe32Data !=3D 0) { + ImageContext.ImageAddress =3D Pe32Data; + ImageContext.PdbPointer =3D PeCoffLoaderGetPdbPointer ((VOID*) (UINTN)= ImageContext.ImageAddress); + PeCoffLoaderRelocateImageExtraAction (&ImageContext); } - - ImageContext.ImageAddress =3D Pe32Data; - ImageContext.PdbPointer =3D PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) I= mageContext.ImageAddress); - PeCoffLoaderRelocateImageExtraAction (&ImageContext); } =20 /** --=20 2.9.3.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel