mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-13 20:28:21 +10:00
build: Adjust save handling
This commit is contained in:
@@ -25,8 +25,6 @@ class build_opencore:
|
||||
self.model = model
|
||||
self.config = None
|
||||
self.constants: constants.Constants = versions
|
||||
self.computer = self.constants.computer
|
||||
self.gfx0_path = None
|
||||
|
||||
|
||||
def build_efi(self):
|
||||
@@ -35,41 +33,9 @@ class build_opencore:
|
||||
print(f"Building Configuration on model: {self.model}")
|
||||
else:
|
||||
print(f"Building Configuration for external model: {self.model}")
|
||||
if not Path(self.constants.build_path).exists():
|
||||
Path(self.constants.build_path).mkdir()
|
||||
print("Created build folder")
|
||||
else:
|
||||
print("Build folder already present, skipping")
|
||||
|
||||
if Path(self.constants.opencore_zip_copied).exists():
|
||||
print("Deleting old copy of OpenCore zip")
|
||||
Path(self.constants.opencore_zip_copied).unlink()
|
||||
if Path(self.constants.opencore_release_folder).exists():
|
||||
print("Deleting old copy of OpenCore folder")
|
||||
shutil.rmtree(self.constants.opencore_release_folder, onerror=rmtree_handler, ignore_errors=True)
|
||||
|
||||
print(f"\n- Adding OpenCore v{self.constants.opencore_version} {self.constants.opencore_build}")
|
||||
shutil.copy(self.constants.opencore_zip_source, self.constants.build_path)
|
||||
zipfile.ZipFile(self.constants.opencore_zip_copied).extractall(self.constants.build_path)
|
||||
|
||||
print("- Adding config.plist for OpenCore")
|
||||
# Setup config.plist for editing
|
||||
shutil.copy(self.constants.plist_template, self.constants.oc_folder)
|
||||
self.config = plistlib.load(Path(self.constants.plist_path).open("rb"))
|
||||
|
||||
# Set revision in config
|
||||
self.config["#Revision"]["Build-Version"] = f"{self.constants.patcher_version} - {date.today()}"
|
||||
if not self.constants.custom_model:
|
||||
self.config["#Revision"]["Build-Type"] = "OpenCore Built on Target Machine"
|
||||
computer_copy = copy.copy(self.computer)
|
||||
computer_copy.ioregistry = None
|
||||
self.config["#Revision"]["Hardware-Probe"] = pickle.dumps(computer_copy)
|
||||
else:
|
||||
self.config["#Revision"]["Build-Type"] = "OpenCore Built for External Machine"
|
||||
self.config["#Revision"]["OpenCore-Version"] = f"{self.constants.opencore_version} - {self.constants.opencore_build} - {self.constants.opencore_commit}"
|
||||
self.config["#Revision"]["Original-Model"] = self.model
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Version"] = f"{self.constants.patcher_version}"
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Model"] = self.model
|
||||
self.generate_base()
|
||||
self.set_revision()
|
||||
|
||||
# Set Lilu and co.
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("Lilu.kext", self.constants.lilu_version, self.constants.lilu_path)
|
||||
@@ -86,17 +52,69 @@ class build_opencore:
|
||||
security.build_security(self.model, self.constants, self.config).build()
|
||||
misc.build_misc(self.model, self.constants, self.config).build()
|
||||
|
||||
# Work-around ocvalidate
|
||||
if self.constants.validate is False:
|
||||
print("- Adding bootmgfw.efi BlessOverride")
|
||||
self.config["Misc"]["BlessOverride"] += ["\\EFI\\Microsoft\\Boot\\bootmgfw.efi"]
|
||||
|
||||
|
||||
def generate_base(self):
|
||||
# Generate OpenCore base folder and config
|
||||
if not Path(self.constants.build_path).exists():
|
||||
print("Creating build folder")
|
||||
Path(self.constants.build_path).mkdir()
|
||||
else:
|
||||
print("Build folder already present, skipping")
|
||||
|
||||
if Path(self.constants.opencore_zip_copied).exists():
|
||||
print("Deleting old copy of OpenCore zip")
|
||||
Path(self.constants.opencore_zip_copied).unlink()
|
||||
if Path(self.constants.opencore_release_folder).exists():
|
||||
print("Deleting old copy of OpenCore folder")
|
||||
shutil.rmtree(self.constants.opencore_release_folder, onerror=rmtree_handler, ignore_errors=True)
|
||||
|
||||
print(f"\n- Adding OpenCore v{self.constants.opencore_version} {self.constants.opencore_build}")
|
||||
shutil.copy(self.constants.opencore_zip_source, self.constants.build_path)
|
||||
zipfile.ZipFile(self.constants.opencore_zip_copied).extractall(self.constants.build_path)
|
||||
|
||||
# Setup config.plist for editing
|
||||
print("- Adding config.plist for OpenCore")
|
||||
shutil.copy(self.constants.plist_template, self.constants.oc_folder)
|
||||
self.config = plistlib.load(Path(self.constants.plist_path).open("rb"))
|
||||
|
||||
|
||||
def set_revision(self):
|
||||
# Set revision in config
|
||||
self.config["#Revision"]["Build-Version"] = f"{self.constants.patcher_version} - {date.today()}"
|
||||
if not self.constants.custom_model:
|
||||
self.config["#Revision"]["Build-Type"] = "OpenCore Built on Target Machine"
|
||||
computer_copy = copy.copy(self.constants.computer)
|
||||
computer_copy.ioregistry = None
|
||||
self.config["#Revision"]["Hardware-Probe"] = pickle.dumps(computer_copy)
|
||||
else:
|
||||
self.config["#Revision"]["Build-Type"] = "OpenCore Built for External Machine"
|
||||
self.config["#Revision"]["OpenCore-Version"] = f"{self.constants.opencore_version} - {self.constants.opencore_build} - {self.constants.opencore_commit}"
|
||||
self.config["#Revision"]["Original-Model"] = self.model
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Version"] = f"{self.constants.patcher_version}"
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Model"] = self.model
|
||||
|
||||
|
||||
def save_config(self):
|
||||
plistlib.dump(self.config, Path(self.constants.plist_path).open("wb"), sort_keys=True)
|
||||
|
||||
|
||||
def build_opencore(self):
|
||||
# Generate OpenCore Configuration
|
||||
self.build_efi()
|
||||
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True or (self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != ""):
|
||||
smbios.build_smbios(self.model, self.constants, self.config).set_smbios()
|
||||
support.build_support(self.model, self.constants, self.config).cleanup()
|
||||
self.save_config()
|
||||
|
||||
# Post-build handling
|
||||
support.build_support(self.model, self.constants, self.config).sign_files()
|
||||
support.build_support(self.model, self.constants, self.config).validate_pathing()
|
||||
|
||||
print("")
|
||||
print(f"Your OpenCore EFI for {self.model} has been built at:")
|
||||
print(f" {self.constants.opencore_release_folder}")
|
||||
|
||||
@@ -71,8 +71,7 @@ class build_misc:
|
||||
|
||||
if block_args != "":
|
||||
print(f"- Setting RestrictEvents block arguments: {block_args}")
|
||||
if support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revblock"] = block_args
|
||||
|
||||
patch_args = ""
|
||||
@@ -89,8 +88,7 @@ class build_misc:
|
||||
|
||||
if patch_args != "":
|
||||
print(f"- Setting RestrictEvents patch arguments: {patch_args}")
|
||||
if support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revpatch"] = patch_args
|
||||
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
@@ -100,8 +98,7 @@ class build_misc:
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revcpuname"] = self.constants.custom_cpu_model_value
|
||||
else:
|
||||
print("- Adding CPU Name Patch")
|
||||
if support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
|
||||
|
||||
if support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
|
||||
# Ensure this is done at the end so all previous RestrictEvents patches are applied
|
||||
|
||||
@@ -19,6 +19,7 @@ class build_security:
|
||||
print("- Setting Vault configuration")
|
||||
self.config["Misc"]["Security"]["Vault"] = "Secure"
|
||||
support.build_support(self.model, self.constants, self.config).get_efi_binary_by_path("OpenShell.efi", "Misc", "Tools")["Enabled"] = False
|
||||
|
||||
if self.constants.sip_status is False or self.constants.custom_sip_value:
|
||||
# Work-around 12.3 bug where Electron apps no longer launch with SIP lowered
|
||||
# Unknown whether this is intended behavior or not, revisit with 12.4
|
||||
@@ -55,6 +56,7 @@ class build_security:
|
||||
# CSLVFixup simply patches out __RESTRICT and __restrict out of the Music.app Binary
|
||||
# Ref: https://pewpewthespells.com/blog/blocking_code_injection_on_ios_and_os_x.html
|
||||
support.build_support(self.model, self.constants, self.config).enable_kext("CSLVFixup.kext", self.constants.cslvfixup_version, self.constants.cslvfixup_path)
|
||||
|
||||
if self.constants.secure_status is False:
|
||||
print("- Disabling SecureBootModel")
|
||||
self.config["Misc"]["Security"]["SecureBootModel"] = "Disabled"
|
||||
|
||||
@@ -62,116 +62,16 @@ class build_smbios:
|
||||
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True:
|
||||
self.config["#Revision"]["Spoofed-Model"] = f"{self.spoofed_model} - {self.constants.serial_settings}"
|
||||
|
||||
# Setup menu
|
||||
def minimal_serial_patch(self):
|
||||
# Generate Firmware Features
|
||||
fw_feature = generate_smbios.generate_fw_features(self.model, self.constants.custom_model)
|
||||
# fw_feature = self.patch_firmware_feature()
|
||||
fw_feature = hex(fw_feature).lstrip("0x").rstrip("L").strip()
|
||||
print(f"- Setting Firmware Feature: {fw_feature}")
|
||||
fw_feature = utilities.string_to_hex(fw_feature)
|
||||
|
||||
# FirmwareFeatures
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeaturesMask"] = fw_feature
|
||||
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeatures"] = fw_feature
|
||||
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeaturesMask"] = fw_feature
|
||||
|
||||
# Board ID
|
||||
self.config["PlatformInfo"]["DataHub"]["BoardProduct"] = self.spoofed_board
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = self.spoofed_board
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = self.spoofed_board
|
||||
|
||||
# Model (ensures tables are not mismatched, even if we're not spoofing)
|
||||
self.config["PlatformInfo"]["DataHub"]["SystemProductName"] = self.model
|
||||
self.config["PlatformInfo"]["SMBIOS"]["SystemProductName"] = self.model
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BoardVersion"] = self.model
|
||||
|
||||
# ProcessorType (when RestrictEvent's CPU naming is used)
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
self.config["PlatformInfo"]["SMBIOS"]["ProcessorType"] = 1537
|
||||
|
||||
# Avoid incorrect Firmware Updates
|
||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BIOSVersion"] = "9999.999.999.999.999"
|
||||
|
||||
# Update tables
|
||||
self.config["PlatformInfo"]["UpdateNVRAM"] = True
|
||||
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
|
||||
self.config["PlatformInfo"]["UpdateDataHub"] = True
|
||||
|
||||
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
|
||||
print("- Adding custom serial numbers")
|
||||
sn = self.constants.custom_serial_number
|
||||
mlb = self.constants.custom_board_serial_number
|
||||
|
||||
# Serial Number
|
||||
self.config["PlatformInfo"]["SMBIOS"]["ChassisSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["SMBIOS"]["SystemSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["DataHub"]["SystemSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["SystemSerialNumber"] = sn
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-SN"] = sn
|
||||
|
||||
# Board Serial Number
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BoardSerialNumber"] = mlb
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["BoardSerialNumber"] = mlb
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-MLB"] = mlb
|
||||
|
||||
|
||||
|
||||
def moderate_serial_patch(self):
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
|
||||
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
|
||||
print("- Adding custom serial numbers")
|
||||
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = self.constants.custom_serial_number
|
||||
self.config["PlatformInfo"]["Generic"]["MLB"] = self.constants.custom_board_serial_number
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-SN"] = self.constants.custom_serial_number
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-MLB"] = self.constants.custom_board_serial_number
|
||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
|
||||
self.config["PlatformInfo"]["Automatic"] = True
|
||||
self.config["PlatformInfo"]["UpdateDataHub"] = True
|
||||
self.config["PlatformInfo"]["UpdateNVRAM"] = True
|
||||
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
|
||||
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
|
||||
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
|
||||
|
||||
def advanced_serial_patch(self):
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
|
||||
if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "":
|
||||
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
|
||||
sn = macserial_output[0]
|
||||
mlb = macserial_output[1]
|
||||
else:
|
||||
sn = self.constants.custom_serial_number
|
||||
mlb = self.constants.custom_board_serial_number
|
||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
|
||||
self.config["PlatformInfo"]["Automatic"] = True
|
||||
self.config["PlatformInfo"]["UpdateDataHub"] = True
|
||||
self.config["PlatformInfo"]["UpdateNVRAM"] = True
|
||||
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
|
||||
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
|
||||
self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("0016CB445566")
|
||||
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
|
||||
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["Generic"]["MLB"] = mlb
|
||||
self.config["PlatformInfo"]["Generic"]["SystemUUID"] = str(uuid.uuid4()).upper()
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-SN"] = sn
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-MLB"] = mlb
|
||||
|
||||
|
||||
if self.constants.serial_settings == "Moderate":
|
||||
print("- Using Moderate SMBIOS patching")
|
||||
moderate_serial_patch(self)
|
||||
self.moderate_serial_patch()
|
||||
elif self.constants.serial_settings == "Advanced":
|
||||
print("- Using Advanced SMBIOS patching")
|
||||
advanced_serial_patch(self)
|
||||
self.advanced_serial_patch()
|
||||
elif self.constants.serial_settings == "Minimal":
|
||||
print("- Using Minimal SMBIOS patching")
|
||||
self.spoofed_model = self.model
|
||||
minimal_serial_patch(self)
|
||||
self.minimal_serial_patch()
|
||||
else:
|
||||
# Update DataHub to resolve Lilu Race Condition
|
||||
# macOS Monterey will sometimes not present the boardIdentifier in the DeviceTree on UEFI 1.2 or older Mac,
|
||||
@@ -269,4 +169,103 @@ class build_smbios:
|
||||
for entry in list(agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"]):
|
||||
if not entry.startswith(self.spoofed_board):
|
||||
agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"].pop(entry)
|
||||
plistlib.dump(agdp_config, Path(new_agdp_ls).open("wb"), sort_keys=True)
|
||||
plistlib.dump(agdp_config, Path(new_agdp_ls).open("wb"), sort_keys=True)
|
||||
|
||||
|
||||
def minimal_serial_patch(self):
|
||||
# Generate Firmware Features
|
||||
fw_feature = generate_smbios.generate_fw_features(self.model, self.constants.custom_model)
|
||||
# fw_feature = self.patch_firmware_feature()
|
||||
fw_feature = hex(fw_feature).lstrip("0x").rstrip("L").strip()
|
||||
print(f"- Setting Firmware Feature: {fw_feature}")
|
||||
fw_feature = utilities.string_to_hex(fw_feature)
|
||||
|
||||
# FirmwareFeatures
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeaturesMask"] = fw_feature
|
||||
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeatures"] = fw_feature
|
||||
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeaturesMask"] = fw_feature
|
||||
|
||||
# Board ID
|
||||
self.config["PlatformInfo"]["DataHub"]["BoardProduct"] = self.spoofed_board
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = self.spoofed_board
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = self.spoofed_board
|
||||
|
||||
# Model (ensures tables are not mismatched, even if we're not spoofing)
|
||||
self.config["PlatformInfo"]["DataHub"]["SystemProductName"] = self.model
|
||||
self.config["PlatformInfo"]["SMBIOS"]["SystemProductName"] = self.model
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BoardVersion"] = self.model
|
||||
|
||||
# ProcessorType (when RestrictEvent's CPU naming is used)
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
self.config["PlatformInfo"]["SMBIOS"]["ProcessorType"] = 1537
|
||||
|
||||
# Avoid incorrect Firmware Updates
|
||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BIOSVersion"] = "9999.999.999.999.999"
|
||||
|
||||
# Update tables
|
||||
self.config["PlatformInfo"]["UpdateNVRAM"] = True
|
||||
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
|
||||
self.config["PlatformInfo"]["UpdateDataHub"] = True
|
||||
|
||||
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
|
||||
print("- Adding custom serial numbers")
|
||||
sn = self.constants.custom_serial_number
|
||||
mlb = self.constants.custom_board_serial_number
|
||||
|
||||
# Serial Number
|
||||
self.config["PlatformInfo"]["SMBIOS"]["ChassisSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["SMBIOS"]["SystemSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["DataHub"]["SystemSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["SystemSerialNumber"] = sn
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-SN"] = sn
|
||||
|
||||
# Board Serial Number
|
||||
self.config["PlatformInfo"]["SMBIOS"]["BoardSerialNumber"] = mlb
|
||||
self.config["PlatformInfo"]["PlatformNVRAM"]["BoardSerialNumber"] = mlb
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-MLB"] = mlb
|
||||
|
||||
|
||||
def moderate_serial_patch(self):
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
|
||||
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
|
||||
print("- Adding custom serial numbers")
|
||||
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = self.constants.custom_serial_number
|
||||
self.config["PlatformInfo"]["Generic"]["MLB"] = self.constants.custom_board_serial_number
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-SN"] = self.constants.custom_serial_number
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-MLB"] = self.constants.custom_board_serial_number
|
||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
|
||||
self.config["PlatformInfo"]["Automatic"] = True
|
||||
self.config["PlatformInfo"]["UpdateDataHub"] = True
|
||||
self.config["PlatformInfo"]["UpdateNVRAM"] = True
|
||||
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
|
||||
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
|
||||
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
|
||||
|
||||
|
||||
def advanced_serial_patch(self):
|
||||
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
|
||||
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
|
||||
if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "":
|
||||
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
|
||||
sn = macserial_output[0]
|
||||
mlb = macserial_output[1]
|
||||
else:
|
||||
sn = self.constants.custom_serial_number
|
||||
mlb = self.constants.custom_board_serial_number
|
||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
|
||||
self.config["PlatformInfo"]["Automatic"] = True
|
||||
self.config["PlatformInfo"]["UpdateDataHub"] = True
|
||||
self.config["PlatformInfo"]["UpdateNVRAM"] = True
|
||||
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
|
||||
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
|
||||
self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("0016CB445566")
|
||||
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
|
||||
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = sn
|
||||
self.config["PlatformInfo"]["Generic"]["MLB"] = mlb
|
||||
self.config["PlatformInfo"]["Generic"]["SystemUUID"] = str(uuid.uuid4()).upper()
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-SN"] = sn
|
||||
self.config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Spoofed-MLB"] = mlb
|
||||
@@ -140,7 +140,6 @@ class build_support:
|
||||
if item["Enabled"] is False:
|
||||
self.config[entry][sub_entry].remove(item)
|
||||
|
||||
plistlib.dump(self.config, Path(self.constants.plist_path).open("wb"), sort_keys=True)
|
||||
for kext in self.constants.kexts_path.rglob("*.zip"):
|
||||
with zipfile.ZipFile(kext) as zip_file:
|
||||
zip_file.extractall(self.constants.kexts_path)
|
||||
|
||||
Reference in New Issue
Block a user