From cd14fe3dcf9445a2b3c9e8e3eef78c23c4d2b7cd Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Mon, 19 Jun 2006 07:40:23 +0000 Subject: =?UTF-8?q?=091.=20PostCodeLib.=20=09=09Rename=20BasePostCodeLib80?= =?UTF-8?q?=20to=20BasePostCodeLibPort80.=20=09=09Fix=20typos=20in=20macro?= =?UTF-8?q?=20POST=5FCODE()=20and=20POST=5FCODE=5FWITH=5FDESCRIPTION()=20?= =?UTF-8?q?=092.=20DebugLib=20=09=09Change=20the=20parameter=20type=20of?= =?UTF-8?q?=20LineNumber=20of=20DebugAssert()=20from=20=E2=80=9CINTN?= =?UTF-8?q?=E2=80=9D=20to=20=E2=80=9CUINTN=E2=80=9D=20to=20follow=20MWG.?= =?UTF-8?q?=20=09=09Add=20type=20cast=20=E2=80=9C(EFI=5FGUID=20*)=E2=80=9D?= =?UTF-8?q?=20in=20macro=20ASSERT=5FPROTCOL=5FALREADY=5FINSTALLED=20()=20t?= =?UTF-8?q?o=20follow=20MWG.=20=093.=20BasePeCoffLib/=20=09=09Add=20librar?= =?UTF-8?q?y=20function=20header=20for=20all=20the=20interfaces=20in=20MWG?= =?UTF-8?q?.=20=09=09Add=20missing=20ASSERT()s.=20=094.=20PciLib=20=09=09A?= =?UTF-8?q?dd=20ASSERT()s=20in=20PciRead/WriteBuffer()=20to=20check=20cros?= =?UTF-8?q?s=20PCI=20function=20access.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@557 6f19259b-4bc3-4df7-8a09-765794883524 --- .../BasePeCoffGetEntryPointLib.msa | 1 + .../PeCoffGetEntryPoint.c | 31 +++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'MdePkg/Library/BasePeCoffGetEntryPointLib') diff --git a/MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.msa b/MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.msa index 1f92c24449..e8cc214548 100644 --- a/MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.msa +++ b/MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.msa @@ -33,6 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. PeCoffGetEntryPointLib + DebugLib PeCoffGetEntryPoint.c diff --git a/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c index d5ff7db009..b740bd6e7c 100644 --- a/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c +++ b/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c @@ -17,38 +17,49 @@ /** - Loads a PE/COFF image into memory. + Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded + into system memory with the PE/COFF Loader Library functions. - @param Pe32Data Pointer to a PE/COFF Image - - @param EntryPoint Pointer to the entry point of the PE/COFF image + Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry + point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then + return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. + If Pe32Data is NULL, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). - @retval EFI_SUCCESS if the EntryPoint was returned - @retval EFI_INVALID_PARAMETER if the EntryPoint could not be found from Pe32Data + @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory. + @param EntryPoint Pointer to entry point to the PE/COFF image to return. + + @retval RETURN_SUCCESS EntryPoint was returned. + @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image. **/ RETURN_STATUS EFIAPI PeCoffLoaderGetEntryPoint ( - IN VOID *Pe32Data, - IN OUT VOID **EntryPoint + IN VOID *Pe32Data, + OUT VOID **EntryPoint ) { EFI_IMAGE_DOS_HEADER *DosHeader; EFI_IMAGE_NT_HEADERS *PeHeader; + ASSERT (Pe32Data != NULL); + ASSERT (EntryPoint != NULL); + DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { // - // DOS image header is present, so read the PE header after the DOS image header + // DOS image header is present, so read the PE header after the DOS image header. // PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); } else { // - // DOS image header is not present, so PE header is at the image base + // DOS image header is not present, so PE header is at the image base. // PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data; } + *EntryPoint = (VOID *) ((UINTN) Pe32Data + (UINTN) (PeHeader->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff)); return RETURN_SUCCESS; } -- cgit v1.2.3