OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
KernelCollection.c File Reference
#include <Uefi.h>
#include <IndustryStandard/AppleCompressedBinaryImage.h>
#include <IndustryStandard/AppleFatBinaryImage.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcAppleKernelLib.h>
#include <Library/OcCompressionLib.h>
#include <Library/OcFileLib.h>
#include "PrelinkedInternal.h"

Go to the source code of this file.

Functions

STATIC UINTN InternalKcGetKextFilesetSize (IN OUT PRELINKED_CONTEXT *Context)
 
STATIC VOID InternalKcWriteCommandHeaders (IN OUT PRELINKED_CONTEXT *Context, IN OUT MACH_HEADER_64 *MachHeader)
 
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)
 
STATIC VOID InternalKcConvertRelocToFixup (IN OUT PRELINKED_CONTEXT *Context, IN OC_MACHO_CONTEXT *MachContext, IN CONST MACH_RELOCATION_INFO *RelocInfo, IN UINT64 RelocBase)
 
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)
 

Detailed Description

Kernel collection support.

Copyright (c) 2020, vit9696. 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 KernelCollection.c.

Function Documentation

◆ InternalKcConvertRelocToFixup()

STATIC VOID InternalKcConvertRelocToFixup ( IN OUT PRELINKED_CONTEXT * Context,
IN OC_MACHO_CONTEXT * MachContext,
IN CONST MACH_RELOCATION_INFO * RelocInfo,
IN UINT64 RelocBase )

Definition at line 431 of file KernelCollection.c.

◆ InternalKcGetKextFilesetSize()

STATIC UINTN InternalKcGetKextFilesetSize ( IN OUT PRELINKED_CONTEXT * Context)

Definition at line 33 of file KernelCollection.c.

◆ InternalKcWriteCommandHeaders()

STATIC VOID InternalKcWriteCommandHeaders ( IN OUT PRELINKED_CONTEXT * Context,
IN OUT MACH_HEADER_64 * MachHeader )

Definition at line 62 of file KernelCollection.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.