Merge pull request #528 from dortania/refactor

Refactor Constants
This commit is contained in:
Mykola Grymalyuk
2021-10-04 13:02:24 -06:00
committed by GitHub
39 changed files with 3220 additions and 2537 deletions

View File

@@ -1,4 +1,4 @@
[flake8]
extend-ignore = E501, E203
per-file-ignores =
Resources/Constants.py:E704
Resources/constants.py:E704

View File

@@ -12,10 +12,10 @@ jobs:
runs-on: x86_64_mojave
steps:
- uses: actions/checkout@v2
- run: python3 create-offline-build.py
- run: python3 create_offline_build.py
- run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OpenCore-Patcher.spec
- run: ./after_pyinstaller.sh
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'
- run: cd dist; zip -r ../OpenCore-Patcher-TUI-Offline.app.zip OpenCore-Patcher.app
- name: Upload App to Artifacts
uses: actions/upload-artifact@v2

View File

@@ -12,10 +12,9 @@ jobs:
runs-on: x86_64_mojave
steps:
- uses: actions/checkout@v2
- run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OpenCore-Patcher.spec
- run: ./after_pyinstaller.sh
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'
- run: cd dist; zip -r ../OpenCore-Patcher-TUI.app.zip OpenCore-Patcher.app
- run: ./../sign-tui.sh
- name: Upload App to Artifacts

View File

@@ -13,19 +13,18 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OCLP-CLI.spec
- run: cd dist; cp OCLP-CLI ../; cd ..
- run: zip OCLP-CLI.zip OCLP-CLI
- run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OpenCore-Patcher.spec
- run: cd dist; cp OpenCore-Patcher ../; cd ..; mv OpenCore-Patcher OCLP-CLI
- name: Download latest nightly OCLP-GUI
run: curl -S -L https://nightly.link/dortania/OCLP-GUI/workflows/build-app/master/OpenCore-Patcher-GUI.app.zip --output ./OpenCore-Patcher-GUI.app.zip
run: curl -S -L https://nightly.link/dortania/OCLP-GUI/workflows/build-app/master/OpenCore-Patcher-GUI.app.zip --output ./OpenCore-Patcher-GUI.app.zip --insecure
- run: unzip -o OpenCore-Patcher-GUI.app.zip
- run: unzip OpenCore-Patcher-GUI.app.zip; rm OpenCore-Patcher-GUI.app.zip
- name: Merge new GUI
run: cp OCLP-CLI OpenCore\ Patcher.app/Contents/Resources/
- run: python3 merge_gui.py
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements entitlements.plist -o runtime "OpenCore Patcher.app/Contents/Resources/OCLP-CLI"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements entitlements.plist -o runtime "OpenCore Patcher.app/Contents/Resources/oclpd"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements entitlements.plist -o runtime "OpenCore Patcher.app"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "OpenCore Patcher.app/Contents/Resources/OCLP-CLI"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "OpenCore Patcher.app/Contents/Resources/oclpd"'
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "OpenCore Patcher.app"'
- run: ditto -c -k --sequesterRsrc --keepParent OpenCore\ Patcher.app OpenCore-Patcher-GUI.app.zip
- run: ./../sign-gui.sh
- name: Upload GUI to Artifacts
@@ -37,7 +36,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: OCLP-CLI
path: OCLP-CLI.zip
path: OCLP-CLI
- name: Upload to Release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@e74ff71f7d8a4c4745b560a485cc5fdb9b5b999d

View File

@@ -29,7 +29,12 @@
- PatcherSupportPkg 0.1.5 release
- RestrictEvents 1.0.5 rolling (2430ed0)
- Limit MacBookPro6,2 G State
- Works around crashing when switching GPUs
- Fix OTA updates on T2 SMBIOS
- Allow iMac13,x iGPU usage always
- Due to both Kepler and Ivy needing root patching, no benefit to disable the iGPU
- Refactor Hardware Model building
- Resolve dGPU output on MacBookPro10,1
## 0.2.5

View File

@@ -1,313 +0,0 @@
#!/usr/bin/env python3
# Copyright (C) 2020-2021 Mykola Grymalyuk
from __future__ import print_function
import subprocess
import sys
import platform
import argparse
from pathlib import Path
from Resources import Build, ModelArray, Constants, SysPatch, device_probe, Utilities, ModelExample
class OpenCoreLegacyPatcher:
def __init__(self):
print("Loading...")
Utilities.disable_cls()
self.constants = Constants.Constants()
self.constants.computer = device_probe.Computer.probe()
self.computer = self.constants.computer
self.constants.detected_os = int(platform.uname().release.partition(".")[0])
self.constants.detected_os_minor = int(platform.uname().release.partition(".")[2].partition(".")[0])
detected_os_build: str = subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
self.constants.detected_os_build = detected_os_build
custom_cpu_model_value = Utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
if custom_cpu_model_value is not None:
# TODO: Fix to not use two separate variables
self.constants.custom_cpu_model = 1
self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0]
if "-v" in (Utilities.get_nvram("boot-args") or ""):
self.constants.verbose_debug = True
# Check if running in RecoveryOS
self.constants.recovery_status = Utilities.check_recovery()
parser = argparse.ArgumentParser()
# Generic building args
parser.add_argument("--build", help="Build OpenCore", action="store_true", required=False)
parser.add_argument("--verbose", help="Enable verbose boot", action="store_true", required=False)
parser.add_argument("--debug_oc", help="Enable OpenCore DEBUG", action="store_true", required=False)
parser.add_argument("--debug_kext", help="Enable kext DEBUG", action="store_true", required=False)
parser.add_argument("--hide_picker", help="Hide OpenCore picker", action="store_true", required=False)
parser.add_argument("--disable_sip", help="Disable SIP", action="store_true", required=False)
parser.add_argument("--disable_smb", help="Disable SecureBootModel", action="store_true", required=False)
parser.add_argument("--vault", help="Enable OpenCore Vaulting", action="store_true", required=False)
parser.add_argument("--support_all", help="Allow OpenCore on natively supported Models", action="store_true", required=False)
parser.add_argument("--firewire", help="Enable FireWire Booting", action="store_true", required=False)
parser.add_argument("--nvme", help="Enable NVMe Booting", action="store_true", required=False)
parser.add_argument("--wlan", help="Enable Wake on WLAN support", action="store_true", required=False)
# parser.add_argument("--disable_amfi", help="Disable AMFI", action="store_true", required=False)
parser.add_argument("--moderate_smbios", help="Moderate SMBIOS Patching", action="store_true", required=False)
parser.add_argument("--moj_cat_accel", help="Allow Root Patching on Mojave and Catalina", action="store_true", required=False)
parser.add_argument("--disable_thunderbolt", help="Disable Thunderbolt on 2013-2014 MacBook Pros", action="store_true", required=False)
parser.add_argument("--force_surplus", help="Force SurPlus in all newer OSes", action="store_true", required=False)
# Building args requiring value values (ie. --model iMac12,2)
parser.add_argument("--model", action="store", help="Set custom model", required=False)
parser.add_argument("--disk", action="store", help="Specifies disk to install to", required=False)
parser.add_argument("--smbios_spoof", action="store", help="Set SMBIOS patching mode", required=False)
# parser.add_argument("--lb_delay", action="store", help="Set Latebloom delay in ms", required=False)
# parser.add_argument("--lb_range", action="store", help="Set Latebloom range in ms", required=False)
# parser.add_argument("--lb_debug", action="store", help="Set Latebloom debug", required=False)
# SysPatch args
parser.add_argument("--patch_sys_vol", help="Patches root volume", action="store_true", required=False)
parser.add_argument("--unpatch_sys_vol", help="Unpatches root volume, EXPERIMENTAL", action="store_true", required=False)
# parser.add_argument("--patch_disk", action="store", help="Specifies disk to root patch", required=False)
parser.add_argument("--validate", help="Validate", action="store_true", required=False)
args = parser.parse_args()
self.constants.gui_mode = True
self.constants.current_path = Path.cwd()
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
print("- Rerouting payloads location")
self.constants.payload_path = sys._MEIPASS / Path("payloads")
else:
print("- Using default payloads location")
if args.disk:
print(f"- Install Disk set: {args.disk}")
self.constants.disk = args.disk
if args.validate:
self.validate()
# if args.patch_disk:
# print(f"- Patch Disk set: {args.patch_disk}")
# self.constants.patch_disk = args.patch_disk
if args.verbose:
print("- Set verbose configuration")
self.constants.verbose_debug = True
if args.debug_oc:
print("- Set OpenCore DEBUG configuration")
self.constants.opencore_debug = True
self.constants.opencore_build = "DEBUG"
if args.debug_kext:
print("- Set kext DEBUG configuration")
self.constants.kext_debug = True
if args.hide_picker:
print("- Set HidePicker configuration")
self.constants.showpicker = False
if args.disable_sip:
print("- Set Disable SIP configuration")
self.constants.sip_status = False
if args.disable_smb:
print("- Set Disable SecureBootModel configuration")
self.constants.secure_status = False
if args.vault:
print("- Set Vault configuration")
self.constants.vault = True
if args.firewire:
print("- Set FireWire Boot configuration")
self.constants.firewire_boot = True
if args.nvme:
print("- Set NVMe Boot configuration")
self.constants.nvme_boot = True
# if args.disable_amfi:
# print("- Set Disable AMFI configuration")
# self.constants.amfi_status = False
if args.wlan:
print("- Set Wake on WLAN configuration")
self.constants.enable_wake_on_wlan = True
if args.disable_thunderbolt:
print("- Set Disable Thunderbolt configuration")
self.constants.disable_thunderbolt = True
if args.force_surplus:
print("- Forcing SurPlus override configuration")
self.constants.force_surplus = True
if args.moderate_smbios:
print("- Set Moderate SMBIOS Patching configuration")
self.constants.serial_settings = "Moderate"
if args.smbios_spoof:
if args.smbios_spoof == "Minimal":
self.constants.serial_settings = "Minimal"
elif args.smbios_spoof == "Moderate":
self.constants.serial_settings = "Moderate"
elif args.smbios_spoof == "Advanced":
self.constants.serial_settings = "Advanced"
else:
print(f"- Unknown SMBIOS arg passed: {args.smbios_spoof}")
# if args.lb_delay:
# try:
# self.constants.latebloom_delay = int(args.lb_delay)
# print(f"- Set LateBloom delay: {args.lb_delay}")
# except ValueError:
# print(f"- Invalid LateBloom delay: {args.lb_delay}")
# if args.lb_range:
# try:
# self.constants.latebloom_range = int(args.lb_range)
# print(f"- Set LateBloom range: {args.lb_range}")
# except ValueError:
# print(f"- Invalid LateBloom range: {args.lb_range}")
# if args.lb_debug:
# try:
# self.constants.latebloom_debug = int(args.lb_debug)
# if self.constants.latebloom_debug in [0, 1]:
# print(f"- Set LateBloom debug: {args.lb_debug}")
# else:
# print(f"- Invalid LateBloom debug: {args.lb_debug}")
# except ValueError:
# print(f"- Invalid LateBloom range: {args.lb_debug}")
if args.support_all:
print("- Building for natively supported model")
self.constants.allow_oc_everywhere = True
self.constants.serial_settings = "None"
if args.build:
if args.model:
print(f"- Using custom model: {args.model}")
self.constants.custom_model = args.model
self.set_defaults(self.constants.custom_model, False)
self.build_opencore()
elif self.computer.real_model not in ModelArray.SupportedSMBIOS and self.constants.allow_oc_everywhere is False:
print(
"""Your model is not supported by this patcher for running unsupported OSes!"
If you plan to create the USB for another machine, please select the "Change Model" option in the menu."""
)
sys.exit(1)
else:
print(f"- Using detected model: {self.constants.computer.real_model}")
self.set_defaults(self.constants.custom_model, True)
self.build_opencore()
if args.patch_sys_vol:
if args.moj_cat_accel:
print("- Set Mojave/Catalina root patch configuration")
self.constants.moj_cat_accel = True
print("- Set System Volume patching")
self.patch_vol()
elif args.unpatch_sys_vol:
print("- Set System Volume unpatching")
self.unpatch_vol()
def set_defaults(self, model, host_is_target):
if host_is_target:
if Utilities.check_metal_support(device_probe, self.computer) is False:
self.constants.disable_cs_lv = True
if self.computer.dgpu and self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
self.constants.sip_status = False
self.constants.amfi_status = True
self.constants.allow_fv_root = True # Allow FileVault on broken seal
if (
isinstance(self.computer.wifi, device_probe.Broadcom)
and self.computer.wifi.chipset in [device_probe.Broadcom.Chipsets.AirPortBrcm4331, device_probe.Broadcom.Chipsets.AirPortBrcm43224]
) or (isinstance(self.computer.wifi, device_probe.Atheros) and self.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40):
self.constants.sip_status = False
self.constants.allow_fv_root = True # Allow FileVault on broken seal
elif model in ModelArray.LegacyGPU:
self.constants.disable_cs_lv = True
if model in ModelArray.LegacyGPU:
if host_is_target and Utilities.check_metal_support(device_probe, self.computer) is True:
# Building on device and we have a native, supported GPU
if self.computer.dgpu and self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
self.constants.sip_status = False
# self.constants.secure_status = True # Monterey
self.constants.amfi_status = True
self.constants.allow_fv_root = True # Allow FileVault on broken seal
else:
self.constants.sip_status = True
# self.constants.secure_status = True # Monterey
self.constants.amfi_status = True
else:
self.constants.sip_status = False # Unsigned kexts
self.constants.secure_status = False # Root volume modified
self.constants.amfi_status = False # Unsigned binaries
self.constants.allow_fv_root = True # Allow FileVault on broken seal
if model in ModelArray.ModernGPU:
self.constants.sip_status = False # Unsigned kexts
self.constants.secure_status = False # Modified root volume
self.constants.allow_fv_root = True # Allow FileVault on broken seal
# self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently
if model == "MacBook8,1":
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
self.constants.serial_settings == "Moderate"
# if self.constants.latebloom_delay == 0:
# self.constants.latebloom_delay, self.constants.latebloom_range, self.constants.latebloom_debug = Utilities.latebloom_detection(model)
if Utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9", decode=True):
self.constants.allow_ts2_accel = False
def patch_vol(self):
SysPatch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants).start_patch()
def unpatch_vol(self):
SysPatch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants).start_unpatch()
def build_opencore(self):
Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore()
def install_opencore(self):
Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).copy_efi()
def validate(self):
# Runs through ocvalidate to check for errors
valid_dumps = [
ModelExample.MacBookPro.MacBookPro92_Stock,
# ModelExample.MacBookPro.MacBookPro171_Stock,
# ModelExample.Macmini.Macmini91_Stock,
ModelExample.iMac.iMac81_Stock,
ModelExample.iMac.iMac112_Stock,
ModelExample.iMac.iMac122_Upgraded,
ModelExample.MacPro.MacPro31_Stock,
ModelExample.MacPro.MacPro31_Upgrade,
ModelExample.MacPro.MacPro31_Modern_AMD,
ModelExample.MacPro.MacPro31_Modern_Kepler,
ModelExample.MacPro.MacPro41_Upgrade,
ModelExample.MacPro.MacPro41_Modern_AMD,
ModelExample.MacPro.MacPro41_51__Flashed_Modern_AMD,
]
self.constants.validate = True
for model in ModelArray.SupportedSMBIOS:
print(f"Validating predefined model: {model}")
self.constants.custom_model = model
self.build_opencore()
result = subprocess.run([self.constants.ocvalidate_path, f"{self.constants.opencore_release_folder}/EFI/OC/config.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
print("Error on build!")
print(result.stdout.decode())
raise Exception(f"Validation failed for predefined model: {model}")
else:
print(f"Validation succeeded for predefined model: {model}")
for model in valid_dumps:
self.constants.computer = model
self.computer = self.constants.computer
self.constants.custom_model = ""
print(f"Validating dumped model: {self.computer.real_model}")
self.build_opencore()
result = subprocess.run([self.constants.ocvalidate_path, f"{self.constants.opencore_release_folder}/EFI/OC/config.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
print("Error on build!")
print(result.stdout.decode())
raise Exception(f"Validation failed for predefined model: {self.computer.real_model}")
else:
print(f"Validation succeeded for predefined model: {self.computer.real_model}")
OpenCoreLegacyPatcher()
# Example arg for OCLP command line
# ./OCLP-CLI --build --verbose --debug_oc --debug_kext --model iMac11,2

View File

@@ -1,35 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
import sys, os
sys.path.append(os.path.abspath(os.getcwd()))
from Resources import Constants
block_cipher = None
a = Analysis(['OCLP-CLI.command'],
pathex=['Resources'],
binaries=[],
datas=[('payloads', 'payloads')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[('u', None, 'OPTION')],
name='OCLP-CLI',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )

View File

@@ -3,382 +3,39 @@
from __future__ import print_function
import platform
import subprocess
import sys
from pathlib import Path
from Resources import Build, CliMenu, Constants, ModelArray, SysPatch, Utilities, device_probe
from resources import build, cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments
from data import model_array
class OpenCoreLegacyPatcher:
def __init__(self):
print("Loading...")
self.constants = Constants.Constants()
self.constants.computer = device_probe.Computer.probe()
self.computer = self.constants.computer
self.constants.detected_os = int(platform.uname().release.partition(".")[0])
self.constants.detected_os_minor = int(platform.uname().release.partition(".")[2].partition(".")[0])
detected_os_build: str = subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
self.constants.detected_os_build = detected_os_build
self.set_defaults(self.computer.real_model, True)
def set_defaults(self, model, host_is_target):
# Defaults
self.constants.sip_status = True
self.constants.secure_status = False # Default false for Monterey
self.constants.amfi_status = True
if host_is_target:
if Utilities.check_metal_support(device_probe, self.computer) is False:
self.constants.disable_cs_lv = True
if self.computer.dgpu and self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
self.constants.sip_status = False
self.constants.amfi_status = True
self.constants.allow_fv_root = True # Allow FileVault on broken seal
if (
isinstance(self.computer.wifi, device_probe.Broadcom)
and self.computer.wifi.chipset in [device_probe.Broadcom.Chipsets.AirPortBrcm4331, device_probe.Broadcom.Chipsets.AirPortBrcm43224]
) or (isinstance(self.computer.wifi, device_probe.Atheros) and self.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40):
self.constants.sip_status = False
self.constants.allow_fv_root = True # Allow FileVault on broken seal
elif model in ModelArray.LegacyGPU:
self.constants.disable_cs_lv = True
if model in ModelArray.LegacyGPU:
if host_is_target and Utilities.check_metal_support(device_probe, self.computer) is True:
# Building on device and we have a native, supported GPU
if self.computer.dgpu and self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
self.constants.sip_status = False
# self.constants.secure_status = True # Monterey
self.constants.allow_fv_root = True # Allow FileVault on broken seal
else:
self.constants.sip_status = True
# self.constants.secure_status = True # Monterey
self.constants.amfi_status = True
else:
self.constants.sip_status = False # Unsigned kexts
self.constants.secure_status = False # Root volume modified
self.constants.amfi_status = False # Unsigned binaries
self.constants.allow_fv_root = True # Allow FileVault on broken seal
if model in ModelArray.ModernGPU:
# Systems with Ivy or Kepler GPUs, Monterey requires root patching for accel
self.constants.sip_status = False # Unsigned kexts
self.constants.secure_status = False # Modified root volume
self.constants.allow_fv_root = True # Allow FileVault on broken seal
# self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently
print("- Loading...")
self.constants = constants.Constants()
self.generate_base_data()
if utilities.check_cli_args() is None:
self.main_menu()
if model == "MacBook8,1":
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
self.constants.serial_settings = "Moderate"
custom_cpu_model_value = Utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
if custom_cpu_model_value is not None:
# TODO: Fix to not use two separate variables
self.constants.custom_cpu_model = 1
self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0]
if "-v" in (Utilities.get_nvram("boot-args") or ""):
self.constants.verbose_debug = True
if Utilities.amfi_status() is False:
self.constants.amfi_status = False
if Utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9"):
# Users disabling TS2 most likely have a faulty dGPU
# users can override this in settings
self.constants.allow_ts2_accel = False
# if self.constants.latebloom_delay == 0:
# self.constants.latebloom_delay, self.constants.latebloom_range, self.constants.latebloom_debug = Utilities.latebloom_detection(model)
# Check if running in RecoveryOS
self.constants.recovery_status = Utilities.check_recovery()
def build_opencore(self):
Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore()
def install_opencore(self):
Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).copy_efi()
def change_model(self):
Utilities.cls()
Utilities.header(["Select Different Model"])
print(
"""
Tip: Run the following command on the target machine to find the model identifier:
system_profiler SPHardwareDataType | grep 'Model Identifier'
"""
)
self.constants.custom_model = input("Please enter the model identifier of the target machine: ").strip()
if self.constants.custom_model not in ModelArray.SupportedSMBIOS:
print(
f"""
{self.constants.custom_model} is not a valid SMBIOS Identifier for macOS {self.constants.os_support}!
"""
)
print_models = input(f"Print list of valid options for macOS {self.constants.os_support}? (y/n)")
if print_models.lower() in {"y", "yes"}:
print("\n".join(ModelArray.SupportedSMBIOS))
input("\nPress [ENTER] to continue")
def generate_base_data(self):
self.constants.detected_os = os_probe.detect_kernel_major()
self.constants.detected_os_minor = os_probe.detect_kernel_minor()
self.constants.detected_os_build = os_probe.detect_kernel_build()
self.constants.computer = device_probe.Computer.probe()
self.constants.recovery_status = utilities.check_recovery()
self.computer = self.constants.computer
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
if utilities.check_cli_args() is not None:
print("- Detected arguments, switching to CLI mode")
self.constants.gui_mode = True # Assumes no user interaction is required
self.constants.current_path = Path.cwd()
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
print("- Rerouting payloads location")
self.constants.payload_path = sys._MEIPASS / Path("payloads")
arguments.arguments().parse_arguments(self.constants)
else:
self.set_defaults(self.constants.custom_model, False)
def patcher_settings(self):
response = None
while not (response and response == -1):
title = ["Adjust Patcher Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
["Debug Settings", self.patcher_setting_debug],
["Security Settings", self.patcher_settings_security],
["SMBIOS Settings", self.patcher_settings_smbios],
["Boot Volume Settings", self.patcher_settings_boot],
["Miscellaneous Settings", self.patcher_settings_misc],
["Dump detected hardware", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).dump_hardware],
[
f"Allow Accel on Mojave/Catalina:\tCurrently {self.constants.moj_cat_accel}",
CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_moj_cat_patch,
],
[
f"Allow OpenCore on native Models:\tCurrently {self.constants.allow_oc_everywhere}",
CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_native_models,
],
["Advanced Settings, for developers only", self.advanced_patcher_settings],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_setting_debug(self):
response = None
while not (response and response == -1):
title = ["Adjust Debug Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Enable Verbose Mode:\tCurrently {self.constants.verbose_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_verbose],
[f"Enable OpenCore DEBUG:\tCurrently {self.constants.opencore_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_oc],
[f"Enable Kext DEBUG:\t\tCurrently {self.constants.kext_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_kext],
] + (
[
[f"Set SurPlus Settings:\tCurrently {self.constants.force_surplus}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).set_surplus]
]
if ((self.constants.custom_model or self.computer.real_model) in ModelArray.PCIRaceCondition)
else []
)
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_security(self):
response = None
while not (response and response == -1):
title = ["Adjust Security Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
# [
# f"Set Apple Mobile File Integrity (AMFI):\tCurrently {self.constants.amfi_status}",
# CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).set_amfi,
# ],
[
f"Set System Intrgity Protection (SIP):\tCurrently {self.constants.sip_status}",
CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_sip,
],
[
f"Set Secure Boot Model (SBM):\t\tCurrently {self.constants.secure_status}",
CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_sbm,
],
[f"Set Vault Mode:\t\t\t\tCurrently {self.constants.vault}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_vault],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_smbios(self):
response = None
while not (response and response == -1):
title = ["Adjust SMBIOS Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set SMBIOS Spoof Level:\tCurrently {self.constants.serial_settings}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_serial],
[f"Set SMBIOS Spoof Model:\tCurrently {self.constants.override_smbios}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).set_smbios],
[f"Set Custom name {self.constants.custom_cpu_model_value}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).custom_cpu],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_boot(self):
response = None
while not (response and response == -1):
title = ["Adjust Bootable Volume Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set FireWire Boot:\tCurrently {self.constants.firewire_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_firewire],
[f"Set NVMe Boot:\tCurrently {self.constants.nvme_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_nvme],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_misc(self):
response = None
while not (response and response == -1):
title = ["Adjust Miscellaneous Settings"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_showpicker],
[f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_wowl],
[f"Set Ivy iMac iGPU:\t\tCurrently {self.constants.allow_ivy_igpu}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_ivy],
[f"Set TeraScale 2 Accel:\tCurrently {self.constants.allow_ts2_accel}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).terascale_2_accel],
[
f"Disable Thunderbolt:\tCurrently {self.constants.disable_thunderbolt}",
CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).disable_thunderbolt,
],
[f"Set AppleALC Usage:\t\tCurrently {self.constants.set_alc_usage}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).applealc_support],
[f"Set Windows GMUX support:\tCurrently {self.constants.dGPU_switch}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).dGPU_switch_support],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def advanced_patcher_settings(self):
response = None
while not (response and response == -1):
title = ["Adjust Advanced Patcher Settings, for developers ONLY"]
menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_metal],
[f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).drm_setting],
[f"Set Generic Bootstrap:\t\tCurrently {self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).bootstrap_setting],
[
f"Disable CPU Friend:\t\t\tCurrently {self.constants.disallow_cpufriend}",
CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).disable_cpufriend,
],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def credits(self):
Utilities.TUIOnlyPrint(
["Credits"],
"Press [Enter] to go back.\n",
[
"""Many thanks to the following:
- Acidanthera:\tOpenCore, kexts and other tools
- Khronokernel:\tWriting and maintaining this patcher
- DhinakG:\t\tWriting and maintaining this patcher
- ASentientBot:\tLegacy Acceleration Patches
- Ausdauersportler:\tLinking fixes for SNBGraphicsFB and AMDX3000
- Syncretic:\t\tAAAMouSSE and telemetrap
- cdf:\t\tNightShiftEnabler and Innie"""
],
).start()
def PatchVolume(self):
Utilities.cls()
Utilities.header(["Patching System Volume"])
big_sur = """Patches Root volume to fix misc issues such as:
- Non-Metal Graphics Acceleration
- Intel: Ironlake - Sandy Bridge
- Nvidia: Tesla - Fermi (8000-500 series)
- AMD: TeraScale 1 and 2 (2000-6000 series)
- Audio support for iMac7,1 and iMac8,1
WARNING: Root Volume Patching is still in active development, please
have all important user data backed up. Note when the system volume
is patched, you can no longer have Delta updates.
Supported Options:
1. Patch System Volume
2. Unpatch System Volume (Experimental)
B. Exit
"""
monterey = """Patches Root volume to fix misc issues such as:
- Metal Graphics Acceleration
- Intel: Ivy Bridge (4000 series iGPUs)
- Nvidia: Kepler (600-700)
- Non-Metal Graphics Accelertation
- Intel: Ironlake - Sandy Bridge
- Nvidia: Tesla - Fermi (8000-500 series)
- AMD: TeraScale 1 and 2 (2000-6000 series)
- Audio support for iMac7,1 and iMac8,1
- Wifi support for BCM94328, BCM94322 and Atheros cards
WARNING: Root Volume Patching is still in active development, please
have all important user data backed up. Note when the system volume
is patched, you can no longer have Delta updates.
Supported Options:
1. Patch System Volume
2. Unpatch System Volume (Experimental)
B. Exit
"""
mojave_catalina = """Patches Root volume to fix misc issues such as:
- Non-Metal Graphics Acceleration
- Intel: Ironlake - Sandy Bridge
- Nvidia: Tesla - Fermi (8000-500 series)
- AMD: TeraScale 1 and 2 (2000-6000 series)
- Audio support for iMac7,1 and iMac8,1
WARNING: Root Volume Patching is still in active development, please
have all important user data backed up. Note when the system volume
is patched, you can no longer have Delta updates.
Supported Options:
1. Patch System Volume
2. Unpatch System Volume (Experimental)
B. Exit
"""
default = """
This OS has no root patches available to apply, please ensure you're patching a booted
install that requires root patches such as macOS Big Sur or Monterey
Supported Options:
B. Exit
"""
no_patch = False
if self.constants.detected_os == self.constants.monterey:
print(monterey)
elif self.constants.detected_os == self.constants.big_sur:
print(big_sur)
elif self.constants.detected_os in [self.constants.mojave, self.constants.catalina] and self.constants.moj_cat_accel == True:
print(mojave_catalina)
else:
print(default)
no_patch = True
change_menu = input("Patch System Volume?: ")
if no_patch is not True and change_menu == "1":
SysPatch.PatchSysVolume(self.constants.custom_model or self.computer.real_model, self.constants).start_patch()
elif no_patch is not True and change_menu == "2":
SysPatch.PatchSysVolume(self.constants.custom_model or self.computer.real_model, self.constants).start_unpatch()
else:
print("Returning to main menu")
print("- No arguments present, loading TUI")
def main_menu(self):
response = None
@@ -388,7 +45,7 @@ B. Exit
f"Selected Model: {self.constants.custom_model or self.computer.real_model}",
]
if (self.constants.custom_model or self.computer.real_model) not in ModelArray.SupportedSMBIOS and self.constants.allow_oc_everywhere is False:
if (self.constants.custom_model or self.computer.real_model) not in model_array.SupportedSMBIOS and self.constants.allow_oc_everywhere is False:
in_between = [
"Your model is not supported by this patcher for running unsupported OSes!",
"",
@@ -407,18 +64,18 @@ B. Exit
else:
in_between = ["This model is supported"]
menu = Utilities.TUIMenu(title, "Please select an option: ", in_between=in_between, auto_number=True, top_level=True)
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.computer.real_model) in ModelArray.SupportedSMBIOS) or self.constants.allow_oc_everywhere is True
[["Build OpenCore", build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore]]
if ((self.constants.custom_model or self.computer.real_model) in model_array.SupportedSMBIOS) or self.constants.allow_oc_everywhere is True
else []
) + [
["Install OpenCore to USB/internal drive", self.install_opencore],
["Post-Install Volume Patch", self.PatchVolume],
["Change Model", self.change_model],
["Patcher Settings", self.patcher_settings],
["Credits", self.credits],
["Install OpenCore to USB/internal drive", build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).copy_efi],
["Post-Install Volume Patch", cli_menu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).PatchVolume],
["Change Model", cli_menu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_model],
["Patcher Settings", cli_menu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).patcher_settings],
["Credits", cli_menu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).credits],
]
for option in options:
@@ -430,4 +87,4 @@ B. Exit
subprocess.run("""osascript -e 'tell application "Terminal" to close first window' & exit""", shell=True)
OpenCoreLegacyPatcher().main_menu()
OpenCoreLegacyPatcher()

View File

@@ -1,12 +1,12 @@
# -*- mode: python ; coding: utf-8 -*-
import sys, os
sys.path.append(os.path.abspath(os.getcwd()))
from Resources import Constants
from resources import constants
block_cipher = None
a = Analysis(['OpenCore-Patcher.command'],
pathex=['Resources'],
pathex=['resources', 'data'],
binaries=[],
datas=[('payloads', 'payloads')],
hiddenimports=[],
@@ -35,10 +35,10 @@ exe = EXE(pyz,
console=True )
app = BUNDLE(exe,
name='OpenCore-Patcher.app',
icon="OC-Patcher.icns",
icon="payloads/OC-Patcher.icns",
bundle_identifier=None,
info_plist={
"CFBundleShortVersionString": Constants.Constants().patcher_version,
"CFBundleShortVersionString": constants.Constants().patcher_version,
"CFBundleExecutable": "MacOS/Launcher",
"NSHumanReadableCopyright": "Copyright 2020-2021 Dortania"
})

File diff suppressed because it is too large Load Diff

View File

@@ -1,110 +0,0 @@
FirmwareFeatures = {
"iMac7,1": "0xC0001407",
"iMac8,1": "0xC0001403",
"iMac9,1": "0xC0001403",
"iMac10,1": "0xE00DE137",
"iMac11,1": "0xE00DE137",
"iMac11,2": "0xC00C9423",
"iMac11,3": "0xE00DE137",
"iMac12,1": "0xE00DE137",
"iMac12,2": "0xE00DE137",
"iMac13,1": "0xE00DE137",
"iMac13,2": "0xE00DE137",
"iMac13,3": "0xE00DE137",
"iMac14,1": "0xFB0FF577",
"iMac14,2": "0xE00FE137",
"iMac14,3": "0xE00FE137",
"iMac14,4": "0xF00FE137",
"iMac15,1": "0xF80FE137",
"iMac16,1": "0xFC0FE137",
"iMac16,2": "0xFC0FE137",
"iMac17,1": "0xFC0FE137",
"iMac18,1": "0xFD0FF576",
"iMac18,2": "0xFD0FF576",
"iMac18,3": "0xFD0FF576",
"iMac19,1": "0xFD8FF576",
"iMac19,2": "0xFD8FF576",
"iMac20,1": "0xFD8FF576",
"iMac20,2": "0xFD8FF576",
"iMacPro1,1": "0xFD8FF53E",
"MacBook3,1": "0xC0001407",
"MacBook4,1": "0xC0001403",
"MacBook5,1": "0xC0001403",
"MacBook5,2": "0xC0001403",
"MacBook6,1": "0xFC0FE13F",
"MacBook7,1": "0xFC0FE13F",
"MacBook8,1": "0xFC0FE13F",
"MacBook9,1": "0xFC0FE13F",
"MacBook10,1": "0xFC0FE13F",
"MacBookAir1,1": "0xC0001403",
"MacBookAir2,1": "0xC0001403",
"MacBookAir3,1": "0xD00DE137",
"MacBookAir3,2": "0xD00DE137",
"MacBookAir4,1": "0xD00DE137",
"MacBookAir4,2": "0xD00DE137",
"MacBookAir5,1": "0xE00DE137",
"MacBookAir5,2": "0xE00DE137",
"MacBookAir6,1": "0xE00FE137",
"MacBookAir6,2": "0xE00FE137",
"MacBookAir7,1": "0xFF0FF576",
"MacBookAir7,2": "0xFF0FF576",
"MacBookAir8,1": "0xFD8FF42E",
"MacBookAir8,2": "0xFD8FF42E",
"MacBookAir9,1": "0xFFAFF06E",
"MacBookPro3,1": "0xC0001407",
"MacBookPro4,1": "0xC0001403",
"MacBookPro5,1": "0xC0001403",
"MacBookPro5,2": "0xC0001403",
"MacBookPro5,3": "0xC0001403",
"MacBookPro5,4": "0xC0001403",
"MacBookPro5,5": "0xC0001403",
"MacBookPro6,1": "0xC00DE137",
"MacBookPro6,2": "0xC00DE137",
"MacBookPro7,1": "0xC00DE137",
"MacBookPro8,1": "0xC00DE137",
"MacBookPro8,2": "0xC00DE137",
"MacBookPro8,3": "0xC00DE137",
"MacBookPro9,1": "0xC00DE137",
"MacBookPro9,2": "0xC10DF577",
"MacBookPro10,1": "0xE00DE137",
"MacBookPro10,2": "0xE00DE137",
"MacBookPro11,1": "0xEB0FF577",
"MacBookPro11,2": "0xEB0FF577",
"MacBookPro11,3": "0xEB0FF577",
"MacBookPro11,4": "0xEB0FF577",
"MacBookPro11,5": "0xEB0FF577",
"MacBookPro12,1": "0xFD0FF576",
"MacBookPro13,1": "0xFC0FE137",
"MacBookPro13,2": "0xFC0FE137",
"MacBookPro13,3": "0xFC0FE137",
"MacBookPro14,1": "0xFF0FF57E",
"MacBookPro14,2": "0xFF0FF57E",
"MacBookPro14,3": "0xFF0FF57E",
"MacBookPro15,1": "0xFD8FF426",
"MacBookPro15,2": "0xFD8FF426",
"MacBookPro15,3": "0xFD8FF426",
"MacBookPro15,4": "0xFD8FF426",
"MacBookPro16,1": "0xFDAFF066",
"MacBookPro16,2": "0xFFAFF06E",
"MacBookPro16,3": "0xFDAFF066",
"MacBookPro16,4": "0xFDAFF066",
"Macmini3,1": "0xC0001403",
"Macmini4,1": "0xC00C9423",
"Macmini5,1": "0xD00DE137",
"Macmini5,2": "0xD00DE137",
"Macmini5,3": "0xD00DE137",
"Macmini6,1": "0xE00DE137",
"Macmini6,2": "0xE00DE137",
"Macmini7,1": "0xE00DE137",
"Macmini8,1": "0xFD8FF466",
"MacPro1,1": "0x80000015",
"MacPro2,1": "0xC0000015",
"MacPro3,1": "0xC0001403",
"MacPro4,1": "0xE001F537",
"MacPro5,1": "0xE80FE137",
"MacPro6,1": "0xE90FF576",
"MacPro7,1": "0xFDAFF066",
"Xserve2,1": "0xC0001403",
"Xserve3,1": "0xE001F537",
"Dortania1,1": "0xFDAFF066",
}

View File

@@ -1,2 +1,2 @@
#!/bin/sh
cp launcher.sh dist/OpenCore-Patcher.app/Contents/MacOS/Launcher
cp payloads/launcher.sh dist/OpenCore-Patcher.app/Contents/MacOS/Launcher

View File

@@ -1,7 +1,7 @@
import subprocess
from Resources import Constants
from resources import constants
patcher_support_pkg_version = Constants.Constants().patcher_support_pkg_version
patcher_support_pkg_version = constants.Constants().patcher_support_pkg_version
binary_packages = ["10.14-Mojave", "10.15-Catalina", "11-Big-Sur", "12-Monterey"]
for binary_package in binary_packages:

14
data/bluetooth_data.py Normal file
View File

@@ -0,0 +1,14 @@
import enum
class bluetooth_data(enum.IntEnum):
# Bluetooth Chipsets
NonApplicable = 0
BRCM2045 = 1 # TODO: Rename chipset, currently guessing MacPro1,1-3,1 name
BRCM2046 = 2 # BT 2.1
BRCM2070 = 3 # BT 2.1
BRCM20702_v1 = 4 # BT 4.0 - 2012
BRCM20702_v2 = 5 # BT 4.0 - 2013+
BRCM20703 = 6 # BT 4.2
BRCM20703_UART = 9 # BRCM20703 over UART, BT 4.2
UART = 10 # T2
PCIe = 20 # Apple Silicon

22
data/cpu_data.py Normal file
View File

@@ -0,0 +1,22 @@
import enum
class cpu_data(enum.IntEnum):
pentium_4 = 0
yonah = 1
conroe = 2
penryn = 3
nehalem = 4 # (Westmere included)
sandy_bridge = 5 # 2000
ivy_bridge = 6 # 3000
haswell = 7 # 4000
broadwell = 8 # 5000
skylake = 9 # 6000
kaby_lake = 10 # 7000
coffee_lake = 11 # 8000
comet_lake = 12 # 9000
ice_lake = 13 # 10000
apple_dtk = 112 # A12
apple_m1 = 114 # A14
apple_m2 = 115 # A15

View File

@@ -1,6 +1,6 @@
# Example Hardware probe of multiple models
# To be used when running validation tests
from Resources import device_probe
from resources import device_probe
class MacBook:

395
data/model_array.py Normal file
View File

@@ -0,0 +1,395 @@
# Lists all models and required patches
# Copyright (C) 2020-2021, Dhinak G, Mykola Grymalyuk
SupportedSMBIOS = [
# MacBook
"MacBook4,1",
"MacBook5,1",
"MacBook5,2",
"MacBook6,1",
"MacBook7,1",
"MacBook8,1",
# MacBook Air
"MacBookAir2,1",
"MacBookAir3,1",
"MacBookAir3,2",
"MacBookAir4,1",
"MacBookAir4,2",
"MacBookAir5,1",
"MacBookAir5,2",
"MacBookAir6,1",
"MacBookAir6,2",
# MacBook Pro
"MacBookPro4,1",
"MacBookPro5,1",
"MacBookPro5,2",
"MacBookPro5,3",
"MacBookPro5,4",
"MacBookPro5,5",
"MacBookPro6,1",
"MacBookPro6,2",
"MacBookPro7,1",
"MacBookPro8,1",
"MacBookPro8,2",
"MacBookPro8,3",
"MacBookPro9,1",
"MacBookPro9,2",
"MacBookPro10,1",
"MacBookPro10,2",
"MacBookPro11,1",
"MacBookPro11,2",
"MacBookPro11,3",
# Mac Mini
"Macmini3,1",
"Macmini4,1",
"Macmini5,1",
"Macmini5,2",
"Macmini5,3",
"Macmini6,1",
"Macmini6,2",
# iMac
"iMac7,1",
"iMac8,1",
"iMac9,1",
"iMac10,1",
"iMac11,1",
"iMac11,2",
"iMac11,3",
"iMac12,1",
"iMac12,2",
"iMac13,1",
"iMac13,2",
"iMac13,3",
"iMac14,1",
"iMac14,2",
"iMac14,3",
"iMac14,4",
"iMac15,1",
# Mac Pro
"MacPro3,1",
"MacPro4,1",
"MacPro5,1",
# Xserve
"Xserve2,1",
"Xserve3,1",
]
# Audio
LegacyAudio = [
"MacBook4,1",
"MacBook5,1",
"MacBook5,2",
"MacBook6,1",
"MacBook7,1",
"MacBookAir2,1",
"MacBookAir3,1",
"MacBookAir3,2",
"MacBookAir4,1",
"MacBookAir4,2",
"MacBookPro4,1",
"MacBookPro5,1",
"MacBookPro5,2",
"MacBookPro5,3",
"MacBookPro5,4",
"MacBookPro5,5",
"MacBookPro6,1",
"MacBookPro6,2",
"MacBookPro7,1",
"MacBookPro8,1",
"MacBookPro8,2",
"MacBookPro8,3",
"Macmini3,1",
"Macmini4,1",
"Macmini5,1",
"Macmini5,2",
"Macmini5,3",
# "iMac7,1",
# "iMac8,1",
"iMac9,1",
"iMac10,1",
"iMac11,1",
"iMac11,2",
"iMac11,3",
"iMac12,1",
"iMac12,2",
"MacPro3,1",
"Dortania1,1",
]
# GPU
ModernGPU = [
"MacBookAir5,1", # Intel 4000
"MacBookAir5,2", # Intel 4000
"MacBookPro9,1", # Intel 4000 + Nvidia 650M
"MacBookPro9,2", # Intel 4000
"MacBookPro10,1", # Intel 4000 + Nvidia 650M
"MacBookPro10,2", # Intel 4000
"MacBookPro11,3", # Intel 5000 + Nvidia Kepler
"Macmini6,1", # Intel 4000
"Macmini6,2", # Intel 4000
"iMac13,1", # Intel 4000
"iMac13,2", # Intel 4000 + Nvidia Kepler
"iMac13,3", # Intel 4000
"iMac14,1", # Intel 5000 + Nvidia Kepler
"iMac14,2", # Intel 5000 + Nvidia Kepler
"iMac14,3", # Intel 5000 + Nvidia Kepler
]
LegacyGPU = [
"MacBook4,1", # GMA X3100
"MacBook5,1", # Nvidia 9000
"MacBook5,2", # Nvidia 9000
"MacBook6,1", # Nvidia 9000
"MacBook7,1", # Nvidia 300
"MacBookAir2,1", # Nvidia 9000
"MacBookAir3,1", # Nvidia 300
"MacBookAir3,2", # Nvidia 300
"MacBookAir4,1", # Intel 3000
"MacBookAir4,2", # Intel 3000
"MacBookPro4,1", # Nvidia 8000
"MacBookPro5,1", # Nvidia 9000
"MacBookPro5,2", # Nvidia 9000
"MacBookPro5,3", # Nvidia 9000
"MacBookPro5,4", # Nvidia 9000
"MacBookPro5,5", # Nvidia 9000
"MacBookPro6,1", # Intel 100 + Nvidia 300
"MacBookPro6,2", # Intel 100 + Nvidia 300
"MacBookPro7,1", # Nvidia 300
"MacBookPro8,1", # Intel 3000
"MacBookPro8,2", # Intel 3000 + AMD 6000
"MacBookPro8,3", # Intel 3000 + AMD 6000
"Macmini3,1", # Nvidia 9000
"Macmini4,1", # Nvidia 300
"Macmini5,1", # Intel 3000
"Macmini5,2", # AMD 6000
"Macmini5,3", # Intel 3000
"iMac7,1", # AMD 2000
"iMac8,1", # Nvidia and AMD 2400
"iMac9,1", # Nvidia 9000
"iMac10,1", # Nvidia 9000 and AMD 4000
"iMac11,1", # AMD 4000
"iMac11,2", # AMD 4000 and 5000
"iMac11,3", # AMD 5000
"iMac12,1", # AMD 6000
"iMac12,2", # AMD 6000
"Dortania1,1", # RTX 3080
]
LegacyGPUNvidia = [
"MacBook5,1", # Nvidia 9000
"MacBook5,2", # Nvidia 9000
"MacBook6,1", # Nvidia 9000
"MacBook7,1", # Nvidia 300
"MacBookAir2,1", # Nvidia 9000
"MacBookAir3,1", # Nvidia 300
"MacBookAir3,2", # Nvidia 300
"MacBookPro4,1", # Nvidia 8000
"MacBookPro5,1", # Nvidia 9000
"MacBookPro5,2", # Nvidia 9000
"MacBookPro5,3", # Nvidia 9000
"MacBookPro5,4", # Nvidia 9000
"MacBookPro5,5", # Nvidia 9000
"MacBookPro6,1", # Intel 100 + Nvidia 300
"MacBookPro6,2", # Intel 100 + Nvidia 300
"MacBookPro7,1", # Nvidia 300
"Macmini3,1", # Nvidia 9000
"Macmini4,1", # Nvidia 300
"iMac9,1", # Nvidia 9000
# "iMac10,1", # Nvidia 9000 and AMD 4000
]
LegacyGPUAMD = [
"MacBookPro8,2", # Intel 3000 + AMD 6000
"MacBookPro8,3", # Intel 3000 + AMD 6000
"Macmini5,2", # AMD 6000
"iMac7,1", # AMD 2000
# "iMac8,1", # Nvidia and AMD 2000
# "iMac10,1", # Nvidia 9000 and AMD 4000
"iMac11,1", # AMD 4000
"iMac11,2", # AMD 4000 and 5000
"iMac11,3", # AMD 5000
"iMac12,1", # AMD 6000
"iMac12,2", # AMD 6000
]
LegacyGPUAMDIntelGen2 = [
"MacBookPro8,2", # Intel 3000 + AMD 6000
"MacBookPro8,3", # Intel 3000 + AMD 6000
"Macmini5,2", # AMD 6000
"iMac12,1", # AMD 6000
"iMac12,2", # AMD 6000
]
LegacyGPUIntelGen1 = [
"MacBookPro6,1", # Intel 100 + Nvidia 300
"MacBookPro6,2", # Intel 100 + Nvidia 300
]
LegacyGPUIntelGen2 = [
"MacBookAir4,1", # Intel 3000
"MacBookAir4,2", # Intel 3000
"MacBookPro8,1", # Intel 3000
"MacBookPro8,2", # Intel 3000 + AMD 6000
"MacBookPro8,3", # Intel 3000 + AMD 6000
"Macmini5,1", # Intel 3000
"Macmini5,3", # Intel 3000
]
LegacyBrightness = [
"MacBook5,2",
"iMac7,1",
"iMac8,1",
"iMac9,1",
]
NVMePatch = ["MacPro3,1", "MacPro4,1", "Xserve3,1", "Dortania1,1"]
DualGPUPatch = [
"MacBookPro5,1",
"MacBookPro5,2",
"MacBookPro5,3",
"MacBookPro6,1",
"MacBookPro6,2",
"MacBookPro8,2",
"MacBookPro8,3",
"Macmini5,2",
"iMac12,1",
"iMac12,2",
"iMac13,1",
"iMac13,2",
"iMac14,2",
"iMac14,3",
"Dortania1,1",
]
DualGPUPatchRetina = [
"MacBookPro10,1",
"MacBookPro11,3",
]
IntelNvidiaDRM = [
"iMac13,1",
"iMac13,2",
"iMac14,2",
"iMac14,3",
]
IDEPatch = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "MacPro3,1", "Xserve2,1", "Dortania1,1"]
# Mac Pro and Xserve
MacPro = ["MacPro3,1", "MacPro4,1", "MacPro5,1", "Xserve2,1", "Xserve3,1", "Dortania1,1"]
SATAPatch = [
"MacBook4,1",
"MacBook5,1",
"MacBook5,2",
"MacBook6,1",
"MacBook7,1",
"MacBookAir2,1",
"MacBookAir3,1",
"MacBookAir3,2",
"MacBookAir4,1",
"MacBookAir4,2",
"MacBookPro4,1",
"MacBookPro5,1",
"MacBookPro5,2",
"MacBookPro5,3",
"MacBookPro5,4",
"MacBookPro5,5",
"MacBookPro6,1",
"MacBookPro6,2",
"MacBookPro7,1",
"MacBookPro8,1",
"MacBookPro8,2",
"MacBookPro8,3",
"MacBookPro9,1",
"MacBookPro9,2",
"Macmini3,1",
"Macmini4,1",
"Macmini5,1",
"Macmini5,2",
"Macmini5,3",
"iMac7,1",
"iMac8,1",
"iMac9,1",
"iMac10,1",
"iMac11,1",
"iMac11,2",
"iMac11,3",
"iMac12,1",
"iMac12,2",
"MacPro3,1",
"MacPro4,1",
"MacPro5,1",
"Xserve2,1",
"Xserve3,1",
"Dortania1,1",
]
NoAGPMSupport = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "MacPro3,1", "Xserve2,1", "Dortania1,1"]
AGDPSupport = [
"MacBookPro9,1",
"MacBookPro10,1",
"iMac13,1",
"iMac13,2",
"iMac14,1",
"iMac14,2",
"iMac14,3",
"iMac14,4",
"iMac15,1",
# TODO: Uncomment when dropped from macOS
# "iMac17,1",
# "iMac18,2",
# "iMac18,3",
# "iMac19,1",
# "iMac19,2",
# "iMac20,1",
# "iMac20,2",
# "iMacPro1,1",
# "MacPro6,1",
]
Missing_USB_Map = [
"MacBook4,1",
"MacBook5,1",
"MacBook5,2",
"MacBook6,1",
"MacBook7,1",
"MacBookAir2,1",
"MacBookAir3,1",
"MacBookAir3,2",
"MacBookAir4,1",
"MacBookAir4,2",
"MacBookPro4,1",
"MacBookPro5,1",
"MacBookPro5,2",
"MacBookPro5,3",
"MacBookPro5,4",
"MacBookPro5,5",
"MacBookPro6,1",
"MacBookPro6,2",
"MacBookPro7,1",
"MacBookPro8,1",
"MacBookPro8,2",
"MacBookPro8,3",
"Macmini3,1",
"Macmini4,1",
"Macmini5,1",
"Macmini5,2",
"Macmini5,3",
"iMac7,1",
"iMac8,1",
"iMac9,1",
"iMac10,1",
"iMac11,1",
"iMac11,2",
"iMac11,3",
"iMac12,1",
"iMac12,2",
"MacPro3,1",
"MacPro4,1",
"Xserve2,1",
"Xserve3,1",
]

19
data/os_data.py Normal file
View File

@@ -0,0 +1,19 @@
import enum
class os_data(enum.IntEnum):
# OS Versions, Based off Major Kernel Version
tiger = 8
leopard = 9
snow_leopard = 10
lion = 11
mountain_lion = 12
mavericks = 13
yosemite = 14
el_capitan = 15
sierra = 16
high_sierra = 17
mojave = 18
catalina = 19
big_sur = 20
monterey = 21
max_os = 99

View File

@@ -1,6 +1,4 @@
# Array of Device IDs for different devices
class nvidia_ids:
# Courteous of envytools as well as Macrumors:
# https://envytools.readthedocs.io/en/latest/hw/pciid.html
@@ -850,6 +848,13 @@ class intel_ids:
class broadcom_ids:
AppleBCMWLANBusInterfacePCIe = [
0x43DC, # BCM4355
0x4464, # BCM4364
0x4488, # BCM4377b
0x4425, # Unknown
]
AirPortBrcmNIC = [
# AirPortBrcmNIC IDs
0x43BA, # BCM43602

35
data/sip_data.py Normal file
View File

@@ -0,0 +1,35 @@
class system_integrity_protection:
csr_values = {
# Source: macOS 11.4 (XNU's csr.h)
# https://opensource.apple.com/source/xnu/xnu-7195.121.3/bsd/sys/csr.h.auto.html
"CSR_ALLOW_UNTRUSTED_KEXTS": False, # 0x1 - Allows Unsigned Kexts - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_UNRESTRICTED_FS": False, # 0x2 - File System Access - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_TASK_FOR_PID": False, # 0x4 - Unrestricted task_for_pid() - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_KERNEL_DEBUGGER": False, # 0x8 - Allow Kernel Debugger - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_APPLE_INTERNAL": False, # 0x10 - Set AppleInternal Features - Introduced in El Capitan # noqa: E241
# "CSR_ALLOW_DESTRUCTIVE_DTRACE": False, # 0x20 - Allow destructive DTrace - Deprecated # noqa: E241
"CSR_ALLOW_UNRESTRICTED_DTRACE": False, # 0x20 - Unrestricted DTrace usage - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_UNRESTRICTED_NVRAM": False, # 0x40 - Unrestricted NVRAM write - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_DEVICE_CONFIGURATION": False, # 0x80 - Allow custom DeviceTree (iOS) - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_ANY_RECOVERY_OS": False, # 0x100 - Skip BaseSystem Verification - Introduced in Sierra # noqa: E241
"CSR_ALLOW_UNAPPROVED_KEXTS": False, # 0x200 - Allow Unnotarized Kexts - Introduced in High Sierra # noqa: E241
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE": False, # 0x400 - Override Executable Policy - Introduced in Mojave # noqa: E241
"CSR_ALLOW_UNAUTHENTICATED_ROOT": False, # 0x800 - Allow Root Volume Mounting - Introduced in Big Sur # noqa: E241
}
root_patch_sip_mojave = [
# Variables required to root patch in Mojave and Catalina
"CSR_ALLOW_UNTRUSTED_KEXTS", # 0x1
"CSR_ALLOW_UNRESTRICTED_FS", # 0x2
"CSR_ALLOW_UNAPPROVED_KEXTS", # 0x200
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE", # 0x400
]
root_patch_sip_big_sur = [
# Variables required to root patch in Big Sur and Monterey
"CSR_ALLOW_UNTRUSTED_KEXTS", # 0x1
"CSR_ALLOW_UNRESTRICTED_FS", # 0x2
"CSR_ALLOW_UNAPPROVED_KEXTS", # 0x200
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE", # 0x400
"CSR_ALLOW_UNAUTHENTICATED_ROOT", # 0x800
]

1588
data/smbios_data.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
# Lists Root patches used by SysPatch.py
# Lists Root patches used by sys_patch.py
# Copyright (C) 2020-2021, Dhinak G, Mykola Grymalyuk
DeleteNvidiaAccel11 = [
"AMDRadeonX4000.kext",

View File

@@ -2,9 +2,9 @@
# Copyright (C) 2021 Mykola Grymalyuk
import plistlib
from pathlib import Path
from Resources import Constants
from resources import constants
app_path = Path.cwd() / Path ("OpenCore Patcher.app/Contents/Info.plist")
info = plistlib.load(Path(app_path).open("rb"))
info["CFBundleShortVersionString"] = Constants.Constants().patcher_version
info["CFBundleShortVersionString"] = constants.Constants().patcher_version
plistlib.dump(info, Path(app_path).open("wb"), sort_keys=True)

107
resources/arguments.py Normal file
View File

@@ -0,0 +1,107 @@
import sys
from resources import defaults, build, utilities, validation, sys_patch
from data import model_array
# Generic building args
class arguments:
def __init__(self):
self.args = utilities.check_cli_args()
def parse_arguments(self, settings):
if self.args.model:
if self.args.model:
print(f"- Using custom model: {self.args.model}")
settings.custom_model = self.args.model
defaults.generate_defaults.probe(settings.custom_model, False, settings)
elif settings.computer.real_model not in model_array.SupportedSMBIOS and settings.allow_oc_everywhere is False:
print(
"""Your model is not supported by this patcher for running unsupported OSes!"
If you plan to create the USB for another machine, please select the "Change Model" option in the menu."""
)
sys.exit(1)
else:
print(f"- Using detected model: {settings.computer.real_model}")
defaults.generate_defaults.probe(settings.custom_model, True, settings)
if self.args.disk:
print(f"- Install Disk set: {self.args.disk}")
settings.disk = self.args.disk
if self.args.validate:
validation.validate(settings)
if self.args.verbose:
print("- Set verbose configuration")
settings.verbose_debug = True
else:
settings.verbose_debug = False # Override Defaults detected
if self.args.debug_oc:
print("- Set OpenCore DEBUG configuration")
settings.opencore_debug = True
settings.opencore_build = "DEBUG"
if self.args.debug_kext:
print("- Set kext DEBUG configuration")
settings.kext_debug = True
if self.args.hide_picker:
print("- Set HidePicker configuration")
settings.showpicker = False
if self.args.disable_sip:
print("- Set Disable SIP configuration")
settings.sip_status = False
else:
settings.sip_status = True # Override Defaults detected
if self.args.disable_smb:
print("- Set Disable SecureBootModel configuration")
settings.secure_status = False
else:
settings.secure_status = True # Override Defaults detected
if self.args.vault:
print("- Set Vault configuration")
settings.vault = True
if self.args.firewire:
print("- Set FireWire Boot configuration")
settings.firewire_boot = True
if self.args.nvme:
print("- Set NVMe Boot configuration")
settings.nvme_boot = True
# if self.args.disable_amfi:
# print("- Set Disable AMFI configuration")
# settings.amfi_status = False
if self.args.wlan:
print("- Set Wake on WLAN configuration")
settings.enable_wake_on_wlan = True
if self.args.disable_tb:
print("- Set Disable Thunderbolt configuration")
settings.disable_tb = True
if self.args.force_surplus:
print("- Forcing SurPlus override configuration")
settings.force_surplus = True
if self.args.moderate_smbios:
print("- Set Moderate SMBIOS Patching configuration")
settings.serial_settings = "Moderate"
if self.args.smbios_spoof:
if self.args.smbios_spoof == "Minimal":
settings.serial_settings = "Minimal"
elif self.args.smbios_spoof == "Moderate":
settings.serial_settings = "Moderate"
elif self.args.smbios_spoof == "Advanced":
settings.serial_settings = "Advanced"
else:
print(f"- Unknown SMBIOS arg passed: {self.args.smbios_spoof}")
if self.args.support_all:
print("- Building for natively supported model")
settings.allow_oc_everywhere = True
settings.serial_settings = "None"
# Avoid running the root patcher if we're just building
if self.args.build:
build.BuildOpenCore(settings.custom_model or settings.computer.real_model, settings).build_opencore()
elif self.args.patch_sys_vol:
if self.args.moj_cat_accel:
print("- Set Mojave/Catalina root patch configuration")
settings.moj_cat_accel = True
print("- Set System Volume patching")
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings).start_patch()
elif self.args.unpatch_sys_vol:
print("- Set System Volume unpatching")
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings).start_unpatch()

View File

@@ -14,7 +14,8 @@ import ast
from pathlib import Path
from datetime import date
from Resources import Constants, ModelArray, Utilities, device_probe, SMBIOSData
from resources import constants, utilities, device_probe, generate_smbios
from data import smbios_data, bluetooth_data, cpu_data, os_data, model_array
def rmtree_handler(func, path, exc_info):
@@ -27,58 +28,10 @@ class BuildOpenCore:
def __init__(self, model, versions):
self.model = model
self.config = None
self.constants: Constants.Constants = versions
self.constants: constants.Constants = versions
self.computer = self.constants.computer
self.gfx0_path = None
def smbios_set(self, model):
if model in ModelArray.MacBookAir_11:
return "MacBookAir7,1"
elif model in ModelArray.MacBookAir_13:
return "MacBookAir7,2"
elif model in ModelArray.MacBook_12:
return "MacBook9,1"
elif model in ModelArray.MacBookPro_13:
return "MacBookPro12,1"
elif model in ModelArray.MacBookPro_15_iGPU:
return "MacBookPro11,4"
elif model in ModelArray.MacBookPro_15_dGPU:
return "MacBookPro11,5"
elif model in ModelArray.Macmini:
return "Macmini7,1"
elif model in ModelArray.iMac_iGPUless:
return "iMacPro1,1"
elif model in ModelArray.iMac_dGPU:
# Check for upgraded GPUs on iMacs
if self.constants.drm_support is True:
return "iMacPro1,1"
else:
return "iMac17,1"
elif model in ModelArray.iMac_iGPU:
return "iMac16,1"
elif model in ModelArray.MacPro:
return "MacPro7,1"
else:
return model
def patch_firmware_feature(self):
# Adjust FirmwareFeature to support everything macOS requires
# APFS Bit (19/20): 10.13+ (OSInstall)
# Large BaseSystem Bit (35): 12.0 B7+ (patchd)
# https://github.com/acidanthera/OpenCorePkg/tree/2f76673546ac3e32d2e2d528095fddcd66ad6a23/Include/Apple/IndustryStandard/AppleFeatures.h
if not self.constants.custom_model:
firmwarefeature = Utilities.get_rom("firmware-features")
if not firmwarefeature:
print("- Failed to find FirmwareFeatures, falling back on defaults")
firmwarefeature = int(SMBIOSData.FirmwareFeatures[self.model], 16)
else:
firmwarefeature = int(SMBIOSData.FirmwareFeatures[self.model], 16)
firmwarefeature = Utilities.enable_apfs(firmwarefeature)
firmwarefeature = Utilities.enable_apfs_extended(firmwarefeature)
firmwarefeature = Utilities.enable_large_basesystem(firmwarefeature)
return firmwarefeature
def disk_type(self):
drive_host_info = plistlib.loads(subprocess.run(f"diskutil info -plist {self.constants.disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
sd_type = drive_host_info["MediaName"]
@@ -102,7 +55,7 @@ class BuildOpenCore:
shutil.copy(self.constants.icon_path_internal, self.constants.opencore_release_folder)
def build_efi(self):
Utilities.cls()
utilities.cls()
if not self.constants.custom_model:
print(f"Building Configuration on model: {self.model}")
else:
@@ -146,14 +99,14 @@ class BuildOpenCore:
# Essential kexts
("Lilu.kext", self.constants.lilu_version, self.constants.lilu_path, lambda: True),
("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path, lambda: self.constants.allow_oc_everywhere is False),
("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path, lambda: self.model in ModelArray.MacPro),
("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path, lambda: self.model in model_array.MacPro),
# Modded RestrictEvents with displaypolicyd blocked to fix dGPU switching
("RestrictEvents.kext", self.constants.restrictevents_mbp_version, self.constants.restrictevents_mbp_path, lambda: self.model in ["MacBookPro6,1", "MacBookPro6,2", "MacBookPro9,1"]),
("SMC-Spoof.kext", self.constants.smcspoof_version, self.constants.smcspoof_path, lambda: self.constants.allow_oc_everywhere is False),
# CPU patches
("AppleMCEReporterDisabler.kext", self.constants.mce_version, self.constants.mce_path, lambda: self.model in ModelArray.DualSocket),
("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path, lambda: self.model in ModelArray.SSEEmulator),
("telemetrap.kext", self.constants.telemetrap_version, self.constants.telemetrap_path, lambda: self.model in ModelArray.MissingSSE42),
("AppleMCEReporterDisabler.kext", self.constants.mce_version, self.constants.mce_path, lambda: self.model.startswith("MacPro") or self.model.startswith("Xserve")),
("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value),
("telemetrap.kext", self.constants.telemetrap_version, self.constants.telemetrap_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value),
(
"CPUFriend.kext",
self.constants.cpufriend_version,
@@ -161,17 +114,15 @@ class BuildOpenCore:
lambda: self.model not in ["iMac7,1", "Xserve2,1", "Dortania1,1"] and self.constants.allow_oc_everywhere is False and self.constants.disallow_cpufriend is False,
),
# Ethernet patches
("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path, lambda: self.model in ModelArray.EthernetNvidia),
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: self.model in ModelArray.EthernetMarvell),
("CatalinaBCM5701Ethernet.kext", self.constants.bcm570_version, self.constants.bcm570_path, lambda: self.model in ModelArray.EthernetBroadcom),
("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Nvidia"),
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Marvell"),
# Legacy audio
("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path, lambda: (self.model in ModelArray.LegacyAudio or self.model in ModelArray.MacPro) and self.constants.set_alc_usage is True),
("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path, lambda: (self.model in model_array.LegacyAudio or self.model in model_array.MacPro) and self.constants.set_alc_usage is True),
# IDE patch
("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in ModelArray.IDEPatch),
("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in model_array.IDEPatch),
# Misc
("FeatureUnlock.kext", self.constants.featureunlock_version, self.constants.featureunlock_path, lambda: self.model in ModelArray.FeatureUnlockSupport),
("FeatureUnlock.kext", self.constants.featureunlock_version, self.constants.featureunlock_path, lambda: smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.kaby_lake.value),
("DebugEnhancer.kext", self.constants.debugenhancer_version, self.constants.debugenhancer_path, lambda: self.constants.kext_debug is True),
# ("latebloom.kext", self.constants.latebloom_version, self.constants.latebloom_path, lambda: self.model in ModelArray.PCIRaceCondition),
("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path, lambda: self.model in ["MacBook4,1", "MacBook5,2"]),
]:
self.enable_kext(name, version, path, check)
@@ -179,14 +130,23 @@ class BuildOpenCore:
if self.constants.allow_oc_everywhere is False:
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleSMC")["Enabled"] = True
if self.smbios_set(self.model) in ModelArray.T2_Models or self.constants.override_smbios in ModelArray.T2_Models:
# Monterey T2 SMBIOS don't get OS updates without a T2 SBM
# Forces VMM patch instead
if self.get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
self.enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
# Ethernet Patch Sets
if smbios_data.smbios_dictionary[self.model]["Ethernet Chipset"] == "Broadcom":
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.cpu_data.ivy_bridge.value:
# Required due to Big Sur's BCM5701 requiring VT-x support
# Applicable for pre-Ivy Bridge models
self.enable_kext("CatalinaBCM5701Ethernet.kext", self.constants.bcm570_version, self.constants.bcm570_path)
if self.constants.allow_oc_everywhere is False:
if (smbios_data.smbios_dictionary[generate_smbios.set_smbios_model_spoof(self.model) or self.constants.override_smbios]["SecureBootModel"]) != None:
# Monterey T2 SMBIOS don't get OS updates without a T2 SBM
# Forces VMM patch instead
if self.get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
self.enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
if self.model in ModelArray.PCIRaceCondition:
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge.value:
# Ref: https://github.com/reenigneorcim/SurPlus
# Enable for all systems missing RDRAND support
print("- Adding SurPlus Patch for Race Condition")
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Comment", "SurPlus v1 - PART 1 of 2 - Patch read_erandom (inlined in _early_random)")["Enabled"] = True
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Comment", "SurPlus v1 - PART 2 of 2 - Patch register_and_init_prng")["Enabled"] = True
@@ -197,7 +157,7 @@ class BuildOpenCore:
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Comment", "SurPlus v1 - PART 1 of 2 - Patch read_erandom (inlined in _early_random)")["MaxKernel"] = ""
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Comment", "SurPlus v1 - PART 2 of 2 - Patch register_and_init_prng")["MaxKernel"] = ""
if not self.constants.custom_model and (self.constants.allow_oc_everywhere is True or self.model in ModelArray.MacPro):
if not self.constants.custom_model and (self.constants.allow_oc_everywhere is True or self.model in model_array.MacPro):
# Use Innie's same logic:
# https://github.com/cdf/Innie/blob/v1.3.0/Innie/Innie.cpp#L90-L97
for i, controller in enumerate(self.computer.storage):
@@ -214,8 +174,8 @@ class BuildOpenCore:
if not self.constants.custom_model:
nvme_devices = [i for i in self.computer.storage if isinstance(i, device_probe.NVMeController)]
for i, controller in enumerate(nvme_devices):
print(f"- Found 3rd Party NVMe SSD ({i + 1}): {Utilities.friendly_hex(controller.vendor_id)}:{Utilities.friendly_hex(controller.device_id)}")
self.config["#Revision"][f"Hardware-NVMe-{i}"] = f"{Utilities.friendly_hex(controller.vendor_id)}:{Utilities.friendly_hex(controller.device_id)}"
print(f"- Found 3rd Party NVMe SSD ({i + 1}): {utilities.friendly_hex(controller.vendor_id)}:{utilities.friendly_hex(controller.device_id)}")
self.config["#Revision"][f"Hardware-NVMe-{i}"] = f"{utilities.friendly_hex(controller.vendor_id)}:{utilities.friendly_hex(controller.device_id)}"
# Disable Bit 0 (L0s), enable Bit 1 (L1)
nvme_aspm = (controller.aspm & (~0b11)) | 0b10
@@ -242,21 +202,24 @@ class BuildOpenCore:
arpt_path = self.computer.wifi.pci_path
print(f"- Found ARPT device at {arpt_path}")
else:
if self.model in ModelArray.nvidiaHDEF:
try:
smbios_data.smbios_dictionary[self.model]["nForce Chipset"]
# Nvidia chipsets all have the same path to ARPT
arpt_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
elif self.model in ("iMac7,1", "iMac8,1", "MacPro3,1", "MacBookPro4,1"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
elif self.model in ("iMac13,1", "iMac13,2"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
elif self.model in ("MacPro4,1", "MacPro5,1"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
else:
# Assumes we have a laptop with Intel chipset
# iMac11,x-12,x also apply
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
except KeyError:
if self.model in ("iMac7,1", "iMac8,1", "MacPro3,1", "MacBookPro4,1"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
elif self.model in ("iMac13,1", "iMac13,2"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
elif self.model in ("MacPro4,1", "MacPro5,1"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
else:
# Assumes we have a laptop with Intel chipset
# iMac11,x-12,x also apply
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
print(f"- Using known DevicePath {arpt_path}")
# self.config["DeviceProperties"]["Add"][arpt_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba"}
if not self.constants.custom_model and self.computer.wifi and self.constants.validate is False and self.computer.wifi.country_code:
print(f"- Applying fake ID for WiFi, setting Country Code: {self.computer.wifi.country_code}")
self.config["DeviceProperties"]["Add"][arpt_path] = {"brcmfx-country": self.computer.wifi.country_code}
@@ -268,8 +231,8 @@ class BuildOpenCore:
# TODO: -a is not supported in Lion and older, need to add proper fix
if self.constants.detected_os > self.constants.lion and not self.constants.custom_model:
if self.computer.wifi:
print(f"- Found Wireless Device {Utilities.friendly_hex(self.computer.wifi.vendor_id)}:{Utilities.friendly_hex(self.computer.wifi.device_id)}")
self.config["#Revision"]["Hardware-Wifi"] = f"{Utilities.friendly_hex(self.computer.wifi.vendor_id)}:{Utilities.friendly_hex(self.computer.wifi.device_id)}"
print(f"- Found Wireless Device {utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}")
self.config["#Revision"]["Hardware-Wifi"] = f"{utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}"
else:
print("- Unable to run Wireless hardware detection")
@@ -303,21 +266,25 @@ class BuildOpenCore:
self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
else:
if self.model in ModelArray.WifiBCM94331:
if smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm4360:
print("- Enabling BCM943224 and BCM94331 Networking Support")
wifi_fake_id(self)
elif self.model in ModelArray.WifiBCM94322:
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm4331:
print("- Enabling BCM94328 Networking Support")
self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
elif self.model in ModelArray.WifiBCM94328:
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm43224:
print("- Enabling BCM94328 Networking Support")
self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
elif self.model in ModelArray.WifiAtheros:
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Atheros.Chipsets.AirPortAtheros40:
print("- Enabling Atheros Networking Support")
self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
else:
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirportBrcmNIC:
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
# print(f"- Setting Wireless Card's Country Code: {self.computer.wifi.country_code}")
# self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" brcmfx-country={self.computer.wifi.country_code}"
@@ -334,18 +301,20 @@ class BuildOpenCore:
self.get_kext_by_bundle_path("CPUFriendDataProvider.kext")["Enabled"] = True
# HID patches
if self.model in ModelArray.LegacyHID:
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value:
print("- Adding IOHIDFamily patch")
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.iokit.IOHIDFamily")["Enabled"] = True
# SSDT patches
if self.model in ModelArray.pciSSDT:
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] == cpu_data.cpu_data.nehalem.value and not (self.model.startswith("MacPro") or self.model.startswith("Xserve")):
# Applicable for consumer Nehalem
print("- Adding SSDT-CPBG.aml")
self.get_item_by_kv(self.config["ACPI"]["Add"], "Path", "SSDT-CPBG.aml")["Enabled"] = True
shutil.copy(self.constants.pci_ssdt_path, self.constants.acpi_path)
if self.model in ModelArray.windows_audio:
if cpu_data.cpu_data.sandy_bridge <= smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.ivy_bridge.value:
# Based on: https://egpu.io/forums/pc-setup/fix-dsdt-override-to-correct-error-12/
# Applicable for Sandy and Ivy Bridge Macs
print("- Enabling Windows 10 UEFI Audio support")
self.get_item_by_kv(self.config["ACPI"]["Add"], "Path", "SSDT-PCI.aml")["Enabled"] = True
self.get_item_by_kv(self.config["ACPI"]["Patch"], "Comment", "BUF0 to BUF1")["Enabled"] = True
@@ -358,7 +327,7 @@ class BuildOpenCore:
usb_map_path.exists()
and self.constants.allow_oc_everywhere is False
and self.model not in ["Xserve2,1", "Dortania1,1"]
and (self.model in ModelArray.Missing_USB_Map or self.constants.serial_settings in ["Moderate", "Advanced"])
and (self.model in model_array.Missing_USB_Map or self.constants.serial_settings in ["Moderate", "Advanced"])
):
print("- Adding USB-Map.kext")
Path(self.constants.map_kext_folder).mkdir()
@@ -375,8 +344,10 @@ class BuildOpenCore:
Path(self.constants.amc_contents_folder).mkdir()
shutil.copy(amc_map_path, self.constants.amc_contents_folder)
self.get_kext_by_bundle_path("AMC-Override.kext")["Enabled"] = True
elif self.model == "MacBookPro10,1":
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"agdpmod": "vit9696"}
if self.model not in ModelArray.NoAGPMSupport:
if self.model not in model_array.NoAGPMSupport:
print("- Adding AppleGraphicsPowerManagement Override")
agpm_map_path = Path(self.constants.plist_folder_path) / Path("AppleGraphicsPowerManagement/Info.plist")
Path(self.constants.agpm_kext_folder).mkdir()
@@ -384,7 +355,7 @@ class BuildOpenCore:
shutil.copy(agpm_map_path, self.constants.agpm_contents_folder)
self.get_kext_by_bundle_path("AGPM-Override.kext")["Enabled"] = True
if self.model in ModelArray.AGDPSupport:
if self.model in model_array.AGDPSupport:
print("- Adding AppleGraphicsDevicePolicy Override")
agdp_map_path = Path(self.constants.plist_folder_path) / Path("AppleGraphicsDevicePolicy/Info.plist")
Path(self.constants.agdp_kext_folder).mkdir()
@@ -393,7 +364,7 @@ class BuildOpenCore:
self.get_kext_by_bundle_path("AGDP-Override.kext")["Enabled"] = True
# AGPM Patch
if self.model in ModelArray.DualGPUPatch:
if self.model in model_array.DualGPUPatch:
print("- Adding dual GPU patch")
if not self.constants.custom_model and self.computer.dgpu and self.computer.dgpu.pci_path:
self.gfx0_path = self.computer.dgpu.pci_path
@@ -403,7 +374,7 @@ class BuildOpenCore:
print("- Failed to find GFX0 Device path, falling back on known logic")
self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"
if self.model in ModelArray.IntelNvidiaDRM and self.constants.drm_support is True:
if self.model in model_array.IntelNvidiaDRM and self.constants.drm_support is True:
print("- Prioritizing DRM support over Intel QuickSync")
self.config["DeviceProperties"]["Add"][self.gfx0_path] = {"agdpmod": "vit9696", "shikigva": 256}
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {
@@ -414,39 +385,51 @@ class BuildOpenCore:
else:
self.config["DeviceProperties"]["Add"][self.gfx0_path] = {"agdpmod": "vit9696"}
if self.model in ["iMac13,1", "iMac13,2", "iMac13,3"]:
if not self.constants.custom_model and self.computer.dgpu:
if self.constants.allow_ivy_igpu is False:
print("- Disabling iGPU to fix sleep support in macOS 12")
self.config["DeviceProperties"]["Add"][self.gfx0_path] = {"agdpmod": "vit9696", "shikigva": 256}
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {
"name": binascii.unhexlify("23646973706C6179"),
"IOName": "#display",
"class-code": binascii.unhexlify("FFFFFFFF"),
}
else:
print("- Enabling iGPU upon request")
# Audio Patch
if self.model in ModelArray.LegacyAudio:
print("- Adding audio properties")
hdef_path = "PciRoot(0x0)/Pci(0x8,0x0)" if self.model in ModelArray.nvidiaHDEF else "PciRoot(0x0)/Pci(0x1b,0x0)"
# In AppleALC, MacPro3,1's original layout is already in use, forcing layout 13 instead
if self.model == "MacPro3,1":
self.config["DeviceProperties"]["Add"][hdef_path] = {
"apple-layout-id": 90,
"use-apple-layout-id": 1,
"alc-layout-id": 13,
}
else:
self.config["DeviceProperties"]["Add"][hdef_path] = {
"apple-layout-id": 90,
"use-apple-layout-id": 1,
"use-layout-id": 1,
}
if self.constants.set_alc_usage is True:
if smbios_data.smbios_dictionary[self.model]["Max OS Supported"] <= os_data.os_data.high_sierra:
# Models dropped in Mojave also lost Audio support
# Xserves and MacPro4,1 are exceptions
# iMac7,1 and iMac8,1 require AppleHDA/IOAudioFamily downgrade
if not (self.model.startswith("Xserve") or self.model in ["MacPro4,1", "iMac7,1", "iMac8,1"]):
try:
smbios_data.smbios_dictionary[self.model]["nForce Chipset"]
hdef_path = "PciRoot(0x0)/Pci(0x8,0x0)"
except KeyError:
hdef_path = "PciRoot(0x0)/Pci(0x1b,0x0)"
# In AppleALC, MacPro3,1's original layout is already in use, forcing layout 13 instead
if self.model == "MacPro3,1":
self.config["DeviceProperties"]["Add"][hdef_path] = {
"apple-layout-id": 90,
"use-apple-layout-id": 1,
"alc-layout-id": 13,
}
else:
self.config["DeviceProperties"]["Add"][hdef_path] = {
"apple-layout-id": 90,
"use-apple-layout-id": 1,
"use-layout-id": 1,
}
self.enable_kext("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path)
elif self.model.startswith("MacPro") or self.model.startswith("Xserve"):
# Used to enable Audio support for non-standard dGPUs
self.enable_kext("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path)
# Enable FireWire Boot Support
if self.constants.firewire_boot is True and self.model not in ModelArray.NoFireWireSupport:
def check_firewire(model):
# MacBooks never supported FireWire
# Pre-Thunderbolt MacBook Airs as well
if model.startswith("MacBook"):
return False
elif model.startswith("MacBookAir"):
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.cpu_data.sandy_bridge.value:
return False
else:
return True
if self.constants.firewire_boot is True and check_firewire(self.model) is True:
# Enable FireWire Boot Support
# Applicable for both native FireWire and Thunderbolt to FireWire adapters
print("- Enabling FireWire Boot Support")
self.enable_kext("IOFireWireFamily.kext", self.constants.fw_kext, self.constants.fw_family_path)
self.enable_kext("IOFireWireSBP2.kext", self.constants.fw_kext, self.constants.fw_sbp2_path)
@@ -522,7 +505,8 @@ class BuildOpenCore:
"class-code": binascii.unhexlify("FFFFFFFF"),
}
elif self.model == "iMac10,1":
self.enable_kext("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path)
if self.get_kext_by_bundle_path("AAAMouSSE.kext")["Enabled"] is False:
self.enable_kext("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path)
# Check GPU Vendor
if self.constants.metal_build is True:
@@ -534,8 +518,8 @@ class BuildOpenCore:
nvidia_patch(self, self.gfx0_path)
else:
print("- Failed to find vendor")
elif not self.constants.custom_model and self.model in ModelArray.LegacyGPU and self.computer.dgpu:
print(f"- Detected dGPU: {Utilities.friendly_hex(self.computer.dgpu.vendor_id)}:{Utilities.friendly_hex(self.computer.dgpu.device_id)}")
elif not self.constants.custom_model and self.model in model_array.LegacyGPU and self.computer.dgpu:
print(f"- Detected dGPU: {utilities.friendly_hex(self.computer.dgpu.vendor_id)}:{utilities.friendly_hex(self.computer.dgpu.device_id)}")
if self.computer.dgpu.arch in [
device_probe.AMD.Archs.Legacy_GCN,
device_probe.AMD.Archs.Polaris,
@@ -547,11 +531,11 @@ class BuildOpenCore:
elif self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
backlight_path_detection(self)
nvidia_patch(self, self.gfx0_path)
if self.model in ModelArray.MacPro:
if self.model in model_array.MacPro:
if not self.constants.custom_model:
for i, device in enumerate(self.computer.gpus):
print(f"- Found dGPU ({i + 1}): {Utilities.friendly_hex(device.vendor_id)}:{Utilities.friendly_hex(device.device_id)}")
self.config["#Revision"][f"Hardware-MacPro-dGPU-{i + 1}"] = f"{Utilities.friendly_hex(device.vendor_id)}:{Utilities.friendly_hex(device.device_id)}"
print(f"- Found dGPU ({i + 1}): {utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}")
self.config["#Revision"][f"Hardware-MacPro-dGPU-{i + 1}"] = f"{utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}"
if device.pci_path and device.acpi_path:
print(f"- Found dGPU ({i + 1}) at {device.pci_path}")
@@ -588,7 +572,7 @@ class BuildOpenCore:
print("- Adding Mac Pro, Xserve DRM patches")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " shikigva=128 unfairgva=1 -wegtree"
if self.constants.disable_thunderbolt is True and self.model in ["MacBookPro11,1", "MacBookPro11,2", "MacBookPro11,3", "MacBookPro11,4", "MacBookPro11,5"]:
if self.constants.disable_tb is True and self.model in ["MacBookPro11,1", "MacBookPro11,2", "MacBookPro11,3", "MacBookPro11,4", "MacBookPro11,5"]:
print("- Disabling 2013-2014 laptop Thunderbolt Controller")
if self.model in ["MacBookPro11,3", "MacBookPro11,5"]:
# 15" dGPU models: IOACPIPlane:/_SB/PCI0@0/PEG1@10001/UPSB@0/DSB0@0/NHI0@0
@@ -605,32 +589,16 @@ class BuildOpenCore:
print("- Fixing Legacy Bluetooth for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
self.enable_kext("Bluetooth-Spoof.kext", self.constants.btspoof_version, self.constants.btspoof_path)
elif self.computer.bluetooth_chipset == "BRCM20702 Hub" and self.model in ModelArray.Bluetooth_BRCM20702_v1:
elif self.computer.bluetooth_chipset == "BRCM20702 Hub" and smbios_data.smbios_dictionary[self.model]["Bluetooth Model"] == bluetooth_data.bluetooth_data.BRCM20702_v1.value:
print("- Fixing Legacy Bluetooth for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
elif self.model in ModelArray.Bluetooth_BRCM2070 or self.model in ModelArray.Bluetooth_BRCM2046 or self.model in ModelArray.Bluetooth_BRCM20702_v1:
# smbios_data.smbios_dictionary[self.model]["Bluetooth Model"]
elif smbios_data.smbios_dictionary[self.model]["Bluetooth Model"] <= bluetooth_data.bluetooth_data.BRCM20702_v1.value:
print("- Fixing Legacy Bluetooth for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
if self.model in ModelArray.Bluetooth_BRCM2070 or self.model in ModelArray.Bluetooth_BRCM2046:
if smbios_data.smbios_dictionary[self.model]["Bluetooth Model"] <= bluetooth_data.bluetooth_data.BRCM2070.value:
self.enable_kext("Bluetooth-Spoof.kext", self.constants.btspoof_version, self.constants.btspoof_path)
# Add XhciDxe if firmware doesn't have XHCI controller support and XCHI controller detected
# TODO: Fix XhciDxe to work on pre UEFI 2.0 Macs
# Ref: https://github.com/acidanthera/bugtracker/issues/1663
# if self.model not in ModelArray.XhciSupport and not self.constants.custom_model:
# devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
# try:
# devices = [i for i in devices if i["class-code"] == binascii.unhexlify(self.constants.classcode_xhci)]
# vendor_id = Utilities.hexswap(binascii.hexlify(devices[0]["vendor-id"]).decode()[:4])
# device_id = Utilities.hexswap(binascii.hexlify(devices[0]["device-id"]).decode()[:4])
# print("- Found XHCI Controller, adding Boot Support")
# shutil.copy(self.constants.xhci_driver_path, self.constants.drivers_path)
# self.get_efi_binary_by_path("XhciDxe.efi", "UEFI", "Drivers")["Enabled"] = True
# except ValueError:
# print("- No XHCI Controller Found (V)")
# except IndexError:
# print("- No XHCI Controller Found (I)")
if self.constants.nvme_boot is True:
print("- Enabling NVMe boot support")
shutil.copy(self.constants.nvme_driver_path, self.constants.drivers_path)
@@ -644,18 +612,22 @@ class BuildOpenCore:
self.get_efi_binary_by_path("OpenRuntime.efi", "UEFI", "Drivers")["Enabled"] = True
self.get_efi_binary_by_path("OpenLinuxBoot.efi", "UEFI", "Drivers")["Enabled"] = True
# Exfat check
if self.model in ModelArray.NoExFat:
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.cpu_data.sandy_bridge.value:
# Sandy Bridge and newer Macs natively support ExFat
print("- Adding ExFatDxeLegacy.efi")
shutil.copy(self.constants.exfat_legacy_driver_path, self.constants.drivers_path)
self.get_efi_binary_by_path("ExFatDxeLegacy.efi", "UEFI", "Drivers")["Enabled"] = True
# Add UGA to GOP layer
if self.model in ModelArray.UGAtoGOP:
try:
smbios_data.smbios_dictionary[self.model]["UGA Graphics"]
print("- Adding UGA to GOP Patch")
self.config["UEFI"]["Output"]["GopPassThrough"] = "Apple"
except KeyError:
pass
# ThirdPartDrives Check
if self.model in ModelArray.SATAPatch and self.constants.allow_oc_everywhere is False:
if self.model in model_array.SATAPatch and self.constants.allow_oc_everywhere is False:
print("- Adding SATA Hibernation Patch")
self.config["Kernel"]["Quirks"]["ThirdPartyDrives"] = True
@@ -677,7 +649,7 @@ class BuildOpenCore:
print("- Enabling ShowPicker")
self.config["Misc"]["Boot"]["ShowPicker"] = True
else:
print("- Hiding picker and enabling PollAppleHotKeys")
print("- Hiding OpenCore picker")
self.config["Misc"]["Boot"]["ShowPicker"] = False
if self.constants.vault is True:
print("- Setting Vault configuration")
@@ -721,28 +693,32 @@ class BuildOpenCore:
if self.constants.validate is False:
print("- Adding bootmgfw.efi BlessOverride")
self.config["Misc"]["BlessOverride"] += ["\\EFI\\Microsoft\\Boot\\bootmgfw.efi"]
if self.model in ModelArray.dGPU_switch and self.constants.dGPU_switch is True:
print("- Allowing GMUX switching in Windows")
try:
if self.constants.dGPU_switch is True:
smbios_data.smbios_dictionary[self.model]["Switchable GPUs"]
print("- Allowing GMUX switching in Windows")
self.config["Booter"]["Quirks"]["SignalAppleOS"] = True
except KeyError:
pass
if self.constants.allow_fv_root is True:
# apfs.kext has an undocumented boot-arg that allows FileVault usage on broken APFS seals (-arv_allow_fv)
# This is however hidden behind kern.development, thus we patch _apfs_filevault_allowed to always return true
# Note this function was added in 11.3 (20E232, 20.4), older builds do not support this (ie. 11.2.3)
print("- Allowing FileVault on Root Patched systems")
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.filesystems.apfs")["Enabled"] = True
# Lets us check in SysPatch.py if config supports FileVault
# Lets us check in sys_patch.py if config supports FileVault
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Settings"] += " -allow_fv"
def set_smbios(self):
spoofed_model = self.model
if self.constants.override_smbios == "Default":
print("- Setting macOS Monterey Supported SMBIOS")
spoofed_model = self.smbios_set(self.model)
spoofed_model = generate_smbios.set_smbios_model_spoof(self.model)
else:
spoofed_model = self.constants.override_smbios
print(f"- Using Model ID: {spoofed_model}")
try:
spoofed_board = self.constants.board_id[spoofed_model]
spoofed_board = smbios_data.smbios_dictionary[spoofed_model]["Board ID"]
print(f"- Using Board ID: {spoofed_board}")
except KeyError:
spoofed_board = ""
@@ -754,10 +730,11 @@ class BuildOpenCore:
# Setup menu
def minimal_serial_patch(self):
# Generate Firmware Features
fw_feature = self.patch_firmware_feature()
fw_feature = generate_smbios.generate_fw_features(self.model, self.constants.custom_model)
# fw_feature = self.patch_firmware_feature()
fw_feature = hex(fw_feature).lstrip("0x").rstrip("L").strip()
print(f"- Setting Firmware Feature: {fw_feature}")
fw_feature = Utilities.string_to_hex(fw_feature)
fw_feature = utilities.string_to_hex(fw_feature)
# FirmwareFeatures
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature
@@ -834,7 +811,7 @@ class BuildOpenCore:
if (
self.constants.allow_oc_everywhere is False
and self.model not in ["Xserve2,1", "Dortania1,1"]
and (self.model in ModelArray.Missing_USB_Map or self.constants.serial_settings in ["Moderate", "Advanced"])
and (self.model in model_array.Missing_USB_Map or self.constants.serial_settings in ["Moderate", "Advanced"])
):
new_map_ls = Path(self.constants.map_contents_folder) / Path("Info.plist")
map_config = plistlib.load(Path(new_map_ls).open("rb"))
@@ -874,7 +851,7 @@ class BuildOpenCore:
if not entry.startswith(self.spoofed_board):
amc_config["IOKitPersonalities"]["AppleMuxControl"]["ConfigMap"].pop(entry)
plistlib.dump(amc_config, Path(new_amc_ls).open("wb"), sort_keys=True)
if self.model not in ModelArray.NoAGPMSupport:
if self.model not in model_array.NoAGPMSupport:
new_agpm_ls = Path(self.constants.agpm_contents_folder) / Path("Info.plist")
agpm_config = plistlib.load(Path(new_agpm_ls).open("rb"))
agpm_config["IOKitPersonalities"]["AGPM"]["Machines"][self.spoofed_board] = agpm_config["IOKitPersonalities"]["AGPM"]["Machines"].pop(self.model)
@@ -891,7 +868,7 @@ class BuildOpenCore:
agpm_config["IOKitPersonalities"]["AGPM"]["Machines"].pop(entry)
plistlib.dump(agpm_config, Path(new_agpm_ls).open("wb"), sort_keys=True)
if self.model in ModelArray.AGDPSupport:
if self.model in model_array.AGDPSupport:
new_agdp_ls = Path(self.constants.agdp_contents_folder) / Path("Info.plist")
agdp_config = plistlib.load(Path(new_agdp_ls).open("rb"))
agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"][self.spoofed_board] = agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"].pop(
@@ -984,7 +961,8 @@ class BuildOpenCore:
def build_opencore(self):
self.build_efi()
self.set_smbios()
if self.constants.allow_oc_everywhere is False:
self.set_smbios()
self.cleanup()
self.sign_files()
print("")
@@ -995,11 +973,11 @@ class BuildOpenCore:
input("Press [Enter] to go back.\n")
def copy_efi(self):
Utilities.cls()
Utilities.header(["Installing OpenCore to Drive"])
utilities.cls()
utilities.header(["Installing OpenCore to Drive"])
if not self.constants.opencore_release_folder.exists():
Utilities.TUIOnlyPrint(
utilities.TUIOnlyPrint(
["Installing OpenCore to Drive"],
"Press [Enter] to go back.\n",
[
@@ -1035,7 +1013,7 @@ Please build OpenCore first!"""
# Avoid crashing with CDs installed
continue
# TODO: Advanced mode
menu = Utilities.TUIMenu(
menu = utilities.TUIMenu(
["Select Disk"],
"Please select the disk you would like to install OpenCore to: ",
in_between=["Missing disks? Ensure they have an EFI or FAT32 partition."],
@@ -1045,7 +1023,7 @@ Please build OpenCore first!"""
for disk in all_disks:
if not any(all_disks[disk]["partitions"][partition]["fs"] in ("msdos", "EFI") for partition in all_disks[disk]["partitions"]):
continue
menu.add_menu_option(f"{disk}: {all_disks[disk]['name']} ({Utilities.human_fmt(all_disks[disk]['size'])})", key=disk[4:])
menu.add_menu_option(f"{disk}: {all_disks[disk]['name']} ({utilities.human_fmt(all_disks[disk]['size'])})", key=disk[4:])
response = menu.start()
@@ -1055,7 +1033,7 @@ Please build OpenCore first!"""
disk_identifier = "disk" + response
selected_disk = all_disks[disk_identifier]
menu = Utilities.TUIMenu(
menu = utilities.TUIMenu(
["Select Partition"],
"Please select the partition you would like to install OpenCore to: ",
return_number_instead_of_direct_call=True,
@@ -1065,7 +1043,7 @@ Please build OpenCore first!"""
for partition in selected_disk["partitions"]:
if selected_disk["partitions"][partition]["fs"] not in ("msdos", "EFI"):
continue
text = f"{partition}: {selected_disk['partitions'][partition]['name']} ({Utilities.human_fmt(selected_disk['partitions'][partition]['size'])})"
text = f"{partition}: {selected_disk['partitions'][partition]['name']} ({utilities.human_fmt(selected_disk['partitions'][partition]['size'])})"
if selected_disk["partitions"][partition]["type"] == "EFI" or (
selected_disk["partitions"][partition]["type"] == "Microsoft Basic Data" and selected_disk["partitions"][partition]["size"] < 1024 * 1024 * 512
): # 512 megabytes:
@@ -1097,7 +1075,7 @@ Please build OpenCore first!"""
# cancelled prompt
return
else:
Utilities.TUIOnlyPrint(
utilities.TUIOnlyPrint(
["Copying OpenCore"], "Press [Enter] to go back.\n", ["An error occurred!"] + result.stderr.decode().split("\n") + ["", "Please report this to the devs at GitHub."]
).start()
return
@@ -1112,8 +1090,8 @@ Please build OpenCore first!"""
ssd_type = False
mount_path = Path(partition_info["MountPoint"])
disk_type = partition_info["BusProtocol"]
Utilities.cls()
Utilities.header(["Copying OpenCore"])
utilities.cls()
utilities.header(["Copying OpenCore"])
if mount_path.exists():
if (mount_path / Path("EFI/Microsoft")).exists():
@@ -1170,4 +1148,4 @@ Please build OpenCore first!"""
print("\nPress [Enter] to continue.\n")
input()
else:
Utilities.TUIOnlyPrint(["Copying OpenCore"], "Press [Enter] to go back.\n", ["EFI failed to mount!", "Please report this to the devs at GitHub."]).start()
utilities.TUIOnlyPrint(["Copying OpenCore"], "Press [Enter] to go back.\n", ["EFI failed to mount!", "Please report this to the devs at GitHub."]).start()

View File

@@ -3,17 +3,18 @@
from __future__ import print_function
import subprocess
from Resources import Constants, Utilities
from resources import constants, utilities, defaults, sys_patch
from data import cpu_data, smbios_data, model_array
class MenuOptions:
def __init__(self, model, versions):
self.model = model
self.constants: Constants.Constants = versions
self.constants: constants.Constants() = versions
def change_verbose(self):
Utilities.cls()
Utilities.header(["Set Verbose mode"])
utilities.cls()
utilities.header(["Set Verbose mode"])
change_menu = input("Enable Verbose mode(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.verbose_debug = True
@@ -25,8 +26,8 @@ class MenuOptions:
self.change_verbose()
def change_oc(self):
Utilities.cls()
Utilities.header(["Set OpenCore DEBUG mode"])
utilities.cls()
utilities.header(["Set OpenCore DEBUG mode"])
change_menu = input("Enable OpenCore DEBUG mode(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.opencore_debug = True
@@ -40,8 +41,8 @@ class MenuOptions:
self.change_oc()
def change_kext(self):
Utilities.cls()
Utilities.header(["Set Kext DEBUG mode"])
utilities.cls()
utilities.header(["Set Kext DEBUG mode"])
change_menu = input("Enable Kext DEBUG mode(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.kext_debug = True
@@ -53,8 +54,8 @@ class MenuOptions:
self.change_kext()
def change_metal(self):
Utilities.cls()
Utilities.header(["Assume Metal GPU Always in iMac"])
utilities.cls()
utilities.header(["Assume Metal GPU Always in iMac"])
print(
"""This is for iMacs that have upgraded Metal GPUs, otherwise
Patcher assumes based on stock configuration (ie. iMac10,x-12,x)
@@ -86,8 +87,8 @@ option is for those patching on a different machine or OCLP cannot detect.
self.change_metal()
def change_serial(self):
Utilities.cls()
Utilities.header(["Set SMBIOS Spoof Level"])
utilities.cls()
utilities.header(["Set SMBIOS Spoof Level"])
print(
"""This section is for setting how OpenCore generates the SMBIOS
Recommended for adanced users who want control how serials are handled
@@ -115,8 +116,8 @@ Note: For new users we recommend leaving as default(1. Minimal)
self.change_serial()
def change_showpicker(self):
Utilities.cls()
Utilities.header(["Set OpenCore Picker mode"])
utilities.cls()
utilities.header(["Set OpenCore Picker mode"])
print(
"""By default, OpenCore will show its boot picker each time on boot up,
however this can be disabled by default and be shown on command by repeatedly
@@ -134,8 +135,8 @@ pressing the "Esc" key
self.change_showpicker()
def change_vault(self):
Utilities.cls()
Utilities.header(["Set OpenCore Vaulting"])
utilities.cls()
utilities.header(["Set OpenCore Vaulting"])
print(
"""By default, this patcher will sign all your files and ensure none of the
contents can be tampered with. However for more advanced users, you may
@@ -156,8 +157,8 @@ Note: For security reasons, OpenShell will be disabled when Vault is set.
self.change_vault()
def change_sip(self):
Utilities.cls()
Utilities.header(["Set System Integrity protection"])
utilities.cls()
utilities.header(["Set System Integrity protection"])
print(
"""SIP is used to ensure proper secuirty measures are set,
however to patch the root volume this must be disabled.
@@ -182,8 +183,8 @@ Q. Return to previous menu
self.change_sip()
def change_sbm(self):
Utilities.cls()
Utilities.header(["Set SecureBootModel"])
utilities.cls()
utilities.header(["Set SecureBootModel"])
print(
"""SecureBootModel is used to ensure best firmware security,
however to patch the root volume this must be disabled.
@@ -208,8 +209,8 @@ Q. Return to previous menu
self.change_sbm()
def set_amfi(self):
Utilities.cls()
Utilities.header(["Set AMFI"])
utilities.cls()
utilities.header(["Set AMFI"])
print(
"""Required for Root Patching non-Metal GPUs
in macOS Big Sur. Without this, will receive kernel panic once
@@ -227,8 +228,8 @@ Patcher finishes installing legacy acceleration patches.
self.set_amfi()
def bootstrap_setting(self):
Utilities.cls()
Utilities.header(["Set Bootstrap method"])
utilities.cls()
utilities.header(["Set Bootstrap method"])
print(
"""Sets OpenCore's bootstrap method, currently the patcher supports the
following options.
@@ -258,8 +259,8 @@ see the EFI Boot entry in the boot picker.
self.bootstrap_setting()
def drm_setting(self):
Utilities.cls()
Utilities.header(["Set DRM preferences"])
utilities.cls()
utilities.header(["Set DRM preferences"])
print(
"""Sets OpenCore's DRM preferences for iMac13,x and iMac14,x.
In Big Sur, some DRM based content may be broken by
@@ -284,8 +285,8 @@ Recommend only disabling if absolutely required.
self.drm_setting()
def allow_native_models(self):
Utilities.cls()
Utilities.header(["Allow OpenCore on native Models"])
utilities.cls()
utilities.header(["Allow OpenCore on native Models"])
print(
"""Allows natively supported Macs to use OpenCore. Recommended
for users with 3rd Party NVMe SSDs to achieve improved overall
@@ -306,8 +307,8 @@ power usage.
self.allow_native_models()
def custom_cpu(self):
Utilities.cls()
Utilities.header(["Set custom CPU Model Name"])
utilities.cls()
utilities.header(["Set custom CPU Model Name"])
print(
"""Change reported CPU Model name in About This Mac
Custom names will report as follows:
@@ -341,8 +342,8 @@ Q. Return to previous menu
self.custom_cpu()
def disable_cpufriend(self):
Utilities.cls()
Utilities.header(["Disable CPU Friend?"])
utilities.cls()
utilities.header(["Disable CPU Friend?"])
print(
"""Only recommended for advanced users
Disabling CPUFriend forces macOS into using a different
@@ -361,8 +362,8 @@ hardware
self.disable_cpufriend()
def set_smbios(self):
Utilities.cls()
Utilities.header(["Set SMBIOS Spoof Model"])
utilities.cls()
utilities.header(["Set SMBIOS Spoof Model"])
print(
"""Change model OpenCore spoofs Mac too
@@ -395,8 +396,8 @@ Q. Return to previous menu
self.set_smbios()
def allow_firewire(self):
Utilities.cls()
Utilities.header(["Allow FireWire Boot Support"])
utilities.cls()
utilities.header(["Allow FireWire Boot Support"])
print(
"""
In macOS Catalina and newer, Apple restricted
@@ -422,8 +423,8 @@ Note: MacBook5,x-7,1 don't support FireWire boot
self.allow_firewire()
def allow_nvme(self):
Utilities.cls()
Utilities.header(["Allow NVMe UEFI Support"])
utilities.cls()
utilities.header(["Allow NVMe UEFI Support"])
print(
"""
For machines not natively supporting NVMe,
@@ -449,8 +450,8 @@ OpenCore will enable NVMe support in it's picker
self.allow_nvme()
def allow_wowl(self):
Utilities.cls()
Utilities.header(["Allow Wake on WLAN"])
utilities.cls()
utilities.header(["Allow Wake on WLAN"])
print(
"""
Due to an unfortunate bug in macOS Big Sur+, Wake on WLAN is
@@ -473,8 +474,8 @@ be prepared if enabling.
self.allow_wowl()
def allow_ivy(self):
Utilities.cls()
Utilities.header(["Allow Ivy iMac iGPU"])
utilities.cls()
utilities.header(["Allow Ivy iMac iGPU"])
print(
"""
For iMac13,x systems with a Nvidia dGPU, the iGPU is disabled by default to
@@ -501,8 +502,8 @@ Note 2: This setting only affects iMac13,x with dGPUs
self.allow_ivy()
def latebloom_settings(self):
Utilities.cls()
Utilities.header(["Set latebloom properties"])
utilities.cls()
utilities.header(["Set latebloom properties"])
print(
f"""
Set latebloom properties, useful for debugging boot stalls on
@@ -547,8 +548,8 @@ Q. Return to previous menu
self.latebloom_settings()
def allow_moj_cat_patch(self):
Utilities.cls()
Utilities.header(["Allow Root Patching on Mojave/Catalina"])
utilities.cls()
utilities.header(["Allow Root Patching on Mojave/Catalina"])
print(
"""
This is an experimental option that allows the usage of legacy acceleration
@@ -574,9 +575,9 @@ Note: for the average user, we recommend using dosdude1's legacy patcher:
else:
self.allow_moj_cat_patch()
def disable_thunderbolt(self):
Utilities.cls()
Utilities.header(["Disable Thunderbolt on 2013-14 MacBook Pros"])
def disable_tb(self):
utilities.cls()
utilities.header(["Disable Thunderbolt on 2013-14 MacBook Pros"])
print(
"""
Some 2013-14 MacBook Pro's have issues with the built-in thunderbolt,
@@ -592,17 +593,17 @@ other devices that benefit from this fix.
change_menu = input("Disable Thunderbolt?(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.disable_thunderbolt = True
self.constants.disable_tb = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.disable_thunderbolt = False
self.constants.disable_tb = False
elif change_menu in {"q", "Q", "Quit", "quit"}:
print("Returning to previous menu")
else:
self.disable_thunderbolt()
self.disable_tb()
def terascale_2_accel(self):
Utilities.cls()
Utilities.header(["Set TeraScale 2 Acceleration"])
utilities.cls()
utilities.header(["Set TeraScale 2 Acceleration"])
print(
"""
By default this patcher will install TeraScale 2 acceleration, however
@@ -626,15 +627,15 @@ handle acceleration tasks.
self.terascale_2_accel()
def dump_hardware(self):
Utilities.cls()
Utilities.header(["Dumping detected hardware"])
utilities.cls()
utilities.header(["Dumping detected hardware"])
print("")
print(self.constants.computer)
input("\nPress [ENTER] to exit: ")
def applealc_support(self):
Utilities.cls()
Utilities.header(["Set AppleALC usage"])
utilities.cls()
utilities.header(["Set AppleALC usage"])
print(
"""
By default this patcher will install audio patches in-memory via
@@ -657,8 +658,8 @@ If AppleALC is detected, the Patcher will not install AppleHDA.
self.applealc_support()
def dGPU_switch_support(self):
Utilities.cls()
Utilities.header(["Set Windows GMUX support"])
utilities.cls()
utilities.header(["Set Windows GMUX support"])
print(
"""
With OCLP, we're able to restore iGPU funbctionality on iGPU+dGPU
@@ -678,8 +679,8 @@ for Windows may prefer to only work with the dGPU and eGPU active.
self.dGPU_switch_support()
def set_surplus(self):
Utilities.cls()
Utilities.header(["Override SurPlus MaxKernel"])
utilities.cls()
utilities.header(["Override SurPlus MaxKernel"])
print(
"""
By default OCLP will only allow SurPlus to be used on kernels 21.1.0
@@ -702,3 +703,308 @@ the event there's issues.
print("Returning to previous menu")
else:
self.set_surplus()
def credits(self):
utilities.TUIOnlyPrint(
["Credits"],
"Press [Enter] to go back.\n",
[
"""Many thanks to the following:
- Acidanthera:\tOpenCore, kexts and other tools
- Khronokernel:\tWriting and maintaining this patcher
- DhinakG:\t\tWriting and maintaining this patcher
- ASentientBot:\tLegacy Acceleration Patches
- Ausdauersportler:\tLinking fixes for SNBGraphicsFB and AMDX3000
- Syncretic:\t\tAAAMouSSE and telemetrap
- cdf:\t\tNightShiftEnabler and Innie"""
],
).start()
def change_model(self):
utilities.cls()
utilities.header(["Select Different Model"])
print(
"""
Tip: Run the following command on the target machine to find the model identifier:
system_profiler SPHardwareDataType | grep 'Model Identifier'
"""
)
self.constants.custom_model = input("Please enter the model identifier of the target machine: ").strip()
if self.constants.custom_model not in model_array.SupportedSMBIOS:
print(
f"""
{self.constants.custom_model} is not a valid SMBIOS Identifier for macOS {self.constants.os_support}!
"""
)
print_models = input(f"Print list of valid options for macOS {self.constants.os_support}? (y/n)")
if print_models.lower() in {"y", "yes"}:
print("\n".join(model_array.SupportedSMBIOS))
input("\nPress [ENTER] to continue")
else:
defaults.generate_defaults.probe(self.constants.custom_model, False, self.constants)
def PatchVolume(self):
utilities.cls()
utilities.header(["Patching System Volume"])
no_patch = False
if self.constants.detected_os == self.constants.monterey:
print(MenuOptions.monterey)
elif self.constants.detected_os == self.constants.big_sur:
print(MenuOptions.big_sur)
elif self.constants.detected_os in [self.constants.mojave, self.constants.catalina] and self.constants.moj_cat_accel == True:
print(MenuOptions.mojave_catalina)
else:
print(MenuOptions.default)
no_patch = True
change_menu = input("Patch System Volume?: ")
if no_patch is not True and change_menu == "1":
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants).start_patch()
elif no_patch is not True and change_menu == "2":
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants).start_unpatch()
else:
print("Returning to main menu")
def advanced_patcher_settings(self):
response = None
while not (response and response == -1):
title = ["Adjust Advanced Patcher Settings, for developers ONLY"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_metal],
[f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).drm_setting],
[f"Set Generic Bootstrap:\t\tCurrently {self.constants.boot_efi}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).bootstrap_setting],
[
f"Disable CPU Friend:\t\t\tCurrently {self.constants.disallow_cpufriend}",
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).disable_cpufriend,
],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings(self):
response = None
while not (response and response == -1):
title = ["Adjust Patcher Settings"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
["Debug Settings", self.patcher_setting_debug],
["Security Settings", self.patcher_settings_security],
["SMBIOS Settings", self.patcher_settings_smbios],
["Boot Volume Settings", self.patcher_settings_boot],
["Miscellaneous Settings", self.patcher_settings_misc],
["Dump detected hardware", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).dump_hardware],
[
f"Allow Accel on Mojave/Catalina:\tCurrently {self.constants.moj_cat_accel}",
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_moj_cat_patch,
],
[
f"Allow OpenCore on native Models:\tCurrently {self.constants.allow_oc_everywhere}",
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_native_models,
],
["Advanced Settings, for developers only", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).advanced_patcher_settings],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_setting_debug(self):
response = None
while not (response and response == -1):
title = ["Adjust Debug Settings"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Enable Verbose Mode:\tCurrently {self.constants.verbose_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_verbose],
[f"Enable OpenCore DEBUG:\tCurrently {self.constants.opencore_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_oc],
[f"Enable Kext DEBUG:\t\tCurrently {self.constants.kext_debug}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_kext],
] + (
[
[f"Set SurPlus Settings:\tCurrently {self.constants.force_surplus}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_surplus]
]
if (smbios_data.smbios_dictionary[self.constants.custom_model or self.constants.computer.real_model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge)
else []
)
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_security(self):
response = None
while not (response and response == -1):
title = ["Adjust Security Settings"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
# [
# f"Set Apple Mobile File Integrity (AMFI):\tCurrently {self.constants.amfi_status}",
# MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_amfi,
# ],
[
f"Set System Intrgity Protection (SIP):\tCurrently {self.constants.sip_status}",
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_sip,
],
[
f"Set Secure Boot Model (SBM):\t\tCurrently {self.constants.secure_status}",
MenuOptions(self.constants.custom_model or self.constant.computer.real_model, self.constants).change_sbm,
],
[f"Set Vault Mode:\t\t\t\tCurrently {self.constants.vault}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_vault],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_smbios(self):
response = None
while not (response and response == -1):
title = ["Adjust SMBIOS Settings"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set SMBIOS Spoof Level:\tCurrently {self.constants.serial_settings}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_serial],
[f"Set SMBIOS Spoof Model:\tCurrently {self.constants.override_smbios}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_smbios],
[f"Set Custom name {self.constants.custom_cpu_model_value}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).custom_cpu],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_boot(self):
response = None
while not (response and response == -1):
title = ["Adjust Bootable Volume Settings"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set FireWire Boot:\tCurrently {self.constants.firewire_boot}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_firewire],
[f"Set NVMe Boot:\tCurrently {self.constants.nvme_boot}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_nvme],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def patcher_settings_misc(self):
response = None
while not (response and response == -1):
title = ["Adjust Miscellaneous Settings"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set ShowPicker Mode:\tCurrently {self.constants.showpicker}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_showpicker],
[f"Set Wake on WLAN:\t\tCurrently {self.constants.enable_wake_on_wlan}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_wowl],
[f"Set Ivy iMac iGPU:\t\tCurrently {self.constants.allow_ivy_igpu}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).allow_ivy],
[f"Set TeraScale 2 Accel:\tCurrently {self.constants.allow_ts2_accel}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).terascale_2_accel],
[
f"Disable Thunderbolt:\tCurrently {self.constants.disable_tb}",
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).disable_tb,
],
[f"Set AppleALC Usage:\t\tCurrently {self.constants.set_alc_usage}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).applealc_support],
[f"Set Windows GMUX support:\tCurrently {self.constants.dGPU_switch}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).dGPU_switch_support],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
def advanced_patcher_settings(self):
response = None
while not (response and response == -1):
title = ["Adjust Advanced Patcher Settings, for developers ONLY"]
menu = utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True)
options = [
[f"Set Metal GPU Status:\t\tCurrently {self.constants.imac_vendor}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_metal],
[f"Set DRM Preferences:\t\tCurrently {self.constants.drm_support}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).drm_setting],
[f"Set Generic Bootstrap:\t\tCurrently {self.constants.boot_efi}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).bootstrap_setting],
[
f"Disable CPU Friend:\t\t\tCurrently {self.constants.disallow_cpufriend}",
MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).disable_cpufriend,
],
]
for option in options:
menu.add_menu_option(option[0], function=option[1])
response = menu.start()
big_sur = """Patches Root volume to fix misc issues such as:
- Non-Metal Graphics Acceleration
- Intel: Ironlake - Sandy Bridge
- Nvidia: Tesla - Fermi (8000-500 series)
- AMD: TeraScale 1 and 2 (2000-6000 series)
- Audio support for iMac7,1 and iMac8,1
WARNING: Root Volume Patching is still in active development, please
have all important user data backed up. Note when the system volume
is patched, you can no longer have Delta updates.
Supported Options:
1. Patch System Volume
2. Unpatch System Volume (Experimental)
B. Exit
"""
monterey = """Patches Root volume to fix misc issues such as:
- Metal Graphics Acceleration
- Intel: Ivy Bridge (4000 series iGPUs)
- Nvidia: Kepler (600-700)
- Non-Metal Graphics Accelertation
- Intel: Ironlake - Sandy Bridge
- Nvidia: Tesla - Fermi (8000-500 series)
- AMD: TeraScale 1 and 2 (2000-6000 series)
- Audio support for iMac7,1 and iMac8,1
- Wifi support for BCM94328, BCM94322 and Atheros cards
WARNING: Root Volume Patching is still in active development, please
have all important user data backed up. Note when the system volume
is patched, you can no longer have Delta updates.
Supported Options:
1. Patch System Volume
2. Unpatch System Volume (Experimental)
B. Exit
"""
mojave_catalina = """Patches Root volume to fix misc issues such as:
- Non-Metal Graphics Acceleration
- Intel: Ironlake - Sandy Bridge
- Nvidia: Tesla - Fermi (8000-500 series)
- AMD: TeraScale 1 and 2 (2000-6000 series)
- Audio support for iMac7,1 and iMac8,1
WARNING: Root Volume Patching is still in active development, please
have all important user data backed up. Note when the system volume
is patched, you can no longer have Delta updates.
Supported Options:
1. Patch System Volume
2. Unpatch System Volume (Experimental)
B. Exit
"""
default = """
This OS has no root patches available to apply, please ensure you're patching a booted
install that requires root patches such as macOS Big Sur or Monterey
Supported Options:
B. Exit
"""

View File

@@ -7,7 +7,7 @@ from __future__ import print_function
from pathlib import Path
from typing import Optional
from Resources import device_probe
from resources import device_probe
class Constants:
@@ -140,7 +140,7 @@ class Constants:
## Miscellaneous
self.disallow_cpufriend = False # Disable CPUFriend
self.enable_wake_on_wlan = False # Allow Wake on WLAN for modern Broadcom
self.disable_thunderbolt = False # Disable Thunderbolt Controller
self.disable_tb = False # Disable Thunderbolt Controller
self.set_alc_usage = True # Set AppleALC usage
self.dGPU_switch = True # Set Display GPU Switching for Windows
self.force_surplus = False # Force SurPlus patch in newer OSes
@@ -474,7 +474,7 @@ class Constants:
# Icons
@property
def app_icon_path(self):
return self.current_path / Path("OC-Patcher.icns")
return self.payload_path / Path("OC-Patcher.icns")
@property
def icon_path_external(self):
@@ -631,41 +631,6 @@ class Constants:
def legacy_wifi_libexec(self):
return self.payload_apple_libexec_path / Path("Legacy-Wifi")
csr_values = {
# Source: macOS 11.4 (XNU's csr.h)
# https://opensource.apple.com/source/xnu/xnu-7195.121.3/bsd/sys/csr.h.auto.html
"CSR_ALLOW_UNTRUSTED_KEXTS": False, # 0x1 - Allows Unsigned Kexts - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_UNRESTRICTED_FS": False, # 0x2 - File System Access - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_TASK_FOR_PID": False, # 0x4 - Unrestricted task_for_pid() - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_KERNEL_DEBUGGER": False, # 0x8 - Allow Kernel Debugger - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_APPLE_INTERNAL": False, # 0x10 - Set AppleInternal Features - Introduced in El Capitan # noqa: E241
# "CSR_ALLOW_DESTRUCTIVE_DTRACE": False, # 0x20 - Allow destructive DTrace - Deprecated # noqa: E241
"CSR_ALLOW_UNRESTRICTED_DTRACE": False, # 0x20 - Unrestricted DTrace usage - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_UNRESTRICTED_NVRAM": False, # 0x40 - Unrestricted NVRAM write - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_DEVICE_CONFIGURATION": False, # 0x80 - Allow custom DeviceTree (iOS) - Introduced in El Capitan # noqa: E241
"CSR_ALLOW_ANY_RECOVERY_OS": False, # 0x100 - Skip BaseSystem Verification - Introduced in Sierra # noqa: E241
"CSR_ALLOW_UNAPPROVED_KEXTS": False, # 0x200 - Allow Unnotarized Kexts - Introduced in High Sierra # noqa: E241
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE": False, # 0x400 - Override Executable Policy - Introduced in Mojave # noqa: E241
"CSR_ALLOW_UNAUTHENTICATED_ROOT": False, # 0x800 - Allow Root Volume Mounting - Introduced in Big Sur # noqa: E241
}
root_patch_sip_mojave = [
# Variables required to root patch in Mojave and Catalina
"CSR_ALLOW_UNTRUSTED_KEXTS", # 0x1
"CSR_ALLOW_UNRESTRICTED_FS", # 0x2
"CSR_ALLOW_UNAPPROVED_KEXTS", # 0x200
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE", # 0x400
]
root_patch_sip_big_sur = [
# Variables required to root patch in Big Sur and Monterey
"CSR_ALLOW_UNTRUSTED_KEXTS", # 0x1
"CSR_ALLOW_UNRESTRICTED_FS", # 0x2
"CSR_ALLOW_UNAPPROVED_KEXTS", # 0x200
"CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE", # 0x400
"CSR_ALLOW_UNAUTHENTICATED_ROOT", # 0x800
]
sbm_values = [
"j137ap", # iMacPro1,1
"j680ap", # MacBookPro15,1
@@ -693,140 +658,4 @@ class Constants:
"Mac-937CB26E2E02BB01", # MacBookAir7,2
"Mac-35C5E08120C7EEAF", # Macmini7,1
"Mac-7BA5B2D9E42DDD94", # iMacPro1,1
]
board_id = {
"MacBook1,1": "Mac-F4208CC8",
"MacBook2,1": "Mac-F4208CA9",
"MacBook3,1": "Mac-F22788C8",
"MacBook4,1": "Mac-F22788A9",
"MacBook5,1": "Mac-F42D89C8",
"MacBook5,2": "Mac-F22788AA",
"MacBook6,1": "Mac-F22C8AC8",
"MacBook7,1": "Mac-F22C89C8",
"MacBook8,1": "Mac-BE0E8AC46FE800CC",
"MacBook9,1": "Mac-9AE82516C7C6B903",
"MacBook10,1": "Mac-EE2EBD4B90B839A8",
"MacBookAir1,1": "Mac-F42C8CC8",
"MacBookAir2,1": "Mac-F42D88C8",
"MacBookAir3,1": "Mac-942452F5819B1C1B",
"MacBookAir3,2": "Mac-942C5DF58193131B",
"MacBookAir4,1": "Mac-C08A6BB70A942AC2",
"MacBookAir4,2": "Mac-742912EFDBEE19B3",
"MacBookAir5,1": "Mac-66F35F19FE2A0D05",
"MacBookAir5,2": "Mac-2E6FAB96566FE58C",
"MacBookAir6,1": "Mac-35C1E88140C3E6CF",
"MacBookAir6,2": "Mac-7DF21CB3ED6977E5",
"MacBookAir7,1": "Mac-9F18E312C5C2BF0B",
"MacBookAir7,2": "Mac-937CB26E2E02BB01",
"MacBookAir8,1": "Mac-827FAC58A8FDFA22",
"MacBookAir8,2": "Mac-226CB3C6A851A671",
"MacBookAir9,1": "Mac-0CFF9C7C2B63DF8D",
"MacBookPro1,1": "Mac-F425BEC8",
"MacBookPro1,2": "Mac-F42DBEC8",
"MacBookPro2,1": "Mac-F42189C8",
"MacBookPro2,2": "Mac-F42187C8",
"MacBookPro3,1": "Mac-F4238BC8",
"MacBookPro4,1": "Mac-F42C89C8",
"MacBookPro5,1": "Mac-F42D86C8",
"MacBookPro5,2": "Mac-F2268EC8",
"MacBookPro5,3": "Mac-F22587C8",
"MacBookPro5,4": "Mac-F22587A1",
"MacBookPro5,5": "Mac-F2268AC8",
"MacBookPro6,1": "Mac-F22589C8",
"MacBookPro6,2": "Mac-F22586C8",
"MacBookPro7,1": "Mac-F222BEC8",
"MacBookPro8,1": "Mac-94245B3640C91C81",
"MacBookPro8,2": "Mac-94245A3940C91C80",
"MacBookPro8,3": "Mac-942459F5819B171B",
"MacBookPro9,1": "Mac-4B7AC7E43945597E",
"MacBookPro9,2": "Mac-6F01561E16C75D06",
"MacBookPro10,1": "Mac-C3EC7CD22292981F",
"MacBookPro10,2": "Mac-AFD8A9D944EA4843",
"MacBookPro11,1": "Mac-189A3D4F975D5FFC",
"MacBookPro11,2": "Mac-3CBD00234E554E41",
"MacBookPro11,3": "Mac-2BD1B31983FE1663",
"MacBookPro11,4": "Mac-06F11FD93F0323C5",
"MacBookPro11,5": "Mac-06F11F11946D27C5",
"MacBookPro12,1": "Mac-E43C1C25D4880AD6",
"MacBookPro13,1": "Mac-473D31EABEB93F9B",
"MacBookPro13,2": "Mac-66E35819EE2D0D05",
"MacBookPro13,3": "Mac-A5C67F76ED83108C",
"MacBookPro14,1": "Mac-B4831CEBD52A0C4C",
"MacBookPro14,2": "Mac-CAD6701F7CEA0921",
"MacBookPro14,3": "Mac-551B86E5744E2388",
"MacBookPro15,1": "Mac-937A206F2EE63C01",
"MacBookPro15,2": "Mac-827FB448E656EC26",
"MacBookPro15,3": "Mac-1E7E29AD0135F9BC",
"MacBookPro15,4": "Mac-53FDB3D8DB8CA971",
"MacBookPro16,1": "Mac-E1008331FDC96864",
"MacBookPro16,2": "Mac-5F9802EFE386AA28",
"MacBookPro16,3": "Mac-E7203C0F68AA0004",
"MacBookPro16,4": "Mac-A61BADE1FDAD7B05",
"Macmini1,1": "Mac-F4208EC8",
"Macmini2,1": "Mac-F4208EAA",
"Macmini3,1": "Mac-F22C86C8",
"Macmini4,1": "Mac-F2208EC8",
"Macmini5,1": "Mac-8ED6AF5B48C039E1",
"Macmini5,2": "Mac-4BC72D62AD45599E",
"Macmini5,3": "Mac-7BA5B2794B2CDB12",
"Macmini6,1": "Mac-031AEE4D24BFF0B1",
"Macmini6,2": "Mac-F65AE981FFA204ED",
"Macmini7,1": "Mac-35C5E08120C7EEAF",
"Macmini8,1": "Mac-7BA5B2DFE22DDD8C",
"iMac4,1": "Mac-F42786C8",
"iMac4,2": "Mac-F4218EC8",
"iMac5,1": "Mac-F4228EC8",
"iMac5,2": "Mac-F4218EC8",
"iMac6,1": "Mac-F4218FC8",
"iMac7,1": "Mac-F42386C8",
"iMac8,1": "Mac-F227BEC8",
"iMac9,1": "Mac-F2218FA9",
"iMac10,1": "Mac-F221DCC8",
# "iMac10,1": "Mac-F2268CC8",
"iMac11,1": "Mac-F2268DAE",
"iMac11,2": "Mac-F2238AC8",
"iMac11,3": "Mac-F2238BAE",
"iMac12,1": "Mac-942B5BF58194151B",
"iMac12,2": "Mac-942B59F58194171B",
"iMac13,1": "Mac-00BE6ED71E35EB86",
"iMac13,2": "Mac-FC02E91DDD3FA6A4",
"iMac13,3": "Mac-7DF2A3B5E5D671ED",
"iMac14,1": "Mac-031B6874CF7F642A",
"iMac14,2": "Mac-27ADBB7B4CEE8E61",
"iMac14,3": "Mac-77EB7D7DAF985301",
"iMac14,4": "Mac-81E3E92DD6088272",
"iMac15,1": "Mac-42FD25EABCABB274",
"iMac16,1": "Mac-A369DDC4E67F1C45",
"iMac16,2": "Mac-FFE5EF870D7BA81A",
"iMac17,1": "Mac-DB15BD556843C820",
# iMac17,1": "Mac-65CE76090165799A",
# iMac17,1": "Mac-B809C3757DA9BB8D",
"iMac18,1": "Mac-4B682C642B45593E",
"iMac18,2": "Mac-77F17D7DA9285301",
"iMac18,3": "Mac-BE088AF8C5EB4FA2",
"iMac19,1": "Mac-AA95B1DDAB278B95",
"iMac19,2": "Mac-63001698E7A34814",
"iMac20,1": "Mac-CFF7D910A743CAAF",
"iMac20,2": "Mac-AF89B6D9451A490B",
"iMacPro1,1": "Mac-7BA5B2D9E42DDD94",
"MacPro1,1": "Mac-F4208DC8",
"MacPro2,1": "Mac-F4208DA9",
"MacPro3,1": "Mac-F42C88C8",
"MacPro4,1": "Mac-F221BEC8",
"MacPro5,1": "Mac-F221BEC8",
"MacPro6,1": "Mac-F60DEB81FF30ACF6",
"MacPro7,1": "Mac-27AD2F918AE68F61",
"Xserve1,1": "Mac-F4208AC8",
"Xserve2,1": "Mac-F42289C8",
"Xserve3,1": "Mac-F223BEC8",
}
target_type = {
"ADP3,2": "J273",
"MacBookAir10,1": "J313",
"MacBookPro17,1": "J293",
"Macmini9,1": "J274",
"iMac21,1": "J256",
"iMac21,2": "J257",
}
]

75
resources/defaults.py Normal file
View File

@@ -0,0 +1,75 @@
# Generate Default Data
from resources import utilities, device_probe
from data import model_array
class generate_defaults():
def probe(model, host_is_target, settings):
# Generate Default Data
# Takes in Settings data set, and returns updated Settings
settings.sip_status = True
settings.secure_status = False # Default false for Monterey
settings.amfi_status = True
if host_is_target:
if utilities.check_metal_support(device_probe, settings.computer) is False:
settings.disable_cs_lv = True
if settings.computer.dgpu and settings.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
settings.sip_status = False
settings.amfi_status = True
settings.allow_fv_root = True # Allow FileVault on broken seal
if (
isinstance(settings.computer.wifi, device_probe.Broadcom)
and settings.computer.wifi.chipset in [device_probe.Broadcom.Chipsets.AirPortBrcm4331, device_probe.Broadcom.Chipsets.AirPortBrcm43224]
) or (isinstance(settings.computer.wifi, device_probe.Atheros) and settings.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40):
settings.sip_status = False
settings.allow_fv_root = True # Allow FileVault on broken seal
elif model in model_array.LegacyGPU:
settings.disable_cs_lv = True
if model in model_array.LegacyGPU:
if host_is_target and utilities.check_metal_support(device_probe, settings.computer) is True:
# Building on device and we have a native, supported GPU
if settings.computer.dgpu and settings.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
settings.sip_status = False
# settings.secure_status = True # Monterey
settings.allow_fv_root = True # Allow FileVault on broken seal
else:
settings.sip_status = True
# settings.secure_status = True # Monterey
settings.amfi_status = True
else:
settings.sip_status = False # Unsigned kexts
settings.secure_status = False # Root volume modified
settings.amfi_status = False # Unsigned binaries
settings.allow_fv_root = True # Allow FileVault on broken seal
if model in model_array.ModernGPU:
# Systems with Ivy or Kepler GPUs, Monterey requires root patching for accel
settings.sip_status = False # Unsigned kexts
settings.secure_status = False # Modified root volume
settings.allow_fv_root = True # Allow FileVault on broken seal
# settings.amfi_status = True # Signed bundles, Don't need to explicitly set currently
if model == "MacBook8,1":
# MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing
settings.serial_settings = "Moderate"
custom_cpu_model_value = utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
if custom_cpu_model_value is not None:
# TODO: Fix to not use two separate variables
settings.custom_cpu_model = 1
settings.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0]
if "-v" in (utilities.get_nvram("boot-args") or ""):
settings.verbose_debug = True
if utilities.amfi_status() is False:
settings.amfi_status = False
if utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9"):
# Users disabling TS2 most likely have a faulty dGPU
# users can override this in settings
settings.allow_ts2_accel = False
# Check if running in RecoveryOS
settings.recovery_status = utilities.check_recovery()

View File

@@ -10,7 +10,8 @@ import subprocess
from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional, Type, Union
from Resources import PCIIDArray, Utilities, ioreg
from resources import utilities, ioreg
from data import pci_data
@dataclass
@@ -168,11 +169,11 @@ class NVIDIA(GPU):
def detect_arch(self):
# G80/G80GL
if self.device_id in PCIIDArray.nvidia_ids.tesla_ids:
if self.device_id in pci_data.nvidia_ids.tesla_ids:
self.arch = NVIDIA.Archs.Tesla
elif self.device_id in PCIIDArray.nvidia_ids.fermi_ids:
elif self.device_id in pci_data.nvidia_ids.fermi_ids:
self.arch = NVIDIA.Archs.Fermi
elif self.device_id in PCIIDArray.nvidia_ids.kepler_ids:
elif self.device_id in pci_data.nvidia_ids.kepler_ids:
self.arch = NVIDIA.Archs.Kepler
else:
self.arch = NVIDIA.Archs.Unknown
@@ -195,17 +196,17 @@ class AMD(GPU):
arch: Archs = field(init=False)
def detect_arch(self):
if self.device_id in PCIIDArray.amd_ids.legacy_gcn_ids:
if self.device_id in pci_data.amd_ids.legacy_gcn_ids:
self.arch = AMD.Archs.Legacy_GCN
elif self.device_id in PCIIDArray.amd_ids.terascale_1_ids:
elif self.device_id in pci_data.amd_ids.terascale_1_ids:
self.arch = AMD.Archs.TeraScale_1
elif self.device_id in PCIIDArray.amd_ids.terascale_2_ids:
elif self.device_id in pci_data.amd_ids.terascale_2_ids:
self.arch = AMD.Archs.TeraScale_2
elif self.device_id in PCIIDArray.amd_ids.polaris_ids:
elif self.device_id in pci_data.amd_ids.polaris_ids:
self.arch = AMD.Archs.Polaris
elif self.device_id in PCIIDArray.amd_ids.vega_ids:
elif self.device_id in pci_data.amd_ids.vega_ids:
self.arch = AMD.Archs.Vega
elif self.device_id in PCIIDArray.amd_ids.navi_ids:
elif self.device_id in pci_data.amd_ids.navi_ids:
self.arch = AMD.Archs.Navi
else:
self.arch = AMD.Archs.Unknown
@@ -231,23 +232,23 @@ class Intel(GPU):
arch: Archs = field(init=False)
def detect_arch(self):
if self.device_id in PCIIDArray.intel_ids.iron_ids:
if self.device_id in pci_data.intel_ids.iron_ids:
self.arch = Intel.Archs.Iron_Lake
elif self.device_id in PCIIDArray.intel_ids.sandy_ids:
elif self.device_id in pci_data.intel_ids.sandy_ids:
self.arch = Intel.Archs.Sandy_Bridge
elif self.device_id in PCIIDArray.intel_ids.ivy_ids:
elif self.device_id in pci_data.intel_ids.ivy_ids:
self.arch = Intel.Archs.Ivy_Bridge
elif self.device_id in PCIIDArray.intel_ids.haswell_ids:
elif self.device_id in pci_data.intel_ids.haswell_ids:
self.arch = Intel.Archs.Haswell
elif self.device_id in PCIIDArray.intel_ids.broadwell_ids:
elif self.device_id in pci_data.intel_ids.broadwell_ids:
self.arch = Intel.Archs.Broadwell
elif self.device_id in PCIIDArray.intel_ids.skylake_ids:
elif self.device_id in pci_data.intel_ids.skylake_ids:
self.arch = Intel.Archs.Skylake
elif self.device_id in PCIIDArray.intel_ids.kaby_lake_ids:
elif self.device_id in pci_data.intel_ids.kaby_lake_ids:
self.arch = Intel.Archs.Kaby_Lake
elif self.device_id in PCIIDArray.intel_ids.coffee_lake_ids:
elif self.device_id in pci_data.intel_ids.coffee_lake_ids:
self.arch = Intel.Archs.Coffee_Lake
elif self.device_id in PCIIDArray.intel_ids.ice_lake_ids:
elif self.device_id in pci_data.intel_ids.ice_lake_ids:
self.arch = Intel.Archs.Ice_Lake
else:
self.arch = Intel.Archs.Unknown
@@ -259,6 +260,7 @@ class Broadcom(WirelessCard):
class Chipsets(enum.Enum):
# pylint: disable=invalid-name
AppleBCMWLANBusInterfacePCIe = "AppleBCMWLANBusInterfacePCIe supported"
AirportBrcmNIC = "AirportBrcmNIC supported"
AirPortBrcm4360 = "AirPortBrcm4360 supported"
AirPortBrcm4331 = "AirPortBrcm4331 supported"
@@ -268,13 +270,15 @@ class Broadcom(WirelessCard):
chipset: Chipsets = field(init=False)
def detect_chipset(self):
if self.device_id in PCIIDArray.broadcom_ids.AirPortBrcmNIC:
if self.device_id in pci_data.broadcom_ids.AppleBCMWLANBusInterfacePCIe:
self.chipset = Broadcom.Chipsets.AppleBCMWLANBusInterfacePCIe
elif self.device_id in pci_data.broadcom_ids.AirPortBrcmNIC:
self.chipset = Broadcom.Chipsets.AirportBrcmNIC
elif self.device_id in PCIIDArray.broadcom_ids.AirPortBrcm4360:
elif self.device_id in pci_data.broadcom_ids.AirPortBrcm4360:
self.chipset = Broadcom.Chipsets.AirPortBrcm4360
elif self.device_id in PCIIDArray.broadcom_ids.AirPortBrcm4331:
elif self.device_id in pci_data.broadcom_ids.AirPortBrcm4331:
self.chipset = Broadcom.Chipsets.AirPortBrcm4331
elif self.device_id in PCIIDArray.broadcom_ids.AppleAirPortBrcm43224:
elif self.device_id in pci_data.broadcom_ids.AppleAirPortBrcm43224:
self.chipset = Broadcom.Chipsets.AirPortBrcm43224
else:
self.chipset = Broadcom.Chipsets.Unknown
@@ -293,7 +297,7 @@ class Atheros(WirelessCard):
chipset: Chipsets = field(init=False)
def detect_chipset(self):
if self.device_id in PCIIDArray.atheros_ids.AtherosWifi:
if self.device_id in pci_data.atheros_ids.AtherosWifi:
self.chipset = Atheros.Chipsets.AirPortAtheros40
else:
self.chipset = Atheros.Chipsets.Unknown
@@ -369,7 +373,7 @@ class Computer:
devices = ioreg.ioiterator_to_list(
ioreg.IOServiceGetMatchingServices(
ioreg.kIOMasterPortDefault,
{"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": {"class-code": binascii.a2b_hex(Utilities.hexswap(hex(WirelessCard.CLASS_CODE)[2:].zfill(8)))}},
{"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": {"class-code": binascii.a2b_hex(utilities.hexswap(hex(WirelessCard.CLASS_CODE)[2:].zfill(8)))}},
None,
)[1]
)
@@ -385,7 +389,7 @@ class Computer:
sata_controllers = ioreg.ioiterator_to_list(
ioreg.IOServiceGetMatchingServices(
ioreg.kIOMasterPortDefault,
{"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": [{"class-code": binascii.a2b_hex(Utilities.hexswap(hex(SATAController.CLASS_CODE)[2:].zfill(8)))}]},
{"IOProviderClass": "IOPCIDevice", "IOPropertyMatch": [{"class-code": binascii.a2b_hex(utilities.hexswap(hex(SATAController.CLASS_CODE)[2:].zfill(8)))}]},
None,
)[1]
)
@@ -427,12 +431,12 @@ class Computer:
# Real model
# TODO: We previously had logic for OC users using iMacPro1,1 with incorrect ExposeSensitiveData. Add logic?
self.real_model = Utilities.get_nvram("oem-product", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_model
self.real_board_id = Utilities.get_nvram("oem-board", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_board_id
self.real_model = utilities.get_nvram("oem-product", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_model
self.real_board_id = utilities.get_nvram("oem-board", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_board_id
# OCLP version
self.oclp_version = Utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
self.opencore_version = Utilities.get_nvram("opencore-version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
self.oclp_version = utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
self.opencore_version = utilities.get_nvram("opencore-version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
def cpu_probe(self):
self.cpu = CPU(

View File

@@ -0,0 +1,75 @@
from data import smbios_data, os_data
from resources import utilities
def set_smbios_model_spoof(model):
try:
smbios_data.smbios_dictionary[model]["Screen Size"]
# Found mobile SMBIOS
if model.startswith("MacBookAir"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookAir7,2"
elif smbios_data.smbios_dictionary[model]["Screen Size"] == 11:
return "MacBookAir7,1"
else:
# Unknown Model
raise Exception
elif model.startswith("MacBookPro"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookPro12,1"
elif smbios_data.smbios_dictionary[model]["Screen Size"] >= 15:
# 15" and 17"
try:
smbios_data.smbios_dictionary[model]["Switchable GPUs"]
return "MacBookPro11,5"
except KeyError:
return "MacBookPro11,4"
else:
# Unknown Model
raise Exception
elif model.startswith("MacBook"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookAir7,2"
elif smbios_data.smbios_dictionary[model]["Screen Size"] == 12:
return "MacBook9,1"
else:
# Unknown Model
raise Exception
else:
# Unknown Model
raise Exception
except KeyError:
# Found desktop model
if model.startswith("MacPro") or model.startswith("Xserve"):
return "MacPro7,1"
elif model.startswith("Macmini"):
return "Macmini7,1"
elif model.startswith("iMac"):
if smbios_data.smbios_dictionary[model]["Max OS Supported"] <= os_data.os_data.high_sierra:
# Models dropped in Mojave either do not have an iGPU, or should have them disabled
return "iMacPro1,1"
else:
return "iMac17,1"
else:
# Unknown Model
raise Exception
def update_firmware_features(firmwarefeature):
# Adjust FirmwareFeature to support everything macOS requires
# APFS Bit (19/20): 10.13+ (OSInstall)
# Large BaseSystem Bit (35): 12.0 B7+ (patchd)
# https://github.com/acidanthera/OpenCorePkg/tree/2f76673546ac3e32d2e2d528095fddcd66ad6a23/Include/Apple/IndustryStandard/AppleFeatures.h
firmwarefeature |= 2 ** 19 # FW_FEATURE_SUPPORTS_APFS
firmwarefeature |= 2 ** 20 # FW_FEATURE_SUPPORTS_APFS_EXTRA
firmwarefeature |= 2 ** 35 # FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
return firmwarefeature
def generate_fw_features(model, custom):
if not custom:
firmwarefeature = utilities.get_rom("firmware-features")
if not firmwarefeature:
print("- Failed to find FirmwareFeatures, falling back on defaults")
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
else:
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
firmwarefeature = update_firmware_features(firmwarefeature)
return firmwarefeature

19
resources/os_probe.py Normal file
View File

@@ -0,0 +1,19 @@
# Probe for OS data
import platform
import subprocess
def detect_kernel_major():
# Return Major Kernel Version
# Example Output: 21 (integer)
return int(platform.uname().release.partition(".")[0])
def detect_kernel_minor():
# Return Minor Kernel Version
# Example Output: 1 (integer)
return int(platform.uname().release.partition(".")[2].partition(".")[0])
def detect_kernel_build():
# Return OS build
# Example Output: 21A5522h (string)
return subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()

View File

@@ -11,13 +11,14 @@ import subprocess
import zipfile
from pathlib import Path
from Resources import Constants, device_probe, ModelArray, SysPatchArray, Utilities
from resources import constants, device_probe, utilities
from data import sip_data, sys_patch_data, model_array
class PatchSysVolume:
def __init__(self, model, versions):
self.model = model
self.constants: Constants.Constants = versions
self.constants: constants.Constants() = versions
self.computer = self.constants.computer
self.root_mount_path = None
self.sip_enabled = True
@@ -44,9 +45,6 @@ class PatchSysVolume:
self.validate = False
self.supports_metal = False
# if (Path.home() / "Desktop/OCLP-Test/").exists:
# self.mount_location = Path.home() / "Desktop/OCLP-Test"
# self.validate = True
if self.constants.detected_os > self.constants.catalina:
# Big Sur and newer use APFS snapshots
self.mount_location = "/System/Volumes/Update/mnt1"
@@ -60,23 +58,17 @@ class PatchSysVolume:
self.mount_libexec = f"{self.mount_location}/usr/libexec"
self.mount_extensions_mux = f"{self.mount_location}/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns/"
def elevated(self, *args, **kwargs) -> subprocess.CompletedProcess:
if os.getuid() == 0 or self.constants.gui_mode is True:
return subprocess.run(*args, **kwargs)
else:
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
def find_mount_root_vol(self, patch):
self.root_mount_path = Utilities.get_disk_path()
self.root_mount_path = utilities.get_disk_path()
if self.root_mount_path.startswith("disk"):
if self.constants.detected_os == self.constants.catalina and self.validate is False:
print("- Mounting Catalina Root Volume as writable")
self.elevated(["mount", "-uw", f"{self.mount_location}/"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
utilities.elevated(["mount", "-uw", f"{self.mount_location}/"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
print(f"- Found Root Volume at: {self.root_mount_path}")
if Path(self.mount_extensions).exists():
print("- Root Volume is already mounted")
if patch is True:
if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and Utilities.check_seal() is True):
if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and utilities.check_seal() is True):
self.backup_volume()
self.patch_root_vol()
return True
@@ -86,11 +78,11 @@ class PatchSysVolume:
else:
if self.constants.detected_os > self.constants.catalina:
print("- Mounting APFS Snapshot as writable")
self.elevated(["mount", "-o", "nobrowse", "-t", "apfs", f"/dev/{self.root_mount_path}", self.mount_location], stdout=subprocess.PIPE).stdout.decode().strip().encode()
utilities.elevated(["mount", "-o", "nobrowse", "-t", "apfs", f"/dev/{self.root_mount_path}", self.mount_location], stdout=subprocess.PIPE).stdout.decode().strip().encode()
if Path(self.mount_extensions).exists():
print("- Successfully mounted the Root Volume")
if patch is True:
if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and Utilities.check_seal() is True):
if self.constants.detected_os < self.constants.big_sur or (self.constants.detected_os == self.constants.big_sur and utilities.check_seal() is True):
self.backup_volume()
self.patch_root_vol()
return True
@@ -108,8 +100,8 @@ class PatchSysVolume:
input("- Press [ENTER] to exit: ")
def backup_volume(self):
for location in SysPatchArray.BackupLocations:
Utilities.cls()
for location in sys_patch_data.BackupLocations:
utilities.cls()
print("Backing up root volume before patching (This may take some time)")
print(f"- Attempting to backup {location}")
location_zip = f"{location}-Backup.zip"
@@ -124,7 +116,7 @@ class PatchSysVolume:
# rm -r ./Extensions-Backup
print("- Creating Backup folder")
Utilities.process_status(
utilities.process_status(
self.elevated(
["cp", "-r", f"{self.mount_location}/{location}", f"{self.mount_location}/{location}-Backup"],
stdout=subprocess.PIPE,
@@ -132,7 +124,7 @@ class PatchSysVolume:
)
)
print("- Zipping Backup folder")
Utilities.process_status(
utilities.process_status(
self.elevated(
["ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", f"{self.mount_location}/{location}-Backup", f"{self.mount_location}/{location_zip}"],
stdout=subprocess.PIPE,
@@ -141,7 +133,7 @@ class PatchSysVolume:
)
print("- Removing Backup folder")
Utilities.process_status(
utilities.process_status(
self.elevated(
["rm", "-r", f"{self.mount_location}/{location}-Backup"],
stdout=subprocess.PIPE,
@@ -154,8 +146,8 @@ class PatchSysVolume:
if (Path(self.mount_location) / Path("/System/Library/Extensions-Backup.zip")).exists():
print("- Verified manual unpatching is available")
for location in SysPatchArray.BackupLocations:
Utilities.cls()
for location in sys_patch_data.BackupLocations:
utilities.cls()
print("Reverting root volume patches (This may take some time)")
print(f"- Attempting to unpatch {location}")
@@ -174,21 +166,21 @@ class PatchSysVolume:
print(f"- Found {location_zip}")
print(f"- Unzipping {location_zip}")
Utilities.process_status(self.elevated(["unzip", location_zip_path, "-d", copy_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["unzip", location_zip_path, "-d", copy_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
if location_old_path.exists():
print(f"- Renaming {location}")
Utilities.process_status(self.elevated(["mv", location_old_path, f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["mv", location_old_path, f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print(f"- Renaming {location}-Backup")
Utilities.process_status(self.elevated(["mv", f"{location_old_path}-Backup", location_old_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["mv", f"{location_old_path}-Backup", location_old_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print(f"- Removing {location_old_path}-Patched")
Utilities.process_status(self.elevated(["rm", "-r", f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["rm", "-r", f"{location_old_path}-Patched"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
# ditto will create a '__MACOSX' folder
# print("- Removing __MACOSX folder")
# Utilities.process_status(self.elevated(["rm", "-r", f"{copy_path}/__MACOSX"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
# utilities.process_status(utilities.elevated(["rm", "-r", f"{copy_path}/__MACOSX"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
else:
print(f"- Failed to find {location_zip}, unable to unpatch")
@@ -200,7 +192,7 @@ class PatchSysVolume:
def unpatch_root_vol(self):
if self.constants.detected_os > self.constants.catalina:
print("- Reverting to last signed APFS snapshot")
result = self.elevated(["bless", "--mount", self.mount_location, "--bootefi", "--last-sealed-snapshot"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = utilities.elevated(["bless", "--mount", self.mount_location, "--bootefi", "--last-sealed-snapshot"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
print("- Unable to revert root volume patches")
print("Reason for unpatch Failure:")
@@ -218,9 +210,9 @@ class PatchSysVolume:
input("Press [ENTER] to continue with cache rebuild: ")
print("- Rebuilding Kernel Cache (This may take some time)")
if self.constants.detected_os > self.constants.catalina:
result = self.elevated(["kmutil", "install", "--volume-root", self.mount_location, "--update-all"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = utilities.elevated(["kmutil", "install", "--volume-root", self.mount_location, "--update-all"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
result = self.elevated(["kextcache", "-i", f"{self.mount_location}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = utilities.elevated(["kextcache", "-i", f"{self.mount_location}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# kextcache always returns 0, even if it fails
# Check the output for 'KernelCache ID' to see if the cache was successfully rebuilt
@@ -244,14 +236,14 @@ class PatchSysVolume:
input("Press [ENTER] to continue with kernel and dyld cache merging")
if self.constants.detected_os > self.constants.catalina:
print("- Creating new APFS snapshot")
self.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
utilities.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
self.unmount_drive()
else:
if self.constants.detected_os == self.constants.catalina:
print("- Merging kernel cache")
Utilities.process_status(self.elevated(["kcditto"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["kcditto"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print("- Merging dyld cache")
Utilities.process_status(self.elevated(["update_dyld_shared_cache", "-root", f"{self.mount_location}/"]))
utilities.process_status(utilities.elevated(["update_dyld_shared_cache", "-root", f"{self.mount_location}/"]))
print("- Patching complete")
print("\nPlease reboot the machine for patches to take effect")
if self.amd_ts2 is True and self.constants.allow_ts2_accel is True:
@@ -266,14 +258,14 @@ set million colour before rebooting"""
def unmount_drive(self):
print("- Unmounting Root Volume (Don't worry if this fails)")
self.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
def delete_old_binaries(self, vendor_patch):
for delete_current_kext in vendor_patch:
delete_path = Path(self.mount_extensions) / Path(delete_current_kext)
if Path(delete_path).exists():
print(f"- Deleting {delete_current_kext}")
Utilities.process_status(self.elevated(["rm", "-R", delete_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["rm", "-R", delete_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
else:
print(f"- Couldn't find {delete_current_kext}, skipping")
@@ -282,173 +274,174 @@ set million colour before rebooting"""
existing_path = Path(self.mount_extensions) / Path(add_current_kext)
if Path(existing_path).exists():
print(f"- Found conflicting kext, Deleting Root Volume's {add_current_kext}")
Utilities.process_status(self.elevated(["rm", "-R", existing_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["rm", "-R", existing_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print(f"- Adding {add_current_kext}")
Utilities.process_status(self.elevated(["cp", "-R", f"{vendor_location}/{add_current_kext}", self.mount_extensions], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["cp", "-R", f"{vendor_location}/{add_current_kext}", self.mount_extensions], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_brightness_patch(self):
self.delete_old_binaries(SysPatchArray.DeleteBrightness)
self.add_new_binaries(SysPatchArray.AddBrightness, self.constants.legacy_brightness)
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_brightness}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
Utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
self.delete_old_binaries(sys_patch_data.DeleteBrightness)
self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_brightness}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
utilities.process_status(utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_audio_patch(self):
if self.model in ["iMac7,1", "iMac8,1"]:
self.delete_old_binaries(SysPatchArray.DeleteVolumeControl)
self.add_new_binaries(SysPatchArray.AddVolumeControl, self.constants.audio_path)
self.delete_old_binaries(sys_patch_data.DeleteVolumeControl)
self.add_new_binaries(sys_patch_data.AddVolumeControl, self.constants.audio_path)
else:
self.add_new_binaries(SysPatchArray.AddVolumeControlv2, self.constants.audio_v2_path)
self.add_new_binaries(sys_patch_data.AddVolumeControlv2, self.constants.audio_v2_path)
def add_wifi_patch(self):
print("- Merging Wireless CoreSerices patches")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_coreservices}/", self.mount_coreservices], stdout=subprocess.PIPE)
Utilities.process_status(self.elevated(["chmod", "-Rf", "755", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_coreservices}/", self.mount_coreservices], stdout=subprocess.PIPE)
utilities.process_status(utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_coreservices}/WiFiAgent.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print("- Merging Wireless usr/libexec patches")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_libexec}/", self.mount_libexec], stdout=subprocess.PIPE)
Utilities.process_status(self.elevated(["chmod", "755", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "root:wheel", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_wifi_libexec}/", self.mount_libexec], stdout=subprocess.PIPE)
utilities.process_status(utilities.elevated(["chmod", "755", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chown", "root:wheel", f"{self.mount_libexec}/airportd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_legacy_mux_patch(self):
self.delete_old_binaries(SysPatchArray.DeleteDemux)
self.delete_old_binaries(sys_patch_data.DeleteDemux)
print("- Merging Legacy Mux Kext patches")
Utilities.process_status(self.elevated(["cp", "-R", f"{self.constants.legacy_mux_path}/AppleMuxControl.kext", self.mount_extensions_mux], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["cp", "-R", f"{self.constants.legacy_mux_path}/AppleMuxControl.kext", self.mount_extensions_mux], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def gpu_accel_legacy(self):
if self.constants.detected_os == self.constants.mojave:
print("- Installing General Acceleration Kext patches for Mojave")
self.add_new_binaries(SysPatchArray.AddGeneralAccelMojave, self.constants.legacy_general_path)
self.add_new_binaries(sys_patch_data.AddGeneralAccelMojave, self.constants.legacy_general_path)
elif self.constants.detected_os == self.constants.catalina:
print("- Installing General Acceleration Kext patches for Catalina")
self.add_new_binaries(SysPatchArray.AddGeneralAccelCatalina, self.constants.legacy_general_path)
self.add_new_binaries(sys_patch_data.AddGeneralAccelCatalina, self.constants.legacy_general_path)
elif self.constants.detected_os in [self.constants.big_sur, self.constants.monterey]:
print("- Installing General Acceleration Kext patches for Big Sur/Monterey")
self.add_new_binaries(SysPatchArray.AddGeneralAccel, self.constants.legacy_general_path)
self.add_new_binaries(sys_patch_data.AddGeneralAccel, self.constants.legacy_general_path)
# Nvidia
def gpu_accel_legacy_nvidia_master(self):
if self.constants.detected_os in [self.constants.mojave, self.constants.catalina]:
print("- Installing Nvidia Acceleration Kext patches for Mojave/Catalina")
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddNvidiaAccelLegacy, self.constants.legacy_nvidia_path)
self.add_new_binaries(sys_patch_data.AddNvidiaAccelLegacy, self.constants.legacy_nvidia_path)
elif self.constants.detected_os in [self.constants.big_sur, self.constants.monterey]:
print("- Installing Nvidia Acceleration Kext patches for Big Sur/Monterey")
self.delete_old_binaries(SysPatchArray.DeleteNvidiaAccel11)
self.delete_old_binaries(sys_patch_data.DeleteNvidiaAccel11)
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path)
self.add_new_binaries(sys_patch_data.AddNvidiaAccel11, self.constants.legacy_nvidia_path)
if self.constants.detected_os == self.constants.monterey and self.constants.detected_os_minor > 0:
# Beta 7+ removes NVDAStartup
self.add_new_binaries(SysPatchArray.AddNvidiaTeslaAccel12, self.constants.legacy_nvidia_kepler_path)
self.add_new_binaries(sys_patch_data.AddNvidiaTeslaAccel12, self.constants.legacy_nvidia_kepler_path)
else:
print("- Installing basic Nvidia Framebuffer Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddNvidiaBrightness, self.constants.legacy_nvidia_path)
self.add_new_binaries(sys_patch_data.AddNvidiaBrightness, self.constants.legacy_nvidia_path)
# AMD/ATI
def gpu_accel_legacy_ts1_master(self):
if self.constants.detected_os in [self.constants.mojave, self.constants.catalina]:
print("- Installing TeraScale 1 Acceleration Kext patches for Mojave/Catalina")
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddAMDAccelLegacy, self.constants.legacy_amd_path)
self.add_new_binaries(sys_patch_data.AddAMDAccelLegacy, self.constants.legacy_amd_path)
elif self.constants.detected_os in [self.constants.big_sur, self.constants.monterey]:
print("- Installing TeraScale 1 Acceleration Kext patches for Big Sur/Monterey")
self.delete_old_binaries(SysPatchArray.DeleteAMDAccel11)
self.delete_old_binaries(sys_patch_data.DeleteAMDAccel11)
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddAMDAccel11, self.constants.legacy_amd_path)
self.add_new_binaries(sys_patch_data.AddAMDAccel11, self.constants.legacy_amd_path)
else:
print("- Installing basic TeraScale 1 Framebuffer Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddAMDBrightness, self.constants.legacy_amd_path)
self.add_new_binaries(sys_patch_data.AddAMDBrightness, self.constants.legacy_amd_path)
def gpu_accel_legacy_ts2_master(self):
if self.constants.detected_os in [self.constants.mojave, self.constants.catalina] and self.constants.allow_ts2_accel is True:
print("- Installing TeraScale 2 Acceleration Kext patches for Mojave/Catalina")
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddAMDAccelLegacy, self.constants.legacy_amd_path)
self.add_new_binaries(sys_patch_data.AddAMDAccelLegacy, self.constants.legacy_amd_path)
elif self.constants.detected_os in [self.constants.big_sur, self.constants.monterey] and self.constants.allow_ts2_accel is True:
# TODO: Enable for Monterey when acceleration patches proress
print("- Installing TeraScale 2 Acceleration Kext patches for Big Sur")
self.delete_old_binaries(SysPatchArray.DeleteAMDAccel11)
self.delete_old_binaries(SysPatchArray.DeleteAMDAccel11TS2)
self.delete_old_binaries(sys_patch_data.DeleteAMDAccel11)
self.delete_old_binaries(sys_patch_data.DeleteAMDAccel11TS2)
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddAMDAccel11, self.constants.legacy_amd_path)
self.add_new_binaries(sys_patch_data.AddAMDAccel11, self.constants.legacy_amd_path)
else:
print("- Installing basic TeraScale 2 Framebuffer Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddAMDBrightness, self.constants.legacy_amd_path)
self.add_new_binaries(sys_patch_data.AddAMDBrightness, self.constants.legacy_amd_path)
# Intel
def gpu_accel_legacy_ironlake_master(self):
if self.constants.detected_os in [self.constants.mojave, self.constants.catalina]:
print("- Installing Ironlake Acceleration Kext patches for Mojave/Catalina")
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path)
self.add_new_binaries(sys_patch_data.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path)
elif self.constants.detected_os in [self.constants.big_sur, self.constants.monterey]:
print("- Installing Ironlake Acceleration Kext patches for Big Sur/Monterey")
self.delete_old_binaries(SysPatchArray.DeleteNvidiaAccel11)
self.delete_old_binaries(sys_patch_data.DeleteNvidiaAccel11)
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path)
self.add_new_binaries(sys_patch_data.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path)
else:
print("- Installing basic Ironlake Framebuffer Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path)
self.add_new_binaries(sys_patch_data.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path)
def gpu_accel_legacy_sandybridge_master(self):
if self.constants.detected_os in [self.constants.mojave, self.constants.catalina]:
print("- Installing Sandy Bridge Acceleration Kext patches for Mojave/Catalina")
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
self.add_new_binaries(sys_patch_data.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
elif self.constants.detected_os in [self.constants.big_sur, self.constants.monterey]:
print("- Installing Sandy Bridge Acceleration Kext patches for Big Sur/Monterey")
self.delete_old_binaries(SysPatchArray.DeleteNvidiaAccel11)
self.delete_old_binaries(sys_patch_data.DeleteNvidiaAccel11)
self.gpu_accel_legacy()
self.add_new_binaries(SysPatchArray.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
self.add_new_binaries(sys_patch_data.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
else:
print("- Installing basic Sandy Bridge Framebuffer Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
self.add_new_binaries(sys_patch_data.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path)
def gpu_framebuffer_ivybridge_master(self):
if self.constants.detected_os == self.constants.monterey:
print("- Installing IvyBridge Acceleration Kext patches for Monterey")
self.add_new_binaries(SysPatchArray.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path)
self.add_new_binaries(sys_patch_data.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path)
if self.validate is False:
print("- Fixing Acceleration in CoreMedia")
Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.coremedia", "hardwareVideoDecoder", "-string", "enable"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(subprocess.run(["defaults", "write", "com.apple.coremedia", "hardwareVideoDecoder", "-string", "enable"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
print("- Merging Ivy Bridge Frameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("- Merging Ivy Bridge PrivateFrameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ivy}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ivy}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
else:
print("- Installing basic Ivy Bridge Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path)
self.add_new_binaries(sys_patch_data.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path)
def gpu_framebuffer_kepler_master(self):
if self.constants.detected_os == self.constants.monterey:
print("- Installing Kepler Acceleration Kext patches for Monterey")
self.add_new_binaries(SysPatchArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path)
self.add_new_binaries(sys_patch_data.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path)
else:
print("- Installing Kepler Kext patches for generic OS")
self.add_new_binaries(SysPatchArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path)
self.add_new_binaries(sys_patch_data.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path)
def gpu_accel_legacy_extended(self):
print("- Merging general legacy Frameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if self.constants.detected_os > self.constants.big_sur:
print("- Merging Monterey WebKit patch")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ivy}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("- Merging general legacy PrivateFrameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
if self.constants.detected_os > self.constants.catalina:
print("- Adding IOHID-Fixup.plist")
Utilities.process_status(
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_lauchd_path_accel}/", self.mount_lauchd], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
utilities.process_status(
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_lauchd_path_accel}/", self.mount_lauchd], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
)
Utilities.process_status(self.elevated(["chmod", "755", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
Utilities.process_status(self.elevated(["chown", "root:wheel", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chmod", "755", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(utilities.elevated(["chown", "root:wheel", f"{self.mount_lauchd}/IOHID-Fixup.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
else:
print("- Disabling Library Validation")
Utilities.process_status(
self.elevated(
utilities.process_status(
utilities.elevated(
["defaults", "write", "/Library/Preferences/com.apple.security.libraryvalidation.plist", "DisableLibraryValidation", "-bool", "true"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
@@ -457,13 +450,13 @@ set million colour before rebooting"""
def gpu_accel_legacy_extended_ts2(self):
print("- Merging TeraScale 2 legacy Frameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ts2}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel_ts2}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("- Merging TeraScale 2 PrivateFrameworks")
self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ts2}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_private_frameworks_path_accel_ts2}/", self.mount_private_frameworks], stdout=subprocess.PIPE)
if self.validate is False:
print("- Fixing Acceleration in CMIO")
Utilities.process_status(subprocess.run(["defaults", "write", "com.apple.cmio", "CMIO_Unit_Input_ASC.DoNotUseOpenCL", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
utilities.process_status(subprocess.run(["defaults", "write", "com.apple.cmio", "CMIO_Unit_Input_ASC.DoNotUseOpenCL", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def patch_root_vol(self):
print(f"- Running patches for {self.model}")
@@ -531,7 +524,7 @@ set million colour before rebooting"""
if self.amd_ts2 is True and self.constants.detected_os in self.constants.legacy_accel_support and self.constants.allow_ts2_accel is True:
# TeraScale 2 patches must be installed after Intel HD3000
self.add_new_binaries(SysPatchArray.AddAMDAccel11TS2, self.constants.legacy_amd_path_ts2)
self.add_new_binaries(sys_patch_data.AddAMDAccel11TS2, self.constants.legacy_amd_path_ts2)
if self.added_legacy_kexts is True and self.constants.detected_os in self.constants.legacy_accel_support:
self.gpu_accel_legacy_extended()
@@ -598,13 +591,13 @@ set million colour before rebooting"""
print(f"- Duplicating into Apple.zip")
shutil.copy(local_zip, self.constants.payload_apple_root_path_zip)
else:
Utilities.download_file(link, self.constants.payload_apple_root_path_zip)
utilities.download_file(link, self.constants.payload_apple_root_path_zip)
if self.constants.payload_apple_root_path_zip.exists():
print("- Download completed")
print("- Unzipping download...")
try:
Utilities.process_status(subprocess.run(["unzip", self.constants.payload_apple_root_path_zip], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.constants.payload_path))
utilities.process_status(subprocess.run(["unzip", self.constants.payload_apple_root_path_zip], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.constants.payload_path))
print("- Renaming folder")
os.rename(self.constants.payload_path / Path(os_ver), self.constants.payload_apple_root_path)
Path(self.constants.payload_apple_root_path_zip).unlink()
@@ -629,7 +622,7 @@ set million colour before rebooting"""
i = 0
for gpu in gpus:
if gpu.class_code and gpu.class_code != 0xFFFFFFFF:
print(f"- Found GPU ({i}): {Utilities.friendly_hex(gpu.vendor_id)}:{Utilities.friendly_hex(gpu.device_id)}")
print(f"- Found GPU ({i}): {utilities.friendly_hex(gpu.vendor_id)}:{utilities.friendly_hex(gpu.device_id)}")
if gpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]:
if self.constants.detected_os > non_metal_os:
self.nvidia_legacy = True
@@ -678,7 +671,7 @@ set million colour before rebooting"""
def detect_demux(self):
# If GFX0 is missing, assume machine was demuxed
# -wegnoegpu would also trigger this, so ensure arg is not present
if not "-wegnoegpu" in (Utilities.get_nvram("boot-args") or ""):
if not "-wegnoegpu" in (utilities.get_nvram("boot-args") or ""):
igpu = self.constants.computer.igpu
dgpu = self.constants.computer.dgpu
if igpu and not dgpu:
@@ -688,11 +681,11 @@ set million colour before rebooting"""
def detect_patch_set(self):
self.detect_gpus()
if self.model in ModelArray.LegacyBrightness:
if self.model in model_array.LegacyBrightness:
if self.constants.detected_os > self.constants.catalina:
self.brightness_legacy = True
if self.model in ["iMac7,1", "iMac8,1"] or (self.model in ModelArray.LegacyAudio and Utilities.check_kext_loaded("AppleALC", self.constants.detected_os) is False):
if self.model in ["iMac7,1", "iMac8,1"] or (self.model in model_array.LegacyAudio and utilities.check_kext_loaded("AppleALC", self.constants.detected_os) is False):
# Special hack for systems with botched GOPs
# TL;DR: No Boot Screen breaks Lilu, therefore breaking audio
if self.constants.detected_os > self.constants.catalina:
@@ -716,7 +709,7 @@ set million colour before rebooting"""
else:
self.legacy_gmux = True
Utilities.cls()
utilities.cls()
print("The following patches will be applied:")
if self.nvidia_legacy is True:
print("- Add Legacy Nvidia Tesla Graphics Patch")
@@ -758,14 +751,14 @@ set million colour before rebooting"""
)
def verify_patch_allowed(self):
sip = self.constants.root_patch_sip_big_sur if self.constants.detected_os > self.constants.catalina else self.constants.root_patch_sip_mojave
if sip == self.constants.root_patch_sip_mojave:
sip = sip_data.system_integrity_protection.root_patch_sip_big_sur if self.constants.detected_os > self.constants.catalina else sip_data.system_integrity_protection.root_patch_sip_mojave
if sip == sip_data.system_integrity_protection.root_patch_sip_mojave:
sip_value = "For Hackintoshes, please set csr-active-config to '03060000' (0x603)\nFor non-OpenCore Macs, please run 'csrutil disable' in RecoveryOS"
else:
sip_value = (
"For Hackintoshes, please set csr-active-config to '030E0000' (0xE03)\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS"
)
self.sip_enabled, self.sbm_enabled, self.amfi_enabled, self.fv_enabled, self.dosdude_patched = Utilities.patching_status(sip, self.constants.detected_os)
self.sip_enabled, self.sbm_enabled, self.amfi_enabled, self.fv_enabled, self.dosdude_patched = utilities.patching_status(sip, self.constants.detected_os)
if self.sip_enabled is True:
print("\nCannot patch! Please disable System Integrity Protection (SIP).")
print("Disable SIP in Patcher Settings and Rebuild OpenCore\n")

View File

@@ -7,9 +7,9 @@ import os
import plistlib
import subprocess
from pathlib import Path
import re
import os
import binascii
import argparse
try:
import requests
@@ -20,7 +20,8 @@ except ImportError:
except ImportError:
raise Exception("Missing requests library!\nPlease run the following before starting OCLP:\npip3 install requests")
from Resources import Constants, ioreg, device_probe
from resources import constants, ioreg
from data import sip_data
def hexswap(input_hex: str):
@@ -91,42 +92,18 @@ def check_seal():
return False
def latebloom_detection(model):
if model in ["MacPro4,1", "MacPro5,1", "iMac7,1", "iMac8,1"]:
# These machines are more likely to experience boot hangs, increase delays to accomodate
lb_delay = "250"
else:
lb_delay = "100"
lb_range = "1"
lb_debug = "1"
boot_args = get_nvram("boot-args", decode=False)
# boot_args = "latebloom=200 lb_range=40 lb_debug=0 keepsyms=1 debug=0x100 -lilubetaall"
if boot_args:
# TODO: This crashes if latebloom=xxx is the very first entry in boot-args
if "latebloom=" in boot_args:
lb_delay = re.search(r"(?:[, ])latebloom=(\d+)", boot_args)
lb_delay = lb_delay[1]
if "lb_range=" in boot_args:
lb_range = re.search(r"(?:[, ])lb_range=(\d+)", boot_args)
lb_range = lb_range[1]
if "lb_debug=" in boot_args:
lb_debug = re.search(r"(?:[, ])lb_debug=(\d+)", boot_args)
lb_debug = lb_debug[1]
return int(lb_delay), int(lb_range), int(lb_debug)
def csr_decode(csr_active_config, os_sip):
if csr_active_config is None:
csr_active_config = b"\x00\x00\x00\x00"
sip_int = int.from_bytes(csr_active_config, byteorder="little")
i = 0
for current_sip_bit in Constants.Constants.csr_values:
for current_sip_bit in sip_data.system_integrity_protection.csr_values:
if sip_int & (1 << i):
Constants.Constants.csr_values[current_sip_bit] = True
sip_data.system_integrity_protection.csr_values[current_sip_bit] = True
i = i + 1
# Can be adjusted to whatever OS needs patching
sip_needs_change = all(Constants.Constants.csr_values[i] for i in os_sip)
sip_needs_change = all(sip_data.system_integrity_protection.csr_values[i] for i in os_sip)
if sip_needs_change is True:
return False
else:
@@ -153,7 +130,7 @@ def amfi_status():
return True
def check_kext_loaded(kext_name, os_version):
if os_version > Constants.Constants().catalina:
if os_version > constants.Constants().catalina:
kext_loaded = subprocess.run(["kmutil", "showloaded", "--list-only", "--variant-suffix", "release"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
kext_loaded = subprocess.run(["kextstat", "-l"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -211,19 +188,19 @@ def patching_status(os_sip, os):
gen6_kext = "/System/Library/Extension/AppleIntelHDGraphics.kext"
gen7_kext = "/System/Library/Extension/AppleIntelHD3000Graphics.kext"
if os > Constants.Constants().catalina:
if os > constants.Constants().catalina:
amfi_enabled = amfi_status()
else:
# Catalina and older supports individually disabling Library Validation
amfi_enabled = False
if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in Constants.Constants.sbm_values:
if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in constants.Constants.sbm_values:
sbm_enabled = False
if get_nvram("csr-active-config", decode=False) and csr_decode(get_nvram("csr-active-config", decode=False), os_sip) is False:
sip_enabled = False
if os > Constants.Constants().catalina and not check_filevault_skip():
if os > constants.Constants().catalina and not check_filevault_skip():
# Assume non-OCLP Macs do not have our APFS seal patch
fv_status: str = subprocess.run("fdesetup status".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if "FileVault is Off" in fv_status:
@@ -249,11 +226,12 @@ def cls():
global clear
if not clear:
return
if not check_recovery():
os.system("cls" if os.name == "nt" else "clear")
else:
print("\u001Bc")
if check_cli_args() is None:
# Our GUI does not support clear screen
if not check_recovery():
os.system("cls" if os.name == "nt" else "clear")
else:
print("\u001Bc")
def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
# TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to
@@ -321,19 +299,55 @@ def download_file(link, location):
chunk = file.read(1024 * 1024 * 16)
return checksum
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
# When runnign through our GUI, we run as root, however we do not get uid 0
# Best to assume CLI is running as root
if os.getuid() == 0 or check_cli_args() is not None:
return subprocess.run(*args, **kwargs)
else:
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
def enable_apfs(fw_feature):
fw_feature |= 2 ** 19 # Enable FW_FEATURE_SUPPORTS_APFS
return fw_feature
def check_cli_args():
parser = argparse.ArgumentParser()
parser.add_argument("--build", help="Build OpenCore", action="store_true", required=False)
parser.add_argument("--verbose", help="Enable verbose boot", action="store_true", required=False)
parser.add_argument("--debug_oc", help="Enable OpenCore DEBUG", action="store_true", required=False)
parser.add_argument("--debug_kext", help="Enable kext DEBUG", action="store_true", required=False)
parser.add_argument("--hide_picker", help="Hide OpenCore picker", action="store_true", required=False)
parser.add_argument("--disable_sip", help="Disable SIP", action="store_true", required=False)
parser.add_argument("--disable_smb", help="Disable SecureBootModel", action="store_true", required=False)
parser.add_argument("--vault", help="Enable OpenCore Vaulting", action="store_true", required=False)
parser.add_argument("--support_all", help="Allow OpenCore on natively supported Models", action="store_true", required=False)
parser.add_argument("--firewire", help="Enable FireWire Booting", action="store_true", required=False)
parser.add_argument("--nvme", help="Enable NVMe Booting", action="store_true", required=False)
parser.add_argument("--wlan", help="Enable Wake on WLAN support", action="store_true", required=False)
# parser.add_argument("--disable_amfi", help="Disable AMFI", action="store_true", required=False)
parser.add_argument("--moderate_smbios", help="Moderate SMBIOS Patching", action="store_true", required=False)
parser.add_argument("--moj_cat_accel", help="Allow Root Patching on Mojave and Catalina", action="store_true", required=False)
parser.add_argument("--disable_tb", help="Disable Thunderbolt on 2013-2014 MacBook Pros", action="store_true", required=False)
parser.add_argument("--force_surplus", help="Force SurPlus in all newer OSes", action="store_true", required=False)
def enable_apfs_extended(fw_feature):
fw_feature |= 2 ** 20 # Enable FW_FEATURE_SUPPORTS_APFS_EXTRA
return fw_feature
# Building args requiring value values (ie. --model iMac12,2)
parser.add_argument("--model", action="store", help="Set custom model", required=False)
parser.add_argument("--disk", action="store", help="Specifies disk to install to", required=False)
parser.add_argument("--smbios_spoof", action="store", help="Set SMBIOS patching mode", required=False)
def enable_large_basesystem(fw_feature):
fw_feature |= 2 ** 35 # Enable FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
return fw_feature
# sys_patch args
parser.add_argument("--patch_sys_vol", help="Patches root volume", action="store_true", required=False)
parser.add_argument("--unpatch_sys_vol", help="Unpatches root volume, EXPERIMENTAL", action="store_true", required=False)
# validation args
parser.add_argument("--validate", help="Runs Validation Tests for CI", action="store_true", required=False)
args = parser.parse_args()
if not(
args.build or
args.patch_sys_vol or
args.unpatch_sys_vol or
args.validate
):
return None
else:
return args
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
# return_option = ["Q", "Quit", None] if top_level else ["B", "Back", None]

71
resources/validation.py Normal file
View File

@@ -0,0 +1,71 @@
import subprocess
from resources import build
from data import example_data, model_array
def validate(settings):
# Runs through ocvalidate to check for errors
valid_dumps = [
example_data.MacBookPro.MacBookPro92_Stock,
# example_data.MacBookPro.MacBookPro171_Stock,
# example_data.Macmini.Macmini91_Stock,
example_data.iMac.iMac81_Stock,
example_data.iMac.iMac112_Stock,
example_data.iMac.iMac122_Upgraded,
example_data.MacPro.MacPro31_Stock,
example_data.MacPro.MacPro31_Upgrade,
example_data.MacPro.MacPro31_Modern_AMD,
example_data.MacPro.MacPro31_Modern_Kepler,
example_data.MacPro.MacPro41_Upgrade,
example_data.MacPro.MacPro41_Modern_AMD,
example_data.MacPro.MacPro41_51__Flashed_Modern_AMD,
]
settings.validate = True
def build_prebuilt():
for model in model_array.SupportedSMBIOS:
print(f"Validating predefined model: {model}")
settings.custom_model = model
build.BuildOpenCore(settings.custom_model, settings).build_opencore()
result = subprocess.run([settings.ocvalidate_path, f"{settings.opencore_release_folder}/EFI/OC/config.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
print("Error on build!")
print(result.stdout.decode())
raise Exception(f"Validation failed for predefined model: {model}")
else:
print(f"Validation succeeded for predefined model: {model}")
def build_dumps():
for model in valid_dumps:
settings.computer = model
settings.custom_model = ""
print(f"Validating dumped model: {settings.computer.real_model}")
build.BuildOpenCore(settings.computer.real_model, settings).build_opencore()
result = subprocess.run([settings.ocvalidate_path, f"{settings.opencore_release_folder}/EFI/OC/config.plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
print("Error on build!")
print(result.stdout.decode())
raise Exception(f"Validation failed for predefined model: {settings.computer.real_model}")
else:
print(f"Validation succeeded for predefined model: {settings.computer.real_model}")
# First run is with default settings
build_prebuilt()
build_dumps()
# Second run, flip all settings
settings.verbose_debug = True
settings.opencore_debug = True
settings.opencore_build = "DEBUG"
settings.kext_debug = True
settings.showpicker = False
settings.sip_status = False
settings.secure_status = True
settings.firewire_boot = True
settings.nvme_boot = True
settings.enable_wake_on_wlan = True
settings.disable_tb = True
settings.force_surplus = True
build_prebuilt()
build_dumps()