From 61e815565ae5ac202bb730c878b85a700fbd1897 Mon Sep 17 00:00:00 2001
From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com>
Date: Mon, 8 Mar 2021 18:01:19 -0700
Subject: [PATCH] Add new SMBIOS patching options
---
CHANGELOG.md | 7 ++++
OpenCore-Patcher.command | 28 +++++++++++--
Resources/Constants.py | 2 +
Resources/build.py | 65 ++++++++++++++++-------------
payloads/Config/v0.6.8/config.plist | 2 +-
5 files changed, 72 insertions(+), 32 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 640df2a34..9bff91a66 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# OpenCore Legacy Patcher changelog
+## 0.0.16
+- Move Serial selection to Patcher Settings
+- Add new SMBIOS patching options:
+ - Minimal: Only update board ID and BIOSVersion, keep original serials
+ - Moderate: Update entire SMBIOS, keep original serials
+ - Advanced: Update entire SMBIOS, generate new serials
+
## 0.0.15
- Add user-configurable OpenCore DEBUG builds
- Add user-configurable Wifi and GPU patches
diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command
index d502bf085..566168109 100755
--- a/OpenCore-Patcher.command
+++ b/OpenCore-Patcher.command
@@ -128,6 +128,30 @@ option is for those patching on a different machine.
else:
print("Invalid option")
+ def change_serial(self):
+ utilities.cls()
+ utilities.header(["Set SMBIOS Mode"])
+ print("""This section is for setting how OpenCore generates the SMBIOS
+Recommended for adanced users who want control how serials are handled
+
+Valid options:
+
+1. Minimal:\tUse original serials and minimally update SMBIOS
+2. Moderate:\tReplave entire SMBIOS but keep original serials
+3. Advanced:\tReplace entire SMBIOS and generate new serials
+
+Note: For new users we recommend leaving as default(1. Minimal)
+ """)
+ change_serial_menu = input("Set SMBIOS Mode(ie. 1): ")
+ if change_serial_menu == "1":
+ self.constants.serial_settings = "Minimal"
+ elif change_serial_menu == "2":
+ self.constants.serial_settings = "Moderate"
+ elif change_serial_menu == "3":
+ self.constants.serial_settings = "Advanced"
+ else:
+ print("Invalid option")
+
def patcher_settings(self):
response = None
while not (response and response == -1):
@@ -143,6 +167,7 @@ option is for those patching on a different machine.
[f"Enable Kext DEBUG:\t\t\tCurrently {self.constants.kext_debug}", self.change_kext],
[f"Assume Metal GPU Always:\t\tCurrently {self.constants.kext_debug}", self.change_metal],
[f"Assume Upgraded Wifi Always:\tCurrently {self.constants.kext_debug}", self.change_wifi],
+ [f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", self.change_serial],
]
for option in options:
@@ -150,9 +175,6 @@ option is for those patching on a different machine.
response = menu.start()
-
- input("Press any key to continue...")
-
def credits(self):
utilities.TUIOnlyPrint(["Credits"], "Press [Enter] to go back.\n",
["""Many thanks to the following:
diff --git a/Resources/Constants.py b/Resources/Constants.py
index 3a4d8fc62..a28ff7941 100644
--- a/Resources/Constants.py
+++ b/Resources/Constants.py
@@ -48,6 +48,8 @@ class Constants:
self.max_os_support = 11.0
self.metal_build = False
self.wifi_build = False
+ self.gui_mode = False
+ self.serial_settings = "Minimal"
# Payload Location
# OpenCore
diff --git a/Resources/build.py b/Resources/build.py
index 406f31dee..dbfbe8432 100644
--- a/Resources/build.py
+++ b/Resources/build.py
@@ -269,36 +269,44 @@ class BuildOpenCore:
print("- Spoofing to MacPro7,1")
spoofed_model = "MacPro7,1"
spoofed_board = "Mac-27AD2F918AE68F61"
- self.config["#Revision"]["Spoofed-Model"] = spoofed_model
- macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- macserial_output = macserial_output.stdout.decode().strip().split(" | ")
+ self.spoofed_model = spoofed_model
+ self.spoofed_board = spoofed_board
+ self.config["#Revision"]["Spoofed-Model"] = self.spoofed_model
+ macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.macserial_output = macserial_output.stdout.decode().strip().split(" | ")
# Setup menu
- smbios_mod = True
- while smbios_mod == True:
- print("Use original or generate new serials")
- print("For new users, we recommend use originals(ie. y)")
- smbios_mod = input("Use original serials?(y, n): ")
-
- if smbios_mod in {"y", "Y", "yes", "Yes"}:
- spoofed_model = self.model
- self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = spoofed_board
- self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = spoofed_board
- self.config["PlatformInfo"]["UpdateNVRAM"] = True
- elif smbios_mod in {"n", "N", "no", "No"}:
- self.config["PlatformInfo"]["Automatic"] = True
- self.config["PlatformInfo"]["UpdateDataHub"] = True
- self.config["PlatformInfo"]["UpdateNVRAM"] = True
- self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
- self.config["PlatformInfo"]["Generic"]["SystemProductName"] = spoofed_model
- self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = macserial_output[0]
- self.config["PlatformInfo"]["Generic"]["MLB"] = macserial_output[1]
- self.config["PlatformInfo"]["Generic"]["SystemUUID"] = str(uuid.uuid4()).upper()
- else:
- smbios_mod = True
-
+ def minimal_serial_patch(self):
+ self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = self.spoofed_board
+ self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = self.spoofed_board
+ self.config["PlatformInfo"]["UpdateNVRAM"] = True
+ def moderate_serial_patch(self):
+ self.config["PlatformInfo"]["Automatic"] = True
+ self.config["PlatformInfo"]["UpdateDataHub"] = True
+ self.config["PlatformInfo"]["UpdateNVRAM"] = True
+ self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
+ self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
+ def adanced_serial_patch(self):
+ self.config["PlatformInfo"]["Automatic"] = True
+ self.config["PlatformInfo"]["UpdateDataHub"] = True
+ self.config["PlatformInfo"]["UpdateNVRAM"] = True
+ self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
+ self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("112233445566")
+ self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
+ self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = self.macserial_output[0]
+ self.config["PlatformInfo"]["Generic"]["MLB"] = self.macserial_output[1]
+ self.config["PlatformInfo"]["Generic"]["SystemUUID"] = str(uuid.uuid4()).upper()
+
+ if self.constants.serial_settings == "Moderate":
+ moderate_serial_patch(self)
+ elif self.constants.serial_settings == "Advanced":
+ adanced_serial_patch(self)
+ else:
+ self.spoofed_model = self.model
+ minimal_serial_patch(self)
+
# USB Map Patching
- self.new_map_ls = Path(self.constants.map_contents_folder) / Path(f"Info.plist")
+ self.new_map_ls = Path(self.constants.map_contents_folder) / Path("Info.plist")
self.map_config = plistlib.load(Path(self.new_map_ls).open("rb"))
self.map_config["IOKitPersonalities_x86_64"][self.model]["model"] = spoofed_model
@@ -382,7 +390,8 @@ class BuildOpenCore:
print("Your OpenCore EFI has been built at:")
print(f" {self.constants.opencore_release_folder}")
print("")
- input("Press [Enter] to go back.\n")
+ if self.constants.gui_mode == False:
+ input("Press [Enter] to go back.\n")
def copy_efi(self):
utilities.cls()
diff --git a/payloads/Config/v0.6.8/config.plist b/payloads/Config/v0.6.8/config.plist
index 64ffe5003..a223ae4f6 100644
--- a/payloads/Config/v0.6.8/config.plist
+++ b/payloads/Config/v0.6.8/config.plist
@@ -930,7 +930,7 @@
ProcessorType
0
ROM
- ESIzRFVm
+
SpoofVendor
SystemProductName