OpenCore
1.0.4
OpenCore Bootloader
|
#include <Uefi.h>
#include <IndustryStandard/AppleKmodInfo.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcAppleKernelLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcStringLib.h>
#include "PrelinkedInternal.h"
Go to the source code of this file.
Functions | |
STATIC UINT64 | PrelinkedFindLastLoadAddress (IN XML_NODE *KextList) |
STATIC EFI_STATUS | PrelinkedGetSegmentsFromMacho (IN OC_MACHO_CONTEXT *MachoContext, OUT MACH_SEGMENT_COMMAND_ANY **PrelinkedInfoSegment, OUT MACH_SECTION_ANY **PrelinkedInfoSection) |
EFI_STATUS | InternalConnectExternalSymtab (IN OUT OC_MACHO_CONTEXT *Context, OUT OC_MACHO_CONTEXT *InnerContext, IN UINT8 *Buffer, IN UINT32 BufferSize, OUT BOOLEAN *KernelCollection 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 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) |
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 PrelinkedContext.c.
EFI_STATUS InternalConnectExternalSymtab | ( | IN OUT OC_MACHO_CONTEXT * | Context, |
OUT OC_MACHO_CONTEXT * | InnerContext, | ||
IN UINT8 * | Buffer, | ||
IN UINT32 | BufferSize, | ||
OUT BOOLEAN *KernelCollection | OPTIONAL ) |
Definition at line 134 of file PrelinkedContext.c.
EFI_STATUS PrelinkedContextApplyPatch | ( | IN OUT PRELINKED_CONTEXT * | Context, |
IN CONST CHAR8 * | Identifier, | ||
IN PATCHER_GENERIC_PATCH * | Patch ) |
Apply kext patch to prelinked.
[in,out] | Context | Prelinked context. |
[in] | Identifier | Kext bundle identifier. |
[in] | Patch | Patch to apply. |
Definition at line 1260 of file PrelinkedContext.c.
EFI_STATUS PrelinkedContextApplyQuirk | ( | IN OUT PRELINKED_CONTEXT * | Context, |
IN KERNEL_QUIRK_NAME | Quirk, | ||
IN UINT32 | KernelVersion ) |
Apply kext quirk to prelinked.
[in,out] | Context | Prelinked context. |
[in] | Quirk | Kext quirk to apply. |
[in] | KernelVersion | Current kernel version. |
EFI_SUCCESS | on success. |
Definition at line 1283 of file PrelinkedContext.c.
EFI_STATUS PrelinkedContextBlock | ( | IN OUT PRELINKED_CONTEXT * | Context, |
IN CONST CHAR8 * | Identifier, | ||
IN BOOLEAN | Exclude ) |
Block kext in prelinked.
[in,out] | Context | Prelinked context. |
[in] | Identifier | Kext bundle identifier. |
[in] | Exclude | TRUE to exclude kext from prelinked. |
Definition at line 1311 of file PrelinkedContext.c.
VOID PrelinkedContextFree | ( | IN OUT PRELINKED_CONTEXT * | Context | ) |
Free resources consumed by prelinked context.
[in,out] | Context | Prelinked context. |
Definition at line 427 of file PrelinkedContext.c.
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.
[in,out] | Context | Prelinked context. |
[in,out] | Prelinked | Unpacked prelinked buffer (Mach-O image). |
[in] | PrelinkedSize | Unpacked prelinked buffer size. |
[in] | PrelinkedAllocSize | Unpacked prelinked buffer allocated size. |
[in] | Is32Bit | TRUE if prelinked is 32-bit. |
Definition at line 208 of file PrelinkedContext.c.
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.
[in,out] | Context | Prelinked context. |
[in] | Buffer | Pool allocated buffer. |
Definition at line 491 of file PrelinkedContext.c.
STATIC UINT64 PrelinkedFindLastLoadAddress | ( | IN XML_NODE * | KextList | ) |
Definition at line 31 of file PrelinkedContext.c.
STATIC EFI_STATUS PrelinkedGetSegmentsFromMacho | ( | IN OC_MACHO_CONTEXT * | MachoContext, |
OUT MACH_SEGMENT_COMMAND_ANY ** | PrelinkedInfoSegment, | ||
OUT MACH_SECTION_ANY ** | PrelinkedInfoSection ) |
Definition at line 99 of file PrelinkedContext.c.
EFI_STATUS PrelinkedInjectComplete | ( | IN OUT PRELINKED_CONTEXT * | Context | ) |
Insert current plist entry after kext injection.
[in,out] | Context | Prelinked context. |
Definition at line 757 of file PrelinkedContext.c.
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 CONST UINT8 *Executable | OPTIONAL, | ||
IN UINT32 ExecutableSize | OPTIONAL, | ||
OUT CHAR8 BundleVersion | OPTIONAL[MAX_INFO_BUNDLE_VERSION_KEY_SIZE] ) |
Definition at line 948 of file PrelinkedContext.c.
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.
[in,out] | Context | Prelinked context. |
[in] | LinkedExpansion | Extra LINKEDIT size for KC required to hold DYLD chained fixups. |
EFI_SUCCESS | on success. |
Definition at line 526 of file PrelinkedContext.c.
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.
[in,out] | ReservedInfoSize | Current reserved PLIST size, updated. |
[in,out] | ReservedExeSize | Current reserved KEXT size, updated. |
[in] | InfoPlistSize | Kext Info.plist size. |
[in] | Executable | Kext executable, optional. |
[in] | ExecutableSize | Kext executable size, optional. |
[in] | Is32Bit | TRUE to process 32-bit kext. |
Definition at line 903 of file PrelinkedContext.c.