]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
Change NameGuid to FvFileName
[mirror_edk2.git] / MdePkg / Library / BasePeCoffLib / BasePeCoffLibInternals.h
1 /** @file
2 Declaration of internal functions in PE/COFF Lib.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. 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 Module Name: BasePeCoffLibInternals.h
14
15 **/
16
17 #ifndef __BASE_PECOFF_LIB_INTERNALS__
18 #define __BASE_PECOFF_LIB_INTERNALS__
19
20 #include <Base.h>
21 #include <Library/PeCoffLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/DebugLib.h>
24 #include <IndustryStandard/PeImage.h>
25
26
27
28 /**
29 Performs an Itanium-based specific relocation fixup and is a no-op on other
30 instruction sets.
31
32 @param Reloc Pointer to the relocation record.
33 @param Fixup Pointer to the address to fix up.
34 @param FixupData Pointer to a buffer to log the fixups.
35 @param Adjust The offset to adjust the fixup.
36
37 @return Status code.
38
39 **/
40 RETURN_STATUS
41 PeCoffLoaderRelocateImageEx (
42 IN UINT16 *Reloc,
43 IN OUT CHAR8 *Fixup,
44 IN OUT CHAR8 **FixupData,
45 IN UINT64 Adjust
46 );
47
48
49 /**
50 Performs an Itanium-based specific re-relocation fixup and is a no-op on other
51 instruction sets. This is used to re-relocated the image into the EFI virtual
52 space for runtime calls.
53
54 @param Reloc Pointer to the relocation record.
55 @param Fixup Pointer to the address to fix up.
56 @param FixupData Pointer to a buffer to log the fixups.
57 @param Adjust The offset to adjust the fixup.
58
59 @return Status code.
60
61 **/
62 RETURN_STATUS
63 PeHotRelocateImageEx (
64 IN UINT16 *Reloc,
65 IN OUT CHAR8 *Fixup,
66 IN OUT CHAR8 **FixupData,
67 IN UINT64 Adjust
68 );
69
70
71 /**
72 Returns TRUE if the machine type of PE/COFF image is supported. Supported
73 does not mean the image can be executed it means the PE/COFF loader supports
74 loading and relocating of the image type. It's up to the caller to support
75 the entry point.
76
77 @param Machine Machine type from the PE Header.
78
79 @return TRUE if this PE/COFF loader can load the image
80
81 **/
82 BOOLEAN
83 PeCoffLoaderImageFormatSupported (
84 IN UINT16 Machine
85 );
86
87 /**
88 Retrieves the magic value from the PE/COFF header.
89
90 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
91
92 @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
93 @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
94
95 **/
96 UINT16
97 PeCoffLoaderGetPeHeaderMagicValue (
98 IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
99 );
100
101 /**
102 Retrieves the PE or TE Header from a PE/COFF or TE image.
103
104 @param ImageContext The context of the image being loaded.
105 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
106
107 @retval RETURN_SUCCESS The PE or TE Header is read.
108 @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.
109
110 **/
111 RETURN_STATUS
112 PeCoffLoaderGetPeHeader (
113 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
114 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
115 );
116
117 /**
118 Converts an image address to the loaded address.
119
120 @param ImageContext The context of the image being loaded.
121 @param Address The address to be converted to the loaded address.
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 );
131
132 #endif