+**/\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *PE_COFF_LOADER_READ_FILE)(\r
+ IN VOID *FileHandle,\r
+ IN UINTN FileOffset,\r
+ IN OUT UINTN *ReadSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+///\r
+/// The context structure used while PE/COFF image is being loaded and relocated.\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to the ImageBase in the PE/COFF header.\r
+ ///\r
+ PHYSICAL_ADDRESS ImageAddress;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to the SizeOfImage in the PE/COFF header.\r
+ /// Image size includes the size of Debug Entry if it is present.\r
+ ///\r
+ UINT64 ImageSize;\r
+ ///\r
+ /// Is set to zero by PeCoffLoaderGetImageInfo(). If DestinationAddress is non-zero,\r
+ /// PeCoffLoaderRelocateImage() will relocate the image using this base address.\r
+ /// If the DestinationAddress is zero, the ImageAddress will be used as the base\r
+ /// address of relocation.\r
+ ///\r
+ PHYSICAL_ADDRESS DestinationAddress;\r
+ ///\r
+ /// PeCoffLoaderLoadImage() sets EntryPoint to to the entry point of the PE/COFF image.\r
+ ///\r
+ PHYSICAL_ADDRESS EntryPoint;\r
+ ///\r
+ /// Passed in by the caller to PeCoffLoaderGetImageInfo() and PeCoffLoaderLoadImage()\r
+ /// to abstract accessing the image from the library.\r
+ ///\r
+ PE_COFF_LOADER_READ_FILE ImageRead;\r
+ ///\r
+ /// Used as the FileHandle passed into the ImageRead function when it's called.\r
+ ///\r
+ VOID *Handle;\r
+ ///\r
+ /// Caller allocated buffer of size FixupDataSize that can be optionally allocated\r
+ /// prior to calling PeCoffLoaderRelocateImage().\r
+ /// This buffer is filled with the information used to fix up the image.\r
+ /// The fixups have been applied to the image and this entry is just for information.\r
+ ///\r
+ VOID *FixupData;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to the Section Alignment in the PE/COFF header.\r
+ /// If the image is a TE image, then this field is set to 0.\r
+ ///\r
+ UINT32 SectionAlignment;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to offset to the PE/COFF header.\r
+ /// If the PE/COFF image does not start with a DOS header, this value is zero.\r
+ /// Otherwise, it's the offset to the PE/COFF header.\r
+ ///\r
+ UINT32 PeCoffHeaderOffset;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to the Relative Virtual Address of the debug directory,\r
+ /// if it exists in the image\r
+ ///\r
+ UINT32 DebugDirectoryEntryRva;\r
+ ///\r
+ /// Set by PeCoffLoaderLoadImage() to CodeView area of the PE/COFF Debug directory.\r
+ ///\r
+ VOID *CodeView;\r
+ ///\r
+ /// Set by PeCoffLoaderLoadImage() to point to the PDB entry contained in the CodeView area.\r
+ /// The PdbPointer points to the filename of the PDB file used for source-level debug of\r
+ /// the image by a debugger.\r
+ ///\r
+ CHAR8 *PdbPointer;\r
+ ///\r
+ /// Is set by PeCoffLoaderGetImageInfo() to the Section Alignment in the PE/COFF header.\r
+ ///\r
+ UINTN SizeOfHeaders;\r
+ ///\r
+ /// Not used by this library class. Other library classes that layer on top of this library\r
+ /// class fill in this value as part of their GetImageInfo call.\r
+ /// This allows the caller of the library to know what type of memory needs to be allocated\r
+ /// to load and relocate the image.\r
+ ///\r
+ UINT32 ImageCodeMemoryType;\r
+ ///\r
+ /// Not used by this library class. Other library classes that layer on top of this library\r
+ /// class fill in this value as part of their GetImageInfo call.\r
+ /// This allows the caller of the library to know what type of memory needs to be allocated\r
+ /// to load and relocate the image.\r
+ ///\r
+ UINT32 ImageDataMemoryType;\r
+ ///\r
+ /// Set by any of the library functions if they encounter an error.\r
+ ///\r
+ UINT32 ImageError;\r
+ ///\r
+ /// Set by PeCoffLoaderLoadImage() to indicate the size of FixupData that the caller must\r
+ /// allocate before calling PeCoffLoaderRelocateImage().\r
+ ///\r
+ UINTN FixupDataSize;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to the machine type stored in the PE/COFF header.\r
+ ///\r
+ UINT16 Machine;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to the subsystem type stored in the PE/COFF header.\r
+ ///\r
+ UINT16 ImageType;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to TRUE if the PE/COFF image does not contain\r
+ /// relocation information.\r
+ ///\r
+ BOOLEAN RelocationsStripped;\r
+ ///\r
+ /// Set by PeCoffLoaderGetImageInfo() to TRUE if the image is a TE image.\r
+ /// For a definition of the TE Image format, see the Platform Initialization Pre-EFI\r
+ /// Initialization Core Interface Specification.\r
+ ///\r
+ BOOLEAN IsTeImage;\r
+ ///\r
+ /// Set by PeCoffLoaderLoadImage() to the HII resource offset\r
+ /// if the image contains a custom PE/COFF resource with the type 'HII'.\r
+ /// Otherwise, the entry remains to be 0.\r
+ ///\r
+ PHYSICAL_ADDRESS HiiResourceData;\r
+ ///\r
+ /// Private storage for implementation specific data.\r
+ ///\r
+ UINT64 Context;\r
+} PE_COFF_LOADER_IMAGE_CONTEXT;\r