OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcAppleKernelLib.h File Reference
#include <IndustryStandard/AppleMkext.h>
#include <Library/OcCpuLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcXmlLib.h>
#include <Protocol/SimpleFileSystem.h>

Go to the source code of this file.

Data Structures

struct  PRELINKED_CONTEXT
 
struct  PATCHER_CONTEXT
 
struct  PATCHER_GENERIC_PATCH
 
struct  CACHELESS_CONTEXT
 
struct  MKEXT_CONTEXT
 
struct  KERNEL_QUIRK
 

Macros

#define PRELINK_KERNEL_IDENTIFIER   "__kernel__"
 
#define PRELINK_KPI_IDENTIFIER_PREFIX   "com.apple.kpi."
 
#define PRELINK_INFO_SEGMENT   "__PRELINK_INFO"
 
#define PRELINK_INFO_SECTION   "__info"
 
#define PRELINK_TEXT_SEGMENT   "__PRELINK_TEXT"
 
#define PRELINK_TEXT_SECTION   "__text"
 
#define PRELINK_STATE_SEGMENT   "__PRELINK_STATE"
 
#define PRELINK_STATE_SECTION_KERNEL   "__kernel"
 
#define PRELINK_STATE_SECTION_KEXTS   "__kexts"
 
#define PRELINK_INFO_DICTIONARY_KEY   "_PrelinkInfoDictionary"
 
#define PRELINK_INFO_KMOD_INFO_KEY   "_PrelinkKmodInfo"
 
#define PRELINK_INFO_BUNDLE_PATH_KEY   "_PrelinkBundlePath"
 
#define PRELINK_INFO_EXECUTABLE_RELATIVE_PATH_KEY   "_PrelinkExecutableRelativePath"
 
#define PRELINK_INFO_EXECUTABLE_LOAD_ADDR_KEY   "_PrelinkExecutableLoadAddr"
 
#define PRELINK_INFO_EXECUTABLE_SOURCE_ADDR_KEY   "_PrelinkExecutableSourceAddr"
 
#define PRELINK_INFO_EXECUTABLE_SIZE_KEY   "_PrelinkExecutableSize"
 
#define PRELINK_INFO_LINK_STATE_ADDR_KEY   "_PrelinkLinkState"
 
#define PRELINK_INFO_LINK_STATE_SIZE_KEY   "_PrelinkLinkStateSize"
 
#define INFO_BUNDLE_IDENTIFIER_KEY   "CFBundleIdentifier"
 
#define INFO_BUNDLE_EXECUTABLE_KEY   "CFBundleExecutable"
 
#define INFO_BUNDLE_LIBRARIES_KEY   "OSBundleLibraries"
 
#define INFO_BUNDLE_LIBRARIES_64_KEY   "OSBundleLibraries_x86_64"
 
#define INFO_BUNDLE_VERSION_KEY   "CFBundleVersion"
 
#define INFO_BUNDLE_COMPATIBLE_VERSION_KEY   "OSBundleCompatibleVersion"
 
#define INFO_BUNDLE_OS_BUNDLE_REQUIRED_KEY   "OSBundleRequired"
 
#define OS_BUNDLE_REQUIRED_ROOT   "Root"
 
#define OS_BUNDLE_REQUIRED_SAFE_BOOT   "Safe Boot"
 
#define MKEXT_INFO_DICTIONARIES_KEY   "_MKEXTInfoDictionaries"
 
#define MKEXT_BUNDLE_PATH_KEY   "_MKEXTBundlePath"
 
#define MKEXT_EXECUTABLE_RELATIVE_PATH_KEY   "_MKEXTExecutableRelativePath"
 
#define MKEXT_EXECUTABLE_KEY   "_MKEXTExecutable"
 
#define PRELINK_INFO_INTEGER_ATTRIBUTES   "size=\"64\""
 
#define MKEXT_INFO_INTEGER_ATTRIBUTES   "size=\"32\""
 
#define KC_REGION_SEGMENT_PREFIX   "__REGION"
 
#define KC_REGION0_SEGMENT   "__REGION0"
 
#define KC_TEXT_SEGMENT   "__TEXT"
 
#define KC_LINKEDIT_SEGMENT   "__LINKEDIT"
 
#define KC_MOSCOW_SEGMENT   "__MOSCOW101"
 
#define MAX_INFO_BUNDLE_VERSION_KEY_SIZE   32
 
#define PRINT_KERNEL_CACHE_TYPE(a)
 
#define PRELINKED_KEXTS_MAX_SIZE   (BIT16 * MACHO_PAGE_SIZE)
 
#define PRELINK_INFO_RESERVE_SIZE   (5U * 1024U * 1024U)
 
#define PLIST_EXPANSION_SIZE   512
 
#define KERNEL_VERSION(A, B, C)
 
#define KERNEL_VERSION_TIGER   8
 
#define KERNEL_VERSION_LEOPARD   9
 
#define KERNEL_VERSION_SNOW_LEOPARD   10
 
#define KERNEL_VERSION_LION   11
 
#define KERNEL_VERSION_MOUNTAIN_LION   12
 
#define KERNEL_VERSION_MAVERICKS   13
 
#define KERNEL_VERSION_YOSEMITE   14
 
#define KERNEL_VERSION_EL_CAPITAN   15
 
#define KERNEL_VERSION_SIERRA   16
 
#define KERNEL_VERSION_HIGH_SIERRA   17
 
#define KERNEL_VERSION_MOJAVE   18
 
#define KERNEL_VERSION_CATALINA   19
 
#define KERNEL_VERSION_BIG_SUR   20
 
#define KERNEL_VERSION_MONTEREY   21
 
#define KERNEL_VERSION_VENTURA   22
 
#define KERNEL_VERSION_SONOMA   23
 
#define KERNEL_VERSION_SEQUOIA   24
 
#define KERNEL_VERSION_TIGER_MIN   KERNEL_VERSION (KERNEL_VERSION_TIGER, 0, 0)
 
#define KERNEL_VERSION_LEOPARD_MIN   KERNEL_VERSION (KERNEL_VERSION_LEOPARD, 0, 0)
 
#define KERNEL_VERSION_SNOW_LEOPARD_MIN   KERNEL_VERSION (KERNEL_VERSION_SNOW_LEOPARD, 0, 0)
 
#define KERNEL_VERSION_LION_MIN   KERNEL_VERSION (KERNEL_VERSION_LION, 0, 0)
 
#define KERNEL_VERSION_MOUNTAIN_LION_MIN   KERNEL_VERSION (KERNEL_VERSION_MOUNTAIN_LION, 0, 0)
 
#define KERNEL_VERSION_MAVERICKS_MIN   KERNEL_VERSION (KERNEL_VERSION_MAVERICKS, 0, 0)
 
#define KERNEL_VERSION_YOSEMITE_MIN   KERNEL_VERSION (KERNEL_VERSION_YOSEMITE, 0, 0)
 
#define KERNEL_VERSION_EL_CAPITAN_MIN   KERNEL_VERSION (KERNEL_VERSION_EL_CAPITAN, 0, 0)
 
#define KERNEL_VERSION_SIERRA_MIN   KERNEL_VERSION (KERNEL_VERSION_SIERRA, 0, 0)
 
#define KERNEL_VERSION_HIGH_SIERRA_MIN   KERNEL_VERSION (KERNEL_VERSION_HIGH_SIERRA, 0, 0)
 
#define KERNEL_VERSION_MOJAVE_MIN   KERNEL_VERSION (KERNEL_VERSION_MOJAVE, 0, 0)
 
#define KERNEL_VERSION_CATALINA_MIN   KERNEL_VERSION (KERNEL_VERSION_CATALINA, 0, 0)
 
#define KERNEL_VERSION_BIG_SUR_MIN   KERNEL_VERSION (KERNEL_VERSION_BIG_SUR, 0, 0)
 
#define KERNEL_VERSION_MONTEREY_MIN   KERNEL_VERSION (KERNEL_VERSION_MONTEREY, 0, 0)
 
#define KERNEL_VERSION_VENTURA_MIN   KERNEL_VERSION (KERNEL_VERSION_VENTURA, 0, 0)
 
#define KERNEL_VERSION_SONOMA_MIN   KERNEL_VERSION (KERNEL_VERSION_SONOMA, 0, 0)
 
#define KERNEL_VERSION_SEQUOIA_MIN   KERNEL_VERSION (KERNEL_VERSION_SEQUOIA, 0, 0)
 
#define KERNEL_VERSION_TIGER_MAX   (KERNEL_VERSION_LEOPARD_MIN - 1)
 
#define KERNEL_VERSION_LEOPARD_MAX   (KERNEL_VERSION_SNOW_LEOPARD_MIN - 1)
 
#define KERNEL_VERSION_SNOW_LEOPARD_MAX   (KERNEL_VERSION_LION_MIN - 1)
 
#define KERNEL_VERSION_LION_MAX   (KERNEL_VERSION_MOUNTAIN_LION_MIN - 1)
 
#define KERNEL_VERSION_MOUNTAIN_LION_MAX   (KERNEL_VERSION_MAVERICKS_MIN - 1)
 
#define KERNEL_VERSION_MAVERICKS_MAX   (KERNEL_VERSION_YOSEMITE_MIN - 1)
 
#define KERNEL_VERSION_YOSEMITE_MAX   (KERNEL_VERSION_EL_CAPITAN_MIN - 1)
 
#define KERNEL_VERSION_EL_CAPITAN_MAX   (KERNEL_VERSION_SIERRA_MIN - 1)
 
#define KERNEL_VERSION_SIERRA_MAX   (KERNEL_VERSION_HIGH_SIERRA_MIN - 1)
 
#define KERNEL_VERSION_HIGH_SIERRA_MAX   (KERNEL_VERSION_MOJAVE_MIN - 1)
 
#define KERNEL_VERSION_MOJAVE_MAX   (KERNEL_VERSION_CATALINA_MIN - 1)
 
#define KERNEL_VERSION_CATALINA_MAX   (KERNEL_VERSION_BIG_SUR_MIN - 1)
 
#define KERNEL_VERSION_BIG_SUR_MAX   (KERNEL_VERSION_MONTEREY_MIN - 1)
 
#define KERNEL_VERSION_MONTEREY_MAX   (KERNEL_VERSION_VENTURA_MIN - 1)
 
#define KERNEL_VERSION_VENTURA_MAX   (KERNEL_VERSION_SONOMA_MIN - 1)
 
#define KERNEL_VERSION_SONOMA_MAX   (KERNEL_VERSION_SEQUOIA_MIN - 1)
 

Typedefs

typedef enum KERNEL_CACHE_TYPE_ KERNEL_CACHE_TYPE
 
typedef EFI_STATUS KERNEL_QUIRK_PATCH_FUNCTION(IN OUT PATCHER_CONTEXT *Patcher OPTIONAL, IN UINT32 KernelVersion)
 

Enumerations

enum  KERNEL_CACHE_TYPE_ { CacheTypeNone , CacheTypeCacheless , CacheTypeMkext , CacheTypePrelinked }
 
enum  KERNEL_QUIRK_NAME {
  KernelQuirkAppleCpuPmCfgLock , KernelQuirkAppleXcpmCfgLock , KernelQuirkAppleXcpmExtraMsrs , KernelQuirkAppleXcpmForceBoost ,
  KernelQuirkCustomPciSerialDevice , KernelQuirkCustomSmbiosGuid1 , KernelQuirkCustomSmbiosGuid2 , KernelQuirkDisableIoMapper ,
  KernelQuirkDisableIoMapperMapping , KernelQuirkDisableRtcChecksum , KernelQuirkDummyPowerManagement , KernelQuirkExtendBTFeatureFlags ,
  KernelQuirkExternalDiskIcons , KernelQuirkForceAquantiaEthernet , KernelQuirkForceSecureBootScheme , KernelQuirkIncreasePciBarSize ,
  KernelQuirkLapicKernelPanic , KernelQuirkLegacyCommpage , KernelQuirkPanicNoKextDump , KernelQuirkPowerTimeoutKernelPanic ,
  KernelQuirkSegmentJettison , KernelQuirkSetApfsTrimTimeout , KernelQuirkThirdPartyDrives , KernelQuirkXhciPortLimit1 ,
  KernelQuirkXhciPortLimit2 , KernelQuirkXhciPortLimit3 , KernelQuirkMax
}
 

Functions

EFI_STATUS KernelApplyQuirk (IN KERNEL_QUIRK_NAME Name, IN OUT PATCHER_CONTEXT *Patcher OPTIONAL, IN UINT32 KernelVersion)
 
EFI_STATUS ReadAppleKernel (IN EFI_FILE_PROTOCOL *File, IN BOOLEAN Prefer32Bit, OUT BOOLEAN *Is32Bit, OUT UINT8 **Kernel, OUT UINT32 *KernelSize, OUT UINT32 *AllocatedSize, IN UINT32 ReservedSize, OUT UINT8 *Digest OPTIONAL)
 
EFI_STATUS ReadAppleMkext (IN EFI_FILE_PROTOCOL *File, IN BOOLEAN Prefer32Bit, OUT UINT8 **Mkext, OUT UINT32 *MkextSize, OUT UINT32 *AllocatedSize, IN UINT32 ReservedSize, IN UINT32 NumReservedKexts)
 
UINT32 OcParseDarwinVersion (IN CONST CHAR8 *String)
 
UINT32 OcKernelReadDarwinVersion (IN CONST UINT8 *Kernel, IN UINT32 KernelSize)
 
BOOLEAN OcMatchDarwinVersion (IN UINT32 CurrentVersion OPTIONAL, IN UINT32 MinVersion OPTIONAL, IN UINT32 MaxVersion OPTIONAL)
 
EFI_STATUS PrelinkedContextInit (IN OUT PRELINKED_CONTEXT *Context, IN OUT UINT8 *Prelinked, IN UINT32 PrelinkedSize, IN UINT32 PrelinkedAllocSize, IN BOOLEAN Is32Bit)
 
VOID PrelinkedContextFree (IN OUT PRELINKED_CONTEXT *Context)
 
EFI_STATUS PrelinkedDependencyInsert (IN OUT PRELINKED_CONTEXT *Context, IN VOID *Buffer)
 
EFI_STATUS PrelinkedInjectPrepare (IN OUT PRELINKED_CONTEXT *Context, IN UINT32 LinkedExpansion, IN UINT32 ReservedExeSize)
 
EFI_STATUS PrelinkedInjectComplete (IN OUT PRELINKED_CONTEXT *Context)
 
EFI_STATUS PrelinkedReserveKextSize (IN OUT UINT32 *ReservedInfoSize, IN OUT UINT32 *ReservedExeSize, IN UINT32 InfoPlistSize, IN UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, IN BOOLEAN Is32Bit)
 
EFI_STATUS PrelinkedInjectKext (IN OUT PRELINKED_CONTEXT *Context, IN CONST CHAR8 *Identifier OPTIONAL, IN CONST CHAR8 *BundlePath, IN CONST CHAR8 *InfoPlist, IN UINT32 InfoPlistSize, IN CONST CHAR8 *ExecutablePath OPTIONAL, IN OUT CONST UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, OUT CHAR8 BundleVersion[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] OPTIONAL)
 
EFI_STATUS PrelinkedContextApplyPatch (IN OUT PRELINKED_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN PATCHER_GENERIC_PATCH *Patch)
 
EFI_STATUS PrelinkedContextApplyQuirk (IN OUT PRELINKED_CONTEXT *Context, IN KERNEL_QUIRK_NAME Quirk, IN UINT32 KernelVersion)
 
EFI_STATUS PrelinkedContextBlock (IN OUT PRELINKED_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN BOOLEAN Exclude)
 
EFI_STATUS KcRebuildMachHeader (IN OUT PRELINKED_CONTEXT *Context)
 
UINT32 KcGetSegmentFixupChainsSize (IN UINT32 SegmentSize)
 
EFI_STATUS KcInitKextFixupChains (IN OUT PRELINKED_CONTEXT *Context, IN UINT32 SegChainSize, IN UINT32 ReservedSize)
 
VOID KcKextIndexFixups (IN OUT PRELINKED_CONTEXT *Context, IN OC_MACHO_CONTEXT *MachContext)
 
UINT32 KcGetKextSize (IN PRELINKED_CONTEXT *Context, IN UINT64 SourceAddress)
 
EFI_STATUS KcKextApplyFileDelta (IN PRELINKED_CONTEXT *PrelinkedContext, IN OUT OC_MACHO_CONTEXT *Context, IN UINT32 Delta)
 
UINT64 KcFixupValue (IN UINT64 Value, IN CONST CHAR8 *Name OPTIONAL)
 
EFI_STATUS PatcherInitContextFromPrelinked (IN OUT PATCHER_CONTEXT *Context, IN OUT PRELINKED_CONTEXT *Prelinked, IN CONST CHAR8 *Name)
 
EFI_STATUS PatcherInitContextFromMkext (IN OUT PATCHER_CONTEXT *Context, IN OUT MKEXT_CONTEXT *Mkext, IN CONST CHAR8 *Name)
 
EFI_STATUS PatcherInitContextFromBuffer (IN OUT PATCHER_CONTEXT *Context, IN OUT UINT8 *Buffer, IN UINT32 BufferSize, IN BOOLEAN Use32Bit)
 
EFI_STATUS PatcherGetSymbolAddress (IN OUT PATCHER_CONTEXT *Context, IN CONST CHAR8 *Name, IN OUT UINT8 **Address)
 
EFI_STATUS PatcherGetSymbolValue (IN OUT PATCHER_CONTEXT *Context, IN CONST CHAR8 *Name, IN OUT UINT64 *Value)
 
EFI_STATUS PatcherGetSymbolAddressValue (IN OUT PATCHER_CONTEXT *Context, IN CONST CHAR8 *Name, IN OUT UINT8 **Address, IN OUT UINT64 *Value)
 
EFI_STATUS PatcherApplyGenericPatch (IN OUT PATCHER_CONTEXT *Context, IN PATCHER_GENERIC_PATCH *Patch)
 
EFI_STATUS PatcherExcludePrelinkedKext (IN CONST CHAR8 *Identifier, IN OUT PATCHER_CONTEXT *PatcherContext, IN OUT PRELINKED_CONTEXT *PrelinkedContext)
 
EFI_STATUS PatcherExcludeMkextKext (IN OUT MKEXT_CONTEXT *MkextContext, IN CONST CHAR8 *Identifier)
 
EFI_STATUS PatcherBlockKext (IN OUT PATCHER_CONTEXT *Context)
 
BOOLEAN KextFindKmodAddress (IN OC_MACHO_CONTEXT *ExecutableContext, IN UINT64 LoadAddress, IN UINT32 Size, OUT UINT64 *Kmod)
 
VOID PatchSetApfsTimeout (IN UINT32 Timeout)
 
VOID PatchSetPciSerialDevice (IN UINTN RegisterBase, IN UINT32 RegisterStride)
 
EFI_STATUS PatchKernelCpuId (IN OUT PATCHER_CONTEXT *Patcher, IN OC_CPU_INFO *CpuInfo, IN UINT32 *Data, IN UINT32 *DataMask, IN UINT32 KernelVersion)
 
EFI_STATUS PatchProvideCurrentCpuInfo (IN OUT PATCHER_CONTEXT *Patcher, IN OC_CPU_INFO *CpuInfo, IN UINT32 KernelVersion)
 
EFI_STATUS CachelessContextInit (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR16 *FileName, IN EFI_FILE_PROTOCOL *ExtensionsDir, IN UINT32 KernelVersion, IN BOOLEAN Is32Bit)
 
VOID CachelessContextFree (IN OUT CACHELESS_CONTEXT *Context)
 
EFI_STATUS CachelessContextAddKext (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *InfoPlist, IN UINT32 InfoPlistSize, IN UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, OUT CHAR8 BundleVersion[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] OPTIONAL)
 
EFI_STATUS CachelessContextForceKext (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier)
 
EFI_STATUS CachelessContextAddPatch (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN PATCHER_GENERIC_PATCH *Patch)
 
EFI_STATUS CachelessContextAddQuirk (IN OUT CACHELESS_CONTEXT *Context, IN KERNEL_QUIRK_NAME Quirk)
 
EFI_STATUS CachelessContextBlock (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN BOOLEAN Exclude)
 
EFI_STATUS CachelessContextOverlayExtensionsDir (IN OUT CACHELESS_CONTEXT *Context, OUT EFI_FILE_PROTOCOL **File)
 
EFI_STATUS CachelessContextPerformInject (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR16 *FileName, OUT EFI_FILE_PROTOCOL **VirtualFile)
 
EFI_STATUS CachelessContextHookBuiltin (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR16 *FileName, IN EFI_FILE_PROTOCOL *File, OUT EFI_FILE_PROTOCOL **VirtualFile)
 
EFI_STATUS MkextDecompress (IN CONST UINT8 *Buffer, IN UINT32 BufferSize, IN UINT32 NumReservedKexts, IN OUT UINT8 *OutBuffer OPTIONAL, IN UINT32 OutBufferSize OPTIONAL, IN OUT UINT32 *OutMkextSize)
 
BOOLEAN MkextCheckCpuType (IN UINT8 *Mkext, IN UINT32 MkextSize, IN MACH_CPU_TYPE CpuType)
 
EFI_STATUS MkextContextInit (IN OUT MKEXT_CONTEXT *Context, IN OUT UINT8 *Mkext, IN UINT32 MkextSize, IN UINT32 MkextAllocSize)
 
VOID MkextContextFree (IN OUT MKEXT_CONTEXT *Context)
 
EFI_STATUS MkextReserveKextSize (IN OUT UINT32 *ReservedInfoSize, IN OUT UINT32 *ReservedExeSize, IN UINT32 InfoPlistSize, IN UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, IN BOOLEAN Is32Bit)
 
EFI_STATUS MkextInjectKext (IN OUT MKEXT_CONTEXT *Context, IN CONST CHAR8 *Identifier OPTIONAL, IN CONST CHAR8 *BundlePath, IN CONST CHAR8 *InfoPlist, IN UINT32 InfoPlistSize, IN UINT8 *Executable OPTIONAL, IN UINT32 ExecutableSize OPTIONAL, OUT CHAR8 BundleVersion[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] OPTIONAL)
 
EFI_STATUS MkextContextApplyPatch (IN OUT MKEXT_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN PATCHER_GENERIC_PATCH *Patch)
 
EFI_STATUS MkextContextApplyQuirk (IN OUT MKEXT_CONTEXT *Context, IN KERNEL_QUIRK_NAME Quirk, IN UINT32 KernelVersion)
 
EFI_STATUS MkextContextBlock (IN OUT MKEXT_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN BOOLEAN Exclude)
 
EFI_STATUS MkextInjectPatchComplete (IN OUT MKEXT_CONTEXT *Context)
 

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

Macro Definition Documentation

◆ INFO_BUNDLE_COMPATIBLE_VERSION_KEY

#define INFO_BUNDLE_COMPATIBLE_VERSION_KEY   "OSBundleCompatibleVersion"

Definition at line 50 of file OcAppleKernelLib.h.

◆ INFO_BUNDLE_EXECUTABLE_KEY

#define INFO_BUNDLE_EXECUTABLE_KEY   "CFBundleExecutable"

Definition at line 46 of file OcAppleKernelLib.h.

◆ INFO_BUNDLE_IDENTIFIER_KEY

#define INFO_BUNDLE_IDENTIFIER_KEY   "CFBundleIdentifier"

Definition at line 45 of file OcAppleKernelLib.h.

◆ INFO_BUNDLE_LIBRARIES_64_KEY

#define INFO_BUNDLE_LIBRARIES_64_KEY   "OSBundleLibraries_x86_64"

Definition at line 48 of file OcAppleKernelLib.h.

◆ INFO_BUNDLE_LIBRARIES_KEY

#define INFO_BUNDLE_LIBRARIES_KEY   "OSBundleLibraries"

Definition at line 47 of file OcAppleKernelLib.h.

◆ INFO_BUNDLE_OS_BUNDLE_REQUIRED_KEY

#define INFO_BUNDLE_OS_BUNDLE_REQUIRED_KEY   "OSBundleRequired"

Definition at line 51 of file OcAppleKernelLib.h.

◆ INFO_BUNDLE_VERSION_KEY

#define INFO_BUNDLE_VERSION_KEY   "CFBundleVersion"

Definition at line 49 of file OcAppleKernelLib.h.

◆ KC_LINKEDIT_SEGMENT

#define KC_LINKEDIT_SEGMENT   "__LINKEDIT"

Definition at line 67 of file OcAppleKernelLib.h.

◆ KC_MOSCOW_SEGMENT

#define KC_MOSCOW_SEGMENT   "__MOSCOW101"

Definition at line 68 of file OcAppleKernelLib.h.

◆ KC_REGION0_SEGMENT

#define KC_REGION0_SEGMENT   "__REGION0"

Definition at line 65 of file OcAppleKernelLib.h.

◆ KC_REGION_SEGMENT_PREFIX

#define KC_REGION_SEGMENT_PREFIX   "__REGION"

Definition at line 64 of file OcAppleKernelLib.h.

◆ KC_TEXT_SEGMENT

#define KC_TEXT_SEGMENT   "__TEXT"

Definition at line 66 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION

#define KERNEL_VERSION ( A,
B,
C )
Value:
((A) * 10000 + (B) * 100 + (C))

Definition at line 112 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_BIG_SUR

#define KERNEL_VERSION_BIG_SUR   20

Definition at line 129 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_BIG_SUR_MAX

#define KERNEL_VERSION_BIG_SUR_MAX   (KERNEL_VERSION_MONTEREY_MIN - 1)

Definition at line 171 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_BIG_SUR_MIN

#define KERNEL_VERSION_BIG_SUR_MIN   KERNEL_VERSION (KERNEL_VERSION_BIG_SUR, 0, 0)

Definition at line 150 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_CATALINA

#define KERNEL_VERSION_CATALINA   19

Definition at line 128 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_CATALINA_MAX

#define KERNEL_VERSION_CATALINA_MAX   (KERNEL_VERSION_BIG_SUR_MIN - 1)

Definition at line 170 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_CATALINA_MIN

#define KERNEL_VERSION_CATALINA_MIN   KERNEL_VERSION (KERNEL_VERSION_CATALINA, 0, 0)

Definition at line 149 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_EL_CAPITAN

#define KERNEL_VERSION_EL_CAPITAN   15

Definition at line 124 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_EL_CAPITAN_MAX

#define KERNEL_VERSION_EL_CAPITAN_MAX   (KERNEL_VERSION_SIERRA_MIN - 1)

Definition at line 166 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_EL_CAPITAN_MIN

#define KERNEL_VERSION_EL_CAPITAN_MIN   KERNEL_VERSION (KERNEL_VERSION_EL_CAPITAN, 0, 0)

Definition at line 145 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_HIGH_SIERRA

#define KERNEL_VERSION_HIGH_SIERRA   17

Definition at line 126 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_HIGH_SIERRA_MAX

#define KERNEL_VERSION_HIGH_SIERRA_MAX   (KERNEL_VERSION_MOJAVE_MIN - 1)

Definition at line 168 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_HIGH_SIERRA_MIN

#define KERNEL_VERSION_HIGH_SIERRA_MIN   KERNEL_VERSION (KERNEL_VERSION_HIGH_SIERRA, 0, 0)

Definition at line 147 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_LEOPARD

#define KERNEL_VERSION_LEOPARD   9

Definition at line 118 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_LEOPARD_MAX

#define KERNEL_VERSION_LEOPARD_MAX   (KERNEL_VERSION_SNOW_LEOPARD_MIN - 1)

Definition at line 160 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_LEOPARD_MIN

#define KERNEL_VERSION_LEOPARD_MIN   KERNEL_VERSION (KERNEL_VERSION_LEOPARD, 0, 0)

Definition at line 139 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_LION

#define KERNEL_VERSION_LION   11

Definition at line 120 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_LION_MAX

#define KERNEL_VERSION_LION_MAX   (KERNEL_VERSION_MOUNTAIN_LION_MIN - 1)

Definition at line 162 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_LION_MIN

#define KERNEL_VERSION_LION_MIN   KERNEL_VERSION (KERNEL_VERSION_LION, 0, 0)

Definition at line 141 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MAVERICKS

#define KERNEL_VERSION_MAVERICKS   13

Definition at line 122 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MAVERICKS_MAX

#define KERNEL_VERSION_MAVERICKS_MAX   (KERNEL_VERSION_YOSEMITE_MIN - 1)

Definition at line 164 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MAVERICKS_MIN

#define KERNEL_VERSION_MAVERICKS_MIN   KERNEL_VERSION (KERNEL_VERSION_MAVERICKS, 0, 0)

Definition at line 143 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MOJAVE

#define KERNEL_VERSION_MOJAVE   18

Definition at line 127 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MOJAVE_MAX

#define KERNEL_VERSION_MOJAVE_MAX   (KERNEL_VERSION_CATALINA_MIN - 1)

Definition at line 169 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MOJAVE_MIN

#define KERNEL_VERSION_MOJAVE_MIN   KERNEL_VERSION (KERNEL_VERSION_MOJAVE, 0, 0)

Definition at line 148 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MONTEREY

#define KERNEL_VERSION_MONTEREY   21

Definition at line 130 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MONTEREY_MAX

#define KERNEL_VERSION_MONTEREY_MAX   (KERNEL_VERSION_VENTURA_MIN - 1)

Definition at line 172 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MONTEREY_MIN

#define KERNEL_VERSION_MONTEREY_MIN   KERNEL_VERSION (KERNEL_VERSION_MONTEREY, 0, 0)

Definition at line 151 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MOUNTAIN_LION

#define KERNEL_VERSION_MOUNTAIN_LION   12

Definition at line 121 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MOUNTAIN_LION_MAX

#define KERNEL_VERSION_MOUNTAIN_LION_MAX   (KERNEL_VERSION_MAVERICKS_MIN - 1)

Definition at line 163 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_MOUNTAIN_LION_MIN

#define KERNEL_VERSION_MOUNTAIN_LION_MIN   KERNEL_VERSION (KERNEL_VERSION_MOUNTAIN_LION, 0, 0)

Definition at line 142 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SEQUOIA

#define KERNEL_VERSION_SEQUOIA   24

Definition at line 133 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SEQUOIA_MIN

#define KERNEL_VERSION_SEQUOIA_MIN   KERNEL_VERSION (KERNEL_VERSION_SEQUOIA, 0, 0)

Definition at line 154 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SIERRA

#define KERNEL_VERSION_SIERRA   16

Definition at line 125 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SIERRA_MAX

#define KERNEL_VERSION_SIERRA_MAX   (KERNEL_VERSION_HIGH_SIERRA_MIN - 1)

Definition at line 167 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SIERRA_MIN

#define KERNEL_VERSION_SIERRA_MIN   KERNEL_VERSION (KERNEL_VERSION_SIERRA, 0, 0)

Definition at line 146 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SNOW_LEOPARD

#define KERNEL_VERSION_SNOW_LEOPARD   10

Definition at line 119 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SNOW_LEOPARD_MAX

#define KERNEL_VERSION_SNOW_LEOPARD_MAX   (KERNEL_VERSION_LION_MIN - 1)

Definition at line 161 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SNOW_LEOPARD_MIN

#define KERNEL_VERSION_SNOW_LEOPARD_MIN   KERNEL_VERSION (KERNEL_VERSION_SNOW_LEOPARD, 0, 0)

Definition at line 140 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SONOMA

#define KERNEL_VERSION_SONOMA   23

Definition at line 132 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SONOMA_MAX

#define KERNEL_VERSION_SONOMA_MAX   (KERNEL_VERSION_SEQUOIA_MIN - 1)

Definition at line 174 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_SONOMA_MIN

#define KERNEL_VERSION_SONOMA_MIN   KERNEL_VERSION (KERNEL_VERSION_SONOMA, 0, 0)

Definition at line 153 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_TIGER

#define KERNEL_VERSION_TIGER   8

Definition at line 117 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_TIGER_MAX

#define KERNEL_VERSION_TIGER_MAX   (KERNEL_VERSION_LEOPARD_MIN - 1)

Definition at line 159 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_TIGER_MIN

#define KERNEL_VERSION_TIGER_MIN   KERNEL_VERSION (KERNEL_VERSION_TIGER, 0, 0)

Definition at line 138 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_VENTURA

#define KERNEL_VERSION_VENTURA   22

Definition at line 131 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_VENTURA_MAX

#define KERNEL_VERSION_VENTURA_MAX   (KERNEL_VERSION_SONOMA_MIN - 1)

Definition at line 173 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_VENTURA_MIN

#define KERNEL_VERSION_VENTURA_MIN   KERNEL_VERSION (KERNEL_VERSION_VENTURA, 0, 0)

Definition at line 152 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_YOSEMITE

#define KERNEL_VERSION_YOSEMITE   14

Definition at line 123 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_YOSEMITE_MAX

#define KERNEL_VERSION_YOSEMITE_MAX   (KERNEL_VERSION_EL_CAPITAN_MIN - 1)

Definition at line 165 of file OcAppleKernelLib.h.

◆ KERNEL_VERSION_YOSEMITE_MIN

#define KERNEL_VERSION_YOSEMITE_MIN   KERNEL_VERSION (KERNEL_VERSION_YOSEMITE, 0, 0)

Definition at line 144 of file OcAppleKernelLib.h.

◆ MAX_INFO_BUNDLE_VERSION_KEY_SIZE

#define MAX_INFO_BUNDLE_VERSION_KEY_SIZE   32

Definition at line 73 of file OcAppleKernelLib.h.

◆ MKEXT_BUNDLE_PATH_KEY

#define MKEXT_BUNDLE_PATH_KEY   "_MKEXTBundlePath"

Definition at line 57 of file OcAppleKernelLib.h.

◆ MKEXT_EXECUTABLE_KEY

#define MKEXT_EXECUTABLE_KEY   "_MKEXTExecutable"

Definition at line 59 of file OcAppleKernelLib.h.

◆ MKEXT_EXECUTABLE_RELATIVE_PATH_KEY

#define MKEXT_EXECUTABLE_RELATIVE_PATH_KEY   "_MKEXTExecutableRelativePath"

Definition at line 58 of file OcAppleKernelLib.h.

◆ MKEXT_INFO_DICTIONARIES_KEY

#define MKEXT_INFO_DICTIONARIES_KEY   "_MKEXTInfoDictionaries"

Definition at line 56 of file OcAppleKernelLib.h.

◆ MKEXT_INFO_INTEGER_ATTRIBUTES

#define MKEXT_INFO_INTEGER_ATTRIBUTES   "size=\"32\""

Definition at line 62 of file OcAppleKernelLib.h.

◆ OS_BUNDLE_REQUIRED_ROOT

#define OS_BUNDLE_REQUIRED_ROOT   "Root"

Definition at line 53 of file OcAppleKernelLib.h.

◆ OS_BUNDLE_REQUIRED_SAFE_BOOT

#define OS_BUNDLE_REQUIRED_SAFE_BOOT   "Safe Boot"

Definition at line 54 of file OcAppleKernelLib.h.

◆ PLIST_EXPANSION_SIZE

#define PLIST_EXPANSION_SIZE   512

Definition at line 107 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_BUNDLE_PATH_KEY

#define PRELINK_INFO_BUNDLE_PATH_KEY   "_PrelinkBundlePath"

Definition at line 37 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_DICTIONARY_KEY

#define PRELINK_INFO_DICTIONARY_KEY   "_PrelinkInfoDictionary"

Definition at line 35 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_EXECUTABLE_LOAD_ADDR_KEY

#define PRELINK_INFO_EXECUTABLE_LOAD_ADDR_KEY   "_PrelinkExecutableLoadAddr"

Definition at line 39 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_EXECUTABLE_RELATIVE_PATH_KEY

#define PRELINK_INFO_EXECUTABLE_RELATIVE_PATH_KEY   "_PrelinkExecutableRelativePath"

Definition at line 38 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_EXECUTABLE_SIZE_KEY

#define PRELINK_INFO_EXECUTABLE_SIZE_KEY   "_PrelinkExecutableSize"

Definition at line 41 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_EXECUTABLE_SOURCE_ADDR_KEY

#define PRELINK_INFO_EXECUTABLE_SOURCE_ADDR_KEY   "_PrelinkExecutableSourceAddr"

Definition at line 40 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_INTEGER_ATTRIBUTES

#define PRELINK_INFO_INTEGER_ATTRIBUTES   "size=\"64\""

Definition at line 61 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_KMOD_INFO_KEY

#define PRELINK_INFO_KMOD_INFO_KEY   "_PrelinkKmodInfo"

Definition at line 36 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_LINK_STATE_ADDR_KEY

#define PRELINK_INFO_LINK_STATE_ADDR_KEY   "_PrelinkLinkState"

Definition at line 42 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_LINK_STATE_SIZE_KEY

#define PRELINK_INFO_LINK_STATE_SIZE_KEY   "_PrelinkLinkStateSize"

Definition at line 43 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_RESERVE_SIZE

#define PRELINK_INFO_RESERVE_SIZE   (5U * 1024U * 1024U)

Definition at line 101 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_SECTION

#define PRELINK_INFO_SECTION   "__info"

Definition at line 28 of file OcAppleKernelLib.h.

◆ PRELINK_INFO_SEGMENT

#define PRELINK_INFO_SEGMENT   "__PRELINK_INFO"

Definition at line 27 of file OcAppleKernelLib.h.

◆ PRELINK_KERNEL_IDENTIFIER

#define PRELINK_KERNEL_IDENTIFIER   "__kernel__"

Definition at line 24 of file OcAppleKernelLib.h.

◆ PRELINK_KPI_IDENTIFIER_PREFIX

#define PRELINK_KPI_IDENTIFIER_PREFIX   "com.apple.kpi."

Definition at line 25 of file OcAppleKernelLib.h.

◆ PRELINK_STATE_SECTION_KERNEL

#define PRELINK_STATE_SECTION_KERNEL   "__kernel"

Definition at line 32 of file OcAppleKernelLib.h.

◆ PRELINK_STATE_SECTION_KEXTS

#define PRELINK_STATE_SECTION_KEXTS   "__kexts"

Definition at line 33 of file OcAppleKernelLib.h.

◆ PRELINK_STATE_SEGMENT

#define PRELINK_STATE_SEGMENT   "__PRELINK_STATE"

Definition at line 31 of file OcAppleKernelLib.h.

◆ PRELINK_TEXT_SECTION

#define PRELINK_TEXT_SECTION   "__text"

Definition at line 30 of file OcAppleKernelLib.h.

◆ PRELINK_TEXT_SEGMENT

#define PRELINK_TEXT_SEGMENT   "__PRELINK_TEXT"

Definition at line 29 of file OcAppleKernelLib.h.

◆ PRELINKED_KEXTS_MAX_SIZE

#define PRELINKED_KEXTS_MAX_SIZE   (BIT16 * MACHO_PAGE_SIZE)

Definition at line 96 of file OcAppleKernelLib.h.

◆ PRINT_KERNEL_CACHE_TYPE

#define PRINT_KERNEL_CACHE_TYPE ( a)
Value:
(\
(a) == CacheTypeCacheless ? "Cacheless" : \
((a) == CacheTypeMkext ? "Mkext" : \
(((a) == CacheTypePrelinked ? "Prelinked" : "Kernel"))))
@ CacheTypeMkext
@ CacheTypePrelinked
@ CacheTypeCacheless

Definition at line 88 of file OcAppleKernelLib.h.

Typedef Documentation

◆ KERNEL_CACHE_TYPE

◆ KERNEL_QUIRK_PATCH_FUNCTION

typedef EFI_STATUS KERNEL_QUIRK_PATCH_FUNCTION(IN OUT PATCHER_CONTEXT *Patcher OPTIONAL, IN UINT32 KernelVersion)

Kernel quirk patch function.

Parameters
[in,out]PatcherA pointer to the patcher context. Only optional for kext patching.
[in]KernelVersionKernel version to be matched.
Returns
EFI_SUCCESS when the patch is successfully applied.

Definition at line 642 of file OcAppleKernelLib.h.

Enumeration Type Documentation

◆ KERNEL_CACHE_TYPE_

Enumerator
CacheTypeNone 
CacheTypeCacheless 
CacheTypeMkext 
CacheTypePrelinked 

Definition at line 78 of file OcAppleKernelLib.h.

◆ KERNEL_QUIRK_NAME

Enumerator
KernelQuirkAppleCpuPmCfgLock 
KernelQuirkAppleXcpmCfgLock 
KernelQuirkAppleXcpmExtraMsrs 
KernelQuirkAppleXcpmForceBoost 
KernelQuirkCustomPciSerialDevice 
KernelQuirkCustomSmbiosGuid1 
KernelQuirkCustomSmbiosGuid2 
KernelQuirkDisableIoMapper 
KernelQuirkDisableIoMapperMapping 
KernelQuirkDisableRtcChecksum 
KernelQuirkDummyPowerManagement 
KernelQuirkExtendBTFeatureFlags 
KernelQuirkExternalDiskIcons 
KernelQuirkForceAquantiaEthernet 
KernelQuirkForceSecureBootScheme 
KernelQuirkIncreasePciBarSize 
KernelQuirkLapicKernelPanic 
KernelQuirkLegacyCommpage 
KernelQuirkPanicNoKextDump 
KernelQuirkPowerTimeoutKernelPanic 
KernelQuirkSegmentJettison 
KernelQuirkSetApfsTrimTimeout 
KernelQuirkThirdPartyDrives 
KernelQuirkXhciPortLimit1 
KernelQuirkXhciPortLimit2 
KernelQuirkXhciPortLimit3 
KernelQuirkMax 

Definition at line 532 of file OcAppleKernelLib.h.

Function Documentation

◆ CachelessContextAddKext()

EFI_STATUS CachelessContextAddKext ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * InfoPlist,
IN UINT32 InfoPlistSize,
IN UINT8 *Executable OPTIONAL,
IN UINT32 ExecutableSize OPTIONAL,
OUT CHAR8 BundleVersion OPTIONAL[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] )

Add kext to cacheless context to be injected later on.

Parameters
[in,out]ContextCacheless context.
[in]InfoPlistKext Info.plist.
[in]InfoPlistSizeKext Info.plist size.
[in]ExecutableKext executable, optional.
[in]ExecutableSizeKext executable size, optional.
[out]BundleVersionKext bundle version, optionally set on request.
Returns
EFI_SUCCESS on success.

Definition at line 807 of file CachelessContext.c.

◆ CachelessContextAddPatch()

EFI_STATUS CachelessContextAddPatch ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN PATCHER_GENERIC_PATCH * Patch )

Add patch to cacheless context to be applied later on.

Parameters
[in,out]ContextCacheless context.
[in]IdentifierKext bundle identifier.
[in]PatchPatch to apply.
Returns
EFI_SUCCESS on success.

Definition at line 1077 of file CachelessContext.c.

◆ CachelessContextAddQuirk()

EFI_STATUS CachelessContextAddQuirk ( IN OUT CACHELESS_CONTEXT * Context,
IN KERNEL_QUIRK_NAME Quirk )

Add kernel quirk to cacheless context to be applied later on.

Parameters
[in,out]ContextCacheless context.
[in]QuirkQuirk to apply.
Returns
EFI_SUCCESS on success.

Definition at line 1091 of file CachelessContext.c.

◆ CachelessContextBlock()

EFI_STATUS CachelessContextBlock ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN BOOLEAN Exclude )

Add block request to cacheless context to be applied later on.

Parameters
[in,out]ContextCacheless context.
[in]IdentifierKext bundle identifier.
[in]ExcludeTRUE to exclude kext from cacheless context.
Returns
EFI_SUCCESS on success.

Definition at line 1102 of file CachelessContext.c.

◆ CachelessContextForceKext()

EFI_STATUS CachelessContextForceKext ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier )

Force built-in kext to load.

Parameters
[in,out]ContextCacheless context.
[in]IdentifierKext bundle identifier.
Returns
EFI_SUCCESS on success.

Definition at line 1065 of file CachelessContext.c.

◆ CachelessContextFree()

VOID CachelessContextFree ( IN OUT CACHELESS_CONTEXT * Context)

Frees cacheless context.

Parameters
[in,out]ContextCacheless context.
Returns
EFI_SUCCESS on success.

Definition at line 734 of file CachelessContext.c.

◆ CachelessContextHookBuiltin()

EFI_STATUS CachelessContextHookBuiltin ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR16 * FileName,
IN EFI_FILE_PROTOCOL * File,
OUT EFI_FILE_PROTOCOL ** VirtualFile )

Apply patches to built-in kexts.

Parameters
[in,out]ContextPrelinked context.
[in]FileNameFilename of kext file to be injected.
[in]FileEFI_FILE_PROTOCOL instance of kext file.
[out]VirtualFileNewly created virtualised EFI_FILE_PROTOCOL instance.
Returns
EFI_SUCCESS on success. If no patches are applicable, VirtualFile will be NULL.

Definition at line 1390 of file CachelessContext.c.

◆ CachelessContextInit()

EFI_STATUS CachelessContextInit ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR16 * FileName,
IN EFI_FILE_PROTOCOL * ExtensionsDir,
IN UINT32 KernelVersion,
IN BOOLEAN Is32Bit )

Initializes cacheless context for later modification. Must be freed with CachelessContextFree on success.

Parameters
[in,out]ContextCacheless context.
[in]FileNameExtensions directory filename.
[in]ExtensionsDirExtensions directory EFI_FILE_PROTOCOL.
[in]KernelVersionCurrent kernel version.
[in]Is32BitTRUE if booting in 32-bit kernel mode.
Returns
EFI_SUCCESS on success.

Definition at line 706 of file CachelessContext.c.

◆ CachelessContextOverlayExtensionsDir()

EFI_STATUS CachelessContextOverlayExtensionsDir ( IN OUT CACHELESS_CONTEXT * Context,
OUT EFI_FILE_PROTOCOL ** File )

Creates virtual directory overlay EFI_FILE_PROTOCOL from cacheless context.

Parameters
[in,out]ContextCacheless context.
[out]FileThe virtual directory instance.
Returns
EFI_SUCCESS on success.

Definition at line 1128 of file CachelessContext.c.

◆ CachelessContextPerformInject()

EFI_STATUS CachelessContextPerformInject ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR16 * FileName,
OUT EFI_FILE_PROTOCOL ** VirtualFile )

Perform kext injection.

Parameters
[in,out]ContextPrelinked context.
[in]FileNameFilename of kext file to be injected.
[out]VirtualFileNewly created virtualised EFI_FILE_PROTOCOL instance.
Returns
EFI_SUCCESS on success.

Definition at line 1211 of file CachelessContext.c.

◆ KcFixupValue()

UINT64 KcFixupValue ( IN UINT64 Value,
IN CONST CHAR8 *Name OPTIONAL )

Update address or dyld fixup value to real address.

Parameters
[in]ValueValue or fixup.
[in]NameSource name, optional.
Returns
real address on sucess.

Definition at line 800 of file KernelCollection.c.

◆ KcGetKextSize()

UINT32 KcGetKextSize ( IN PRELINKED_CONTEXT * Context,
IN UINT64 SourceAddress )

Retrieves a KC KEXT's virtual size.

Parameters
[in]ContextPrelinked context.
[in]SourceAddressThe virtual address within the KC image of the KEXT.
Return values
0An error has occured.
otherThe virtual size, in bytes, of the KEXT at SourceAddress.

Definition at line 643 of file KernelCollection.c.

◆ KcGetSegmentFixupChainsSize()

UINT32 KcGetSegmentFixupChainsSize ( IN UINT32 SegmentSize)

Returns the size required to store a segment's fixup chains information.

Parameters
[in]SegmentSizeThe size, in bytes, of the segment to index.
Return values
0The segment is too large to index with a single structure.
otherThe size, in bytes, required to store a segment's fixup chain information.

Definition at line 270 of file KernelCollection.c.

◆ KcInitKextFixupChains()

EFI_STATUS KcInitKextFixupChains ( IN OUT PRELINKED_CONTEXT * Context,
IN UINT32 SegChainSize,
IN UINT32 ReservedSize )

Initialises a structure that stores a segments's fixup chains information.

Parameters
[out]SegChainThe information structure to initialise.
[in]SegChainSizeThe size, in bytes, available to SegChain.
[in]VmAddressThe virtual address of the segment to index.
[in]VmSizeThe virtual size of the segment to index.

Definition at line 287 of file KernelCollection.c.

◆ KcKextApplyFileDelta()

EFI_STATUS KcKextApplyFileDelta ( IN PRELINKED_CONTEXT * PrelinkedContext,
IN OUT OC_MACHO_CONTEXT * Context,
IN UINT32 Delta )

Apply the delta from KC header to the file's offsets.

Parameters
[in]PrelinkedContextPrelinked context.
[in,out]ContextThe context of the KEXT to rebase.
[in]DeltaThe offset from KC header the KEXT starts at.
Return values
EFI_SUCCESSThe file has beem rebased successfully.
otherAn error has occured.

Definition at line 684 of file KernelCollection.c.

◆ KcKextIndexFixups()

VOID KcKextIndexFixups ( IN OUT PRELINKED_CONTEXT * Context,
IN OC_MACHO_CONTEXT * MachContext )

Indexes all relocations of MachContext into the kernel described by Context.

Parameters
[in,out]ContextPrelinked context.
[in]MachContextThe context of the Mach-O to index. It must have been prelinked by OcAppleKernelLib. The image must reside in Segment.

Definition at line 559 of file KernelCollection.c.

◆ KcRebuildMachHeader()

EFI_STATUS KcRebuildMachHeader ( IN OUT PRELINKED_CONTEXT * Context)

Update Mach-O header with new commands.

@Param[in,out] Context Prelinked context.

Return values
EFI_SUCCESSon success.

Definition at line 189 of file KernelCollection.c.

◆ KernelApplyQuirk()

EFI_STATUS KernelApplyQuirk ( IN KERNEL_QUIRK_NAME Name,
IN OUT PATCHER_CONTEXT *Patcher OPTIONAL,
IN UINT32 KernelVersion )

Applies the specified quirk.

Parameters
[in]NameKERNEL_QUIRK_NAME specifying the quirk name.
[in,out]PatcherPATCHER_CONTEXT instance. Only optional for kext patching.
[in]KernelVersionCurrent kernel version.
Returns
EFI_SUCCESS on success.

Definition at line 2981 of file CommonPatches.c.

◆ KextFindKmodAddress()

BOOLEAN KextFindKmodAddress ( IN OC_MACHO_CONTEXT * ExecutableContext,
IN UINT64 LoadAddress,
IN UINT32 Size,
OUT UINT64 * Kmod )

Find kmod address.

Parameters
[in]ExecutableContextMach-O context.
[in]LoadAddressLoad address.
[in]SizeExecutable size.
[out]KmodPointer to kmod.
Returns
TRUE on success.

Definition at line 790 of file KextPatcher.c.

◆ MkextCheckCpuType()

BOOLEAN MkextCheckCpuType ( IN UINT8 * Mkext,
IN UINT32 MkextSize,
IN MACH_CPU_TYPE CpuType )

Check if passed mkext is of desired CPU arch.

Parameters
[in]MkextMkext buffer.
[in]MkextSizeMkext buffer size.
[in]CpuTypeDesired CPU arch.
Returns
FALSE if mismatched arch or invalid mkext.

Definition at line 1008 of file MkextContext.c.

◆ MkextContextApplyPatch()

EFI_STATUS MkextContextApplyPatch ( IN OUT MKEXT_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN PATCHER_GENERIC_PATCH * Patch )

Apply kext patch to mkext.

Parameters
[in,out]ContextMkext context.
[in]IdentifierKext bundle identifier.
[in]PatchPatch to apply.
Returns
EFI_SUCCESS on success.

Definition at line 1574 of file MkextContext.c.

◆ MkextContextApplyQuirk()

EFI_STATUS MkextContextApplyQuirk ( IN OUT MKEXT_CONTEXT * Context,
IN KERNEL_QUIRK_NAME Quirk,
IN UINT32 KernelVersion )

Apply kext quirk to mkext.

Parameters
[in,out]ContextMkext context.
[in]QuirkKext quirk to apply.
[in]KernelVersionCurrent kernel version.
Returns
EFI_SUCCESS on success.

Definition at line 1597 of file MkextContext.c.

◆ MkextContextBlock()

EFI_STATUS MkextContextBlock ( IN OUT MKEXT_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN BOOLEAN Exclude )

Block kext in mkext.

Parameters
[in,out]ContextMkext context.
[in]IdentifierKext bundle identifier.
[in]ExcludeTRUE to exclude kext from mkext.
Returns
EFI_SUCCESS on success.

Definition at line 1625 of file MkextContext.c.

◆ MkextContextFree()

VOID MkextContextFree ( IN OUT MKEXT_CONTEXT * Context)

Free resources consumed by mkext context.

Parameters
[in,out]ContextMkext context.

Definition at line 1203 of file MkextContext.c.

◆ MkextContextInit()

EFI_STATUS MkextContextInit ( IN OUT MKEXT_CONTEXT * Context,
IN OUT UINT8 * Mkext,
IN UINT32 MkextSize,
IN UINT32 MkextAllocSize )

Construct mkext context for later modification. Must be freed with MkextContextFree on success. Note that MkextAllocSize never changes, and is to be estimated.

Mkext buffers cannot contain any compression, and should be run through MkextDecompress first.

Parameters
[in,out]ContextMkext context.
[in,out]MkextDecompressed Mkext buffer.
[in]MkextSizeDecompressed Mkext buffer size.
[in]MkextAllocSizeDecompressed Mkext buffer allocated size.
Returns
EFI_SUCCESS on success.

Definition at line 1040 of file MkextContext.c.

◆ MkextDecompress()

EFI_STATUS MkextDecompress ( IN CONST UINT8 * Buffer,
IN UINT32 BufferSize,
IN UINT32 NumReservedKexts,
IN OUT UINT8 *OutBuffer OPTIONAL,
IN UINT32 OutBufferSize OPTIONAL,
IN OUT UINT32 * OutMkextSize )

Decompress mkext buffer while reserving space for injected kexts later on. Specifying zero for OutBufferSize will calculate the size of the buffer required for the decompressed mkext in OutMkextSize.

Parameters
[in]BufferMkext buffer.
[in]BufferSizeMkext buffer size.
[in]NumReservedKextsNumber of kext slots to reserve for injection.
[in,out]OutBufferOutput buffer. Optional if OutBufferSize is zero.
[in]OutBufferSizeTotal output buffer size. Specify zero to calculate output buffer size.
[in,out]OutMkextSizeDecompressed Mkext size.
Returns
EFI_SUCCESS on success.

Definition at line 568 of file MkextContext.c.

◆ MkextInjectKext()

EFI_STATUS MkextInjectKext ( IN OUT MKEXT_CONTEXT * Context,
IN CONST CHAR8 *Identifier OPTIONAL,
IN CONST CHAR8 * BundlePath,
IN CONST CHAR8 * InfoPlist,
IN UINT32 InfoPlistSize,
IN UINT8 *Executable OPTIONAL,
IN UINT32 ExecutableSize OPTIONAL,
OUT CHAR8 BundleVersion OPTIONAL[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] )

Perform mkext kext injection.

Parameters
[in,out]ContextMkext context.
[in]IdentifierKext bundle identifier. If a kext with this identifier already exists, the kext will not be injected. Optional.
[in]BundlePathKext bundle path (e.g. /L/E/mykext.kext).
[in,out]InfoPlistKext Info.plist.
[in]InfoPlistSizeKext Info.plist size.
[in,out]ExecutableKext executable, optional.
[in]ExecutableSizeKext executable size, optional.
[out]BundleVersionKext bundle version, optionally set on request.
Returns
EFI_SUCCESS on success.

Definition at line 1274 of file MkextContext.c.

◆ MkextInjectPatchComplete()

EFI_STATUS MkextInjectPatchComplete ( IN OUT MKEXT_CONTEXT * Context)

Refresh plist and checksum after kext injection and/or patching.

Parameters
[in,out]ContextMkext context.
Returns
EFI_SUCCESS on success.

Definition at line 1653 of file MkextContext.c.

◆ MkextReserveKextSize()

EFI_STATUS MkextReserveKextSize ( IN OUT UINT32 * ReservedInfoSize,
IN OUT UINT32 * ReservedExeSize,
IN UINT32 InfoPlistSize,
IN UINT8 *Executable OPTIONAL,
IN UINT32 ExecutableSize OPTIONAL,
IN BOOLEAN Is32Bit )

Updated required mkext reserve size to inject this kext.

Parameters
[in,out]ReservedInfoSizeCurrent reserved PLIST size, updated.
[in,out]ReservedExeSizeCurrent reserved KEXT size, updated.
[in]InfoPlistSizeKext Info.plist size.
[in]ExecutableKext executable, optional.
[in]ExecutableSizeKext executable size, optional.
[in]Is32BitTRUE to process 32-bit kext.
Returns
EFI_SUCCESS on success.

Definition at line 1233 of file MkextContext.c.

◆ OcKernelReadDarwinVersion()

UINT32 OcKernelReadDarwinVersion ( IN CONST UINT8 * Kernel,
IN UINT32 KernelSize )

Read Apple kernel version in integer format.

Parameters
[in]KernelApple kernel binary.
[in]KernelSizeApple kernel size.
Returns
Kernel version or 0.

Definition at line 116 of file KernelVersion.c.

◆ OcMatchDarwinVersion()

BOOLEAN OcMatchDarwinVersion ( IN UINT32 CurrentVersion OPTIONAL,
IN UINT32 MinVersion OPTIONAL,
IN UINT32 MaxVersion OPTIONAL )

Check whether min <= current <= max is true. When current or max are 0 they are considered infinite.

Parameters
[in]CurrentVersionCurrent kernel version.
[in]MinVersionMinimal kernel version.
[in]MaxVersionMaximum kernel version.
Returns
TRUE on match.

Definition at line 73 of file KernelVersion.c.

◆ OcParseDarwinVersion()

UINT32 OcParseDarwinVersion ( IN CONST CHAR8 * String)

Create Apple kernel version in integer format. See KERNEL_VERSION on how to build it from integers.

Parameters
[in]StringApple kernel version.
Returns
Kernel version or 0.

Definition at line 27 of file KernelVersion.c.

◆ PatcherApplyGenericPatch()

EFI_STATUS PatcherApplyGenericPatch ( IN OUT PATCHER_CONTEXT * Context,
IN PATCHER_GENERIC_PATCH * Patch )

Apply generic patch.

Parameters
[in,out]ContextPatcher context.
[in]PatchPatch description.
Returns
EFI_SUCCESS on success.

Definition at line 310 of file KextPatcher.c.

◆ PatcherBlockKext()

EFI_STATUS PatcherBlockKext ( IN OUT PATCHER_CONTEXT * Context)

Block kext from loading.

Parameters
[in,out]ContextPatcher context.
Returns
EFI_SUCCESS on success.

Definition at line 712 of file KextPatcher.c.

◆ PatcherExcludeMkextKext()

EFI_STATUS PatcherExcludeMkextKext ( IN OUT MKEXT_CONTEXT * MkextContext,
IN CONST CHAR8 * Identifier )

Exclude kext from mkext.

Parameters
[in,out]MkextContextMkext context.
[in]IdentifierKext identifier to be excluded.
Returns
EFI_SUCCESS on success.

Definition at line 546 of file KextPatcher.c.

◆ PatcherExcludePrelinkedKext()

EFI_STATUS PatcherExcludePrelinkedKext ( IN CONST CHAR8 * Identifier,
IN OUT PATCHER_CONTEXT * PatcherContext,
IN OUT PRELINKED_CONTEXT * PrelinkedContext )

Exclude kext from prelinked.

Parameters
[in]IdentifierKext identifier to be excluded.
[in,out]PatcherContextPatcher context.
[in,out]PrelinkedContextPrelinked context.
Returns
EFI_SUCCESS on success.

Definition at line 396 of file KextPatcher.c.

◆ PatcherGetSymbolAddress()

EFI_STATUS PatcherGetSymbolAddress ( IN OUT PATCHER_CONTEXT * Context,
IN CONST CHAR8 * Name,
IN OUT UINT8 ** Address )

Get local symbol address.

Parameters
[in,out]ContextPatcher context.
[in]NameSymbol name.
[in,out]AddressReturned symbol address in file.
Returns
EFI_SUCCESS on success.

Definition at line 214 of file KextPatcher.c.

◆ PatcherGetSymbolAddressValue()

EFI_STATUS PatcherGetSymbolAddressValue ( IN OUT PATCHER_CONTEXT * Context,
IN CONST CHAR8 * Name,
IN OUT UINT8 ** Address,
IN OUT UINT64 * Value )

Get local symbol address and symbol value.

Parameters
[in,out]ContextPatcher context.
[in]NameSymbol name.
[in,out]AddressReturned symbol address in file.
[in,out]ValueReturned original symbol value.
Returns
EFI_SUCCESS on success.

Definition at line 234 of file KextPatcher.c.

◆ PatcherGetSymbolValue()

EFI_STATUS PatcherGetSymbolValue ( IN OUT PATCHER_CONTEXT * Context,
IN CONST CHAR8 * Name,
IN OUT UINT64 * Value )

Get local symbol value.

Parameters
[in,out]ContextPatcher context.
[in]NameSymbol name.
[in,out]ValueReturned original symbol value.
Returns
EFI_SUCCESS on success.

Definition at line 224 of file KextPatcher.c.

◆ PatcherInitContextFromBuffer()

EFI_STATUS PatcherInitContextFromBuffer ( IN OUT PATCHER_CONTEXT * Context,
IN OUT UINT8 * Buffer,
IN UINT32 BufferSize,
IN BOOLEAN Use32Bit )

Initialize patcher from buffer for e.g. kernel patching.

Parameters
[in,out]ContextPatcher context.
[in,out]BufferKernel buffer (could be prelinked).
[in]BufferSizeKernel buffer size.
[in]Is32BitTRUE to use 32-bit.
Returns
EFI_SUCCESS on success.

Definition at line 134 of file KextPatcher.c.

◆ PatcherInitContextFromMkext()

EFI_STATUS PatcherInitContextFromMkext ( IN OUT PATCHER_CONTEXT * Context,
IN OUT MKEXT_CONTEXT * Mkext,
IN CONST CHAR8 * Name )

Initialize patcher from mkext context for kext patching.

Parameters
[in,out]ContextPatcher context.
[in,out]MkextMkext context.
[in]NameKext bundle identifier.
Returns
EFI_SUCCESS on success.

Definition at line 117 of file KextPatcher.c.

◆ PatcherInitContextFromPrelinked()

EFI_STATUS PatcherInitContextFromPrelinked ( IN OUT PATCHER_CONTEXT * Context,
IN OUT PRELINKED_CONTEXT * Prelinked,
IN CONST CHAR8 * Name )

Initialize patcher from prelinked context for kext patching.

Parameters
[in,out]ContextPatcher context.
[in,out]PrelinkedPrelinked context.
[in]NameKext bundle identifier.
Returns
EFI_SUCCESS on success.

Definition at line 99 of file KextPatcher.c.

◆ PatchKernelCpuId()

EFI_STATUS PatchKernelCpuId ( IN OUT PATCHER_CONTEXT * Patcher,
IN OC_CPU_INFO * CpuInfo,
IN UINT32 * Data,
IN UINT32 * DataMask,
IN UINT32 KernelVersion )

Apply modification to CPUID 1.

Parameters
PatcherPatcher context.
CpuInfoCPU information.
Data4 32-bit integers with CPUID data.
DataMask4 32-bit integers with CPUID enabled overrides data.
KernelVersionCurrent kernel version.
Returns
EFI_SUCCESS on success.

Definition at line 879 of file CpuidPatches.c.

◆ PatchProvideCurrentCpuInfo()

EFI_STATUS PatchProvideCurrentCpuInfo ( IN OUT PATCHER_CONTEXT * Patcher,
IN OC_CPU_INFO * CpuInfo,
IN UINT32 KernelVersion )

Apply current CPU information patches.

Parameters
PatcherPatcher context.
CpuInfoCPU information.
KernelVersionCurrent kernel version.
Returns
EFI_SUCCESS on success.

Definition at line 1557 of file CpuidPatches.c.

◆ PatchSetApfsTimeout()

VOID PatchSetApfsTimeout ( IN UINT32 Timeout)

Set timeout value in microseconds for KernelQuirkSetApfsTrimTimeout quirk.

Parameters
[in]TimeoutTimeout in microseconds.

Definition at line 2863 of file CommonPatches.c.

◆ PatchSetPciSerialDevice()

VOID PatchSetPciSerialDevice ( IN UINTN RegisterBase,
IN UINT32 RegisterStride )

Set PCI serial device properties for KernelQuirkCustomPciSerialDevice quirk.

Parameters
[in]RegisterBasePCI serial device regiser base.
[in]RegisterStridePCI serial device regiser stride.

Definition at line 1513 of file CommonPatches.c.

◆ PrelinkedContextApplyPatch()

EFI_STATUS PrelinkedContextApplyPatch ( IN OUT PRELINKED_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN PATCHER_GENERIC_PATCH * Patch )

Apply kext patch to prelinked.

Parameters
[in,out]ContextPrelinked context.
[in]IdentifierKext bundle identifier.
[in]PatchPatch to apply.
Returns
EFI_SUCCESS on success.

Definition at line 1260 of file PrelinkedContext.c.

◆ PrelinkedContextApplyQuirk()

EFI_STATUS PrelinkedContextApplyQuirk ( IN OUT PRELINKED_CONTEXT * Context,
IN KERNEL_QUIRK_NAME Quirk,
IN UINT32 KernelVersion )

Apply kext quirk to prelinked.

Parameters
[in,out]ContextPrelinked context.
[in]QuirkKext quirk to apply.
[in]KernelVersionCurrent kernel version.
Return values
EFI_SUCCESSon success.

Definition at line 1283 of file PrelinkedContext.c.

◆ PrelinkedContextBlock()

EFI_STATUS PrelinkedContextBlock ( IN OUT PRELINKED_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN BOOLEAN Exclude )

Block kext in prelinked.

Parameters
[in,out]ContextPrelinked context.
[in]IdentifierKext bundle identifier.
[in]ExcludeTRUE to exclude kext from prelinked.
Returns
EFI_SUCCESS on success.

Definition at line 1311 of file PrelinkedContext.c.

◆ PrelinkedContextFree()

VOID PrelinkedContextFree ( IN OUT PRELINKED_CONTEXT * Context)

Free resources consumed by prelinked context.

Parameters
[in,out]ContextPrelinked context.

Definition at line 427 of file PrelinkedContext.c.

◆ PrelinkedContextInit()

EFI_STATUS PrelinkedContextInit ( IN OUT PRELINKED_CONTEXT * Context,
IN OUT UINT8 * Prelinked,
IN UINT32 PrelinkedSize,
IN UINT32 PrelinkedAllocSize,
IN BOOLEAN Is32Bit )

Construct prelinked context for later modification. Must be freed with PrelinkedContextFree on success. Note, that PrelinkedAllocSize never changes, and is to be estimated.

Parameters
[in,out]ContextPrelinked context.
[in,out]PrelinkedUnpacked prelinked buffer (Mach-O image).
[in]PrelinkedSizeUnpacked prelinked buffer size.
[in]PrelinkedAllocSizeUnpacked prelinked buffer allocated size.
[in]Is32BitTRUE if prelinked is 32-bit.
Returns
EFI_SUCCESS on success.

Definition at line 208 of file PrelinkedContext.c.

◆ PrelinkedDependencyInsert()

EFI_STATUS PrelinkedDependencyInsert ( IN OUT PRELINKED_CONTEXT * Context,
IN VOID * Buffer )

Insert pool-allocated buffer dependency with the same lifetime as prelinked context, so it gets freed with PrelinkedContextFree.

Parameters
[in,out]ContextPrelinked context.
[in]BufferPool allocated buffer.
Returns
EFI_SUCCESS on success.

Definition at line 491 of file PrelinkedContext.c.

◆ PrelinkedInjectComplete()

EFI_STATUS PrelinkedInjectComplete ( IN OUT PRELINKED_CONTEXT * Context)

Insert current plist entry after kext injection.

Parameters
[in,out]ContextPrelinked context.
Returns
EFI_SUCCESS on success.

Definition at line 757 of file PrelinkedContext.c.

◆ PrelinkedInjectKext()

EFI_STATUS PrelinkedInjectKext ( IN OUT PRELINKED_CONTEXT * Context,
IN CONST CHAR8 *Identifier OPTIONAL,
IN CONST CHAR8 * BundlePath,
IN CONST CHAR8 * InfoPlist,
IN UINT32 InfoPlistSize,
IN CONST CHAR8 *ExecutablePath OPTIONAL,
IN OUT CONST UINT8 *Executable OPTIONAL,
IN UINT32 ExecutableSize OPTIONAL,
OUT CHAR8 BundleVersion OPTIONAL[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] )

Perform kext injection.

Parameters
[in,out]ContextPrelinked context.
[in]IdentifierKext bundle identifier. If a kext with this identifier already exists, the kext will not be injected. Optional.
[in]BundlePathKext bundle path (e.g. /L/E/mykext.kext).
[in,out]InfoPlistKext Info.plist.
[in]InfoPlistSizeKext Info.plist size.
[in,out]ExecutablePathKext executable path (e.g. Contents/MacOS/mykext), optional.
[in,out]ExecutableKext executable, optional.
[in]ExecutableSizeKext executable size, optional.
[out]BundleVersionKext bundle version, optionally set on request.
Returns
EFI_SUCCESS on success.

◆ PrelinkedInjectPrepare()

EFI_STATUS PrelinkedInjectPrepare ( IN OUT PRELINKED_CONTEXT * Context,
IN UINT32 LinkedExpansion,
IN UINT32 ReservedExeSize )

Drop current plist entry, required for kext injection. Ensure that prelinked text can grow with new kexts.

Parameters
[in,out]ContextPrelinked context.
[in]LinkedExpansionExtra LINKEDIT size for KC required to hold DYLD chained fixups.
Return values
EFI_SUCCESSon success.

Definition at line 526 of file PrelinkedContext.c.

◆ PrelinkedReserveKextSize()

EFI_STATUS PrelinkedReserveKextSize ( IN OUT UINT32 * ReservedInfoSize,
IN OUT UINT32 * ReservedExeSize,
IN UINT32 InfoPlistSize,
IN UINT8 *Executable OPTIONAL,
IN UINT32 ExecutableSize OPTIONAL,
IN BOOLEAN Is32Bit )

Updated required reserve size to inject this kext.

Parameters
[in,out]ReservedInfoSizeCurrent reserved PLIST size, updated.
[in,out]ReservedExeSizeCurrent reserved KEXT size, updated.
[in]InfoPlistSizeKext Info.plist size.
[in]ExecutableKext executable, optional.
[in]ExecutableSizeKext executable size, optional.
[in]Is32BitTRUE to process 32-bit kext.
Returns
EFI_SUCCESS on success.

Definition at line 903 of file PrelinkedContext.c.

◆ ReadAppleKernel()

EFI_STATUS ReadAppleKernel ( IN EFI_FILE_PROTOCOL * File,
IN BOOLEAN Prefer32Bit,
OUT BOOLEAN * Is32Bit,
OUT UINT8 ** Kernel,
OUT UINT32 * KernelSize,
OUT UINT32 * AllocatedSize,
IN UINT32 ReservedSize,
OUT UINT8 *Digest OPTIONAL )

Read Apple kernel for target architecture (possibly decompressing) into pool allocated buffer. If CpuType does not exist in fat mkext, an error is returned.

Parameters
[in]FileFile handle instance.
[in]Prefer32BitPrefer 32-bit in case of fat binary.
[out]Is32BitWhether resulting kernel is 32-bit or not.
[in,out]KernelResulting non-fat kernel buffer from pool.
[out]KernelSizeActual kernel size.
[out]AllocatedSizeAllocated kernel size (AllocatedSize >= KernelSize).
[in]ReservedSizeAllocated extra size for added kernel extensions.
[out]DigestSHA-384 digest for the original kernel, optional.
Returns
EFI_SUCCESS on success.

Definition at line 418 of file KernelReader.c.

◆ ReadAppleMkext()

EFI_STATUS ReadAppleMkext ( IN EFI_FILE_PROTOCOL * File,
IN BOOLEAN Prefer32Bit,
OUT UINT8 ** Mkext,
OUT UINT32 * MkextSize,
OUT UINT32 * AllocatedSize,
IN UINT32 ReservedSize,
IN UINT32 NumReservedKexts )

Read mkext for target architecture (possibly decompressing) into pool allocated buffer. If CpuType does not exist in fat mkext, an error is returned.

Parameters
[in]FileFile handle instance.
[in]Prefer32BitPrefer 32-bit in case of fat binary.
[in,out]MkextResulting non-fat mkext buffer from pool.
[out]MkextSizeActual mkext size.
[out]AllocatedSizeAllocated mkext size (AllocatedSize >= MkextSize).
[in]ReservedSizeAllocated extra size for added kernel extensions.
[in]NumReservedKextsNumber of kext slots to reserve in mkext.
Returns
EFI_SUCCESS on success.

Definition at line 514 of file KernelReader.c.