From 8f7df604af6dafeb1cf110a67d30006b1f1f6a01 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Wed, 25 May 2022 17:11:50 -0600 Subject: [PATCH 01/31] Implement Alpha Support for Nvidia Web Drivers --- data/sys_patch_dict.py | 20 ++++++++++++++++++++ resources/build.py | 10 ++++++++++ resources/constants.py | 2 +- resources/sys_patch_detect.py | 8 ++++++-- resources/utilities.py | 2 ++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/data/sys_patch_dict.py b/data/sys_patch_dict.py index f9a257136..315c6e4ec 100644 --- a/data/sys_patch_dict.py +++ b/data/sys_patch_dict.py @@ -123,6 +123,26 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support): }, }, + "Non-Metal CoreDisplay Common": { + # Nvidia Web Drivers require an older build of CoreDisplay + "Display Name": "", + "OS Support": { + "Minimum OS Support": { + "OS Major": non_metal_os_support[0], + "OS Minor": 0 + }, + "Maximum OS Support": { + "OS Major": non_metal_os_support[-1], + "OS Minor": 99 + }, + }, + "Install": { + "/System/Library/Frameworks": { + "CoreDisplay.framework": f"10.13.6-{os_major}", + }, + }, + }, + "Non-Metal Enforcement": { # Forces Metal kexts from High Sierra to run in the fallback non-Metal mode # Verified functional with HD4000 and Iris Plus 655 diff --git a/resources/build.py b/resources/build.py index ade662216..971b9ab1e 100644 --- a/resources/build.py +++ b/resources/build.py @@ -689,6 +689,12 @@ class BuildOpenCore: self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True + if device.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + print("- Adding Web Driver Patches") + self.config["DeviceProperties"]["Add"][device.pci_path].update({"disable-metal": 1, "force-compat": 1}) + if "nvda_drv_vrl=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " nvda_drv_vrl=1" + else: print(f"- Failed to find Device path for dGPU {i + 1}") if isinstance(device, device_probe.AMD): @@ -705,6 +711,10 @@ class BuildOpenCore: self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -wegtree agdpmod=vit9696" self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True + if device.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + if "ngfxgl=1 ngfxcompat=1 nvda_drv_vrl=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + print("- Adding Web Driver Patches") + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1 nvda_drv_vrl=1" if not self.computer.gpus: print("- No socketed dGPU found") diff --git a/resources/constants.py b/resources/constants.py index 62a02a8a1..ec637f142 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -15,7 +15,7 @@ class Constants: def __init__(self): # Patcher Versioning self.patcher_version = "0.4.6" # OpenCore-Legacy-Patcher - self.patcher_support_pkg_version = "0.4.1" # PatcherSupportPkg + self.patcher_support_pkg_version = "0.5.0" # PatcherSupportPkg self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/" self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/" self.discord_link = "https://discord.gg/rqdPgH8xSN" diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 62e5c13f3..2ac5774b2 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -65,6 +65,7 @@ class detect_root_patch: elif gpu.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: if self.constants.detected_os > os_data.os_data.mojave: self.nvidia_web = True + self.amfi_must_disable = True elif gpu.arch == device_probe.AMD.Archs.TeraScale_1: if self.constants.detected_os > non_metal_os: self.amd_ts1 = True @@ -91,6 +92,7 @@ class detect_root_patch: # Avoid patching Metal and non-Metal GPUs if both present, prioritize Metal GPU # Main concerns are for iMac12,x with Sandy iGPU and Kepler dGPU self.nvidia_tesla = False + self.nvidia_web = False self.amd_ts1 = False self.amd_ts2 = False self.iron_gpu = False @@ -159,8 +161,8 @@ class detect_root_patch: self.root_patch_dict = { "Graphics: Nvidia Tesla": self.nvidia_tesla, "Graphics: Nvidia Kepler": self.kepler_gpu, - # "Graphics: Nvidia Web Drivers": self.nvidia_web, - "Graphics: Nvidia Web Drivers": False, + "Graphics: Nvidia Web Drivers": self.nvidia_web, + # "Graphics: Nvidia Web Drivers": False, "Graphics: AMD TeraScale 1": self.amd_ts1, "Graphics: AMD TeraScale 2": self.amd_ts2, "Graphics: Intel Ironlake": self.iron_gpu, @@ -245,7 +247,9 @@ class detect_root_patch: if hardware_details["Graphics: Nvidia Web Drivers"] is True: required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) required_patches.update({"Non-Metal IOAccelerator Common": all_hardware_patchset["Graphics"]["Non-Metal IOAccelerator Common"]}) + required_patches.update({"Non-Metal CoreDisplay Common": all_hardware_patchset["Graphics"]["Non-Metal CoreDisplay Common"]}) required_patches.update({"Nvidia Web Drivers": all_hardware_patchset["Graphics"]["Nvidia Web Drivers"]}) + required_patches.update({"Non-Metal Enforcement": all_hardware_patchset["Graphics"]["Non-Metal Enforcement"]}) if hardware_details["Graphics: Nvidia Kepler"] is True: required_patches.update({"Metal Common": all_hardware_patchset["Graphics"]["Metal Common"]}) required_patches.update({"Nvidia Kepler": all_hardware_patchset["Graphics"]["Nvidia Kepler"]}) diff --git a/resources/utilities.py b/resources/utilities.py index cb33247b4..d3f7abc03 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -197,6 +197,8 @@ def check_metal_support(device_probe, computer): (gpu.arch in [ device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi, + device_probe.NVIDIA.Archs.Maxwell, + device_probe.NVIDIA.Archs.Pascal, device_probe.AMD.Archs.TeraScale_1, device_probe.AMD.Archs.TeraScale_2, device_probe.Intel.Archs.Iron_Lake, From a2858a1ecf56f902133d5c010c9e69b40d06494f Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Wed, 25 May 2022 19:06:54 -0600 Subject: [PATCH 02/31] build.py: Add WhateverGreen for Web Driver configs --- resources/build.py | 4 ++++ resources/validation.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/build.py b/resources/build.py index 971b9ab1e..afdd3f65a 100644 --- a/resources/build.py +++ b/resources/build.py @@ -694,6 +694,8 @@ class BuildOpenCore: self.config["DeviceProperties"]["Add"][device.pci_path].update({"disable-metal": 1, "force-compat": 1}) if "nvda_drv_vrl=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " nvda_drv_vrl=1" + if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: + self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) else: print(f"- Failed to find Device path for dGPU {i + 1}") @@ -715,6 +717,8 @@ class BuildOpenCore: if "ngfxgl=1 ngfxcompat=1 nvda_drv_vrl=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: print("- Adding Web Driver Patches") self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1 nvda_drv_vrl=1" + if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: + self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) if not self.computer.gpus: print("- No socketed dGPU found") diff --git a/resources/validation.py b/resources/validation.py index 337c55cf6..71b6ffefb 100644 --- a/resources/validation.py +++ b/resources/validation.py @@ -66,8 +66,6 @@ def validate(settings): host_os_float = float(f"{major_kernel}.{minor_kernel}") for patch_subject in patchset: for patch_core in patchset[patch_subject]: - if patch_core == "Nvidia Web Drivers": - continue patch_os_min_float = float(f'{patchset[patch_subject][patch_core]["OS Support"]["Minimum OS Support"]["OS Major"]}.{patchset[patch_subject][patch_core]["OS Support"]["Minimum OS Support"]["OS Minor"]}') patch_os_max_float = float(f'{patchset[patch_subject][patch_core]["OS Support"]["Maximum OS Support"]["OS Major"]}.{patchset[patch_subject][patch_core]["OS Support"]["Maximum OS Support"]["OS Minor"]}') if (host_os_float < patch_os_min_float or host_os_float > patch_os_max_float): From 87df6151505d63c068e2c0c4c7854ec8221aa91e Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Wed, 25 May 2022 21:03:05 -0600 Subject: [PATCH 03/31] build.py: Move nvda_drv to dedicated entry --- resources/build.py | 14 +++++++++----- resources/defaults.py | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/resources/build.py b/resources/build.py index afdd3f65a..2ca896d5d 100644 --- a/resources/build.py +++ b/resources/build.py @@ -692,10 +692,11 @@ class BuildOpenCore: if device.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: print("- Adding Web Driver Patches") self.config["DeviceProperties"]["Add"][device.pci_path].update({"disable-metal": 1, "force-compat": 1}) - if "nvda_drv_vrl=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " nvda_drv_vrl=1" if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].update({"nvda_drv": binascii.unhexlify("31")}) + if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]: + self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"] else: print(f"- Failed to find Device path for dGPU {i + 1}") @@ -714,11 +715,14 @@ class BuildOpenCore: self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True if device.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: - if "ngfxgl=1 ngfxcompat=1 nvda_drv_vrl=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: - print("- Adding Web Driver Patches") - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1 nvda_drv_vrl=1" + print("- Adding Web Driver Patches") + if "ngfxgl=1 ngfxcompat=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1" if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].update({"nvda_drv": binascii.unhexlify("31")}) + if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]: + self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"] if not self.computer.gpus: print("- No socketed dGPU found") diff --git a/resources/defaults.py b/resources/defaults.py index 58af072f3..9770c9df6 100644 --- a/resources/defaults.py +++ b/resources/defaults.py @@ -47,6 +47,9 @@ class generate_defaults: settings.amfi_status = True settings.allow_fv_root = True # Allow FileVault on broken seal break + elif gpu.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + settings.custom_sip_value = "0xA03" + break if ( isinstance(settings.computer.wifi, device_probe.Broadcom) and settings.computer.wifi.chipset in [device_probe.Broadcom.Chipsets.AirPortBrcm4331, device_probe.Broadcom.Chipsets.AirPortBrcm43224] From 035d441cb94092c1cb7d49fa4a84ffdd9df5c1b8 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 26 May 2022 18:43:59 -0600 Subject: [PATCH 04/31] sys_patch_dict.py: Remove Nvidia Pref Pane Broken in Mojave and newer, unneeded for ourselves --- data/sys_patch_dict.py | 9 ++++++--- resources/sys_patch.py | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/data/sys_patch_dict.py b/data/sys_patch_dict.py index 315c6e4ec..d86ca3c4a 100644 --- a/data/sys_patch_dict.py +++ b/data/sys_patch_dict.py @@ -303,9 +303,12 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support): "NVDANV50HalTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", "NVDAResmanTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", }, - "/Library/PreferencePanes": { - "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", - }, + + # Nvidia's control panel crashes on 10.14+ + # For us, no real point in using it so ignore + # "/Library/PreferencePanes": { + # "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", + # }, }, }, "AMD TeraScale Common": { diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 921cd395b..e92860648 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -114,14 +114,17 @@ class PatchSysVolume: def rebuild_snapshot(self): print("- Rebuilding Kernel Cache (This may take some time)") - args = ["kmutil", "install", "--volume-root", self.mount_location, "--update-all"] + if self.constants.detected_os > os_data.os_data.catalina: + args = ["kmutil", "install", "--volume-root", self.mount_location, "--update-all"] - if self.needs_kmutil_exemptions is True: - # When installing to '/Library/Extensions', following args skip kext consent - # prompt in System Preferences when SIP's disabled - print("- Disabling auth checks in kmutil") - args.append("--no-authentication") - args.append("--no-authorization") + if self.needs_kmutil_exemptions is True: + # When installing to '/Library/Extensions', following args skip kext consent + # prompt in System Preferences when SIP's disabled + print("- Disabling auth checks in kmutil") + args.append("--no-authentication") + args.append("--no-authorization") + else: + args = ["kextcache", "-i", f"{self.mount_location}/"] result = utilities.elevated(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -132,7 +135,7 @@ class PatchSysVolume: # - will return 71 on failure to build KCs # - will return 31 on 'No binaries or codeless kexts were provided' # - will return -10 if the volume is missing (ie. unmounted by another process) - if result.returncode != 0: + if result.returncode != 0 or (self.constants.detected_os < os_data.os_data.catalina and "KernelCache ID" not in result.stdout.decode()): print("- Unable to build new kernel cache") print(f"\nReason for Patch Failure ({result.returncode}):") print(result.stdout.decode()) @@ -142,6 +145,8 @@ class PatchSysVolume: input("Press [ENTER] to continue") else: print("- Successfully built new kernel cache") + self.update_preboot_kernel_cache() + self.rebuild_dyld_shared_cache() if self.root_supports_snapshot is True: print("- Creating new APFS snapshot") bless = utilities.elevated( @@ -166,6 +171,15 @@ class PatchSysVolume: print("- Unmounting Root Volume (Don't worry if this fails)") utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() + def rebuild_dyld_shared_cache(self): + if self.constants.detected_os <= os_data.os_data.catalina: + print("- Rebuilding dyld shared cache") + utilities.process_status(utilities.elevated(["update_dyld_shared_cache", "-root", f"{self.mount_location}/"])) + + def update_preboot_kernel_cache(self): + if self.constants.detected_os == os_data.os_data.catalina: + print("- Rebuilding preboot kernel cache") + utilities.process_status(utilities.elevated(["kcditto"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) def clean_skylight_plugins(self): if (Path(self.mount_application_support) / Path("SkyLightPlugins/")).exists(): From 61ef7fe81ba5c826c2208e727fc0f531ae97ff6a Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 26 May 2022 20:10:41 -0600 Subject: [PATCH 05/31] Add M4000 PCI ID --- data/pci_data.py | 1 + resources/build.py | 4 ++-- resources/defaults.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/pci_data.py b/data/pci_data.py index 5a40fd1c3..6e8a72700 100644 --- a/data/pci_data.py +++ b/data/pci_data.py @@ -543,6 +543,7 @@ class nvidia_ids: 0x13d7, # GM204 [GeForce GTX 980M] 0x13d8, # GM204 [GeForce GTX 970M] 0x13d9, # GM204 [GeForce GTX 965M] + 0x13F1, # GM204 [Quadro M4000] 0x1401, # GM206 [GeForce GTX 960] 0x1407, # GM206 [GeForce GTX 750 v2] diff --git a/resources/build.py b/resources/build.py index 2ca896d5d..e06ec7c66 100644 --- a/resources/build.py +++ b/resources/build.py @@ -689,7 +689,7 @@ class BuildOpenCore: self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - if device.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + if device.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: print("- Adding Web Driver Patches") self.config["DeviceProperties"]["Add"][device.pci_path].update({"disable-metal": 1, "force-compat": 1}) if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: @@ -714,7 +714,7 @@ class BuildOpenCore: self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -wegtree agdpmod=vit9696" self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - if device.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + if device.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: print("- Adding Web Driver Patches") if "ngfxgl=1 ngfxcompat=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1" diff --git a/resources/defaults.py b/resources/defaults.py index 9770c9df6..6d83ce4cd 100644 --- a/resources/defaults.py +++ b/resources/defaults.py @@ -47,7 +47,7 @@ class generate_defaults: settings.amfi_status = True settings.allow_fv_root = True # Allow FileVault on broken seal break - elif gpu.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + elif gpu.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: settings.custom_sip_value = "0xA03" break if ( From de21c361db4f6a84ff1e3e66ea4a6c56094c29ea Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 26 May 2022 21:33:10 -0600 Subject: [PATCH 06/31] sys_patch_detect.py: Add additional checks for Web Drivers Ensures system is correctly configured before patching, avoiding users incorrectly faulting the program instead of their local configuration --- gui/gui_main.py | 4 +- resources/device_probe.py | 14 ++- resources/sys_patch_detect.py | 171 +++++++++++++++++++++++++--------- 3 files changed, 140 insertions(+), 49 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index c8678bd3a..94b9a27a9 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -932,11 +932,11 @@ class wx_python_gui: for patch in patches: if patch.startswith("Validation") and patches[patch] is True: print(f"- Adding check: {patch} - {patches[patch]}") - self.patch_label = wx.StaticText(self.frame_modal, label=f"- {patch.lstrip('Validation: ')}") + self.patch_label = wx.StaticText(self.frame_modal, label=f"- {patch[12:]}") self.patch_label.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self.patch_label.SetPosition( wx.Point( - self.subheader.GetPosition().x + 20, + self.subheader.GetPosition().x, self.subheader.GetPosition().y + self.subheader.GetSize().height + 3 + i ) ) diff --git a/resources/device_probe.py b/resources/device_probe.py index e9b58a0c5..5e3e778d4 100644 --- a/resources/device_probe.py +++ b/resources/device_probe.py @@ -30,10 +30,12 @@ class PCIDevice: device_id: int # The device ID of this PCI device class_code: int # The class code of this PCI device - https://pci-ids.ucw.cz/read/PD - name: Optional[str] = None # Name of IORegistryEntry - model: Optional[str] = None # model property - acpi_path: Optional[str] = None - pci_path: Optional[str] = None + name: Optional[str] = None # Name of IORegistryEntry + model: Optional[str] = None # model property + acpi_path: Optional[str] = None # ACPI Device Path + pci_path: Optional[str] = None # PCI Device Path + disable_metal: Optional[bool] = False # 'disable-metal' property + force_compatible: Optional[bool] = False # 'force-compat' property @classmethod def from_ioregistry(cls, entry: ioreg.io_registry_entry_t, anti_spoof=False): @@ -51,6 +53,10 @@ class PCIDevice: device.model = model if "acpi-path" in properties: device.acpi_path = properties["acpi-path"] + if "disable-metal" in properties: + device.disable_metal = True + if "force-compat" in properties: + device.force_compatible = True device.populate_pci_path(entry) return device diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 2ac5774b2..157d50605 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -13,33 +13,38 @@ class detect_root_patch: self.computer = self.constants.computer # GPU Patch Detection - self.nvidia_tesla= False - self.kepler_gpu= False - self.nvidia_web= False - self.amd_ts1= False - self.amd_ts2= False - self.iron_gpu= False - self.sandy_gpu= False - self.ivy_gpu= False + self.nvidia_tesla = False + self.kepler_gpu = False + self.nvidia_web = False + self.amd_ts1 = False + self.amd_ts2 = False + self.iron_gpu = False + self.sandy_gpu = False + self.ivy_gpu = False # Misc Patch Detection - self.brightness_legacy= False - self.legacy_audio= False - self.legacy_wifi= False - self.legacy_gmux= False - self.legacy_keyboard_backlight= False + self.brightness_legacy = False + self.legacy_audio = False + self.legacy_wifi = False + self.legacy_gmux = False + self.legacy_keyboard_backlight = False # Patch Requirements - self.amfi_must_disable= False - self.supports_metal= False + self.amfi_must_disable = False + self.supports_metal = False + self.needs_nv_web_checks = False # Validation Checks - self.sip_enabled = False - self.sbm_enabled = False - self.amfi_enabled = False - self.fv_enabled = False + self.sip_enabled = False + self.sbm_enabled = False + self.amfi_enabled = False + self.fv_enabled = False self.dosdude_patched = False + self.missing_whatever_green = False + self.missing_nv_web_nvram = False + self.missing_nv_web_opengl = False + self.missing_nv_compat = False def detect_gpus(self): gpus = self.constants.computer.gpus @@ -47,7 +52,7 @@ class detect_root_patch: for i, gpu in enumerate(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)}") - if gpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]: + if gpu.arch in [device_probe.NVIDIA.Archs.Tesla]: if self.constants.detected_os > non_metal_os: self.nvidia_tesla = True self.amfi_must_disable = True @@ -62,10 +67,11 @@ class detect_root_patch: if "21A5506j" not in self.constants.detected_os_build: self.kepler_gpu = True self.supports_metal = True - elif gpu.arch in [device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + elif gpu.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: if self.constants.detected_os > os_data.os_data.mojave: self.nvidia_web = True self.amfi_must_disable = True + self.needs_nv_web_checks = True elif gpu.arch == device_probe.AMD.Archs.TeraScale_1: if self.constants.detected_os > non_metal_os: self.amd_ts1 = True @@ -125,6 +131,44 @@ class detect_root_patch: return self.constants.computer.ambient_light_sensor return False + def check_nv_web_nvram(self): + # First check boot-args, then dedicated nvram variable + nv_on = utilities.get_nvram("boot-args") + if nv_on: + if "nvda_drv_vrl" in nv_on: + return True + nv_on = utilities.get_nvram("nvda_drv") + if nv_on: + return True + return False + + def check_nv_web_opengl(self): + # First check boot-args, then whether property exists on GPU + nv_on = utilities.get_nvram("boot-args") + if nv_on: + if "ngfxgl" in nv_on: + return True + for gpu in self.constants.computer.gpus: + if isinstance(gpu, device_probe.NVIDIA): + if gpu.disable_metal: + return True + return False + + def check_nv_compat(self): + # Check for 'nv_web' in boot-args, then whether property exists on GPU + nv_on = utilities.get_nvram("boot-args") + if nv_on: + if "ngfxcompat" in nv_on: + return True + for gpu in self.constants.computer.gpus: + if isinstance(gpu, device_probe.NVIDIA): + if gpu.force_compatible: + return True + return False + + def check_whatevergreen(self): + return utilities.check_kext_loaded("WhateverGreen", self.constants.detected_os) + def detect_patch_set(self): self.detect_gpus() if self.model in model_array.LegacyBrightness: @@ -159,27 +203,31 @@ class detect_root_patch: self.legacy_gmux = True self.root_patch_dict = { - "Graphics: Nvidia Tesla": self.nvidia_tesla, - "Graphics: Nvidia Kepler": self.kepler_gpu, - "Graphics: Nvidia Web Drivers": self.nvidia_web, - # "Graphics: Nvidia Web Drivers": False, - "Graphics: AMD TeraScale 1": self.amd_ts1, - "Graphics: AMD TeraScale 2": self.amd_ts2, - "Graphics: Intel Ironlake": self.iron_gpu, - "Graphics: Intel Sandy Bridge": self.sandy_gpu, - "Graphics: Intel Ivy Bridge": self.ivy_gpu, - "Brightness: Legacy Backlight Control": self.brightness_legacy, - "Audio: Legacy Realtek": self.legacy_audio, - "Networking: Legacy Wireless": self.legacy_wifi, - "Miscellaneous: Legacy GMUX": self.legacy_gmux, - "Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight, - "Settings: Requires AMFI exemption": self.amfi_must_disable, - "Validation: Patching Possible": self.verify_patch_allowed(), - "Validation: SIP is enabled": self.sip_enabled, - "Validation: SecureBootModel is enabled": self.sbm_enabled, - "Validation: AMFI is enabled": self.amfi_enabled if self.amfi_must_disable else False, - "Validation: FileVault is enabled": self.fv_enabled, - "Validation: System is dosdude1 patched": self.dosdude_patched, + "Graphics: Nvidia Tesla": self.nvidia_tesla, + "Graphics: Nvidia Kepler": self.kepler_gpu, + "Graphics: Nvidia Web Drivers": self.nvidia_web, + "Graphics: AMD TeraScale 1": self.amd_ts1, + "Graphics: AMD TeraScale 2": self.amd_ts2, + "Graphics: Intel Ironlake": self.iron_gpu, + "Graphics: Intel Sandy Bridge": self.sandy_gpu, + "Graphics: Intel Ivy Bridge": self.ivy_gpu, + "Brightness: Legacy Backlight Control": self.brightness_legacy, + "Audio: Legacy Realtek": self.legacy_audio, + "Networking: Legacy Wireless": self.legacy_wifi, + "Miscellaneous: Legacy GMUX": self.legacy_gmux, + "Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight, + "Settings: Requires AMFI exemption": self.amfi_must_disable, + "Validation: Patching Possible": self.verify_patch_allowed(), + "Validation: SIP is enabled": self.sip_enabled, + "Validation: SecureBootModel is enabled": self.sbm_enabled, + "Validation: AMFI is enabled": self.amfi_enabled if self.amfi_must_disable else False, + "Validation: FileVault is enabled": self.fv_enabled, + "Validation: System is dosdude1 patched": self.dosdude_patched, + "Validation: WhateverGreen.kext missing": self.missing_whatever_green if self.nvidia_web is True else False, + "Validation: Force OpenGL property missing": self.missing_nv_web_opengl if self.nvidia_web is True else False, + "Validation: Force compat property missing": self.missing_nv_compat if self.nvidia_web is True else False, + "Validation: nvda_drv(_vrl) variable missing": self.missing_nv_web_nvram if self.nvidia_web is True else False, + } return self.root_patch_dict @@ -187,6 +235,13 @@ class detect_root_patch: def verify_patch_allowed(self, print_errors=False): sip = sip_data.system_integrity_protection.root_patch_sip_big_sur if self.constants.detected_os > os_data.os_data.catalina else sip_data.system_integrity_protection.root_patch_sip_mojave 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.nvidia_web is True: + self.missing_nv_web_nvram = not self.check_nv_web_nvram() + self.missing_nv_web_opengl = not self.check_nv_web_opengl() + self.missing_nv_compat = not self.check_nv_compat() + self.missing_whatever_green = not self.check_whatevergreen() + 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: @@ -219,8 +274,38 @@ class detect_root_patch: print("\nCannot patch! Detected machine has already been patched by another patcher") print("Please ensure your install is either clean or patched with OpenCore Legacy Patcher") + if self.nvidia_web is True: + if self.missing_nv_web_opengl is True: + print("\nCannot patch! Force OpenGL property missing") + print("Please ensure ngfxgl=1 is set in boot-args") + + if self.missing_nv_compat is True: + print("\nCannot patch! Force Nvidia compatibility property missing") + print("Please ensure ngfxcompat=1 is set in boot-args") + + if self.missing_nv_web_nvram is True: + print("\nCannot patch! nvda_drv(_vrl) variable missing") + print("Please ensure nvda_drv_vrl=1 is set in boot-args") + + if self.missing_whatever_green is True: + print("\nCannot patch! WhateverGreen.kext missing") + print("Please ensure WhateverGreen.kext is installed") + + if any( - [self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched, self.amfi_enabled if self.amfi_must_disable else False] + [ + # General patch checks + self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched, + + # non-Metal specific + self.amfi_enabled if self.amfi_must_disable else False, + + # Web Driver specific + self.missing_nv_web_nvram if self.nvidia_web else False, + self.missing_nv_web_opengl if self.nvidia_web else False, + self.missing_nv_compat if self.nvidia_web else False, + self.missing_whatever_green if self.nvidia_web else False, + ] ): return False else: From c1ebfd900f99f0fa0617d14f8c9cb6e5bc0ae650 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 26 May 2022 22:31:15 -0600 Subject: [PATCH 07/31] sys_patch.py: Add handling for System Preferences prompt --- gui/gui_main.py | 22 +++++++++++++++++++++- resources/constants.py | 1 + resources/sys_patch.py | 6 +++++- resources/sys_patch_detect.py | 10 +++++----- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index 94b9a27a9..6666bf181 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -1173,7 +1173,27 @@ class wx_python_gui: sys.stderr = self.stock_stderr if self.constants.root_patcher_succeded is True: print("- Root Patcher finished successfully") - self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?") + if self.constants.needs_to_open_preferences is True: + # Create dialog box to open System Preferences -> Security and Privacy + self.popup = wx.MessageDialog( + self.frame_modal, + "We just finished installing the patches to your Root Volume!\n\nHowever, Apple requires users to manually approve the kernel extensions installed before they can be used next reboot.\n\nWould you like to open System Preferences?", + "Open System Preferences?", + wx.YES_NO | wx.ICON_INFORMATION + ) + self.popup.SetYesNoLabels("Open System Preferences", "Ignore") + answer = self.popup.ShowModal() + if answer == wx.ID_YES: + subprocess.Popen( + [ + "osascript", "-e", + 'tell app "System Preferences" to reveal anchor "General" of pane id "com.apple.preference.security"' + ] + ) + time.sleep(5) + self.OnCloseFrame(None) + else: + self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?") self.return_to_main_menu.Enable() wx.GetApp().Yield() diff --git a/resources/constants.py b/resources/constants.py index ec637f142..0646c0f2b 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -190,6 +190,7 @@ class Constants: self.booted_oc_disk = None # Determine current disk OCLP booted from self.start_build_install = False # Determine if build install should be started self.host_is_non_metal = False # Determine if host is non-metal (ie. enable UI hacks) + self.needs_to_open_preferences = False # Determine if preferences need to be opened self.legacy_accel_support = [ os_data.os_data.big_sur, diff --git a/resources/sys_patch.py b/resources/sys_patch.py index e92860648..c7ec35cbc 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -41,6 +41,7 @@ class PatchSysVolume: self.root_mount_path = None self.root_supports_snapshot = utilities.check_if_root_is_apfs_snapshot() self.constants.root_patcher_succeded = False # Reset Variable each time we start + self.constants.needs_to_open_preferences = False self.patch_set_dictionary = {} self.needs_kmutil_exemptions = False # For '/Library/Extensions' rebuilds @@ -120,9 +121,10 @@ class PatchSysVolume: if self.needs_kmutil_exemptions is True: # When installing to '/Library/Extensions', following args skip kext consent # prompt in System Preferences when SIP's disabled - print("- Disabling auth checks in kmutil") + print(" (You will get a prompt by System Preferences, ignore for now)") args.append("--no-authentication") args.append("--no-authorization") + self.constants.needs_to_open_preferences = True # Notify in GUI to open System Preferences else: args = ["kextcache", "-i", f"{self.mount_location}/"] @@ -163,6 +165,8 @@ class PatchSysVolume: self.unmount_drive() print("- Patching complete") print("\nPlease reboot the machine for patches to take effect") + if self.needs_kmutil_exemptions is True: + print("Note: Apple will require you to open System Preferences -> Security to\nallow the new kernel extensions to be loaded") self.constants.root_patcher_succeded = True if self.constants.gui_mode is False: input("\nPress [ENTER] to continue") diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 157d50605..04299781e 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -135,7 +135,7 @@ class detect_root_patch: # First check boot-args, then dedicated nvram variable nv_on = utilities.get_nvram("boot-args") if nv_on: - if "nvda_drv_vrl" in nv_on: + if "nvda_drv_vrl=" in nv_on: return True nv_on = utilities.get_nvram("nvda_drv") if nv_on: @@ -146,11 +146,11 @@ class detect_root_patch: # First check boot-args, then whether property exists on GPU nv_on = utilities.get_nvram("boot-args") if nv_on: - if "ngfxgl" in nv_on: + if "ngfxgl=" in nv_on: return True for gpu in self.constants.computer.gpus: if isinstance(gpu, device_probe.NVIDIA): - if gpu.disable_metal: + if gpu.disable_metal is True: return True return False @@ -158,11 +158,11 @@ class detect_root_patch: # Check for 'nv_web' in boot-args, then whether property exists on GPU nv_on = utilities.get_nvram("boot-args") if nv_on: - if "ngfxcompat" in nv_on: + if "ngfxcompat=" in nv_on: return True for gpu in self.constants.computer.gpus: if isinstance(gpu, device_probe.NVIDIA): - if gpu.force_compatible: + if gpu.force_compatible is True: return True return False From 4a1199cb5918186d71a052a2ccaa95c7c580c997 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 10:25:38 -0600 Subject: [PATCH 08/31] sys_patch_detect.py: Implement proper SIP checks for Web Drivers --- data/sip_data.py | 8 ++++++++ resources/sys_patch_detect.py | 36 ++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/data/sip_data.py b/data/sip_data.py index ad70e8935..f90d16550 100644 --- a/data/sip_data.py +++ b/data/sip_data.py @@ -126,6 +126,14 @@ class system_integrity_protection: "CSR_ALLOW_UNAUTHENTICATED_ROOT", # 0x800 - Required to avoid KC mismatch kernel panic ] + root_patch_sip_big_sur_3rd_part_kexts = [ + # Variables required to root patch in Big Sur and Monterey with 3rd party kexts + "CSR_ALLOW_UNTRUSTED_KEXTS", # 0x1 - Required for Aux Cache in Big Sur+ + "CSR_ALLOW_UNRESTRICTED_FS", # 0x2 - Required to mount and edit root volume, as well as load modded platform binaries + "CSR_ALLOW_UNAUTHENTICATED_ROOT", # 0x800 - Required to avoid KC mismatch kernel panic + "CSR_ALLOW_UNAPPROVED_KEXTS", # 0x200 - Required for Aux Cache in Big Sur+ + ] + # CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE (introduced with Mojave): # This bit is quite strange and was originally assumed to be required for modded platform binaries # However after extensive testing, this doesn't seem true. In addition, this bit is never flipped via diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 04299781e..f55ca55ea 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -168,6 +168,26 @@ class detect_root_patch: def check_whatevergreen(self): return utilities.check_kext_loaded("WhateverGreen", self.constants.detected_os) + + def check_sip(self): + if self.constants.detected_os > os_data.os_data.catalina: + if self.nvidia_web is True: + sip = sip_data.system_integrity_protection.root_patch_sip_big_sur_3rd_part_kexts + sip_hex = "0xA03" + sip_value = ( + f"For Hackintoshes, please set csr-active-config to '030A0000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" + ) + else: + sip = sip_data.system_integrity_protection.root_patch_sip_big_sur + sip_hex = "0x802" + sip_value = ( + f"For Hackintoshes, please set csr-active-config to '02080000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" + ) + else: + sip = sip_data.system_integrity_protection.root_patch_sip_mojave + sip_hex = "0x603" + sip_value = f"For Hackintoshes, please set csr-active-config to '03060000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' in RecoveryOS" + return (sip, sip_value, sip_hex) def detect_patch_set(self): self.detect_gpus() @@ -218,7 +238,8 @@ class detect_root_patch: "Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight, "Settings: Requires AMFI exemption": self.amfi_must_disable, "Validation: Patching Possible": self.verify_patch_allowed(), - "Validation: SIP is enabled": self.sip_enabled, + f"Validation: SIP is enabled (Required: {self.check_sip()[2]} or higher)": self.sip_enabled, + f"Validation: Currently Booted SIP: ({hex(utilities.csr_dump())})": self.sip_enabled, "Validation: SecureBootModel is enabled": self.sbm_enabled, "Validation: AMFI is enabled": self.amfi_enabled if self.amfi_must_disable else False, "Validation: FileVault is enabled": self.fv_enabled, @@ -233,7 +254,10 @@ class detect_root_patch: return self.root_patch_dict def verify_patch_allowed(self, print_errors=False): - sip = sip_data.system_integrity_protection.root_patch_sip_big_sur if self.constants.detected_os > os_data.os_data.catalina else sip_data.system_integrity_protection.root_patch_sip_mojave + sip_dict = self.check_sip() + sip = sip_dict[0] + sip_value = sip_dict[1] + 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.nvidia_web is True: @@ -241,13 +265,7 @@ class detect_root_patch: self.missing_nv_web_opengl = not self.check_nv_web_opengl() self.missing_nv_compat = not self.check_nv_compat() self.missing_whatever_green = not self.check_whatevergreen() - - 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 '02080000' (0x802)\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" - ) + if print_errors is True: if self.sip_enabled is True: print("\nCannot patch! Please disable System Integrity Protection (SIP).") From 897f89d47c798053cf3f66c6dd42c1a4a92de67b Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 11:39:34 -0600 Subject: [PATCH 09/31] gui_main.py: fix Privacy prompt --- gui/gui_main.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index 6666bf181..618672448 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -1184,14 +1184,18 @@ class wx_python_gui: self.popup.SetYesNoLabels("Open System Preferences", "Ignore") answer = self.popup.ShowModal() if answer == wx.ID_YES: - subprocess.Popen( + output =subprocess.run( [ "osascript", "-e", - 'tell app "System Preferences" to reveal anchor "General" of pane id "com.apple.preference.security"' - ] + 'tell app "System Preferences" to reveal anchor "General" of pane id "com.apple.preference.security"', + "-e", 'tell app "System Preferences" to activate', + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE ) - time.sleep(5) - self.OnCloseFrame(None) + if output.returncode == 0: + time.sleep(5) + self.OnCloseFrame(None) else: self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?") self.return_to_main_menu.Enable() From 7a0e824536cdede617a0056ba7167b08f16673dc Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 12:14:01 -0600 Subject: [PATCH 10/31] pci_data.py: Add additional Maxwell and Pascal IDs --- CHANGELOG.md | 2 + data/pci_data.py | 231 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 171 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6957a5051..356560666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ - Resolve failing to find binaries with `--patch_sys_vol` argument - Downgrade AppleFSCompressionTypeZlib to 12.3.1 on pre-Sandy Bridge Macs - Resolves ZLib decompression kernel panics on 12.4 and newer +- Add Nvidia Web Driver support for Maxwell and Pascal + - Currently running in OpenGL mode, [non-Metal issues](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/108) applicable ## 0.4.5 - Fix AutoPatcher.pkg download on releases diff --git a/data/pci_data.py b/data/pci_data.py index 6e8a72700..68a6938b5 100644 --- a/data/pci_data.py +++ b/data/pci_data.py @@ -3,8 +3,9 @@ class nvidia_ids: # Courteous of envytools as well as Macrumors: # https://envytools.readthedocs.io/en/latest/hw/pciid.html # https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/ + # https://pci-ids.ucw.cz/read/PC/10de curie_ids = [ - 0x0040, # NV40 [GeForce 6800 Ultra] + 0x0040, # NV40 [GeForce 6800 Ultra] 0x00f0, # BR02 0x0220, # NV44A 0x0140, # NV43 [GeForce 6600 GT] @@ -525,77 +526,183 @@ class nvidia_ids: maxwell_ids = [ - 0x1381, # GM107 [GeForce GTX 750] - 0x1392, # GM107 [GeForce GTX 860M] - 0x139a, # GM107 [GeForce GTX 950M] - 0x139b, # GM107 [GeForce GTX 960M] - 0x13b0, # GM107 [Quadro M2000M] - 0x13BB, # GM107 [Quadro K620] + 0x1340, # GM108M [GeForce 830M] + 0x1341, # GM108M [GeForce 840M] + 0x1344, # GM108M [GeForce 845M] + 0x1346, # GM108M [GeForce 930M] + 0x1347, # GM108M [GeForce 940M] + 0x1348, # GM108M [GeForce 945M / 945A] + 0x1349, # GM108M [GeForce 930M] + 0x134b, # GM108M [GeForce 940MX] + 0x134d, # GM108M [GeForce 940MX] + 0x134e, # GM108M [GeForce 930MX] + 0x134f, # GM108M [GeForce 920MX] + 0x137a, # GM108GLM [Quadro K620M / Quadro M500M] + 0x137b, # GM108GLM [Quadro M520 Mobile] + 0x137d, # GM108M [GeForce 940A] - 0x1340, # GM108 - 0x1341, # GM108 [GeForce 840M] - 0x1346, # GM108 [GeForce 930M] - 0x1347, # GM108 [GeForce 940M] - 0x134d, # GM108 [GeForce 940MX] + 0x1380, # GM107 [GeForce GTX 750 Ti] + 0x1381, # GM107 [GeForce GTX 750] + 0x1382, # GM107 [GeForce GTX 745] + 0x1389, # GM107GL [GRID M30] + 0x1390, # GM107M [GeForce 845M] + 0x1391, # GM107M [GeForce GTX 850M] + 0x1392, # GM107M [GeForce GTX 860M] + 0x1393, # GM107M [GeForce 840M] + 0x1398, # GM107M [GeForce 845M] + 0x1399, # GM107M [GeForce 945M] + 0x139a, # GM107M [GeForce GTX 950M] + 0x139b, # GM107M [GeForce GTX 960M] + 0x139c, # GM107M [GeForce 940M] + 0x139d, # GM107M [GeForce GTX 750 Ti] + 0x13b0, # GM107GLM [Quadro M2000M] + 0x13b1, # GM107GLM [Quadro M1000M] + 0x13b2, # GM107GLM [Quadro M600M] + 0x13b3, # GM107GLM [Quadro K2200M] + 0x13b4, # GM107GLM [Quadro M620 Mobile] + 0x13b6, # GM107GLM [Quadro M1200 Mobile] + 0x13b9, # GM107GL [NVS 810] + 0x13ba, # GM107GL [Quadro K2200] + 0x13bb, # GM107GL [Quadro K620] + 0x13bc, # GM107GL [Quadro K1200] + 0x13bd, # GM107GL [Tesla M10] - 0x13c0, # GM204 [GeForce GTX 980] - 0x13c2, # GM204 [GeForce GTX 970] - 0x13d7, # GM204 [GeForce GTX 980M] - 0x13d8, # GM204 [GeForce GTX 970M] - 0x13d9, # GM204 [GeForce GTX 965M] - 0x13F1, # GM204 [Quadro M4000] + 0x13c0, # GM204 [GeForce GTX 980] + 0x13c1, # GM204 + 0x13c2, # GM204 [GeForce GTX 970] + 0x13c3, # GM204 + 0x13d7, # GM204M [GeForce GTX 980M] + 0x13d8, # GM204M [GeForce GTX 970M] + 0x13d9, # GM204M [GeForce GTX 965M] + 0x13da, # GM204M [GeForce GTX 980 Mobile] + 0x13e7, # GM204GL [GeForce GTX 980 Engineering Sample] + 0x13f0, # GM204GL [Quadro M5000] + 0x13f1, # GM204GL [Quadro M4000] + 0x13f2, # GM204GL [Tesla M60] + 0x13f3, # GM204GL [Tesla M6] + 0x13f8, # GM204GLM [Quadro M5000M / M5000 SE] + 0x13f9, # GM204GLM [Quadro M4000M] + 0x13fa, # GM204GLM [Quadro M3000M] + 0x13fb, # GM204GLM [Quadro M5500] - 0x1401, # GM206 [GeForce GTX 960] - 0x1407, # GM206 [GeForce GTX 750 v2] - 0x1427, # GM206 [GeForce GTX 965M v2] + 0x1401, # GM206 [GeForce GTX 960] + 0x1402, # GM206 [GeForce GTX 950] + 0x1404, # GM206 [GeForce GTX 960 FAKE] + 0x1406, # GM206 [GeForce GTX 960 OEM] + 0x1407, # GM206 [GeForce GTX 750 v2] + 0x1427, # GM206M [GeForce GTX 965M] + 0x1430, # GM206GL [Quadro M2000] + 0x1431, # GM206GL [Tesla M4] + 0x1436, # GM206GLM [Quadro M2200 Mobile] ] pascal_ids = [ - 0x15f7, # GP100 [Tesla P100 PCIe 12GB] - 0x15f8, # GP100 [Tesla P100 PCIe 16GB] - 0x15f9, # GP100 [Tesla P100 SXM2 16GB] + 0x15f0, # GP100GL [Quadro GP100] + 0x15f1, # GP100GL + 0x15f7, # GP100GL [Tesla P100 PCIe 12GB] + 0x15f8, # GP100GL [Tesla P100 PCIe 16GB] + 0x15f9, # GP100GL [Tesla P100 SXM2 16GB] - 0x1b00, # GP102 [GeForce TITAN X] - 0x1b02, # GP102 [GeForce TITAN Xp] - 0x1b06, # GP102 [GeForce GTX 1080 Ti] - 0x1b30, # GP102 [Quadro P6000] - 0x1b38, # GP102 [Tesla P40] + 0x1b00, # GP102 [TITAN X] + 0x1b01, # GP102 [GeForce GTX 1080 Ti 10GB] + 0x1b02, # GP102 [TITAN Xp] + 0x1b04, # GP102 + 0x1b06, # GP102 [GeForce GTX 1080 Ti] + 0x1b07, # GP102 [P102-100] + 0x1b30, # GP102GL [Quadro P6000] + 0x1b38, # GP102GL [Tesla P40] + 0x1b39, # GP102GL [Tesla P10] + 0x1b70, # GP102GL + 0x1b78, # GP102GL - 0x1b80, # GP104 [GeForce GTX 1080] - 0x1b81, # GP104 [GeForce GTX 1070] - 0x1b82, # GP104 [GeForce GTX 1070 Ti] - 0x1b83, # GP104 [GeForce GTX 1060 6GB] - 0x1b84, # GP104 [GeForce GTX 1060 3GB] - 0x1ba0, # GP104 [GeForce GTX 1080 Mobile] - 0x1ba1, # GP104 [GeForce GTX 1070 Mobile] - 0x1ba2, # GP104 [GeForce GTX 1070 Mobile] - 0x1bb0, # GP104 [Quadro P5000] - 0x1bb3, # GP104 [Tesla P4] - 0x1bb6, # GP104 [Quadro P5000 Mobile] - 0x1bb7, # GP104 [Quadro P4000 Mobile] - 0x1bb8, # GP104 [Quadro P3000 Mobile] - 0x1be0, # GP104 [GeForce GTX 1080 Mobile] - 0x1be1, # GP104 [GeForce GTX 1070 Mobile] + 0x1b80, # GP104 [GeForce GTX 1080] + 0x1b81, # GP104 [GeForce GTX 1070] + 0x1b82, # GP104 [GeForce GTX 1070 Ti] + 0x1b83, # GP104 [GeForce GTX 1060 6GB] + 0x1b84, # GP104 [GeForce GTX 1060 3GB] + 0x1b87, # GP104 [P104-100] + 0x1ba0, # GP104M [GeForce GTX 1080 Mobile] + 0x1ba1, # GP104M [GeForce GTX 1070 Mobile] + 0x1ba2, # GP104M [GeForce GTX 1070 Mobile] + 0x1ba9, # GP104M + 0x1baa, # GP104M + 0x1bad, # GP104 [GeForce GTX 1070 Engineering Sample] + 0x1bb0, # GP104GL [Quadro P5000] + 0x1bb1, # GP104GL [Quadro P4000] + 0x1bb3, # GP104GL [Tesla P4] + 0x1bb4, # GP104GL [Tesla P6] + 0x1bb5, # GP104GLM [Quadro P5200 Mobile] + 0x1bb6, # GP104GLM [Quadro P5000 Mobile] + 0x1bb7, # GP104GLM [Quadro P4000 Mobile] + 0x1bb8, # GP104GLM [Quadro P3000 Mobile] + 0x1bb9, # GP104GLM [Quadro P4200 Mobile] + 0x1bbb, # GP104GLM [Quadro P3200 Mobile] + 0x1bc7, # GP104 [P104-101] + 0x1be0, # GP104BM [GeForce GTX 1080 Mobile] + 0x1be1, # GP104BM [GeForce GTX 1070 Mobile] - 0x1c02, # GP106 [GeForce GTX 1060 3GB] - 0x1c03, # GP106 [GeForce GTX 1060 6GB] - 0x1c20, # GP106 [GeForce GTX 1060 Mobile] - 0x1c23, # GP106 [GeForce GTX 1060] - 0x1c60, # GP106 [GeForce GTX 1060 Mobile] - 0x1c61, # GP106 [GeForce GTX 1050 Ti Mobile] - 0x1c62, # GP106 [GeForce GTX 1050 Mobile] + 0x1c00, # GP106 + 0x1c01, # GP106 + 0x1c02, # GP106 [GeForce GTX 1060 3GB] + 0x1c03, # GP106 [GeForce GTX 1060 6GB] + 0x1c04, # GP106 [GeForce GTX 1060 5GB] + 0x1c06, # GP106 [GeForce GTX 1060 6GB Rev. 2] + 0x1c07, # GP106 [P106-100] + 0x1c09, # GP106 [P106-090] + 0x1c20, # GP106M [GeForce GTX 1060 Mobile] + 0x1c21, # GP106M [GeForce GTX 1050 Ti Mobile] + 0x1c22, # GP106M [GeForce GTX 1050 Mobile] + 0x1c23, # GP106M [GeForce GTX 1060 Mobile Rev. 2] + 0x1c2d, # GP106M + 0x1c30, # GP106GL [Quadro P2000] + 0x1c31, # GP106GL [Quadro P2200] + 0x1c35, # GP106M [Quadro P2000 Mobile] + 0x1c36, # GP106 [P106M] + 0x1c60, # GP106BM [GeForce GTX 1060 Mobile 6GB] + 0x1c61, # GP106BM [GeForce GTX 1050 Ti Mobile] + 0x1c62, # GP106BM [GeForce GTX 1050 Mobile] + 0x1c70, # GP106GL - 0x1c81, # GP107 [GeForce GTX 1050] - 0x1c82, # GP107 [GeForce GTX 1050 Ti] - 0x1c83, # GP107 [GeForce GTX 1050 3GB] - 0x1c8c, # GP107 [GeForce GTX 1050 Ti Mobile] - 0x1c8d, # GP107 [GeForce GTX 1050 Mobile] - 0x1c8f, # GP107 [GeForce GTX 1050 Ti Max-Q] - 0x1c92, # GP107 [GeForce GTX 1050 Max-Q] + 0x1c80, + 0x1c81, # GP107 [GeForce GTX 1050] + 0x1c82, # GP107 [GeForce GTX 1050 Ti] + 0x1c83, # GP107 [GeForce GTX 1050 3GB] + 0x1c8c, # GP107M [GeForce GTX 1050 Ti Mobile] + 0x1c8d, # GP107M [GeForce GTX 1050 Mobile] + 0x1c8e, # GP107M + 0x1c8f, # GP107M [GeForce GTX 1050 Ti Max-Q] + 0x1c90, # GP107M [GeForce MX150] + 0x1c91, # GP107M [GeForce GTX 1050 3 GB Max-Q] + 0x1c92, # GP107M [GeForce GTX 1050 Mobile] + 0x1c94, # GP107M [GeForce MX350] + 0x1c96, # GP107M [GeForce MX350] + 0x1ca7, # GP107GL + 0x1ca8, # GP107GL + 0x1caa, # GP107GL + 0x1cb1, # GP107GL [Quadro P1000] + 0x1cb2, # GP107GL [Quadro P600] + 0x1cb3, # GP107GL [Quadro P400] + 0x1cb6, # GP107GL [Quadro P620] + 0x1cba, # GP107GLM [Quadro P2000 Mobile] + 0x1cbb, # GP107GLM [Quadro P1000 Mobile] + 0x1cbc, # GP107GLM [Quadro P600 Mobile] + 0x1cbd, # GP107GLM [Quadro P620] + 0x1ccc, # GP107BM [GeForce GTX 1050 Ti Mobile] + 0x1ccd, # GP107BM [GeForce GTX 1050 Mobile] + 0x1cfa, # GP107GL [Quadro P2000] + 0x1cfb, # GP107GL [Quadro P1000] - 0x1d01, # GP108 [GeForce GT 1030] - 0x1d10, # GP108 [GeForce MX150] - 0x1d12, # GP108 [GeForce MX150] + 0x1d01, # GP108 [GeForce GT 1030] + 0x1d02, # GP108 [GeForce GT 1010] + 0x1d10, # GP108M [GeForce MX150] + 0x1d11, # GP108M [GeForce MX230] + 0x1d12, # GP108M [GeForce MX150] + 0x1d13, # GP108M [GeForce MX250] + 0x1d16, # GP108M [GeForce MX330] + 0x1d33, # GP108GLM [Quadro P500 Mobile] + 0x1d34, # GP108GLM [Quadro P520] + 0x1d52, # GP108BM [GeForce MX250] + 0x1d56, # GP108BM [GeForce MX330] ] @@ -676,7 +783,7 @@ class amd_ids: 0x67E9, # Unknown # AMDEllesmereGraphicsAccelerator - AMD9500Controller 0x67C0, # Pro WX 7100 Mobile - 0x67C1, # Unknown + 0x67C1, # Unknown 0x67C2, # Pro V7300X / V7350x2 0x67C4, # Pro WX 7100 0x67C7, # Pro WX 5100 From 90e23bef925a2fd2eb8bb1dc196ead9c3ab80048 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 16:02:19 -0600 Subject: [PATCH 11/31] sys_patch_detect.py: Add support for Web Drivers on Tesla/Kepler --- data/sys_patch_dict.py | 15 +++++++++------ resources/constants.py | 3 ++- resources/defaults.py | 8 ++++++++ resources/sys_patch.py | 2 +- resources/sys_patch_detect.py | 12 +++++++++--- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/data/sys_patch_dict.py b/data/sys_patch_dict.py index d86ca3c4a..6371d0b82 100644 --- a/data/sys_patch_dict.py +++ b/data/sys_patch_dict.py @@ -303,12 +303,15 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support): "NVDANV50HalTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", "NVDAResmanTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", }, - - # Nvidia's control panel crashes on 10.14+ - # For us, no real point in using it so ignore - # "/Library/PreferencePanes": { - # "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", - # }, + "/Library/PreferencePanes": { + "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", + }, + "/Library/LaunchAgents": { + "com.nvidia.nvagent.plist": "WebDriver-387.10.10.10.40.140", + }, + "/Library/LaunchDaemons": { + "com.nvidia.nvroothelper.plist": "WebDriver-387.10.10.10.40.140", + }, }, }, "AMD TeraScale Common": { diff --git a/resources/constants.py b/resources/constants.py index 0646c0f2b..97d67db3d 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -15,7 +15,7 @@ class Constants: def __init__(self): # Patcher Versioning self.patcher_version = "0.4.6" # OpenCore-Legacy-Patcher - self.patcher_support_pkg_version = "0.5.0" # PatcherSupportPkg + self.patcher_support_pkg_version = "0.5.1" # PatcherSupportPkg self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/" self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/" self.discord_link = "https://discord.gg/rqdPgH8xSN" @@ -167,6 +167,7 @@ class Constants: self.imac_model = "" # Set MXM GPU model self.drm_support = False # Set iMac14,x DRM support self.allow_ts2_accel = True # Set TeraScale 2 Acceleration support + self.force_nv_web = False # Force Nvidia Web Drivers on Tesla and Kepler ## Miscellaneous self.disallow_cpufriend = False # Disable CPUFriend diff --git a/resources/defaults.py b/resources/defaults.py index 6d83ce4cd..070babc33 100644 --- a/resources/defaults.py +++ b/resources/defaults.py @@ -172,3 +172,11 @@ class generate_defaults: settings.force_vmm = False except KeyError: pass + + + nv_web_status = subprocess.run(["defaults", "read", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + if nv_web_status in ["1", "true"]: + settings.force_nv_web = True + else: + subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) + settings.force_nv_web = False \ No newline at end of file diff --git a/resources/sys_patch.py b/resources/sys_patch.py index c7ec35cbc..64df04da7 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -166,7 +166,7 @@ class PatchSysVolume: print("- Patching complete") print("\nPlease reboot the machine for patches to take effect") if self.needs_kmutil_exemptions is True: - print("Note: Apple will require you to open System Preferences -> Security to\nallow the new kernel extensions to be loaded") + print("Note: Apple will require you to open System Preferences -> Security to allow the new kernel extensions to be loaded") self.constants.root_patcher_succeded = True if self.constants.gui_mode is False: input("\nPress [ENTER] to continue") diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index f55ca55ea..2c81987b2 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -52,12 +52,12 @@ class detect_root_patch: for i, gpu in enumerate(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)}") - if gpu.arch in [device_probe.NVIDIA.Archs.Tesla]: + if gpu.arch in [device_probe.NVIDIA.Archs.Tesla] and self.constants.force_nv_web is False: if self.constants.detected_os > non_metal_os: self.nvidia_tesla = True self.amfi_must_disable = True self.legacy_keyboard_backlight = self.check_legacy_keyboard_backlight() - elif gpu.arch == device_probe.NVIDIA.Archs.Kepler: + elif gpu.arch == device_probe.NVIDIA.Archs.Kepler and self.constants.force_nv_web is False: if self.constants.detected_os > os_data.os_data.big_sur: # Kepler drivers were dropped with Beta 7 # 12.0 Beta 5: 21.0.0 - 21A5304g @@ -67,7 +67,13 @@ class detect_root_patch: if "21A5506j" not in self.constants.detected_os_build: self.kepler_gpu = True self.supports_metal = True - elif gpu.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: + elif gpu.arch in [ + device_probe.NVIDIA.Archs.Tesla, + device_probe.NVIDIA.Archs.Fermi, + device_probe.NVIDIA.Archs.Kepler, + device_probe.NVIDIA.Archs.Maxwell, + device_probe.NVIDIA.Archs.Pascal, + ] and self.constants.force_nv_web is True: if self.constants.detected_os > os_data.os_data.mojave: self.nvidia_web = True self.amfi_must_disable = True From a70e977eb6c8654c828c6d5e9583574bdf2693ee Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 18:10:45 -0600 Subject: [PATCH 12/31] gui_main.py: Add Force Web Drivers option --- data/sys_patch_dict.py | 7 +++++++ gui/gui_main.py | 24 ++++++++++++++++++++++-- resources/sys_patch_detect.py | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/data/sys_patch_dict.py b/data/sys_patch_dict.py index 6371d0b82..c3e848e24 100644 --- a/data/sys_patch_dict.py +++ b/data/sys_patch_dict.py @@ -313,6 +313,13 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support): "com.nvidia.nvroothelper.plist": "WebDriver-387.10.10.10.40.140", }, }, + "Remove": { + "/System/Library/Extensions": [ + # Due to how late the Auxiliary cache loads, NVDAStartup will match first and then the Web Driver kexts. + # This has no effect for Maxwell and Pascal, however for development purposes, Tesla and Kepler are partially supported. + "NVDAStartup.kext", + ], + }, }, "AMD TeraScale Common": { "Display Name": "", diff --git a/gui/gui_main.py b/gui/gui_main.py index 618672448..bdad30395 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -2273,13 +2273,23 @@ class wx_python_gui: if self.computer.real_model not in ["MacBookPro8,2", "MacBookPro8,3"]: self.set_terascale_accel_checkbox.Disable() + # Force Web Drivers in Tesla/Kepler + self.force_web_drivers_checkbox = wx.CheckBox(self.frame_modal, label="Force Web Drivers") + self.force_web_drivers_checkbox.SetValue(self.constants.force_nv_web) + self.force_web_drivers_checkbox.Bind(wx.EVT_CHECKBOX, self.force_web_drivers_click) + self.force_web_drivers_checkbox.SetPosition(wx.Point( + self.disable_thunderbolt_checkbox.GetPosition().x, + self.set_terascale_accel_checkbox.GetPosition().y + self.set_terascale_accel_checkbox.GetSize().height)) + self.force_web_drivers_checkbox.SetToolTip(wx.ToolTip("This option will force Nvidia Web Driver support onto Nvidia Tesla and Kepler GPUs. This should only be used for development purposes.")) + + # Windows GMUX self.windows_gmux_checkbox = wx.CheckBox(self.frame_modal, label="Windows GMUX") self.windows_gmux_checkbox.SetValue(self.constants.dGPU_switch) self.windows_gmux_checkbox.Bind(wx.EVT_CHECKBOX, self.windows_gmux_click) self.windows_gmux_checkbox.SetPosition(wx.Point( - self.set_terascale_accel_checkbox.GetPosition().x, - self.set_terascale_accel_checkbox.GetPosition().y + self.set_terascale_accel_checkbox.GetSize().height)) + self.force_web_drivers_checkbox.GetPosition().x, + self.force_web_drivers_checkbox.GetPosition().y + self.force_web_drivers_checkbox.GetSize().height)) self.windows_gmux_checkbox.SetToolTip(wx.ToolTip("Enable this option to allow usage of the hardware GMUX to switch between Intel and Nvidia/AMD GPUs in Windows.")) # Hibernation Workaround @@ -2463,6 +2473,16 @@ class wx_python_gui: subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) self.constants.allow_ts2_accel = False + def force_web_drivers_click(self, event=None): + if self.force_web_drivers_checkbox.GetValue(): + print("Force Web Drivers Enabled") + subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "TRUE"]) + self.constants.force_nv_web = True + else: + print("Force Web Drivers Disabled") + subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) + self.constants.force_nv_web = False + def windows_gmux_click(self, event=None): if self.windows_gmux_checkbox.GetValue(): print("Windows GMUX Enabled") diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 2c81987b2..12e1a3d1e 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -247,7 +247,7 @@ class detect_root_patch: f"Validation: SIP is enabled (Required: {self.check_sip()[2]} or higher)": self.sip_enabled, f"Validation: Currently Booted SIP: ({hex(utilities.csr_dump())})": self.sip_enabled, "Validation: SecureBootModel is enabled": self.sbm_enabled, - "Validation: AMFI is enabled": self.amfi_enabled if self.amfi_must_disable else False, + "Validation: AMFI is enabled": self.amfi_enabled if self.amfi_must_disable is True else False, "Validation: FileVault is enabled": self.fv_enabled, "Validation: System is dosdude1 patched": self.dosdude_patched, "Validation: WhateverGreen.kext missing": self.missing_whatever_green if self.nvidia_web is True else False, From f1d045e5f4d7d1eed8b03f93ec59785ac913c923 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 18:33:17 -0600 Subject: [PATCH 13/31] Set defaults location on r/w --- gui/gui_main.py | 16 ++++++++-------- resources/cli_menu.py | 4 ++-- resources/defaults.py | 8 ++++---- resources/sys_patch_auto.py | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index bdad30395..f0a6c7e75 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -180,7 +180,7 @@ class wx_python_gui: threading.Thread(target=self.check_for_updates).start() def check_for_updates(self, event=None): - ignore_updates = subprocess.run(["defaults", "read", "com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates"], capture_output=True).stdout.decode("utf-8").strip() + ignore_updates = subprocess.run(["defaults", "read", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates"], capture_output=True).stdout.decode("utf-8").strip() if ignore_updates not in ["1", "True", "TRUE"]: self.constants.ignore_updates = False dict = updates.check_binary_updates(self.constants).check_binary_updates() @@ -202,7 +202,7 @@ class wx_python_gui: elif responce == wx.ID_NO: print("- Setting IgnoreAppUpdates to True") self.constants.ignore_updates = True - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates", "-bool", "TRUE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates", "-bool", "TRUE"]) else: self.constants.ignore_updates = True print("- Ignoring App Updates due to defaults") @@ -2403,9 +2403,9 @@ class wx_python_gui: def set_ignore_app_updates_click(self, event): self.constants.ignore_updates = self.set_ignore_app_updates_checkbox.GetValue() if self.constants.ignore_updates is True: - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates", "-bool", "TRUE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates", "-bool", "TRUE"]) else: - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates", "-bool", "FALSE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "IgnoreAppUpdates", "-bool", "FALSE"]) def firewire_click(self, event=None): if self.firewire_boot_checkbox.GetValue(): @@ -2466,21 +2466,21 @@ class wx_python_gui: def ts2_accel_click(self, event=None): if self.set_terascale_accel_checkbox.GetValue(): print("TS2 Acceleration Enabled") - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "TRUE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "TRUE"]) self.constants.allow_ts2_accel = True else: print("TS2 Acceleration Disabled") - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) self.constants.allow_ts2_accel = False def force_web_drivers_click(self, event=None): if self.force_web_drivers_checkbox.GetValue(): print("Force Web Drivers Enabled") - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "TRUE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "TRUE"]) self.constants.force_nv_web = True else: print("Force Web Drivers Disabled") - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) self.constants.force_nv_web = False def windows_gmux_click(self, event=None): diff --git a/resources/cli_menu.py b/resources/cli_menu.py index 88056c181..1de0c784c 100644 --- a/resources/cli_menu.py +++ b/resources/cli_menu.py @@ -589,10 +589,10 @@ handle acceleration tasks. change_menu = input("Allow TeraScale 2 Acceleration?(y/n/q): ") if change_menu in {"y", "Y", "yes", "Yes"}: - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "TRUE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "TRUE"]) self.constants.allow_ts2_accel = True elif change_menu in {"n", "N", "no", "No"}: - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) self.constants.allow_ts2_accel = False elif change_menu in {"q", "Q", "Quit", "quit"}: print("Returning to previous menu") diff --git a/resources/defaults.py b/resources/defaults.py index 070babc33..9b766f86a 100644 --- a/resources/defaults.py +++ b/resources/defaults.py @@ -122,11 +122,11 @@ class generate_defaults: if model in ["MacBookPro8,2", "MacBookPro8,3"]: # Users disabling TS2 most likely have a faulty dGPU # users can override this in settings - ts2_status = subprocess.run(["defaults", "read", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + ts2_status = subprocess.run(["defaults", "read", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() if ts2_status in ["1", "true"]: settings.allow_ts2_accel = True else: - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "MacBookPro_TeraScale_2_Accel", "-bool", "FALSE"]) settings.allow_ts2_accel = False try: @@ -174,9 +174,9 @@ class generate_defaults: pass - nv_web_status = subprocess.run(["defaults", "read", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + nv_web_status = subprocess.run(["defaults", "read", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() if nv_web_status in ["1", "true"]: settings.force_nv_web = True else: - subprocess.run(["defaults", "write", "com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) + subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) settings.force_nv_web = False \ No newline at end of file diff --git a/resources/sys_patch_auto.py b/resources/sys_patch_auto.py index f7252452c..26d3cead4 100644 --- a/resources/sys_patch_auto.py +++ b/resources/sys_patch_auto.py @@ -112,7 +112,7 @@ class AutomaticSysPatch: print("- Determining if macOS drive matches boot drive") - should_notify = subprocess.run(["defaults", "read", "com.dortania.opencore-legacy-patcher", "AutoPatch_Notify_Mismatched_Disks"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + should_notify = subprocess.run(["defaults", "read", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "AutoPatch_Notify_Mismatched_Disks"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() if should_notify in ["0", "false"]: print("- Skipping due to user preference") else: From f068e82bb57c8d9d0425a3d50793bd7bf0d65139 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 21:03:54 -0600 Subject: [PATCH 14/31] Convert NV Web default to global_settings.py --- gui/gui_main.py | 4 ++-- resources/defaults.py | 10 +++------- resources/global_settings.py | 1 + resources/main.py | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index 322b5918c..982437937 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -2476,11 +2476,11 @@ class wx_python_gui: def force_web_drivers_click(self, event=None): if self.force_web_drivers_checkbox.GetValue(): print("Force Web Drivers Enabled") - subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "TRUE"]) + global_settings.global_settings().write_property("Force_Web_Drivers", True) self.constants.force_nv_web = True else: print("Force Web Drivers Disabled") - subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) + global_settings.global_settings().write_property("Force_Web_Drivers", False) self.constants.force_nv_web = False def windows_gmux_click(self, event=None): diff --git a/resources/defaults.py b/resources/defaults.py index 26958ab4d..9ec2808d5 100644 --- a/resources/defaults.py +++ b/resources/defaults.py @@ -173,10 +173,6 @@ class generate_defaults: except KeyError: pass - - nv_web_status = subprocess.run(["defaults", "read", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() - if nv_web_status in ["1", "true"]: - settings.force_nv_web = True - else: - subprocess.run(["defaults", "write", "~/Library/Preferences/com.dortania.opencore-legacy-patcher", "Force_Web_Drivers", "-bool", "FALSE"]) - settings.force_nv_web = False \ No newline at end of file + nv_web_status = global_settings.global_settings().read_property("Force_Web_Drivers") + if nv_web_status is True: + settings.force_nv_web = True \ No newline at end of file diff --git a/resources/global_settings.py b/resources/global_settings.py index e79d195b6..284566ca2 100644 --- a/resources/global_settings.py +++ b/resources/global_settings.py @@ -13,6 +13,7 @@ class global_settings: self.global_settings_folder = "/Users/Shared" self.global_settings_plist = f"{self.global_settings_folder}/{self.file_name}" self.generate_settings_file() + self.convert_defaults_to_global_settings() def generate_settings_file(self): if Path(self.global_settings_plist).exists(): diff --git a/resources/main.py b/resources/main.py index 65908b488..9757c203d 100644 --- a/resources/main.py +++ b/resources/main.py @@ -46,7 +46,6 @@ class OpenCoreLegacyPatcher: self.constants.unpack_thread.start() defaults.generate_defaults.probe(self.computer.real_model, True, self.constants) - global_settings.global_settings().convert_defaults_to_global_settings() if utilities.check_cli_args() is not None: print("- Detected arguments, switching to CLI mode") From 46549b6dd3bebdb4e5f5c1f36549682e956ca918 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 27 May 2022 23:06:02 -0600 Subject: [PATCH 15/31] build.py: Move Web Driver poperty building to dedicated loop Allows properties to be applied on all units if applicable --- resources/build.py | 47 ++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/resources/build.py b/resources/build.py index e06ec7c66..9cf9951f1 100644 --- a/resources/build.py +++ b/resources/build.py @@ -689,15 +689,6 @@ class BuildOpenCore: self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - if device.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: - print("- Adding Web Driver Patches") - self.config["DeviceProperties"]["Add"][device.pci_path].update({"disable-metal": 1, "force-compat": 1}) - if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: - self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].update({"nvda_drv": binascii.unhexlify("31")}) - if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]: - self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"] - else: print(f"- Failed to find Device path for dGPU {i + 1}") if isinstance(device, device_probe.AMD): @@ -714,15 +705,6 @@ class BuildOpenCore: self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -wegtree agdpmod=vit9696" self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - if device.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal]: - print("- Adding Web Driver Patches") - if "ngfxgl=1 ngfxcompat=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1" - if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: - self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].update({"nvda_drv": binascii.unhexlify("31")}) - if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]: - self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"] if not self.computer.gpus: print("- No socketed dGPU found") @@ -731,6 +713,35 @@ 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 not self.constants.custom_model: + for i, device in enumerate(self.computer.gpus): + if isinstance(device, device_probe.NVIDIA): + if ( + device.arch in [device_probe.NVIDIA.Archs.Fermi, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal] or + (self.constants.force_nv_web is True and device.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Kepler]) + ): + print(f"- Enabling Web Driver Patches for GPU ({i + 1}): {utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}") + if device.pci_path and device.acpi_path: + if device.pci_path in self.config["DeviceProperties"]["Add"]: + self.config["DeviceProperties"]["Add"][device.pci_path].update({"disable-metal": 1, "force-compat": 1}) + else: + self.config["DeviceProperties"]["Add"][device.pci_path] = {"disable-metal": 1, "force-compat": 1} + if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: + self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].update({"nvda_drv": binascii.unhexlify("31")}) + if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]: + self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"] + else: + if "ngfxgl=1 ngfxcompat=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " ngfxgl=1 ngfxcompat=1" + if self.get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is False: + self.enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path) + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].update({"nvda_drv": binascii.unhexlify("31")}) + if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]: + self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"] + + 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"]: From db72c0cbb7c4461a517fd5f9b556f899b922607a Mon Sep 17 00:00:00 2001 From: flagersgit <48706788+flagersgit@users.noreply.github.com> Date: Sat, 28 May 2022 11:17:41 -0400 Subject: [PATCH 16/31] sys_patch.py: Clean-up non-Metal enforcement during preflight & unpatch --- resources/sys_patch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 64df04da7..6158831c6 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -108,6 +108,7 @@ class PatchSysVolume: print("- Failed to revert snapshot via Apple's 'bless' command") else: self.clean_skylight_plugins() + self.delete_nonmetal_enforcement() self.constants.root_patcher_succeded = True print("- Unpatching complete") print("\nPlease reboot the machine for patches to take effect") @@ -193,6 +194,14 @@ class PatchSysVolume: else: print("- Creating SkylightPlugins folder") utilities.process_status(utilities.elevated(["mkdir", "-p", f"{self.mount_application_support}/SkyLightPlugins/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + + def delete_nonmetal_enforcement(self): + use_metal = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + use_iop = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + if use_metal or use_iop in ["1", "true"]: + print("- Removing non-Metal Enforcement Preferences") + subprocess.run(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"]) + subprocess.run(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"]) def write_patchset(self, patchset): destination_path = f"{self.mount_location}/System/Library/CoreServices" @@ -260,6 +269,8 @@ class PatchSysVolume: # Make sure old SkyLight plugins aren't being used self.clean_skylight_plugins() + # Make sure non-Metal Enforcement preferences are not present + self.delete_nonmetal_enforcement() # Make sure SNB kexts are compatible with the host if "Intel Sandy Bridge" in required_patches: From 43f9dd7c48804a87a5cb3219bb03d713cdae86f8 Mon Sep 17 00:00:00 2001 From: flagersgit <48706788+flagersgit@users.noreply.github.com> Date: Sat, 28 May 2022 11:17:41 -0400 Subject: [PATCH 17/31] sys_patch.py: Clean-up non-Metal enforcement during preflight & unpatch --- resources/sys_patch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 64df04da7..062da3b5d 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -108,6 +108,7 @@ class PatchSysVolume: print("- Failed to revert snapshot via Apple's 'bless' command") else: self.clean_skylight_plugins() + self.delete_nonmetal_enforcement() self.constants.root_patcher_succeded = True print("- Unpatching complete") print("\nPlease reboot the machine for patches to take effect") @@ -193,6 +194,14 @@ class PatchSysVolume: else: print("- Creating SkylightPlugins folder") utilities.process_status(utilities.elevated(["mkdir", "-p", f"{self.mount_application_support}/SkyLightPlugins/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + + def delete_nonmetal_enforcement(self): + use_metal = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + use_iop = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + if use_metal or use_iop in ["1", "true"]: + print("- Removing non-Metal Enforcement Preferences") + utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"]) + utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"]) def write_patchset(self, patchset): destination_path = f"{self.mount_location}/System/Library/CoreServices" @@ -260,6 +269,8 @@ class PatchSysVolume: # Make sure old SkyLight plugins aren't being used self.clean_skylight_plugins() + # Make sure non-Metal Enforcement preferences are not present + self.delete_nonmetal_enforcement() # Make sure SNB kexts are compatible with the host if "Intel Sandy Bridge" in required_patches: From 46f5e6a49157c4f28a9a888ffd19fa9919f971da Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sat, 28 May 2022 09:23:30 -0600 Subject: [PATCH 18/31] sys_patch.py: Run defaults delete with privilage --- resources/sys_patch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 6158831c6..062da3b5d 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -200,8 +200,8 @@ class PatchSysVolume: use_iop = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() if use_metal or use_iop in ["1", "true"]: print("- Removing non-Metal Enforcement Preferences") - subprocess.run(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"]) - subprocess.run(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"]) + utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"]) + utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"]) def write_patchset(self, patchset): destination_path = f"{self.mount_location}/System/Library/CoreServices" From a129d611fbb84da04893d16cf8043d4c54956507 Mon Sep 17 00:00:00 2001 From: flagersgit <48706788+flagersgit@users.noreply.github.com> Date: Sat, 28 May 2022 11:29:07 -0400 Subject: [PATCH 19/31] sys_patch.py: Correct non-Metal Enforcement cleanup faulty logic --- resources/sys_patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 062da3b5d..9ca0ef8ab 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -198,7 +198,7 @@ class PatchSysVolume: def delete_nonmetal_enforcement(self): use_metal = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() use_iop = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() - if use_metal or use_iop in ["1", "true"]: + if use_metal or use_iop in ["0", "false", "1", "true"]: print("- Removing non-Metal Enforcement Preferences") utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"]) utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"]) From fe4914f67b181537b919c095a1b1170792f16b2e Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sat, 28 May 2022 09:43:31 -0600 Subject: [PATCH 20/31] utilities.py: Fix amfi check --- resources/utilities.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/resources/utilities.py b/resources/utilities.py index d3f7abc03..481dbcbdc 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -150,16 +150,15 @@ def amfi_status(): amfi_1 = "amfi_get_out_of_my_way=0x1" amfi_2 = "amfi_get_out_of_my_way=1" - if get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False): - if "-allow_amfi" in get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True): + oclp_guid = get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False) + if oclp_guid: + if "-allow_amfi" in oclp_guid: return False - else: - return True - elif get_nvram("boot-args", decode=False): - if amfi_1 in get_nvram("boot-args", decode=False) or amfi_2 in get_nvram("boot-args", decode=False): + boot_args = get_nvram("boot-args", decode=False) + if boot_args: + if amfi_1 in boot_args or amfi_2 in boot_args: return False - else: - return True + return True def check_kext_loaded(kext_name, os_version): From b547c2e407246e165fd52ab38c3280f62c69b92e Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sat, 28 May 2022 10:00:00 -0600 Subject: [PATCH 21/31] utilities.py: Add amfi=128 support for amfi check --- resources/utilities.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/resources/utilities.py b/resources/utilities.py index 481dbcbdc..8e4026e52 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -147,8 +147,11 @@ def enable_sleep_after_running(): sleep_process = None def amfi_status(): - amfi_1 = "amfi_get_out_of_my_way=0x1" - amfi_2 = "amfi_get_out_of_my_way=1" + amfi_args = [ + "amfi_get_out_of_my_way=0x1", + "amfi_get_out_of_my_way=1", + "amfi=128", + ] oclp_guid = get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False) if oclp_guid: @@ -156,8 +159,9 @@ def amfi_status(): return False boot_args = get_nvram("boot-args", decode=False) if boot_args: - if amfi_1 in boot_args or amfi_2 in boot_args: - return False + for arg in amfi_args: + if arg in boot_args: + return False return True From 31599c90b4cc617fc545b7deec428ba14bef6d9b Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sat, 28 May 2022 10:15:57 -0600 Subject: [PATCH 22/31] sys_patch_detect.py: explisitly check for true --- resources/sys_patch_detect.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 12e1a3d1e..a3c42c556 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -322,13 +322,13 @@ class detect_root_patch: self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched, # non-Metal specific - self.amfi_enabled if self.amfi_must_disable else False, + self.amfi_enabled if self.amfi_must_disable is True else False, # Web Driver specific - self.missing_nv_web_nvram if self.nvidia_web else False, - self.missing_nv_web_opengl if self.nvidia_web else False, - self.missing_nv_compat if self.nvidia_web else False, - self.missing_whatever_green if self.nvidia_web else False, + self.missing_nv_web_nvram if self.nvidia_web is True else False, + self.missing_nv_web_opengl if self.nvidia_web is True else False, + self.missing_nv_compat if self.nvidia_web is True else False, + self.missing_whatever_green if self.nvidia_web is True else False, ] ): return False From 467cc78f58a322a578637ed4f61604bc38fafecd Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 29 May 2022 10:58:06 -0600 Subject: [PATCH 23/31] utilities.py: decode amfi argument --- resources/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/utilities.py b/resources/utilities.py index 8e4026e52..82cf8d943 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -153,7 +153,7 @@ def amfi_status(): "amfi=128", ] - oclp_guid = get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False) + oclp_guid = get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) if oclp_guid: if "-allow_amfi" in oclp_guid: return False From e8f2f7fd78bd947cc71bd8558a92c883f71dd596 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 29 May 2022 11:09:48 -0600 Subject: [PATCH 24/31] sys_patch_dict.py: ensure `get_nvram()` decodes when `str` expected --- resources/sys_patch_detect.py | 8 ++++---- resources/utilities.py | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 622fc21ad..e51e9c8f9 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -123,7 +123,7 @@ class detect_root_patch: 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", decode=True) or ""): igpu = self.constants.computer.igpu dgpu = self.check_dgpu_status() if igpu and not dgpu: @@ -139,7 +139,7 @@ class detect_root_patch: def check_nv_web_nvram(self): # First check boot-args, then dedicated nvram variable - nv_on = utilities.get_nvram("boot-args") + nv_on = utilities.get_nvram("boot-args", decode=True) if nv_on: if "nvda_drv_vrl=" in nv_on: return True @@ -150,7 +150,7 @@ class detect_root_patch: def check_nv_web_opengl(self): # First check boot-args, then whether property exists on GPU - nv_on = utilities.get_nvram("boot-args") + nv_on = utilities.get_nvram("boot-args", decode=True) if nv_on: if "ngfxgl=" in nv_on: return True @@ -162,7 +162,7 @@ class detect_root_patch: def check_nv_compat(self): # Check for 'nv_web' in boot-args, then whether property exists on GPU - nv_on = utilities.get_nvram("boot-args") + nv_on = utilities.get_nvram("boot-args", decode=True) if nv_on: if "ngfxcompat=" in nv_on: return True diff --git a/resources/utilities.py b/resources/utilities.py index 82cf8d943..e6ea35df3 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -157,7 +157,7 @@ def amfi_status(): if oclp_guid: if "-allow_amfi" in oclp_guid: return False - boot_args = get_nvram("boot-args", decode=False) + boot_args = get_nvram("boot-args", decode=True) if boot_args: for arg in amfi_args: if arg in boot_args: @@ -215,10 +215,11 @@ def check_metal_support(device_probe, computer): def check_filevault_skip(): # Check whether we can skip FileVault check with Root Patching - if get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=False) and "-allow_fv" in get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True): - return True - else: - return False + nvram = get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) + if nvram: + if "-allow_fv" in nvram: + return True + return False def check_secure_boot_model(): From 391b5381f6ec2192d45b2ae32930582c68bfb06f Mon Sep 17 00:00:00 2001 From: Dhinak G <17605561+dhinakg@users.noreply.github.com> Date: Sun, 29 May 2022 13:23:49 -0400 Subject: [PATCH 25/31] utilities.py: Ensure null terminators are stripped when value is already string --- resources/utilities.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/utilities.py b/resources/utilities.py index e6ea35df3..ba9b50301 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -345,8 +345,11 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False): value = ioreg.corefoundation_to_native(value) - if decode and isinstance(value, bytes): - value = value.strip(b"\0").decode() + if decode: + if isinstance(value, bytes): + value = value.strip(b"\0").decode() + elif isinstance(value, str): + value = value.strip("\0") return value From c249eb767a4e2500688537e4aa9d8ea5c9111b02 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 29 May 2022 13:07:48 -0600 Subject: [PATCH 26/31] defaults.py: Set non-Metal Beta options by default on Desktops --- resources/defaults.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/resources/defaults.py b/resources/defaults.py index 9ec2808d5..4e8f4c1ca 100644 --- a/resources/defaults.py +++ b/resources/defaults.py @@ -1,6 +1,6 @@ # Generate Default Data from resources import utilities, device_probe, generate_smbios, global_settings -from data import model_array, smbios_data, cpu_data +from data import model_array, smbios_data, cpu_data, os_data import subprocess @@ -39,6 +39,20 @@ class generate_defaults: settings.sip_status = False settings.allow_fv_root = True settings.host_is_non_metal = True + + # If a Mac is non-Metal based, Beta Blur is highly recommended + # However on lower end hardware, users may prefer the performance benefits without + if not model.startswith("MacBook") and settings.detected_os >= os_data.os_data.big_sur: + non_metal_args = [ + "Moraea_BlurBeta", + "Moraea_RimBeta", + ] + for arg in non_metal_args: + # If user explicitly set the blur, don't override + arg_result = subprocess.run(["defaults", "read", "-g", arg], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + if arg_result not in ["true", "1", "false", "0"]: + subprocess.run(["defaults", "write", "-g", arg, "-bool", "TRUE"]) + if settings.computer.gpus: for gpu in settings.computer.gpus: if gpu.arch == device_probe.NVIDIA.Archs.Kepler: From 9be9c1313b816ee97148e3a96031691c7e625b18 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 29 May 2022 13:26:12 -0600 Subject: [PATCH 27/31] sys_patch_detect.py: Remove unneeded check --- resources/sys_patch_detect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index e51e9c8f9..60e007e7b 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -73,7 +73,7 @@ class detect_root_patch: device_probe.NVIDIA.Archs.Kepler, device_probe.NVIDIA.Archs.Maxwell, device_probe.NVIDIA.Archs.Pascal, - ] and self.constants.force_nv_web is True: + ]: if self.constants.detected_os > os_data.os_data.mojave: self.nvidia_web = True self.amfi_must_disable = True From d289dbbffa80e583cece6747620e746217d14130 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 29 May 2022 20:00:03 -0600 Subject: [PATCH 28/31] sys_patch_dict.py: Omit NV Web Pref Pane --- data/sys_patch_dict.py | 21 ++++++++++++--------- gui/gui_main.py | 5 ++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/data/sys_patch_dict.py b/data/sys_patch_dict.py index b54e18dac..dda970503 100644 --- a/data/sys_patch_dict.py +++ b/data/sys_patch_dict.py @@ -344,15 +344,18 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support): "NVDANV50HalTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", "NVDAResmanTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", }, - "/Library/PreferencePanes": { - "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", - }, - "/Library/LaunchAgents": { - "com.nvidia.nvagent.plist": "WebDriver-387.10.10.10.40.140", - }, - "/Library/LaunchDaemons": { - "com.nvidia.nvroothelper.plist": "WebDriver-387.10.10.10.40.140", - }, + + # Disabled due to issues with Pref pane stripping 'nvda_drv' NVRAM + # variables + # "/Library/PreferencePanes": { + # "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", + # }, + # "/Library/LaunchAgents": { + # "com.nvidia.nvagent.plist": "WebDriver-387.10.10.10.40.140", + # }, + # "/Library/LaunchDaemons": { + # "com.nvidia.nvroothelper.plist": "WebDriver-387.10.10.10.40.140", + # }, }, "Remove": { "/System/Library/Extensions": [ diff --git a/gui/gui_main.py b/gui/gui_main.py index 68688ee77..cf1ca48f9 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -1193,9 +1193,8 @@ class wx_python_gui: stdout=subprocess.PIPE, stderr=subprocess.PIPE ) - if output.returncode == 0: - time.sleep(5) - self.OnCloseFrame(None) + time.sleep(5) + self.OnCloseFrame(None) else: self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?") self.return_to_main_menu.Enable() From d84fbb6cb01dc51a3eeb9226abb41d3a6e80d8b3 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Sun, 29 May 2022 21:49:57 -0600 Subject: [PATCH 29/31] device_probe.py: Add non-Mac detection Applicable for Virtual Machines and Hackintoshes --- gui/gui_main.py | 29 ++++++++++++++++++++++------- resources/constants.py | 1 + resources/device_probe.py | 8 ++++++++ resources/main.py | 3 +++ resources/utilities.py | 15 +++++++++++++++ 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/gui/gui_main.py b/gui/gui_main.py index cf1ca48f9..2d5c34c23 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -164,7 +164,8 @@ class wx_python_gui: def preflight_check(self): if ( self.constants.computer.build_model != None and - self.constants.computer.build_model != self.constants.computer.real_model + self.constants.computer.build_model != self.constants.computer.real_model and + self.constants.host_is_hackintosh is False ): # Notify user they're booting an unsupported configuration self.constants.start_build_install = True @@ -366,9 +367,16 @@ class wx_python_gui: self.build_install.Centre(wx.HORIZONTAL) # Disable button if real_model not in model_array.SupportedSMBIOS - if self.constants.allow_oc_everywhere is False and \ - self.constants.custom_model is None and \ - self.computer.real_model not in model_array.SupportedSMBIOS: + if ( + ( + self.constants.allow_oc_everywhere is False and \ + self.constants.custom_model is None and \ + self.computer.real_model not in model_array.SupportedSMBIOS + ) or ( + self.constants.custom_model is None and \ + self.constants.host_is_hackintosh is True + ) + ): self.build_install.Disable() self.build_install.SetToolTip(wx.ToolTip("""If building for a native Mac model, \nselect 'Allow Native Models' in Settings.\nIf building for another Mac, change model in Settings""")) @@ -1877,9 +1885,16 @@ class wx_python_gui: self.finished_cim_process = False # Only prompt user with option to install OC to disk if # the model is supported. - if self.constants.allow_oc_everywhere is False and \ - self.constants.custom_model is None and \ - self.computer.real_model not in model_array.SupportedSMBIOS: + if ( + ( + self.constants.allow_oc_everywhere is False and \ + self.constants.custom_model is None and \ + self.computer.real_model not in model_array.SupportedSMBIOS + ) or ( + self.constants.custom_model is None and \ + self.constants.host_is_hackintosh is True + ) + ): popup_message = wx.MessageDialog(self.frame, "Sucessfully created a macOS installer!", "Success", wx.OK) popup_message.ShowModal() else: diff --git a/resources/constants.py b/resources/constants.py index 97d67db3d..7383a8659 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -192,6 +192,7 @@ class Constants: self.start_build_install = False # Determine if build install should be started self.host_is_non_metal = False # Determine if host is non-metal (ie. enable UI hacks) self.needs_to_open_preferences = False # Determine if preferences need to be opened + self.host_is_hackintosh = False # Determine if host is Hackintosh self.legacy_accel_support = [ os_data.os_data.big_sur, diff --git a/resources/device_probe.py b/resources/device_probe.py index 5e3e778d4..487b6072e 100644 --- a/resources/device_probe.py +++ b/resources/device_probe.py @@ -484,6 +484,7 @@ class Computer: secure_boot_policy: Optional[int] = None oclp_sys_version: Optional[str] = None oclp_sys_date: Optional[str] = None + firmware_vendor: Optional[str] = None @staticmethod def probe(): @@ -704,6 +705,13 @@ class Computer: # SecureBoot Variables self.secure_boot_model = utilities.check_secure_boot_model() self.secure_boot_policy = utilities.check_ap_security_policy() + + # Firmware Vendor + firmware_vendor = utilities.get_firmware_vendor(decode=False) + if isinstance(firmware_vendor, bytes): + firmware_vendor = str(firmware_vendor.replace(b"\x00", b"").decode("utf-8")) + self.firmware_vendor = firmware_vendor + def cpu_probe(self): self.cpu = CPU( subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(), diff --git a/resources/main.py b/resources/main.py index 9757c203d..dd2053492 100644 --- a/resources/main.py +++ b/resources/main.py @@ -33,6 +33,9 @@ class OpenCoreLegacyPatcher: self.constants.recovery_status = utilities.check_recovery() self.computer = self.constants.computer self.constants.booted_oc_disk = utilities.find_disk_off_uuid(utilities.clean_device_path(self.computer.opencore_path)) + if self.constants.computer.firmware_vendor: + if self.constants.computer.firmware_vendor != "Apple": + self.constants.host_is_hackintosh = True launcher_script = None launcher_binary = sys.executable if "python" in launcher_binary: diff --git a/resources/utilities.py b/resources/utilities.py index ba9b50301..70ff41666 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -371,6 +371,21 @@ def get_rom(variable: str, *, decode: bool = False): value = value.strip(b"\0").decode() return value +def get_firmware_vendor(*, decode: bool = False): + efi = ioreg.IORegistryEntryFromPath(ioreg.kIOMasterPortDefault, "IODeviceTree:/efi".encode()) + value = ioreg.IORegistryEntryCreateCFProperty(efi, "firmware-vendor", ioreg.kCFAllocatorDefault, ioreg.kNilOptions) + ioreg.IOObjectRelease(efi) + + if not value: + return None + + value = ioreg.corefoundation_to_native(value) + if decode: + if isinstance(value, bytes): + value = value.strip(b"\0").decode() + elif isinstance(value, str): + value = value.strip("\0") + return value def verify_network_connection(url): try: From c1258ac50db913fd9b5bb7ed322b989dc841f2b2 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Mon, 30 May 2022 11:18:28 -0600 Subject: [PATCH 30/31] sys_patch.py: Adjust `delete_nonmetal_enforcement()` logic --- resources/sys_patch.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/sys_patch.py b/resources/sys_patch.py index 9ca0ef8ab..4f564e927 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -196,12 +196,11 @@ class PatchSysVolume: utilities.process_status(utilities.elevated(["mkdir", "-p", f"{self.mount_application_support}/SkyLightPlugins/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) def delete_nonmetal_enforcement(self): - use_metal = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() - use_iop = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() - if use_metal or use_iop in ["0", "false", "1", "true"]: - print("- Removing non-Metal Enforcement Preferences") - utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useMetal"]) - utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", "useIOP"]) + for arg in ["useMetal", "useIOP"]: + result = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", arg], stdout=subprocess.PIPE).stdout.decode("utf-8").strip() + if result in ["0", "false", "1", "true"]: + print(f"- Removing non-Metal Enforcement Preference: {arg}") + utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", arg]) def write_patchset(self, patchset): destination_path = f"{self.mount_location}/System/Library/CoreServices" From 4fe9679660f77ba8b58273ed27817c1eba0bd57d Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Mon, 30 May 2022 11:29:27 -0600 Subject: [PATCH 31/31] sys_patch_auto.py: Avoid prompting config changes on hackintoshes --- resources/sys_patch_auto.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/sys_patch_auto.py b/resources/sys_patch_auto.py index b5f1393ae..2341c611a 100644 --- a/resources/sys_patch_auto.py +++ b/resources/sys_patch_auto.py @@ -115,6 +115,8 @@ class AutomaticSysPatch: should_notify = global_settings.global_settings().read_property("AutoPatch_Notify_Mismatched_Disks") if should_notify is False: print("- Skipping due to user preference") + elif settings.host_is_hackintosh is True: + print("- Skipping due to hackintosh") else: if settings.booted_oc_disk: root_disk = settings.booted_oc_disk.strip("disk")