OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcPeCoffExtLib.h File Reference
#include <IndustryStandard/Apfs.h>
#include <Library/PeCoffLib2.h>

Go to the source code of this file.

Functions

EFI_STATUS PeCoffVerifyAppleSignature (IN OUT VOID *PeImage, IN OUT UINT32 *ImageSize)
 
EFI_STATUS PeCoffGetApfsDriverVersion (IN VOID *DriverBuffer, IN UINT32 DriverSize, OUT APFS_DRIVER_VERSION **DriverVersionPtr)
 
EFI_STATUS OcPatchLegacyEfi (IN VOID *DriverBuffer, IN UINT32 DriverSize)
 
RETURN_STATUS OcPeCoffFixupInitializeContext (OUT PE_COFF_LOADER_IMAGE_CONTEXT *Context, IN CONST VOID *FileBuffer, IN UINT32 FileSize, IN BOOLEAN InMemoryFixup)
 

Detailed Description

Provides additional services for Apple PE/COFF image.

Copyright (c) 2018, savvas. All rights reserved.
Copyright (c) 2021, vit9696. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file OcPeCoffExtLib.h.

Function Documentation

◆ OcPatchLegacyEfi()

EFI_STATUS OcPatchLegacyEfi ( IN VOID * DriverBuffer,
IN UINT32 DriverSize )

Detect and patch W^X and overlapping section errors in legacy boot.efi. Expected to fix overlapping sections in 10.4 and 10.5 32-bit only, and W^X errors in most macOS binaries.

Parameters
[in]DriverBufferImage buffer.
[in]DriverSizeSize of the image.
Return values
EFI_SUCCESSon success.

Definition at line 577 of file OcPeCoffExtLib.c.

◆ OcPeCoffFixupInitializeContext()

RETURN_STATUS OcPeCoffFixupInitializeContext ( OUT PE_COFF_LOADER_IMAGE_CONTEXT * Context,
IN CONST VOID * FileBuffer,
IN UINT32 FileSize,
IN BOOLEAN InMemoryFixup )

Fix W^X and section overlap issues in loaded TE, PE32, or PE32+ Image in memory while initialising Context.

Closely based on PeCoffInitializeContext from PeCoffLib2.

The approach of modifying the image in memory is basically incompatible with secure boot, although: a) Certain firmware may allow optionally registering the hash of any image which does not load, which would still work. b) It is fairly crazy anyway to want to apply secure boot to the old, insecure .efi files which need these fixups.

Parameters
[out]ContextThe context describing the Image.
[in]FileBufferThe file data to parse as PE Image.
[in]FileSizeThe size, in Bytes, of FileBuffer.
[in]InMemoryFixupIf TRUE, fixes are made to image in memory. If FALSE, Context is initialised as if fixes were made, but no changes are made to loaded image.
Return values
RETURN_SUCCESSThe Image context has been initialised successfully.
otherThe file data is malformed.

Definition at line 739 of file OcPeCoffFixupInit.c.

◆ PeCoffGetApfsDriverVersion()

EFI_STATUS PeCoffGetApfsDriverVersion ( IN VOID * DriverBuffer,
IN UINT32 DriverSize,
OUT APFS_DRIVER_VERSION ** DriverVersionPtr )

Obtain APFS driver version.

Parameters
[in]DriverBufferImage buffer.
[in]DriverSizeSize of the image.
[out]DriverVersionPtrDriver version within image buffer.
Return values
EFI_SUCCESSon success.

Definition at line 553 of file OcPeCoffExtLib.c.

◆ PeCoffVerifyAppleSignature()

EFI_STATUS PeCoffVerifyAppleSignature ( IN OUT VOID * PeImage,
IN OUT UINT32 * ImageSize )

Verify Apple COFF legacy signature. Image buffer is sanitized where necessary (zeroed), and an updated length is returned through size parameter.

Parameters
[in,out]PeImageImage buffer.
[in,out]ImageSizeSize of the image.
Return values
EFI_SUCCESSon success.

Definition at line 458 of file OcPeCoffExtLib.c.