Support Minimal SMBIOS spoofing on ElCap era Macs

This commit is contained in:
Mykola Grymalyuk
2021-05-31 14:01:30 -06:00
parent ccb9aea1e6
commit 2da88a22d7
4 changed files with 58 additions and 11 deletions

View File

@@ -12,6 +12,8 @@
- Fix device tree renaming on Mac Pros and Xserves
- Ensure no Acceleration Patches applied when no compatible GPU found
- Allow custom SMBIOS overriding
- Fix incorrectly setting CPU override for non-Minimal SMBIOS spoofs
- Support Minimal SMBIOS spoofing on El Capitan era Macs
## 0.1.5
- Fix crashing when Wireless module not present

View File

@@ -15,15 +15,8 @@ class OpenCoreLegacyPatcher():
def __init__(self):
self.constants = Constants.Constants()
self.current_model: str = None
opencore_model: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-product".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if not opencore_model.startswith("nvram: Error getting variable"):
opencore_model = [line.strip().split(":oem-product ", 1)[1] for line in opencore_model.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0]
self.current_model = opencore_model
else:
self.current_model = plistlib.loads(subprocess.run("system_profiler -detailLevel mini -xml SPHardwareDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.strip())[0]["_items"][0]["machine_model"]
self.current_model = DeviceProbe.smbios_probe().model_detect(False)
self.constants.detected_os = int(platform.uname().release.partition(".")[0])
if self.current_model in ModelArray.NoAPFSsupport:
self.constants.serial_settings = "Moderate"
if self.current_model in ModelArray.LegacyGPU:
dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0")
@@ -91,8 +84,6 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
if print_models in {"y", "Y", "yes", "Yes"}:
print("\n".join(ModelArray.SupportedSMBIOS))
input("Press any key to continue...")
if self.constants.custom_model in ModelArray.NoAPFSsupport:
self.constants.serial_settings = "Moderate"
def patcher_settings(self):
response = None

View File

@@ -72,6 +72,36 @@ class BuildOpenCore:
else:
return self.model
def fw_feature_detect(self, model):
# Flip bit 19 to enable APFS support
# https://github.com/acidanthera/OpenCorePkg/blob/0.6.9/Include/Apple/IndustryStandard/AppleFeatures.h#L136
if model == "iMac7,1":
fw_feature = 3221230599
fw_mask = 3221233663
elif model in ["MacPro4,1", "Xserve3,1"]:
fw_feature = 3758224695
fw_mask = 3221487415
else:
fw_feature = 3221230595
fw_mask = 3221241855
#print(f"- Detected FirmwareFeature value: {fw_feature}")
fw_feature |= 2**19
fw_mask |= 2**19
#print(f"- Updated FirmwareFeatures value: {fw_feature}")
# Allow for easy usage in config.plist
fw_feature = hex(fw_feature)
fw_feature = fw_feature.replace("0x", "")
fw_feature = Utilities.hexswap(fw_feature)
fw_feature = binascii.unhexlify(fw_feature)
fw_mask = hex(fw_mask)
fw_mask = fw_mask.replace("0x", "")
fw_mask = Utilities.hexswap(fw_mask)
fw_mask = binascii.unhexlify(fw_mask)
return fw_feature, fw_mask
def build_efi(self):
Utilities.cls()
if not self.constants.custom_model:
@@ -613,7 +643,13 @@ class BuildOpenCore:
# Setup menu
def minimal_serial_patch(self):
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
self.config["PlatformInfo"]["PlatformNVRAM"]["ProcessorType"] = 1537
self.config["PlatformInfo"]["SMBIOS"]["ProcessorType"] = 1537
if self.model in ModelArray.NoAPFSsupport:
fw_feature,fw_mask = self.fw_feature_detect(self.model)
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeatures"] = fw_feature
self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeaturesMask"] = fw_mask
self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeaturesMask"] = fw_mask
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = self.spoofed_board
self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = self.spoofed_board

View File

@@ -86,3 +86,21 @@ class pci_probe:
except IndexError:
print(f"- No IOService entry found for Wireless Card (I)")
return "", "", "", ""
class smbios_probe:
def model_detect(self, custom):
opencore_model: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-product".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if not opencore_model.startswith("nvram: Error getting variable") and custom is False:
current_model = [line.strip().split(":oem-product ", 1)[1] for line in opencore_model.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0]
else:
current_model = plistlib.loads(subprocess.run("system_profiler -detailLevel mini -xml SPHardwareDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.strip())[0]["_items"][0]["machine_model"]
return current_model
def board_detect(self, custom):
opencore_model: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-board".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if not opencore_model.startswith("nvram: Error getting variable") and custom is False:
current_model = [line.strip().split(":oem-board ", 1)[1] for line in opencore_model.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0]
else:
current_model = plistlib.loads(subprocess.run(f"ioreg -p IODeviceTree -r -n / -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
current_model = current_model[0]["board-id"]
return current_model