mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-19 22:00:00 +10:00
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
This commit is contained in:
+2
-2
@@ -932,11 +932,11 @@ class wx_python_gui:
|
|||||||
for patch in patches:
|
for patch in patches:
|
||||||
if patch.startswith("Validation") and patches[patch] is True:
|
if patch.startswith("Validation") and patches[patch] is True:
|
||||||
print(f"- Adding check: {patch} - {patches[patch]}")
|
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.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
|
||||||
self.patch_label.SetPosition(
|
self.patch_label.SetPosition(
|
||||||
wx.Point(
|
wx.Point(
|
||||||
self.subheader.GetPosition().x + 20,
|
self.subheader.GetPosition().x,
|
||||||
self.subheader.GetPosition().y + self.subheader.GetSize().height + 3 + i
|
self.subheader.GetPosition().y + self.subheader.GetSize().height + 3 + i
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ class PCIDevice:
|
|||||||
device_id: int # The device ID of this PCI device
|
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
|
class_code: int # The class code of this PCI device - https://pci-ids.ucw.cz/read/PD
|
||||||
|
|
||||||
name: Optional[str] = None # Name of IORegistryEntry
|
name: Optional[str] = None # Name of IORegistryEntry
|
||||||
model: Optional[str] = None # model property
|
model: Optional[str] = None # model property
|
||||||
acpi_path: Optional[str] = None
|
acpi_path: Optional[str] = None # ACPI Device Path
|
||||||
pci_path: Optional[str] = None
|
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
|
@classmethod
|
||||||
def from_ioregistry(cls, entry: ioreg.io_registry_entry_t, anti_spoof=False):
|
def from_ioregistry(cls, entry: ioreg.io_registry_entry_t, anti_spoof=False):
|
||||||
@@ -51,6 +53,10 @@ class PCIDevice:
|
|||||||
device.model = model
|
device.model = model
|
||||||
if "acpi-path" in properties:
|
if "acpi-path" in properties:
|
||||||
device.acpi_path = properties["acpi-path"]
|
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)
|
device.populate_pci_path(entry)
|
||||||
return device
|
return device
|
||||||
|
|
||||||
|
|||||||
+128
-43
@@ -13,33 +13,38 @@ class detect_root_patch:
|
|||||||
self.computer = self.constants.computer
|
self.computer = self.constants.computer
|
||||||
|
|
||||||
# GPU Patch Detection
|
# GPU Patch Detection
|
||||||
self.nvidia_tesla= False
|
self.nvidia_tesla = False
|
||||||
self.kepler_gpu= False
|
self.kepler_gpu = False
|
||||||
self.nvidia_web= False
|
self.nvidia_web = False
|
||||||
self.amd_ts1= False
|
self.amd_ts1 = False
|
||||||
self.amd_ts2= False
|
self.amd_ts2 = False
|
||||||
self.iron_gpu= False
|
self.iron_gpu = False
|
||||||
self.sandy_gpu= False
|
self.sandy_gpu = False
|
||||||
self.ivy_gpu= False
|
self.ivy_gpu = False
|
||||||
|
|
||||||
# Misc Patch Detection
|
# Misc Patch Detection
|
||||||
self.brightness_legacy= False
|
self.brightness_legacy = False
|
||||||
self.legacy_audio= False
|
self.legacy_audio = False
|
||||||
self.legacy_wifi= False
|
self.legacy_wifi = False
|
||||||
self.legacy_gmux= False
|
self.legacy_gmux = False
|
||||||
self.legacy_keyboard_backlight= False
|
self.legacy_keyboard_backlight = False
|
||||||
|
|
||||||
# Patch Requirements
|
# Patch Requirements
|
||||||
self.amfi_must_disable= False
|
self.amfi_must_disable = False
|
||||||
self.supports_metal= False
|
self.supports_metal = False
|
||||||
|
self.needs_nv_web_checks = False
|
||||||
|
|
||||||
# Validation Checks
|
# Validation Checks
|
||||||
self.sip_enabled = False
|
self.sip_enabled = False
|
||||||
self.sbm_enabled = False
|
self.sbm_enabled = False
|
||||||
self.amfi_enabled = False
|
self.amfi_enabled = False
|
||||||
self.fv_enabled = False
|
self.fv_enabled = False
|
||||||
self.dosdude_patched = 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):
|
def detect_gpus(self):
|
||||||
gpus = self.constants.computer.gpus
|
gpus = self.constants.computer.gpus
|
||||||
@@ -47,7 +52,7 @@ class detect_root_patch:
|
|||||||
for i, gpu in enumerate(gpus):
|
for i, gpu in enumerate(gpus):
|
||||||
if gpu.class_code and gpu.class_code != 0xFFFFFFFF:
|
if gpu.class_code and gpu.class_code != 0xFFFFFFFF:
|
||||||
print(f"- Found GPU ({i}): {utilities.friendly_hex(gpu.vendor_id)}:{utilities.friendly_hex(gpu.device_id)}")
|
print(f"- Found GPU ({i}): {utilities.friendly_hex(gpu.vendor_id)}:{utilities.friendly_hex(gpu.device_id)}")
|
||||||
if gpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]:
|
if gpu.arch in [device_probe.NVIDIA.Archs.Tesla]:
|
||||||
if self.constants.detected_os > non_metal_os:
|
if self.constants.detected_os > non_metal_os:
|
||||||
self.nvidia_tesla = True
|
self.nvidia_tesla = True
|
||||||
self.amfi_must_disable = True
|
self.amfi_must_disable = True
|
||||||
@@ -62,10 +67,11 @@ class detect_root_patch:
|
|||||||
if "21A5506j" not in self.constants.detected_os_build:
|
if "21A5506j" not in self.constants.detected_os_build:
|
||||||
self.kepler_gpu = True
|
self.kepler_gpu = True
|
||||||
self.supports_metal = 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:
|
if self.constants.detected_os > os_data.os_data.mojave:
|
||||||
self.nvidia_web = True
|
self.nvidia_web = True
|
||||||
self.amfi_must_disable = True
|
self.amfi_must_disable = True
|
||||||
|
self.needs_nv_web_checks = True
|
||||||
elif gpu.arch == device_probe.AMD.Archs.TeraScale_1:
|
elif gpu.arch == device_probe.AMD.Archs.TeraScale_1:
|
||||||
if self.constants.detected_os > non_metal_os:
|
if self.constants.detected_os > non_metal_os:
|
||||||
self.amd_ts1 = True
|
self.amd_ts1 = True
|
||||||
@@ -125,6 +131,44 @@ class detect_root_patch:
|
|||||||
return self.constants.computer.ambient_light_sensor
|
return self.constants.computer.ambient_light_sensor
|
||||||
return False
|
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):
|
def detect_patch_set(self):
|
||||||
self.detect_gpus()
|
self.detect_gpus()
|
||||||
if self.model in model_array.LegacyBrightness:
|
if self.model in model_array.LegacyBrightness:
|
||||||
@@ -159,27 +203,31 @@ class detect_root_patch:
|
|||||||
self.legacy_gmux = True
|
self.legacy_gmux = True
|
||||||
|
|
||||||
self.root_patch_dict = {
|
self.root_patch_dict = {
|
||||||
"Graphics: Nvidia Tesla": self.nvidia_tesla,
|
"Graphics: Nvidia Tesla": self.nvidia_tesla,
|
||||||
"Graphics: Nvidia Kepler": self.kepler_gpu,
|
"Graphics: Nvidia Kepler": self.kepler_gpu,
|
||||||
"Graphics: Nvidia Web Drivers": self.nvidia_web,
|
"Graphics: Nvidia Web Drivers": self.nvidia_web,
|
||||||
# "Graphics: Nvidia Web Drivers": False,
|
"Graphics: AMD TeraScale 1": self.amd_ts1,
|
||||||
"Graphics: AMD TeraScale 1": self.amd_ts1,
|
"Graphics: AMD TeraScale 2": self.amd_ts2,
|
||||||
"Graphics: AMD TeraScale 2": self.amd_ts2,
|
"Graphics: Intel Ironlake": self.iron_gpu,
|
||||||
"Graphics: Intel Ironlake": self.iron_gpu,
|
"Graphics: Intel Sandy Bridge": self.sandy_gpu,
|
||||||
"Graphics: Intel Sandy Bridge": self.sandy_gpu,
|
"Graphics: Intel Ivy Bridge": self.ivy_gpu,
|
||||||
"Graphics: Intel Ivy Bridge": self.ivy_gpu,
|
"Brightness: Legacy Backlight Control": self.brightness_legacy,
|
||||||
"Brightness: Legacy Backlight Control": self.brightness_legacy,
|
"Audio: Legacy Realtek": self.legacy_audio,
|
||||||
"Audio: Legacy Realtek": self.legacy_audio,
|
"Networking: Legacy Wireless": self.legacy_wifi,
|
||||||
"Networking: Legacy Wireless": self.legacy_wifi,
|
"Miscellaneous: Legacy GMUX": self.legacy_gmux,
|
||||||
"Miscellaneous: Legacy GMUX": self.legacy_gmux,
|
"Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight,
|
||||||
"Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight,
|
"Settings: Requires AMFI exemption": self.amfi_must_disable,
|
||||||
"Settings: Requires AMFI exemption": self.amfi_must_disable,
|
"Validation: Patching Possible": self.verify_patch_allowed(),
|
||||||
"Validation: Patching Possible": self.verify_patch_allowed(),
|
"Validation: SIP is enabled": self.sip_enabled,
|
||||||
"Validation: SIP is enabled": self.sip_enabled,
|
"Validation: SecureBootModel is enabled": self.sbm_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 else False,
|
"Validation: FileVault is enabled": self.fv_enabled,
|
||||||
"Validation: FileVault is enabled": self.fv_enabled,
|
"Validation: System is dosdude1 patched": self.dosdude_patched,
|
||||||
"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
|
return self.root_patch_dict
|
||||||
@@ -187,6 +235,13 @@ class detect_root_patch:
|
|||||||
def verify_patch_allowed(self, print_errors=False):
|
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 = 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)
|
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:
|
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"
|
sip_value = "For Hackintoshes, please set csr-active-config to '03060000' (0x603)\nFor non-OpenCore Macs, please run 'csrutil disable' in RecoveryOS"
|
||||||
else:
|
else:
|
||||||
@@ -219,8 +274,38 @@ class detect_root_patch:
|
|||||||
print("\nCannot patch! Detected machine has already been patched by another patcher")
|
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")
|
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(
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user