OpenCore
1.0.4
OpenCore Bootloader
|
#include "BootManagementInternal.h"
#include <Protocol/DevicePath.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/SimpleFileSystem.h>
#include <Guid/AppleVariable.h>
#include <Guid/FileInfo.h>
#include <Guid/GlobalVariable.h>
#include <Guid/OcVariable.h>
#include <AppleMacEfi/AppleMacEfiSpec.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/MemoryAllocationLibEx.h>
#include <Library/OcAppleSecureBootLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcDevicePathLib.h>
#include <Library/OcFileLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcPeCoffExtLib.h>
#include <Library/OcStringLib.h>
#include <Library/UefiImageLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/PrintLib.h>
Go to the source code of this file.
Data Structures | |
struct | OC_LOADED_IMAGE_PROTOCOL |
struct | OC_IMAGE_LOADER_CAPS_PROTOCOL |
Functions | |
STATIC VOID | PreserveGrubShimHooks (VOID) |
STATIC VOID | RestoreGrubShimHooks (IN CONST CHAR8 *Caller) |
STATIC EFI_STATUS | InternalEfiLoadImageFile (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINTN *FileSize, OUT VOID **FileBuffer) |
STATIC EFI_STATUS | InternalEfiLoadImageProtocol (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN UseLoadImage2, OUT UINTN *FileSize, OUT VOID **FileBuffer) |
STATIC EFI_STATUS | InternalUpdateLoadedImage (IN EFI_HANDLE ImageHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) |
EFI_STATUS EFIAPI | OcImageLoaderLoad (IN BOOLEAN BootPolicy, IN EFI_HANDLE ParentImageHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle) |
STATIC EFI_STATUS | InternalDirectUnloadImage (IN OC_LOADED_IMAGE_PROTOCOL *OcLoadedImage, IN EFI_HANDLE ImageHandle) |
STATIC EFI_STATUS | InternalDirectExit (IN OC_LOADED_IMAGE_PROTOCOL *OcLoadedImage, IN EFI_HANDLE ImageHandle, IN EFI_STATUS ExitStatus, IN UINTN ExitDataSize, IN CHAR16 *ExitData OPTIONAL) |
STATIC EFI_STATUS | InternalDirectStartImage (IN OC_LOADED_IMAGE_PROTOCOL *OcLoadedImage, IN EFI_HANDLE ImageHandle, OUT UINTN *ExitDataSize, OUT CHAR16 **ExitData OPTIONAL) |
STATIC UINT32 | DetectCapabilities (IN VOID *SourceBuffer, IN UINT32 SourceSize) |
STATIC EFI_STATUS EFIAPI | InternalEfiLoadImage (IN BOOLEAN BootPolicy, IN EFI_HANDLE ParentImageHandle, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle) |
STATIC EFI_STATUS EFIAPI | InternalEfiStartImage (IN EFI_HANDLE ImageHandle, OUT UINTN *ExitDataSize, OUT CHAR16 **ExitData OPTIONAL) |
STATIC EFI_STATUS EFIAPI | InternalEfiUnloadImage (IN EFI_HANDLE ImageHandle) |
STATIC EFI_STATUS EFIAPI | InternalEfiExit (IN EFI_HANDLE ImageHandle, IN EFI_STATUS ExitStatus, IN UINTN ExitDataSize, IN CHAR16 *ExitData OPTIONAL) |
VOID | OcImageLoaderInit (IN CONST BOOLEAN ProtectUefiServices, IN CONST BOOLEAN FixupAppleEfiImages) |
VOID | OcImageLoaderActivate (VOID) |
VOID | OcImageLoaderRegisterPatch (IN OC_IMAGE_LOADER_PATCH Patch OPTIONAL) |
VOID | OcImageLoaderRegisterConfigure (IN OC_IMAGE_LOADER_CONFIGURE Configure OPTIONAL) |
Variables | |
STATIC EFI_GUID | mOcLoadedImageProtocolGuid |
STATIC EFI_GUID | mOcImageLoaderCapsProtocolGuid |
STATIC EFI_IMAGE_LOAD | mOriginalEfiLoadImage |
STATIC EFI_IMAGE_START | mOriginalEfiStartImage |
STATIC EFI_IMAGE_UNLOAD | mOriginalEfiUnloadImage |
STATIC EFI_EXIT | mOriginalEfiExit |
STATIC EFI_HANDLE | mCurrentImageHandle |
STATIC OC_IMAGE_LOADER_PATCH | mImageLoaderPatch |
STATIC OC_IMAGE_LOADER_CONFIGURE | mImageLoaderConfigure |
STATIC BOOLEAN | mImageLoaderEnabled |
STATIC BOOLEAN | mProtectUefiServices |
STATIC BOOLEAN | mFixupAppleEfiImages |
STATIC EFI_IMAGE_LOAD | mPreservedLoadImage |
STATIC EFI_IMAGE_START | mPreservedStartImage |
STATIC EFI_EXIT_BOOT_SERVICES | mPreservedExitBootServices |
STATIC EFI_EXIT | mPreservedExit |
Copyright (C) 2019, vit9696. All rights reserved.
All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Definition in file ImageLoader.c.
STATIC UINT32 DetectCapabilities | ( | IN VOID * | SourceBuffer, |
IN UINT32 | SourceSize ) |
Detect kernel capabilities from EfiBoot image.
[in] | SourceBuffer | Buffer containing EfiBoot. |
[in] | SourceSize | Size of EfiBoot buffer. |
Definition at line 702 of file ImageLoader.c.
STATIC EFI_STATUS InternalDirectExit | ( | IN OC_LOADED_IMAGE_PROTOCOL * | OcLoadedImage, |
IN EFI_HANDLE | ImageHandle, | ||
IN EFI_STATUS | ExitStatus, | ||
IN UINTN | ExitDataSize, | ||
IN CHAR16 *ExitData | OPTIONAL ) |
Unload image routine for OcImageLoaderLoad.
[in] | OcLoadedImage | Our loaded image instance. |
[in] | ImageHandle | Handle that identifies the image to be unloaded. |
[in] | ExitStatus | The image's exit code. |
[in] | ExitDataSize | The size, in bytes, of ExitData. Ignored if ExitStatus is EFI_SUCCESS. |
[in] | ExitData | The pointer to a data buffer that includes a Null-terminated string, optionally followed by additional binary data. The string is a description that the caller may use to further indicate the reason for the image's exit. ExitData is only valid if ExitStatus is something other than EFI_SUCCESS. The ExitData buffer must be allocated by calling AllocatePool(). |
EFI_SUCCESS | The image has been unloaded. |
Definition at line 501 of file ImageLoader.c.
STATIC EFI_STATUS InternalDirectStartImage | ( | IN OC_LOADED_IMAGE_PROTOCOL * | OcLoadedImage, |
IN EFI_HANDLE | ImageHandle, | ||
OUT UINTN * | ExitDataSize, | ||
OUT CHAR16 **ExitData | OPTIONAL ) |
Simplified start image routine for OcImageLoaderLoad.
[in] | OcLoadedImage | Our loaded image instance. |
[in] | ImageHandle | Handle of image to be started. |
[out] | ExitDataSize | The pointer to the size, in bytes, of ExitData. |
[out] | ExitData | The pointer to a pointer to a data buffer that includes a Null-terminated string, optionally followed by additional binary data. |
EFI_SUCCESS | on success. |
Definition at line 589 of file ImageLoader.c.
STATIC EFI_STATUS InternalDirectUnloadImage | ( | IN OC_LOADED_IMAGE_PROTOCOL * | OcLoadedImage, |
IN EFI_HANDLE | ImageHandle ) |
Unload image routine for OcImageLoaderLoad.
[in] | OcLoadedImage | Our loaded image instance. |
[in] | ImageHandle | Handle that identifies the image to be unloaded. |
EFI_SUCCESS | The image has been unloaded. |
Definition at line 440 of file ImageLoader.c.
STATIC EFI_STATUS EFIAPI InternalEfiExit | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_STATUS | ExitStatus, | ||
IN UINTN | ExitDataSize, | ||
IN CHAR16 *ExitData | OPTIONAL ) |
Definition at line 1180 of file ImageLoader.c.
STATIC EFI_STATUS EFIAPI InternalEfiLoadImage | ( | IN BOOLEAN | BootPolicy, |
IN EFI_HANDLE | ParentImageHandle, | ||
IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, | ||
IN VOID *SourceBuffer | OPTIONAL, | ||
IN UINTN | SourceSize, | ||
OUT EFI_HANDLE * | ImageHandle ) |
Definition at line 774 of file ImageLoader.c.
STATIC EFI_STATUS InternalEfiLoadImageFile | ( | IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, |
OUT UINTN * | FileSize, | ||
OUT VOID ** | FileBuffer ) |
Definition at line 154 of file ImageLoader.c.
STATIC EFI_STATUS InternalEfiLoadImageProtocol | ( | IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, |
IN BOOLEAN | UseLoadImage2, | ||
OUT UINTN * | FileSize, | ||
OUT VOID ** | FileBuffer ) |
Definition at line 209 of file ImageLoader.c.
STATIC EFI_STATUS EFIAPI InternalEfiStartImage | ( | IN EFI_HANDLE | ImageHandle, |
OUT UINTN * | ExitDataSize, | ||
OUT CHAR16 **ExitData | OPTIONAL ) |
Definition at line 1045 of file ImageLoader.c.
STATIC EFI_STATUS EFIAPI InternalEfiUnloadImage | ( | IN EFI_HANDLE | ImageHandle | ) |
Definition at line 1129 of file ImageLoader.c.
STATIC EFI_STATUS InternalUpdateLoadedImage | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath ) |
Definition at line 224 of file ImageLoader.c.
VOID OcImageLoaderActivate | ( | VOID | ) |
Make DirectImageLoader the default for Apple Secure Boot.
Definition at line 1242 of file ImageLoader.c.
VOID OcImageLoaderInit | ( | IN CONST BOOLEAN | ProtectUefiServices, |
IN CONST BOOLEAN | FixupAppleEfiImages ) |
Initialises custom Boot Services overrides to support direct images.
Definition at line 1219 of file ImageLoader.c.
EFI_STATUS EFIAPI OcImageLoaderLoad | ( | IN BOOLEAN | BootPolicy, |
IN EFI_HANDLE | ParentImageHandle, | ||
IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, | ||
IN VOID *SourceBuffer | OPTIONAL, | ||
IN UINTN | SourceSize, | ||
OUT EFI_HANDLE * | ImageHandle ) |
Simplified load image routine, which bypasses UEFI and loads the image directly.
[in] | BootPolicy | Ignored. |
[in] | ParentImageHandle | The caller's image handle. |
[in] | DevicePath | Ignored. |
[in] | SourceBuffer | Pointer to the memory location containing image to be loaded. |
[in] | SourceSize | The size in bytes of SourceBuffer. |
[out] | ImageHandle | The pointer to the returned image handle created on success. |
EFI_SUCCESS | on success. |
Definition at line 262 of file ImageLoader.c.
VOID OcImageLoaderRegisterConfigure | ( | IN OC_IMAGE_LOADER_CONFIGURE Configure | OPTIONAL | ) |
Register image start callback.
[in] | Configure | Callback function to call on image start. |
Definition at line 1258 of file ImageLoader.c.
VOID OcImageLoaderRegisterPatch | ( | IN OC_IMAGE_LOADER_PATCH Patch | OPTIONAL | ) |
Register image loading callback.
[in] | Patch | Callback function to call on image load. |
Definition at line 1250 of file ImageLoader.c.
STATIC VOID PreserveGrubShimHooks | ( | VOID | ) |
Definition at line 103 of file ImageLoader.c.
STATIC VOID RestoreGrubShimHooks | ( | IN CONST CHAR8 * | Caller | ) |
Definition at line 122 of file ImageLoader.c.
STATIC EFI_HANDLE mCurrentImageHandle |
Definition at line 87 of file ImageLoader.c.
STATIC BOOLEAN mFixupAppleEfiImages |
Definition at line 94 of file ImageLoader.c.
STATIC OC_IMAGE_LOADER_CONFIGURE mImageLoaderConfigure |
Definition at line 90 of file ImageLoader.c.
STATIC BOOLEAN mImageLoaderEnabled |
Definition at line 91 of file ImageLoader.c.
STATIC OC_IMAGE_LOADER_PATCH mImageLoaderPatch |
Definition at line 89 of file ImageLoader.c.
STATIC EFI_GUID mOcImageLoaderCapsProtocolGuid |
Definition at line 61 of file ImageLoader.c.
STATIC EFI_GUID mOcLoadedImageProtocolGuid |
Definition at line 57 of file ImageLoader.c.
STATIC EFI_EXIT mOriginalEfiExit |
Definition at line 86 of file ImageLoader.c.
STATIC EFI_IMAGE_LOAD mOriginalEfiLoadImage |
Definition at line 83 of file ImageLoader.c.
STATIC EFI_IMAGE_START mOriginalEfiStartImage |
Definition at line 84 of file ImageLoader.c.
STATIC EFI_IMAGE_UNLOAD mOriginalEfiUnloadImage |
Definition at line 85 of file ImageLoader.c.
STATIC EFI_EXIT mPreservedExit |
Definition at line 99 of file ImageLoader.c.
STATIC EFI_EXIT_BOOT_SERVICES mPreservedExitBootServices |
Definition at line 98 of file ImageLoader.c.
STATIC EFI_IMAGE_LOAD mPreservedLoadImage |
Definition at line 96 of file ImageLoader.c.
STATIC EFI_IMAGE_START mPreservedStartImage |
Definition at line 97 of file ImageLoader.c.
STATIC BOOLEAN mProtectUefiServices |
Definition at line 93 of file ImageLoader.c.