Skip to content

Commit

Permalink
Allow amfi_get_out_of_my_way=1
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Mar 11, 2021
1 parent 231d478 commit 629a146
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Fix GPU vendor user-configuration
- Fix custom EFI Boot icon in Mac Boot Picker
- Enable UserInterfaceTheme to ensure DefaultBackgroundColor is respected
- Enable `amfi_get_out_of_my_way=1` when SIP is disabled

## 0.0.15
- Add user-configurable OpenCore DEBUG builds
Expand Down
12 changes: 8 additions & 4 deletions OpenCore-Patcher.command
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import print_function

import subprocess, sys, time
import subprocess, sys, time, platform

from Resources import build, ModelArray, Constants, utilities

Expand All @@ -18,6 +18,8 @@ class OpenCoreLegacyPatcher():
else:
self.current_model = subprocess.run("system_profiler SPHardwareDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.current_model = [line.strip().split(": ", 1)[1] for line in self.current_model.stdout.decode().split("\n") if line.strip().startswith("Model Identifier")][0]
self.constants.detected_os, _, _ = platform.mac_ver()
self.constants.detected_os = float('.'.join(self.constants.detected_os.split('.')[:2]))

def build_opencore(self):
build.BuildOpenCore(self.constants.custom_model or self.current_model, self.constants).build_opencore()
Expand Down Expand Up @@ -203,6 +205,8 @@ however to patch the root volume both of these must be disabled.
Only disable is absolutely necessary.
Note: for minor changes, SIP can be adjusted in recovery like normal.
Additionally, when disabling SIP via the patcher amfi_get_out_of_my_way=1
will be added to boot-args.
Valid options:
Expand Down Expand Up @@ -287,7 +291,7 @@ running, however this will enforce iMac Nvidia Build Patches.
title = [
f"OpenCore Legacy Patcher v{self.constants.patcher_version}",
f"Selected Model: {self.constants.custom_model or self.current_model}",
f"Target OS: macOS {self.constants.os_support}"
f"Target OS: macOS {self.constants.os_support}",
]

if (self.constants.custom_model or self.current_model) not in ModelArray.SupportedSMBIOS:
Expand All @@ -312,8 +316,8 @@ running, however this will enforce iMac Nvidia Build Patches.

menu = utilities.TUIMenu(title, "Please select an option: ", in_between=in_between, auto_number=True, top_level=True)

options = ([["Build OpenCore", self.build_opencore]] if ((self.constants.custom_model or self.current_model) in ModelArray.SupportedSMBIOS) else []) + [
["Install OpenCore to USB/internal drive", self.install_opencore],
options = (
[["Build OpenCore", self.build_opencore]] if ((self.constants.custom_model or self.current_model) in ModelArray.SupportedSMBIOS) else []) + ([["Install OpenCore to USB/internal drive", self.install_opencore]] if (self.constants.detected_os > 10.12) else []) + [
["Change Model", self.change_model],
["Patcher Settings", self.patcher_settings],
["Credits", self.credits]
Expand Down
1 change: 1 addition & 0 deletions Resources/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self):
self.vault = True
self.sip_status = True
self.secure_status = True
self.detected_os = 0.0

# Payload Location
# OpenCore
Expand Down
12 changes: 10 additions & 2 deletions Resources/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ def build_efi(self):
self.enable_kext(name, version, path, check)

# WiFi patches
wifi_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
wifi_devices = [i for i in wifi_devices if i["vendor-id"] == binascii.unhexlify("E4140000") and i["class-code"] == binascii.unhexlify("00800200")]
# TODO: -a is not supported in Lion and older, need to add proper fix
if self.constants.detected_os < 10.8:
print(f"- Unable to run Wifi detection on {self.constants.detected_os}")
wifi_devices = ["NULL", "NULL"]
else:
wifi_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
wifi_devices = [i for i in wifi_devices if i["vendor-id"] == binascii.unhexlify("E4140000") and i["class-code"] == binascii.unhexlify("00800200")]
if self.constants.wifi_build is True:
print("- Skipping Wifi patches on request")
elif not self.constants.custom_model and wifi_devices and self.hexswap(binascii.hexlify(wifi_devices[0]["device-id"]).decode()[:4]) in ModelArray.nativeWifi:
Expand Down Expand Up @@ -251,6 +256,7 @@ def amd_patch(self):
print("- Disabling SIP")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["csr-active-config"] = binascii.unhexlify("FF0F0000")
self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["csr-active-config"]
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " amfi_get_out_of_my_way=1"
if self.constants.secure_status is False:
print("- Disabling SecureBootModel")
self.config["Misc"]["Security"]["SecureBootModel"] = "Disabled"
Expand Down Expand Up @@ -459,6 +465,8 @@ def copy_efi(self):
print("\nDisk picker is loading...")

all_disks = {}
# TODO: physical is not supported in Sierra and older
# AllDisksAndPartitions is not supported in Yosemite(?) and older
disks = plistlib.loads(subprocess.run("diskutil list -plist physical".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
for disk in disks["AllDisksAndPartitions"]:
disk_info = plistlib.loads(subprocess.run(f"diskutil info -plist {disk['DeviceIdentifier']}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
Expand Down
Binary file added images/OC-Picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 629a146

Please sign in to comment.