1 /** @file 2 Declaration of internal functions in PE/COFF Lib. 3 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php. 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #ifndef __BASE_PECOFF_LIB_INTERNALS__ 16 #define __BASE_PECOFF_LIB_INTERNALS__ 17 18 #include <Base.h> 19 #include <Library/PeCoffLib.h> 20 #include <Library/BaseMemoryLib.h> 21 #include <Library/DebugLib.h> 22 #include <Library/PeCoffExtraActionLib.h> 23 #include <IndustryStandard/PeImage.h> 24 25 26 27 /** 28 Performs an Itanium-based specific relocation fixup and is a no-op on other 29 instruction sets. 30 31 @param Reloc The pointer to the relocation record. 32 @param Fixup The pointer to the address to fix up. 33 @param FixupData The pointer to a buffer to log the fixups. 34 @param Adjust The offset to adjust the fixup. 35 36 @return Status code. 37 38 **/ 39 RETURN_STATUS 40 PeCoffLoaderRelocateImageEx ( 41 IN UINT16 *Reloc, 42 IN OUT CHAR8 *Fixup, 43 IN OUT CHAR8 **FixupData, 44 IN UINT64 Adjust 45 ); 46 47 48 /** 49 Performs an Itanium-based specific re-relocation fixup and is a no-op on other 50 instruction sets. This is used to re-relocated the image into the EFI virtual 51 space for runtime calls. 52 53 @param Reloc The pointer to the relocation record. 54 @param Fixup The pointer to the address to fix up. 55 @param FixupData The pointer to a buffer to log the fixups. 56 @param Adjust The offset to adjust the fixup. 57 58 @return Status code. 59 60 **/ 61 RETURN_STATUS 62 PeHotRelocateImageEx ( 63 IN UINT16 *Reloc, 64 IN OUT CHAR8 *Fixup, 65 IN OUT CHAR8 **FixupData, 66 IN UINT64 Adjust 67 ); 68 69 70 /** 71 Returns TRUE if the machine type of PE/COFF image is supported. Supported 72 does not mean the image can be executed it means the PE/COFF loader supports 73 loading and relocating of the image type. It's up to the caller to support 74 the entry point. 75 76 @param Machine Machine type from the PE Header. 77 78 @return TRUE if this PE/COFF loader can load the image 79 80 **/ 81 BOOLEAN 82 PeCoffLoaderImageFormatSupported ( 83 IN UINT16 Machine 84 ); 85 86 /** 87 Retrieves the magic value from the PE/COFF header. 88 89 @param Hdr The buffer in which to return the PE32, PE32+, or TE header. 90 91 @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 92 @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ 93 94 **/ 95 UINT16 96 PeCoffLoaderGetPeHeaderMagicValue ( 97 IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr 98 ); 99 100 /** 101 Retrieves the PE or TE Header from a PE/COFF or TE image. 102 103 @param ImageContext The context of the image being loaded. 104 @param Hdr The buffer in which to return the PE32, PE32+, or TE header. 105 106 @retval RETURN_SUCCESS The PE or TE Header is read. 107 @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function. 108 109 **/ 110 RETURN_STATUS 111 PeCoffLoaderGetPeHeader ( 112 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, 113 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr 114 ); 115 116 /** 117 Converts an image address to the loaded address. 118 119 @param ImageContext The context of the image being loaded. 120 @param Address The address to be converted to the loaded address. 121 @param TeStrippedOffset Stripped offset for TE image. 122 123 @return The converted address or NULL if the address can not be converted. 124 125 **/ 126 VOID * 127 PeCoffLoaderImageAddress ( 128 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, 129 IN UINTN Address, 130 IN UINTN TeStrippedOffset 131 ); 132 133 #endif 134