diff --git a/CHANGELOG.md b/CHANGELOG.md index 1abd04359..958871fc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Ensure Apple Silicon-specific installers are not listed - ie. M2 specific build (21F2092) - Avoid adding OpenCore icon in boot picker if Windows bootloader on same partition +- Add error-handling to corrupt/non-standard NVRAM variables +- Add warning prompt when using 'Allow native models' + - Attempt to avoid misuse of option - Ventura Specific Updates: - Switch boot.efi model patch to iMac18,1 - Resolve pre-Force Touch Trackpad support in Ventura diff --git a/data/os_data.py b/data/os_data.py index 65dbd5bc8..92952c3b2 100644 --- a/data/os_data.py +++ b/data/os_data.py @@ -3,22 +3,26 @@ import enum class os_data(enum.IntEnum): # OS Versions, Based off Major Kernel Version - tiger = 8 - leopard = 9 - snow_leopard = 10 - lion = 11 + cheetah = 4 # Actually 1.3.1 + puma = 5 + jaguar = 6 + panther = 7 + tiger = 8 + leopard = 9 + snow_leopard = 10 + lion = 11 mountain_lion = 12 - mavericks = 13 - yosemite = 14 - el_capitan = 15 - sierra = 16 - high_sierra = 17 - mojave = 18 - catalina = 19 - big_sur = 20 - monterey = 21 - ventura = 22 - max_os = 99 + mavericks = 13 + yosemite = 14 + el_capitan = 15 + sierra = 16 + high_sierra = 17 + mojave = 18 + catalina = 19 + big_sur = 20 + monterey = 21 + ventura = 22 + max_os = 99 class os_conversion: @@ -45,4 +49,32 @@ class os_conversion: if source_minor < target_minor: return True else: - return False \ No newline at end of file + return False + + def convert_kernel_to_marketing_name(kernel): + # Convert major XNU version to Marketing Name + try: + # Find os_data enum name + os_name = os_data(kernel).name + + # Remove "_" from the string + os_name = os_name.replace("_", " ") + + # Upper case the first letter of each word + os_name = os_name.title() + except ValueError: + # Handle cases where no enum value exists + # Pass kernel_to_os() as a substitute for a proper OS name + os_name = os_conversion.kernel_to_os(kernel) + + return os_name + + def convert_marketing_name_to_kernel(marketing_name): + # Convert Marketing Name to major XNU version + try: + # Find os_data enum value + os_kernel = os_data[marketing_name.lower().replace(" ", "_")] + except KeyError: + os_kernel = 0 + + return int(os_kernel) \ No newline at end of file diff --git a/gui/gui_main.py b/gui/gui_main.py index 7f89e29c7..1e0c0e1d1 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -2175,6 +2175,21 @@ class wx_python_gui: def allow_native_models_click(self, event=None): if self.checkbox_allow_native_models.GetValue(): + # Throw a prompt warning about this + dlg = wx.MessageDialog(self.frame_modal, "This option should only be used if your Mac natively supports the OSes you wish to run.\n\nIf you are currently running an unsupported OS, this option will break booting. Only toggle for enabling OS features on a native Mac.\n\nAre you sure you want to continue?", "Warning", wx.YES_NO | wx.ICON_WARNING) + if dlg.ShowModal() == wx.ID_NO: + self.checkbox_allow_native_models.SetValue(False) + return + # If the system is running an unsupported OS, throw a second warning + if self.constants.computer.real_model in smbios_data.smbios_dictionary: + if self.constants.detected_os > smbios_data.smbios_dictionary[self.constants.computer.real_model]["Max OS Supported"]: + chassis_type = "aluminum" + if self.constants.computer.real_model in ["MacBook4,1", "MacBook5,2", "MacBook6,1", "MacBook7,1"]: + chassis_type = "plastic" + dlg = wx.MessageDialog(self.frame_modal, f"This model, {self.constants.computer.real_model}, does not natively support macOS {os_data.os_conversion.kernel_to_os(self.constants.detected_os)}, {os_data.os_conversion.convert_kernel_to_marketing_name(self.constants.detected_os)}. The last native OS was macOS {os_data.os_conversion.kernel_to_os(smbios_data.smbios_dictionary[self.constants.computer.real_model]['Max OS Supported'])}, {os_data.os_conversion.convert_kernel_to_marketing_name(smbios_data.smbios_dictionary[self.constants.computer.real_model]['Max OS Supported'])}\n\nToggling this option will breaking booting on this OS. Are you absolutely certain this is desired?\n\nYou may end up with a nice {chassis_type} brick 🧱", "Are you certain?", wx.YES_NO | wx.ICON_WARNING) + if dlg.ShowModal() == wx.ID_NO: + self.checkbox_allow_native_models.SetValue(False) + return print("Allow Native Models") self.constants.allow_oc_everywhere = True self.constants.serial_settings = "None" diff --git a/resources/utilities.py b/resources/utilities.py index f81a73a76..71d3864dd 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -346,7 +346,12 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False): if decode: if isinstance(value, bytes): - value = value.strip(b"\0").decode() + try: + value = value.strip(b"\0").decode() + except UnicodeDecodeError: + # Some sceanrios the firmware will throw garbage in + # ie. iMac12,2 with FireWire boot-path + value = None elif isinstance(value, str): value = value.strip("\0") return value