mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-17 21:24:40 +10:00
device_probe.py: Add non-Mac detection
Applicable for Virtual Machines and Hackintoshes
This commit is contained in:
@@ -192,6 +192,7 @@ class Constants:
|
||||
self.start_build_install = False # Determine if build install should be started
|
||||
self.host_is_non_metal = False # Determine if host is non-metal (ie. enable UI hacks)
|
||||
self.needs_to_open_preferences = False # Determine if preferences need to be opened
|
||||
self.host_is_hackintosh = False # Determine if host is Hackintosh
|
||||
|
||||
self.legacy_accel_support = [
|
||||
os_data.os_data.big_sur,
|
||||
|
||||
@@ -484,6 +484,7 @@ class Computer:
|
||||
secure_boot_policy: Optional[int] = None
|
||||
oclp_sys_version: Optional[str] = None
|
||||
oclp_sys_date: Optional[str] = None
|
||||
firmware_vendor: Optional[str] = None
|
||||
|
||||
@staticmethod
|
||||
def probe():
|
||||
@@ -704,6 +705,13 @@ class Computer:
|
||||
# SecureBoot Variables
|
||||
self.secure_boot_model = utilities.check_secure_boot_model()
|
||||
self.secure_boot_policy = utilities.check_ap_security_policy()
|
||||
|
||||
# Firmware Vendor
|
||||
firmware_vendor = utilities.get_firmware_vendor(decode=False)
|
||||
if isinstance(firmware_vendor, bytes):
|
||||
firmware_vendor = str(firmware_vendor.replace(b"\x00", b"").decode("utf-8"))
|
||||
self.firmware_vendor = firmware_vendor
|
||||
|
||||
def cpu_probe(self):
|
||||
self.cpu = CPU(
|
||||
subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(),
|
||||
|
||||
@@ -33,6 +33,9 @@ class OpenCoreLegacyPatcher:
|
||||
self.constants.recovery_status = utilities.check_recovery()
|
||||
self.computer = self.constants.computer
|
||||
self.constants.booted_oc_disk = utilities.find_disk_off_uuid(utilities.clean_device_path(self.computer.opencore_path))
|
||||
if self.constants.computer.firmware_vendor:
|
||||
if self.constants.computer.firmware_vendor != "Apple":
|
||||
self.constants.host_is_hackintosh = True
|
||||
launcher_script = None
|
||||
launcher_binary = sys.executable
|
||||
if "python" in launcher_binary:
|
||||
|
||||
@@ -371,6 +371,21 @@ def get_rom(variable: str, *, decode: bool = False):
|
||||
value = value.strip(b"\0").decode()
|
||||
return value
|
||||
|
||||
def get_firmware_vendor(*, decode: bool = False):
|
||||
efi = ioreg.IORegistryEntryFromPath(ioreg.kIOMasterPortDefault, "IODeviceTree:/efi".encode())
|
||||
value = ioreg.IORegistryEntryCreateCFProperty(efi, "firmware-vendor", ioreg.kCFAllocatorDefault, ioreg.kNilOptions)
|
||||
ioreg.IOObjectRelease(efi)
|
||||
|
||||
if not value:
|
||||
return None
|
||||
|
||||
value = ioreg.corefoundation_to_native(value)
|
||||
if decode:
|
||||
if isinstance(value, bytes):
|
||||
value = value.strip(b"\0").decode()
|
||||
elif isinstance(value, str):
|
||||
value = value.strip("\0")
|
||||
return value
|
||||
|
||||
def verify_network_connection(url):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user