mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-24 03:50:14 +10:00
Fix AMFI check
This commit is contained in:
@@ -9,6 +9,7 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import binascii
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
@@ -29,6 +30,14 @@ def hexswap(input_hex: str):
|
|||||||
return hex_str.upper()
|
return hex_str.upper()
|
||||||
|
|
||||||
|
|
||||||
|
def string_to_hex(input_string):
|
||||||
|
if not (len(input_string) % 2) == 0:
|
||||||
|
input_string = "0" + input_string
|
||||||
|
input_string = hexswap(input_string)
|
||||||
|
input_string = binascii.unhexlify(input_string)
|
||||||
|
return input_string
|
||||||
|
|
||||||
|
|
||||||
def process_status(process_result):
|
def process_status(process_result):
|
||||||
if process_result.returncode != 0:
|
if process_result.returncode != 0:
|
||||||
print(f"Process failed with exit code {process_result.returncode}")
|
print(f"Process failed with exit code {process_result.returncode}")
|
||||||
@@ -131,8 +140,13 @@ def friendly_hex(integer: int):
|
|||||||
def amfi_status():
|
def amfi_status():
|
||||||
amfi_1 = "amfi_get_out_of_my_way=0x1"
|
amfi_1 = "amfi_get_out_of_my_way=0x1"
|
||||||
amfi_2 = "amfi_get_out_of_my_way=1"
|
amfi_2 = "amfi_get_out_of_my_way=1"
|
||||||
if (get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False) and "-allow_amfi" in get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)) or (
|
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))
|
(
|
||||||
|
get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False) and "-allow_amfi" in get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
|
||||||
|
) or
|
||||||
|
(
|
||||||
|
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 False
|
||||||
return True
|
return True
|
||||||
@@ -255,6 +269,25 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def get_rom(variable: str, *, decode: bool = False):
|
||||||
|
# TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to
|
||||||
|
|
||||||
|
rom = ioreg.IORegistryEntryFromPath(ioreg.kIOMasterPortDefault, "IODeviceTree:/rom".encode())
|
||||||
|
|
||||||
|
value = ioreg.IORegistryEntryCreateCFProperty(rom, variable, ioreg.kCFAllocatorDefault, ioreg.kNilOptions)
|
||||||
|
|
||||||
|
ioreg.IOObjectRelease(rom)
|
||||||
|
|
||||||
|
if not value:
|
||||||
|
return None
|
||||||
|
|
||||||
|
value = ioreg.corefoundation_to_native(value)
|
||||||
|
|
||||||
|
if decode and isinstance(value, bytes):
|
||||||
|
value = value.strip(b"\0").decode()
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def download_file(link, location):
|
def download_file(link, location):
|
||||||
print("- Attempting download from following link:")
|
print("- Attempting download from following link:")
|
||||||
print(link)
|
print(link)
|
||||||
@@ -279,10 +312,17 @@ def download_file(link, location):
|
|||||||
return checksum
|
return checksum
|
||||||
|
|
||||||
|
|
||||||
def enable_apfs(fw_feature, fw_mask):
|
def enable_apfs(fw_feature):
|
||||||
fw_feature |= 2 ** 19
|
fw_feature |= 2 ** 19 # Enable FW_FEATURE_SUPPORTS_APFS
|
||||||
fw_mask |= 2 ** 19
|
return fw_feature
|
||||||
return fw_feature, fw_mask
|
|
||||||
|
def enable_apfs_extended(fw_feature):
|
||||||
|
fw_feature |= 2 ** 20 # Enable FW_FEATURE_SUPPORTS_APFS_EXTRA
|
||||||
|
return fw_feature
|
||||||
|
|
||||||
|
def enable_large_basesystem(fw_feature):
|
||||||
|
fw_feature |= 2 ** 35 # Enable FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
|
||||||
|
return fw_feature
|
||||||
|
|
||||||
|
|
||||||
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
||||||
|
|||||||
@@ -1374,7 +1374,7 @@
|
|||||||
<key>Generic</key>
|
<key>Generic</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>AdviseFeatures</key>
|
<key>AdviseFeatures</key>
|
||||||
<false/>
|
<true/>
|
||||||
<key>SystemMemoryStatus</key>
|
<key>SystemMemoryStatus</key>
|
||||||
<string>Auto</string>
|
<string>Auto</string>
|
||||||
<key>MaxBIOSVersion</key>
|
<key>MaxBIOSVersion</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user