OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
BootCompatInternal.h File Reference
#include <Uefi.h>
#include <IndustryStandard/AppleBootArgs.h>
#include <IndustryStandard/AppleEfiBootRtInfo.h>
#include <Library/OcAfterBootCompatLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcMemoryLib.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/OcFirmwareRuntime.h>

Go to the source code of this file.

Data Structures

struct  CALL_GATE_JUMP_
 
struct  RT_RELOC_PROTECT_INFO_
 
struct  RT_RELOC_PROTECT_DATA_
 
struct  UEFI_SERVICES_POINTERS_
 
struct  SERVICES_OVERRIDE_STATE_
 
struct  KERNEL_SUPPORT_STATE_
 
struct  SLIDE_SUPPORT_STATE_
 
struct  BOOT_COMPAT_CONTEXT_
 

Macros

#define RT_RELOC_PROTECT_MAX_NUM   ((UINTN) 64)
 
#define RT_DESC_ENTRY_NUM   ((UINTN) 64)
 
#define KERNEL_STATIC_VADDR   ((UINT64) 0xFFFFFF8000000000ULL)
 
#define KERNEL_HIB_VADDR   ((UINTN) (0xFFFFFF8000100000ULL & MAX_UINTN))
 
#define KERNEL_TEXT_VADDR   ((UINTN) (0xFFFFFF8000200000ULL & MAX_UINTN))
 
#define KERNEL_TEXT_VADDR_LEGACY   0x111000
 
#define KERNEL_BASE_PADDR   ((UINT32) (KERNEL_HIB_VADDR & MAX_UINT32))
 
#define KERNEL_TEXT_PADDR   ((UINT32) (KERNEL_TEXT_VADDR & MAX_UINT32))
 
#define KERNEL_TEXT_PADDR_LEGACY   (KERNEL_TEXT_VADDR_LEGACY)
 
#define SLIDE_GRANULARITY   ((UINTN) SIZE_2MB)
 
#define TOTAL_SLIDE_NUM   ((UINTN) 0x100)
 
#define SLIDE_ERRATA_NUM   ((UINTN) 0x80)
 
#define SLIDE_ERRATA_SKIP_RANGE   ((UINTN) 0x10200000)
 
#define ESTIMATED_KERNEL_SIZE   ((UINTN) (200 * SIZE_1MB))
 
#define ESTIMATED_CALL_GATE_SIZE   256
 
#define CALL_GATE_JUMP_SIZE   (sizeof (CALL_GATE_JUMP))
 
#define CALL_GATE_MIN_SIZE   (ESTIMATED_CALL_GATE_SIZE + CALL_GATE_JUMP_SIZE)
 

Typedefs

typedef struct CALL_GATE_JUMP_ CALL_GATE_JUMP
 
typedef UINTN(EFIAPI * KERNEL_CALL_GATE) (IN UINTN Arg1, IN UINTN Arg2)
 
typedef UINTN(EFIAPI * RELOCATION_CALL_GATE) (IN UINTN QWordCount, IN UINTN EntryPoint, IN EFI_PHYSICAL_ADDRESS Source, IN UINTN Args)
 
typedef struct RT_RELOC_PROTECT_INFO_ RT_RELOC_PROTECT_INFO
 
typedef struct RT_RELOC_PROTECT_DATA_ RT_RELOC_PROTECT_DATA
 
typedef struct UEFI_SERVICES_POINTERS_ UEFI_SERVICES_POINTERS
 
typedef struct SERVICES_OVERRIDE_STATE_ SERVICES_OVERRIDE_STATE
 
typedef struct KERNEL_SUPPORT_STATE_ KERNEL_SUPPORT_STATE
 
typedef struct SLIDE_SUPPORT_STATE_ SLIDE_SUPPORT_STATE
 
typedef struct BOOT_COMPAT_CONTEXT_ BOOT_COMPAT_CONTEXT
 

Functions

 STATIC_ASSERT (sizeof(CALL_GATE_JUMP)==7+14, "Invalid CALL_GATE_JUMP size")
 
BOOT_COMPAT_CONTEXTGetBootCompatContext (VOID)
 
VOID InstallServiceOverrides (IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
 
VOID AppleMapPrepareMemoryPool (IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
 
VOID AppleMapPrepareBooterState (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT EFI_LOADED_IMAGE *LoadedImage, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL)
 
VOID AppleMapPrepareKernelJump32 (IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
 
VOID AppleMapPrepareKernelJump64 (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN EFI_PHYSICAL_ADDRESS CallGate, IN UINTN HookAddress)
 
VOID AppleMapPrepareForBooting (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT VOID *BootArgs)
 
VOID AppleMapPrepareForHibernateWake (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN UINTN ImageHeaderPage)
 
EFI_STATUS AppleMapPrepareMemState (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
 
VOID AsmAppleMapPrepareKernelState32 (VOID)
 
UINTN EFIAPI AppleMapPrepareKernelState32 (IN UINTN Args)
 
EFI_STATUS EFIAPI AppleMapPrepareKernelStateNew64 (IN UINTN SystemTable, IN OUT APPLE_EFI_BOOT_RT_KCG_ARGS *KcgArguments, IN KERNEL_CALL_GATE CallGate)
 
UINTN EFIAPI AppleMapPrepareKernelStateOld64 (IN UINTN Args, IN UINTN EntryPoint, IN KERNEL_CALL_GATE CallGate)
 
VOID AppleSlideUnlockForSafeMode (IN OUT UINT8 *ImageBase, IN UINTN ImageSize)
 
EFI_STATUS AppleSlideGetVariable (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN EFI_GET_VARIABLE GetVariable, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN OC_MEMORY_FILTER FilterMap OPTIONAL, IN VOID *FilterMapContext OPTIONAL, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
 
VOID AppleSlideRestore (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT OC_BOOT_ARGUMENTS *BootArgs)
 
UINTN AppleSlideGetRelocationSize (IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
 
EFI_STATUS AppleRelocationAllocatePages (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN EFI_GET_MEMORY_MAP GetMemoryMap, IN EFI_ALLOCATE_PAGES AllocatePages, IN UINTN NumberOfPages, IN OUT EFI_PHYSICAL_ADDRESS *Memory)
 
EFI_STATUS AppleRelocationRelease (IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
 
EFI_STATUS AppleRelocationVirtualize (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT OC_BOOT_ARGUMENTS *BA)
 
VOID AppleRelocationRebase (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT OC_BOOT_ARGUMENTS *BA)
 
VOID AppleRelocationCallGate64 (IN OUT UINTN *Args, IN BOOT_COMPAT_CONTEXT *BootCompat, IN KERNEL_CALL_GATE CallGate, IN UINTN *KcgArg1, IN UINTN KcgArg2)
 

Detailed Description

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 BootCompatInternal.h.

Macro Definition Documentation

◆ CALL_GATE_JUMP_SIZE

#define CALL_GATE_JUMP_SIZE   (sizeof (CALL_GATE_JUMP))

Size of jump from call gate inserted before Call Gate to jump to our code.

Definition at line 130 of file BootCompatInternal.h.

◆ CALL_GATE_MIN_SIZE

#define CALL_GATE_MIN_SIZE   (ESTIMATED_CALL_GATE_SIZE + CALL_GATE_JUMP_SIZE)

Definition at line 135 of file BootCompatInternal.h.

◆ ESTIMATED_CALL_GATE_SIZE

#define ESTIMATED_CALL_GATE_SIZE   256

Assume call gate (normally a little over 100 bytes) can be up to 256 bytes. It is allocated in its own page and is relocatable.

WARNING: Keep this in sync with RelocationCallGate assembly!

Definition at line 125 of file BootCompatInternal.h.

◆ ESTIMATED_KERNEL_SIZE

#define ESTIMATED_KERNEL_SIZE   ((UINTN) (200 * SIZE_1MB))

Assume the kernel is roughly 128 MBs. And the recovery introduced with Big Sur has roughly 200 MBs. See 11.0b10 EB.MM.AKMR function (EfiBoot.MemoryMap.AllocateKernelMemoryRecovery), it has 0xC119 pages requested. This value is likely calculated from KC size.

Definition at line 117 of file BootCompatInternal.h.

◆ KERNEL_BASE_PADDR

#define KERNEL_BASE_PADDR   ((UINT32) (KERNEL_HIB_VADDR & MAX_UINT32))

Kernel physical base address.

Definition at line 79 of file BootCompatInternal.h.

◆ KERNEL_HIB_VADDR

#define KERNEL_HIB_VADDR   ((UINTN) (0xFFFFFF8000100000ULL & MAX_UINTN))

Kernel __HIB segment virtual address.

Definition at line 64 of file BootCompatInternal.h.

◆ KERNEL_STATIC_VADDR

#define KERNEL_STATIC_VADDR   ((UINT64) 0xFFFFFF8000000000ULL)

Kernel static vaddr mapping base.

Definition at line 59 of file BootCompatInternal.h.

◆ KERNEL_TEXT_PADDR

#define KERNEL_TEXT_PADDR   ((UINT32) (KERNEL_TEXT_VADDR & MAX_UINT32))

Kernel __TEXT physical base address (macOS 10.6 and higher).

Definition at line 84 of file BootCompatInternal.h.

◆ KERNEL_TEXT_PADDR_LEGACY

#define KERNEL_TEXT_PADDR_LEGACY   (KERNEL_TEXT_VADDR_LEGACY)

Kernel __TEXT physical base address (macOS 10.4 and 10.5).

Definition at line 89 of file BootCompatInternal.h.

◆ KERNEL_TEXT_VADDR

#define KERNEL_TEXT_VADDR   ((UINTN) (0xFFFFFF8000200000ULL & MAX_UINTN))

Kernel __TEXT segment virtual address (macOS 10.6 and higher).

Definition at line 69 of file BootCompatInternal.h.

◆ KERNEL_TEXT_VADDR_LEGACY

#define KERNEL_TEXT_VADDR_LEGACY   0x111000

Kernel __TEXT segment virtual address (macOS 10.4 and 10.5).

Definition at line 74 of file BootCompatInternal.h.

◆ RT_DESC_ENTRY_NUM

#define RT_DESC_ENTRY_NUM   ((UINTN) 64)

Runtime descriptor number to virtualise. Currently hardocded for simplicity.

Definition at line 54 of file BootCompatInternal.h.

◆ RT_RELOC_PROTECT_MAX_NUM

#define RT_RELOC_PROTECT_MAX_NUM   ((UINTN) 64)

Maximum number of supported runtime reloc protection areas. Currently hardocded for simplicity.

Definition at line 48 of file BootCompatInternal.h.

◆ SLIDE_ERRATA_NUM

#define SLIDE_ERRATA_NUM   ((UINTN) 0x80)

Slide errate number to skip range from.

Definition at line 104 of file BootCompatInternal.h.

◆ SLIDE_ERRATA_SKIP_RANGE

#define SLIDE_ERRATA_SKIP_RANGE   ((UINTN) 0x10200000)

Sandy/Ivy skip slide range for Intel HD graphics.

Definition at line 109 of file BootCompatInternal.h.

◆ SLIDE_GRANULARITY

#define SLIDE_GRANULARITY   ((UINTN) SIZE_2MB)

Slide offset per slide entry

Definition at line 94 of file BootCompatInternal.h.

◆ TOTAL_SLIDE_NUM

#define TOTAL_SLIDE_NUM   ((UINTN) 0x100)

Total possible number of KASLR slide offsets.

Definition at line 99 of file BootCompatInternal.h.

Typedef Documentation

◆ BOOT_COMPAT_CONTEXT

Apple Boot Compatibility context.

◆ CALL_GATE_JUMP

Command used to perform an absolute 64-bit jump from Call Gate to our code.

◆ KERNEL_CALL_GATE

typedef UINTN(EFIAPI * KERNEL_CALL_GATE) (IN UINTN Arg1, IN UINTN Arg2)

Kernel call gate prototype.

Definition at line 159 of file BootCompatInternal.h.

◆ KERNEL_SUPPORT_STATE

Apple kernel support internal state..

◆ RELOCATION_CALL_GATE

typedef UINTN(EFIAPI * RELOCATION_CALL_GATE) (IN UINTN QWordCount, IN UINTN EntryPoint, IN EFI_PHYSICAL_ADDRESS Source, IN UINTN Args)

Relocation call gate prototype.

Definition at line 169 of file BootCompatInternal.h.

◆ RT_RELOC_PROTECT_DATA

Preserved relocation entry list.

◆ RT_RELOC_PROTECT_INFO

Preserved relocation entry.

◆ SERVICES_OVERRIDE_STATE

UEFI services override internal state.

◆ SLIDE_SUPPORT_STATE

Apple booter KASLR slide support internal state.

◆ UEFI_SERVICES_POINTERS

UEFI Boot & Runtime Services original pointers.

Function Documentation

◆ AppleMapPrepareBooterState()

VOID AppleMapPrepareBooterState ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT EFI_LOADED_IMAGE * LoadedImage,
IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL )

Prepare environment for Apple UEFI bootloader. See more details inside.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]LoadedImageUEFI loaded image protocol instance.
[in]GetMemoryMapUnmodified GetMemoryMap pointer, optional.

Definition at line 542 of file KernelSupport.c.

◆ AppleMapPrepareForBooting()

VOID AppleMapPrepareForBooting ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT VOID * BootArgs )

Prepare environment for normal booting. Called when boot.efi jumps to kernel.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]BootArgsApple kernel boot arguments.

Definition at line 325 of file KernelSupport.c.

◆ AppleMapPrepareForHibernateWake()

VOID AppleMapPrepareForHibernateWake ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN UINTN ImageHeaderPage )

Prepare environment for hibernate wake. Called when boot.efi jumps to kernel.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]ImageHeaderPageApple hibernate image page number.

Definition at line 436 of file KernelSupport.c.

◆ AppleMapPrepareKernelJump32()

VOID AppleMapPrepareKernelJump32 ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat)

Patch kernel entry point with KernelJump to later land in AppleMapPrepareKernelState.

Parameters
[in,out]BootCompatBoot compatibility context.

< mov bx, ds

< mov es, ebx

< mov ebp, eax

< call

Definition at line 36 of file KernelSupport32.c.

◆ AppleMapPrepareKernelJump64()

VOID AppleMapPrepareKernelJump64 ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN EFI_PHYSICAL_ADDRESS CallGate,
IN UINTN HookAddress )

Patch kernel entry point with KernelJump to later land in AppleMapPrepareKernelState.

Parameters
[in,out]BootCompatBoot compatibility context.
[in]CallGateKernel call gate address.
[in]HookAddressThe function address to jump to when entering the kernel call gate.

Definition at line 36 of file KernelSupport64.c.

◆ AppleMapPrepareKernelState32()

UINTN EFIAPI AppleMapPrepareKernelState32 ( IN UINTN Args)

Prepare environment for Apple kernel bootloader in boot or wake cases. This callback arrives when boot.efi jumps to kernel entry point. Should transfer control to restored kernel entry point with the same arguments.

Parameters
[in]ArgsCase-specific kernel argument handle.
Returns
Case-specific value if any.

Definition at line 114 of file KernelSupport32.c.

◆ AppleMapPrepareKernelStateNew64()

EFI_STATUS EFIAPI AppleMapPrepareKernelStateNew64 ( IN UINTN SystemTable,
IN OUT APPLE_EFI_BOOT_RT_KCG_ARGS * KcgArguments,
IN KERNEL_CALL_GATE CallGate )

Prepare environment for Apple kernel bootloader in boot or wake cases. This callback arrives when boot.efi jumps to kernel call gate. Should transfer control to kernel call gate + CALL_GATE_JUMP_SIZE with the same arguments.

This uses the new (as of macOS 13 Developer Beta 1) prototype. This is due to EfiBootRt wrapping the actual kernel call gate.

Parameters
[in]SystemTableA pointer to the EFI System Table.
[in,out]KcgArgumentsArguments to the kernel call gate.
[in]CallGateThe kernel call gate.
Return values
EFI_ABORTEDThe kernel could not be started.
otherOn success, this function does not return.

Definition at line 135 of file KernelSupport64.c.

◆ AppleMapPrepareKernelStateOld64()

UINTN EFIAPI AppleMapPrepareKernelStateOld64 ( IN UINTN Args,
IN UINTN EntryPoint,
IN KERNEL_CALL_GATE CallGate )

Prepare environment for Apple kernel bootloader in boot or wake cases. This callback arrives when boot.efi jumps to kernel call gate. Should transfer control to kernel call gate + CALL_GATE_JUMP_SIZE with the same arguments.

This uses the old (prior to macOS 13 Developer Beta 1) prototype.

Parameters
[in]ArgsCase-specific kernel argument handle.
[in]EntryPointCase-specific kernel entry point.
[in]CallGateThe kernel call gate.
Returns
Case-specific value if any.

Definition at line 152 of file KernelSupport64.c.

◆ AppleMapPrepareMemoryPool()

VOID AppleMapPrepareMemoryPool ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat)

Prepare virtual memory management environment for later usage.

Parameters
[in,out]BootCompatBoot compatibility context.

Definition at line 518 of file KernelSupport.c.

◆ AppleMapPrepareMemState()

EFI_STATUS AppleMapPrepareMemState ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize,
IN UINT32 DescriptorVersion,
IN EFI_MEMORY_DESCRIPTOR * MemoryMap )

Prepare memory state and perform virtual address translation.

Parameters
[in,out]BootCompatBoot compatibility context.
[in]MemoryMapSizeSetVirtualAddresses memory map size argument.
[in]DescriptorSizeSetVirtualAddresses descriptor size argument.
[in]DescriptorVersionSetVirtualAddresses descriptor version argument.
[in]MemoryMapSetVirtualAddresses memory map argument.

Definition at line 608 of file KernelSupport.c.

◆ AppleRelocationAllocatePages()

EFI_STATUS AppleRelocationAllocatePages ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN EFI_GET_MEMORY_MAP GetMemoryMap,
IN EFI_ALLOCATE_PAGES AllocatePages,
IN UINTN NumberOfPages,
IN OUT EFI_PHYSICAL_ADDRESS * Memory )

Allocate memory from a relocation block when zero slide is unavailable. EfiLoaderData at address.

Parameters
[in,out]BootCompatBoot compatibility context.
[in]GetMemoryMapUnmodified GetMemoryMap pointer, optional.
[in]AllocatePagesUnmodified AllocatePages pointer.
[in]NumberOfPagesNumber of pages to allocate.
[in,out]MemoryMemory address to allocate, may be updated.
Return values
EFI_SUCCESSon success.
EFI_UNSUPPORTEDwhen zero slide is available.

Definition at line 40 of file RelocationBlock.c.

◆ AppleRelocationCallGate64()

VOID AppleRelocationCallGate64 ( IN OUT UINTN * Args,
IN BOOT_COMPAT_CONTEXT * BootCompat,
IN KERNEL_CALL_GATE CallGate,
IN UINTN * KcgArg1,
IN UINTN KcgArg2 )

Boot Apple Kernel through relocation block.

Parameters
[in,out]ArgsOn input, the un-relocated kernel argument handle. On output, the relocated kernel argument handle.
[in]BootCompatBoot compatibility context.
[in]CallGateKernel call gate address.
[in]KcgArg1Pointer to the first kernel call gate argument.
[in]KcgArg2Second kernel call gate argument.

Definition at line 378 of file RelocationBlock.c.

◆ AppleRelocationRebase()

VOID AppleRelocationRebase ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT OC_BOOT_ARGUMENTS * BA )

Transition from relocation block address space to normal low memory address space in the relevant XNU areas.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]BootArgsApple kernel boot arguments.

Definition at line 253 of file RelocationBlock.c.

◆ AppleRelocationRelease()

EFI_STATUS AppleRelocationRelease ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat)

Release relocation block if present.

Parameters
[in,out]BootCompatBoot compatibility context.
Return values
EFI_SUCCESSon success.
EFI_UNSUPPORTEDwhen zero slide is available.

Definition at line 125 of file RelocationBlock.c.

◆ AppleRelocationVirtualize()

EFI_STATUS AppleRelocationVirtualize ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT OC_BOOT_ARGUMENTS * BA )

Transitions to virtual memory for the relocation block.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]BootArgsApple kernel boot arguments.

Definition at line 154 of file RelocationBlock.c.

◆ AppleSlideGetRelocationSize()

UINTN AppleSlideGetRelocationSize ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat)

Get calculated relocation block size for booting with slide=0 (e.g. Safe Mode) or without KASLR (older macOS) when it is otherwise impossible.

Parameters
[in,out]BootCompatBoot compatibility context.
Returns
Size of the relocation block (maximum).
Return values
0otherwise.

Definition at line 879 of file CustomSlide.c.

◆ AppleSlideGetVariable()

EFI_STATUS AppleSlideGetVariable ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN EFI_GET_VARIABLE GetVariable,
IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL,
IN OC_MEMORY_FILTER FilterMap OPTIONAL,
IN VOID *FilterMapContext OPTIONAL,
IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid,
OUT UINT32 *Attributes OPTIONAL,
IN OUT UINTN * DataSize,
OUT VOID * Data )

Primary custom KASLR support handler. This gets called on every UEFI RuntimeServices GetVariable call and thus is useful to perform KASLR slide injection through boot-args.

Parameters
[in,out]BootCompatBoot compatibility context.
[in]GetVariableOriginal UEFI GetVariable service.
[in]GetMemoryMapUnmodified GetMemoryMap pointer, optional.
[in]FilterMapGetMemoryMap result filter, optional.
[in]FilterMapContextFilterMap context, optional.
[in]VariableNameGetVariable variable name argument.
[in]VendorGuidGetVariable vendor GUID argument.
[out]AttributesGetVariable attributes argument.
[in,out]DataSizeGetVariable data size argument.
[out]DataGetVariable data argument.
Return values
GetVariablestatus code.

Definition at line 773 of file CustomSlide.c.

◆ AppleSlideRestore()

VOID AppleSlideRestore ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT OC_BOOT_ARGUMENTS * BootArgs )

Ensures that the original csr-active-config is passed to the kernel, and removes customised slide value for security reasons.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]BootArgsApple kernel boot arguments.

Definition at line 849 of file CustomSlide.c.

◆ AppleSlideUnlockForSafeMode()

VOID AppleSlideUnlockForSafeMode ( IN OUT UINT8 * ImageBase,
IN UINTN ImageSize )

Patch boot.efi to support random and passed slide values in safe mode.

Parameters
[in,out]ImageBaseApple booter image base.
[in]ImageSizeApple booter image size.

Definition at line 609 of file CustomSlide.c.

◆ AsmAppleMapPrepareKernelState32()

VOID AsmAppleMapPrepareKernelState32 ( VOID )

Assembly wrapper for AppleMapPrepareKernelState32. Used to convert calling conventions and fixup registers.

◆ GetBootCompatContext()

BOOT_COMPAT_CONTEXT * GetBootCompatContext ( VOID )

Obtain Apple Boot Compatibility context. This function must only be called from wrapped services, where passing context arguments is not possible.

Return values
AppleBoot Compatibility context (not null).

Definition at line 90 of file OcAfterBootCompatLib.c.

◆ InstallServiceOverrides()

VOID InstallServiceOverrides ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat)

Install UEFI services overrides as necessary.

Parameters
[in,out]BootCompatBoot compatibility context.

Definition at line 1626 of file ServiceOverrides.c.

◆ STATIC_ASSERT()

STATIC_ASSERT ( sizeof(CALL_GATE_JUMP) = =7+14,
"Invalid CALL_GATE_JUMP size"  )