Commit | Line | Data |
---|---|---|
23c98c94 | 1 | /** @file\r |
504214c4 | 2 | Data structure and functions to load and unload PeImage.\r |
23c98c94 | 3 | \r |
b695e7ff | 4 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r |
cd5ebaa0 | 5 | This program and the accompanying materials\r |
28a00297 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
504214c4 | 13 | **/\r |
28a00297 | 14 | \r |
15 | \r | |
16 | #ifndef _IMAGE_H_\r | |
17 | #define _IMAGE_H_\r | |
18 | \r | |
023c0fec | 19 | #define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','p','e','i')\r |
20 | \r | |
21 | typedef struct {\r | |
853adefc | 22 | UINTN Signature;\r |
23 | /// Image handle\r | |
24 | EFI_HANDLE Handle; \r | |
25 | EFI_PE32_IMAGE_PROTOCOL Pe32Image;\r | |
023c0fec | 26 | } LOAD_PE32_IMAGE_PRIVATE_DATA;\r |
27 | \r | |
28 | #define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r | |
29 | CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)\r | |
30 | \r | |
31 | \r | |
28a00297 | 32 | //\r |
33 | // Private Data Types\r | |
34 | //\r | |
f3f2e05d | 35 | #define IMAGE_FILE_HANDLE_SIGNATURE SIGNATURE_32('i','m','g','f')\r |
28a00297 | 36 | typedef struct {\r |
37 | UINTN Signature;\r | |
38 | BOOLEAN FreeBuffer;\r | |
39 | VOID *Source;\r | |
40 | UINTN SourceSize;\r | |
41 | } IMAGE_FILE_HANDLE;\r | |
42 | \r | |
023c0fec | 43 | /**\r |
44 | Loads an EFI image into memory and returns a handle to the image with extended parameters.\r | |
45 | \r | |
46 | @param This Calling context\r | |
47 | @param ParentImageHandle The caller's image handle.\r | |
48 | @param FilePath The specific file path from which the image is\r | |
49 | loaded.\r | |
50 | @param SourceBuffer If not NULL, a pointer to the memory location\r | |
51 | containing a copy of the image to be loaded.\r | |
52 | @param SourceSize The size in bytes of SourceBuffer.\r | |
53 | @param DstBuffer The buffer to store the image.\r | |
54 | @param NumberOfPages For input, specifies the space size of the\r | |
55 | image by caller if not NULL. For output,\r | |
56 | specifies the actual space size needed.\r | |
57 | @param ImageHandle Image handle for output.\r | |
58 | @param EntryPoint Image entry point for output.\r | |
59 | @param Attribute The bit mask of attributes to set for the load\r | |
60 | PE image.\r | |
61 | \r | |
62 | @retval EFI_SUCCESS The image was loaded into memory.\r | |
63 | @retval EFI_NOT_FOUND The FilePath was not found.\r | |
64 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
65 | @retval EFI_UNSUPPORTED The image type is not supported, or the device\r | |
66 | path cannot be parsed to locate the proper\r | |
67 | protocol for loading the file.\r | |
68 | @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient\r | |
69 | resources.\r | |
b695e7ff LG |
70 | @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not\r |
71 | understood.\r | |
72 | @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.\r | |
73 | @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the \r | |
74 | image from being loaded. NULL is returned in *ImageHandle.\r | |
75 | @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a \r | |
76 | valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r | |
77 | platform policy specifies that the image should not be started.\r | |
023c0fec | 78 | \r |
79 | **/\r | |
80 | EFI_STATUS\r | |
81 | EFIAPI\r | |
82 | CoreLoadImageEx (\r | |
83 | IN EFI_PE32_IMAGE_PROTOCOL *This,\r | |
84 | IN EFI_HANDLE ParentImageHandle,\r | |
85 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r | |
86 | IN VOID *SourceBuffer OPTIONAL,\r | |
87 | IN UINTN SourceSize,\r | |
88 | IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,\r | |
89 | OUT UINTN *NumberOfPages OPTIONAL,\r | |
90 | OUT EFI_HANDLE *ImageHandle,\r | |
91 | OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,\r | |
92 | IN UINT32 Attribute\r | |
93 | );\r | |
94 | \r | |
95 | \r | |
96 | /**\r | |
97 | Unload the specified image.\r | |
98 | \r | |
99 | @param This Indicates the calling context.\r | |
100 | @param ImageHandle The specified image handle.\r | |
162ed594 | 101 | \r |
023c0fec | 102 | @retval EFI_INVALID_PARAMETER Image handle is NULL.\r |
103 | @retval EFI_UNSUPPORTED Attempt to unload an unsupported image.\r | |
104 | @retval EFI_SUCCESS Image successfully unloaded.\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | CoreUnloadImageEx (\r | |
110 | IN EFI_PE32_IMAGE_PROTOCOL *This,\r | |
111 | IN EFI_HANDLE ImageHandle\r | |
112 | );\r | |
28a00297 | 113 | #endif\r |