From bb09b0432f57abc0e1738439849a20b00a431d98 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Sun, 25 Jul 2021 23:15:23 -0600 Subject: [PATCH] Add AMFI detection on build --- OpenCore-Patcher.command | 3 +++ Resources/Utilities.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 863db4aba..127b97c99 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -70,6 +70,9 @@ class OpenCoreLegacyPatcher: if "-v" in (Utilities.get_nvram("boot-args") or ""): self.constants.verbose_debug = True + if Utilities.amfi_status() is False: + self.constants.disable_amfi = True + self.constants.latebloom_delay, self.constants.latebloom_range, self.constants.latebloom_debug = Utilities.latebloom_detection(model) # Check if running in RecoveryOS diff --git a/Resources/Utilities.py b/Resources/Utilities.py index 2e01d3d2c..6701280d1 100644 --- a/Resources/Utilities.py +++ b/Resources/Utilities.py @@ -108,6 +108,14 @@ def friendly_hex(integer: int): return "{:02X}".format(integer) +def amfi_status(): + amfi_1 = "amfi_get_out_of_my_way=0x1" + amfi_2 = "amfi_get_out_of_my_way=1" + if get_nvram("boot-args", decode=False) and (amfi_1 in get_nvram("boot-args", decode=False) or amfi_2 in get_nvram("boot-args", decode=False)): + return False + return True + + def patching_status(os_sip): # Detection for Root Patching sip_enabled = True # System Integrity Protection @@ -116,13 +124,11 @@ def patching_status(os_sip): fv_enabled = True # FileVault dosdude_patched = True - amfi_1 = "amfi_get_out_of_my_way=0x1" - amfi_2 = "amfi_get_out_of_my_way=1" gen6_kext = "/System/Library/Extension/AppleIntelHDGraphics.kext" gen7_kext = "/System/Library/Extension/AppleIntelHD3000Graphics.kext" - if get_nvram("boot-args", decode=False) and (amfi_1 in get_nvram("boot-args", decode=False) or amfi_2 in get_nvram("boot-args", decode=False)): - amfi_enabled = False + amfi_enabled = amfi_status() + if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in Constants.Constants.sbm_values: sbm_enabled = False