OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
CachelessContext.c File Reference
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/OcAppleKernelLib.h>
#include <Library/OcFileLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcVirtualFsLib.h>
#include "CachelessInternal.h"
#include "MkextInternal.h"
#include "PrelinkedInternal.h"

Go to the source code of this file.

Functions

STATIC VOID FreeBuiltInKext (IN BUILTIN_KEXT *BuiltinKext)
 
STATIC EFI_STATUS AddKextDependency (IN OUT LIST_ENTRY *Dependencies, IN CONST CHAR8 *Identifier)
 
STATIC EFI_STATUS AddKextDependencies (IN OUT LIST_ENTRY *Dependencies, IN XML_NODE *InfoPlistLibraries)
 
STATIC EFI_STATUS ScanExtensions (IN OUT CACHELESS_CONTEXT *Context, IN EFI_FILE_PROTOCOL *File, IN CONST CHAR16 *FilePath, IN BOOLEAN ReadPlugins)
 
STATIC PATCHED_KEXTLookupPatchedKextForIdentifier (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier)
 
STATIC BUILTIN_KEXTLookupBuiltinKextForIdentifier (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier)
 
STATIC BUILTIN_KEXTLookupBuiltinKextForPlistPath (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR16 *PlistPath)
 
STATIC BUILTIN_KEXTLookupBuiltinKextForBinaryPath (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR16 *BinaryPath)
 
STATIC EFI_STATUS ScanDependencies (IN OUT CACHELESS_CONTEXT *Context, IN CHAR8 *Identifier)
 
STATIC EFI_STATUS InternalAddPatchedKext (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier, OUT PATCHED_KEXT **Kext)
 
STATIC EFI_STATUS InternalAddKextPatch (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR8 *Identifier, IN PATCHER_GENERIC_PATCH *Patch OPTIONAL, IN KERNEL_QUIRK_NAME QuirkName)
 
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 **File)
 
EFI_STATUS CachelessContextHookBuiltin (IN OUT CACHELESS_CONTEXT *Context, IN CONST CHAR16 *FileName, IN EFI_FILE_PROTOCOL *File, OUT EFI_FILE_PROTOCOL **VirtualFile)
 

Detailed Description

Cacheless boot (S/L/E) support.

Copyright (c) 2020, Goldfish64. 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 CachelessContext.c.

Function Documentation

◆ AddKextDependencies()

STATIC EFI_STATUS AddKextDependencies ( IN OUT LIST_ENTRY * Dependencies,
IN XML_NODE * InfoPlistLibraries )

Definition at line 112 of file CachelessContext.c.

◆ AddKextDependency()

STATIC EFI_STATUS AddKextDependency ( IN OUT LIST_ENTRY * Dependencies,
IN CONST CHAR8 * Identifier )

Definition at line 75 of file CachelessContext.c.

◆ 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.

◆ FreeBuiltInKext()

STATIC VOID FreeBuiltInKext ( IN BUILTIN_KEXT * BuiltinKext)

Definition at line 35 of file CachelessContext.c.

◆ InternalAddKextPatch()

STATIC EFI_STATUS InternalAddKextPatch ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
IN PATCHER_GENERIC_PATCH *Patch OPTIONAL,
IN KERNEL_QUIRK_NAME QuirkName )

Definition at line 650 of file CachelessContext.c.

◆ InternalAddPatchedKext()

STATIC EFI_STATUS InternalAddPatchedKext ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier,
OUT PATCHED_KEXT ** Kext )

Definition at line 620 of file CachelessContext.c.

◆ LookupBuiltinKextForBinaryPath()

STATIC BUILTIN_KEXT * LookupBuiltinKextForBinaryPath ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR16 * BinaryPath )

Definition at line 549 of file CachelessContext.c.

◆ LookupBuiltinKextForIdentifier()

STATIC BUILTIN_KEXT * LookupBuiltinKextForIdentifier ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier )

Definition at line 501 of file CachelessContext.c.

◆ LookupBuiltinKextForPlistPath()

STATIC BUILTIN_KEXT * LookupBuiltinKextForPlistPath ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR16 * PlistPath )

Definition at line 525 of file CachelessContext.c.

◆ LookupPatchedKextForIdentifier()

STATIC PATCHED_KEXT * LookupPatchedKextForIdentifier ( IN OUT CACHELESS_CONTEXT * Context,
IN CONST CHAR8 * Identifier )

Definition at line 477 of file CachelessContext.c.

◆ ScanDependencies()

STATIC EFI_STATUS ScanDependencies ( IN OUT CACHELESS_CONTEXT * Context,
IN CHAR8 * Identifier )

Definition at line 575 of file CachelessContext.c.

◆ ScanExtensions()

STATIC EFI_STATUS ScanExtensions ( IN OUT CACHELESS_CONTEXT * Context,
IN EFI_FILE_PROTOCOL * File,
IN CONST CHAR16 * FilePath,
IN BOOLEAN ReadPlugins )

Definition at line 140 of file CachelessContext.c.