Update PCI Bus Driver to use the PeCoffLib instead of paring the PE/COFF image itself
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Feb 2009 19:32:40 +0000 (19:32 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Feb 2009 19:32:40 +0000 (19:32 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7440 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.h
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDriverOverride.c

index 74a4abf4dff29e6cb1bf38d106125193d64937d5..2c0906169565168dc032fe288433c3fd2656b14a 100644 (file)
@@ -45,6 +45,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/PciIncompatibleDeviceSupportLib.h>\r
+#include <Library/PeCoffLib.h>\r
 \r
 #include <IndustryStandard/Pci.h>\r
 #include <IndustryStandard/PeImage.h>\r
index 3c8b63cd78c655029de8000915b3c1d51b00acc0..8fa69ec72951f205eb33245e90d528bfc62c05e6 100644 (file)
@@ -86,7 +86,7 @@
   BaseLib\r
   UefiDriverEntryPoint\r
   DebugLib\r
-\r
+  PeCoffLib\r
 \r
 [Guids]\r
   gEfiPciOptionRomTableGuid                     # SOMETIMES_CONSUMED  System Table\r
index 6c9d6f8079d170e340d0fac3e9cfff52b8f30de6..6ec208453e91be79d93edf1dfd97651a4f864fd1 100644 (file)
@@ -101,9 +101,8 @@ AddDriver (
   )\r
 {\r
   EFI_STATUS                    Status;\r
-  EFI_IMAGE_DOS_HEADER          *DosHdr;\r
-  EFI_IMAGE_NT_HEADERS          *PeHdr;\r
   EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
   PCI_DRIVER_OVERRIDE_LIST      *Node;\r
 \r
   Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
@@ -123,16 +122,21 @@ AddDriver (
 \r
   PciIoDevice->BusOverride  = TRUE;\r
 \r
-  DosHdr                    = (EFI_IMAGE_DOS_HEADER *) LoadedImage->ImageBase;\r
-  if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+  ImageContext.Handle    = LoadedImage->ImageBase;\r
+  ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r
+\r
+  //\r
+  // Get information about the image \r
+  //\r
+  Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
-  PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) LoadedImage->ImageBase + DosHdr->e_lfanew);\r
-\r
-  if (PeHdr->FileHeader.Machine != EFI_IMAGE_MACHINE_EBC) {\r
+  if (ImageContext.Machine != EFI_IMAGE_MACHINE_EBC) {\r
     return EFI_SUCCESS;\r
   }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r