OpenCore
1.0.4
OpenCore Bootloader
|
#include "BootCompatInternal.h"
#include <Guid/AppleVariable.h>
#include <Guid/OcVariable.h>
#include <IndustryStandard/AppleHibernate.h>
#include <IndustryStandard/AppleCsrConfig.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcCryptoLib.h>
#include <Library/OcDeviceTreeLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcMemoryLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcRngLib.h>
#include <Library/OcStringLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
Go to the source code of this file.
Functions | |
STATIC VOID | GetSlideRangeForValue (IN UINTN EstimatedKernelArea, IN BOOLEAN HasSandyOrIvy, IN UINT8 Slide, OUT UINTN *StartAddr, OUT UINTN *EndAddr) |
STATIC UINT8 | GenerateSlideValue (IN SLIDE_SUPPORT_STATE *SlideSupport) |
STATIC BOOLEAN | ShouldUseCustomSlideOffsetDecision (IN OUT SLIDE_SUPPORT_STATE *SlideSupport, IN UINT8 FallbackSlide, IN UINT64 MaxAvailableSize) |
STATIC BOOLEAN | ShouldUseCustomSlideOffset (IN OUT SLIDE_SUPPORT_STATE *SlideSupport, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN OC_MEMORY_FILTER FilterMap OPTIONAL, IN VOID *FilterMapContext OPTIONAL, IN BOOLEAN HasSandyOrIvy) |
STATIC EFI_STATUS | GetVariableCsrActiveConfig (IN OUT SLIDE_SUPPORT_STATE *SlideSupport, IN EFI_GET_VARIABLE GetVariable, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data) |
STATIC EFI_STATUS | GetVariableBootArgs (IN OUT SLIDE_SUPPORT_STATE *SlideSupport, IN EFI_GET_VARIABLE GetVariable, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data) |
STATIC VOID | HideSlideFromOs (IN OUT SLIDE_SUPPORT_STATE *SlideSupport, IN OUT OC_BOOT_ARGUMENTS *BootArgs) |
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) |
Copyright (C) 2018, Downlod-Fritz. All rights reserved. Copyright (C) 2018, 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 CustomSlide.c.
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.
[in,out] | BootCompat | Boot compatibility context. |
0 | otherwise. |
Definition at line 879 of file CustomSlide.c.
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.
[in,out] | BootCompat | Boot compatibility context. |
[in] | GetVariable | Original UEFI GetVariable service. |
[in] | GetMemoryMap | Unmodified GetMemoryMap pointer, optional. |
[in] | FilterMap | GetMemoryMap result filter, optional. |
[in] | FilterMapContext | FilterMap context, optional. |
[in] | VariableName | GetVariable variable name argument. |
[in] | VendorGuid | GetVariable vendor GUID argument. |
[out] | Attributes | GetVariable attributes argument. |
[in,out] | DataSize | GetVariable data size argument. |
[out] | Data | GetVariable data argument. |
GetVariable | status code. |
Definition at line 773 of file CustomSlide.c.
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.
[in,out] | BootCompat | Boot compatibility context. |
[in,out] | BootArgs | Apple kernel boot arguments. |
Definition at line 849 of file CustomSlide.c.
VOID AppleSlideUnlockForSafeMode | ( | IN OUT UINT8 * | ImageBase, |
IN UINTN | ImageSize ) |
Patch boot.efi to support random and passed slide values in safe mode.
[in,out] | ImageBase | Apple booter image base. |
[in] | ImageSize | Apple booter image size. |
Definition at line 609 of file CustomSlide.c.
STATIC UINT8 GenerateSlideValue | ( | IN SLIDE_SUPPORT_STATE * | SlideSupport | ) |
Generate more or less random slide value.
[in] | SlideSupport | Slide support state. |
Definition at line 78 of file CustomSlide.c.
STATIC VOID GetSlideRangeForValue | ( | IN UINTN | EstimatedKernelArea, |
IN BOOLEAN | HasSandyOrIvy, | ||
IN UINT8 | Slide, | ||
OUT UINTN * | StartAddr, | ||
OUT UINTN * | EndAddr ) |
Obtain estimated kernel area start and end addresses for specified slide number.
[in] | EstimatedKernelArea | Estimated kernel area size. |
[in] | HasSandyOrIvy | CPU type. |
[in] | Slide | Slide number. |
[out] | StartAddr | Starting address. |
[out] | EndAddr | Ending address (not inclusive). |
Definition at line 51 of file CustomSlide.c.
STATIC EFI_STATUS GetVariableBootArgs | ( | IN OUT SLIDE_SUPPORT_STATE * | SlideSupport, |
IN EFI_GET_VARIABLE | GetVariable, | ||
IN CHAR16 * | VariableName, | ||
IN EFI_GUID * | VendorGuid, | ||
OUT UINT32 *Attributes | OPTIONAL, | ||
IN OUT UINTN * | DataSize, | ||
OUT VOID * | Data ) |
UEFI GetVariable override specific to boot-args. See caller for more details.
[in,out] | SlideSupport | Slide support state. |
[in] | GetVariable | Original UEFI GetVariable service. |
[in] | VariableName | GetVariable variable name argument. |
[in] | VendorGuid | GetVariable vendor GUID argument. |
[out] | Attributes | GetVariable attributes argument. |
[in,out] | DataSize | GetVariable data size argument. |
[out] | Data | GetVariable data argument. |
GetVariable | status code. |
Definition at line 482 of file CustomSlide.c.
STATIC EFI_STATUS GetVariableCsrActiveConfig | ( | IN OUT SLIDE_SUPPORT_STATE * | SlideSupport, |
IN EFI_GET_VARIABLE | GetVariable, | ||
IN CHAR16 * | VariableName, | ||
IN EFI_GUID * | VendorGuid, | ||
OUT UINT32 *Attributes | OPTIONAL, | ||
IN OUT UINTN * | DataSize, | ||
OUT VOID * | Data ) |
UEFI GetVariable override specific to csr-active-config. See caller for more details.
[in,out] | SlideSupport | Slide support state. |
[in] | GetVariable | Original UEFI GetVariable service. |
[in] | VariableName | GetVariable variable name argument. |
[in] | VendorGuid | GetVariable vendor GUID argument. |
[out] | Attributes | GetVariable attributes argument. |
[in,out] | DataSize | GetVariable data size argument. |
[out] | Data | GetVariable data argument. |
GetVariable | status code. |
Definition at line 416 of file CustomSlide.c.
STATIC VOID HideSlideFromOs | ( | IN OUT SLIDE_SUPPORT_STATE * | SlideSupport, |
IN OUT OC_BOOT_ARGUMENTS * | BootArgs ) |
Erases customised slide value from everywhere accessible for security purposes.
[in,out] | SlideSupport | Slide support state. |
[in,out] | BootArgs | Apple kernel boot arguments. |
Definition at line 572 of file CustomSlide.c.
STATIC BOOLEAN ShouldUseCustomSlideOffset | ( | IN OUT SLIDE_SUPPORT_STATE * | SlideSupport, |
IN EFI_GET_MEMORY_MAP GetMemoryMap | OPTIONAL, | ||
IN OC_MEMORY_FILTER FilterMap | OPTIONAL, | ||
IN VOID *FilterMapContext | OPTIONAL, | ||
IN BOOLEAN | HasSandyOrIvy ) |
Return cached decision or perform memory map analysis to decide whether to use custom slide for reliable kernel booting or not.
[in,out] | SlideSupport | Slide support state. |
[in] | GetMemoryMap | Function to get current memory map for analysis. optional. |
[in] | FilterMap | Function to filter returned memory map, optional. |
[in] | FilterMapContext | Filter map context, optional. |
TRUE | in case custom slide is to be used. |
Definition at line 227 of file CustomSlide.c.
STATIC BOOLEAN ShouldUseCustomSlideOffsetDecision | ( | IN OUT SLIDE_SUPPORT_STATE * | SlideSupport, |
IN UINT8 | FallbackSlide, | ||
IN UINT64 | MaxAvailableSize ) |
Decide on whether to use custom slide based on memory map analysis. This additionally logs the decision through standard services.
[in,out] | SlideSupport | Slide support state. |
[in] | FallbackSlide | Fallback slide number with largest area. |
[in] | MaxAvailableSize | Maximum available contiguous area. |
TRUE | in case custom slide is to be used. |
Definition at line 110 of file CustomSlide.c.