Ronak Kanabar | 1ae366f | 2023-06-07 01:21:56 +0530 | [diff] [blame^] | 1 | /** @file |
| 2 | Provides a service to retrieve the PE/COFF entry point from a PE/COFF image. |
| 3 | |
| 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> |
| 5 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 6 | |
| 7 | **/ |
| 8 | |
| 9 | #ifndef __PE_COFF_GET_ENTRY_POINT_LIB_H__ |
| 10 | #define __PE_COFF_GET_ENTRY_POINT_LIB_H__ |
| 11 | |
| 12 | /** |
| 13 | Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded |
| 14 | into system memory with the PE/COFF Loader Library functions. |
| 15 | |
| 16 | Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry |
| 17 | point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then |
| 18 | return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. |
| 19 | If Pe32Data is NULL, then ASSERT(). |
| 20 | If EntryPoint is NULL, then ASSERT(). |
| 21 | |
| 22 | @param Pe32Data The pointer to the PE/COFF image that is loaded in system memory. |
| 23 | @param EntryPoint The pointer to entry point to the PE/COFF image to return. |
| 24 | |
| 25 | @retval RETURN_SUCCESS EntryPoint was returned. |
| 26 | @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image. |
| 27 | |
| 28 | **/ |
| 29 | RETURN_STATUS |
| 30 | EFIAPI |
| 31 | PeCoffLoaderGetEntryPoint ( |
| 32 | IN VOID *Pe32Data, |
| 33 | OUT VOID **EntryPoint |
| 34 | ); |
| 35 | |
| 36 | /** |
| 37 | Returns the machine type of a PE/COFF image. |
| 38 | |
| 39 | Returns the machine type from the PE/COFF image specified by Pe32Data. |
| 40 | If Pe32Data is NULL, then ASSERT(). |
| 41 | |
| 42 | @param Pe32Data The pointer to the PE/COFF image that is loaded in system |
| 43 | memory. |
| 44 | |
| 45 | @return Machine type or zero if not a valid image. |
| 46 | |
| 47 | **/ |
| 48 | UINT16 |
| 49 | EFIAPI |
| 50 | PeCoffLoaderGetMachineType ( |
| 51 | IN VOID *Pe32Data |
| 52 | ); |
| 53 | |
| 54 | /** |
| 55 | Returns a pointer to the PDB file name for a PE/COFF image that has been |
| 56 | loaded into system memory with the PE/COFF Loader Library functions. |
| 57 | |
| 58 | Returns the PDB file name for the PE/COFF image specified by Pe32Data. If |
| 59 | the PE/COFF image specified by Pe32Data is not a valid, then NULL is |
| 60 | returned. If the PE/COFF image specified by Pe32Data does not contain a |
| 61 | debug directory entry, then NULL is returned. If the debug directory entry |
| 62 | in the PE/COFF image specified by Pe32Data does not contain a PDB file name, |
| 63 | then NULL is returned. |
| 64 | If Pe32Data is NULL, then ASSERT(). |
| 65 | |
| 66 | @param Pe32Data The pointer to the PE/COFF image that is loaded in system |
| 67 | memory. |
| 68 | |
| 69 | @return The PDB file name for the PE/COFF image specified by Pe32Data, or NULL |
| 70 | if it cannot be retrieved. |
| 71 | |
| 72 | **/ |
| 73 | VOID * |
| 74 | EFIAPI |
| 75 | PeCoffLoaderGetPdbPointer ( |
| 76 | IN VOID *Pe32Data |
| 77 | ); |
| 78 | |
| 79 | /** |
| 80 | Returns the size of the PE/COFF headers |
| 81 | |
| 82 | Returns the size of the PE/COFF header specified by Pe32Data. |
| 83 | If Pe32Data is NULL, then ASSERT(). |
| 84 | |
| 85 | @param Pe32Data The pointer to the PE/COFF image that is loaded in system |
| 86 | memory. |
| 87 | |
| 88 | @return Size of PE/COFF header in bytes, or zero if not a valid image. |
| 89 | |
| 90 | **/ |
| 91 | UINT32 |
| 92 | EFIAPI |
| 93 | PeCoffGetSizeOfHeaders ( |
| 94 | IN VOID *Pe32Data |
| 95 | ); |
| 96 | |
| 97 | /** |
| 98 | Returns PE/COFF image base specified by the address in this PE/COFF image. |
| 99 | |
| 100 | On DEBUG build, searches the PE/COFF image base forward the address in this |
| 101 | PE/COFF image and returns it. |
| 102 | |
| 103 | @param Address Address located in one PE/COFF image. |
| 104 | |
| 105 | @retval 0 RELEASE build or cannot find the PE/COFF image base. |
| 106 | @retval others PE/COFF image base found. |
| 107 | |
| 108 | **/ |
| 109 | UINTN |
| 110 | EFIAPI |
| 111 | PeCoffSearchImageBase ( |
| 112 | IN UINTN Address |
| 113 | ); |
| 114 | |
| 115 | #endif |