VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxPeCoffLib/BasePeCoffLibInternals.h@ 106061

Last change on this file since 106061 was 106061, checked in by vboxsync, 5 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: BasePeCoffLibInternals.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * BasePeCoffLibInternals.h
4 */
5
6/*
7 * Copyright (C) 2009-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*
39 This code is based on:
40
41 Declaration of internal functions in PE/COFF Lib.
42
43 Copyright (c) 2006, Intel Corporation<BR>
44 All rights reserved. This program and the accompanying materials
45 are licensed and made available under the terms and conditions of the BSD License
46 which accompanies this distribution. The full text of the license may be found at
47 http://opensource.org/licenses/bsd-license.php
48
49 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
50 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
51
52*/
53
54#ifndef __BASE_PECOFF_LIB_INTERNALS__
55#define __BASE_PECOFF_LIB_INTERNALS__
56
57#include <Base.h>
58#include <Library/PeCoffLib.h>
59#include <Library/BaseMemoryLib.h>
60#include <Library/DebugLib.h>
61#include <Library/PeCoffExtraActionLib.h>
62#include <IndustryStandard/PeImage.h>
63#include <IndustryStandard/VBoxFatImage.h>
64
65
66
67/**
68 Performs an Itanium-based specific relocation fixup and is a no-op on other
69 instruction sets.
70
71 @param Reloc Pointer to the relocation record.
72 @param Fixup Pointer to the address to fix up.
73 @param FixupData Pointer to a buffer to log the fixups.
74 @param Adjust The offset to adjust the fixup.
75
76 @return Status code.
77
78**/
79RETURN_STATUS
80PeCoffLoaderRelocateImageEx (
81 IN UINT16 *Reloc,
82 IN OUT CHAR8 *Fixup,
83 IN OUT CHAR8 **FixupData,
84 IN UINT64 Adjust
85 );
86
87
88/**
89 Performs an Itanium-based specific re-relocation fixup and is a no-op on other
90 instruction sets. This is used to re-relocated the image into the EFI virtual
91 space for runtime calls.
92
93 @param Reloc Pointer to the relocation record.
94 @param Fixup Pointer to the address to fix up.
95 @param FixupData Pointer to a buffer to log the fixups.
96 @param Adjust The offset to adjust the fixup.
97
98 @return Status code.
99
100**/
101RETURN_STATUS
102PeHotRelocateImageEx (
103 IN UINT16 *Reloc,
104 IN OUT CHAR8 *Fixup,
105 IN OUT CHAR8 **FixupData,
106 IN UINT64 Adjust
107 );
108
109
110/**
111 Returns TRUE if the machine type of PE/COFF image is supported. Supported
112 does not mean the image can be executed it means the PE/COFF loader supports
113 loading and relocating of the image type. It's up to the caller to support
114 the entry point.
115
116 @param Machine Machine type from the PE Header.
117
118 @return TRUE if this PE/COFF loader can load the image
119
120**/
121BOOLEAN
122PeCoffLoaderImageFormatSupported (
123 IN UINT16 Machine
124 );
125
126/**
127 Retrieves the magic value from the PE/COFF header.
128
129 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
130
131 @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
132 @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
133
134**/
135UINT16
136PeCoffLoaderGetPeHeaderMagicValue (
137 IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
138 );
139
140/**
141 Retrieves the PE or TE Header from a PE/COFF or TE image.
142
143 @param ImageContext The context of the image being loaded.
144 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
145
146 @retval RETURN_SUCCESS The PE or TE Header is read.
147 @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.
148
149**/
150RETURN_STATUS
151PeCoffLoaderGetPeHeader (
152 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
153 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
154 );
155
156/**
157 Converts an image address to the loaded address.
158
159 @param ImageContext The context of the image being loaded.
160 @param Address The address to be converted to the loaded address.
161
162 @return The converted address or NULL if the address can not be converted.
163
164**/
165VOID *
166PeCoffLoaderImageAddress (
167 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
168 IN UINTN Address
169 );
170
171#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette