diff --git a/src/detection/bootmgr/bootmgr_apple.c b/src/detection/bootmgr/bootmgr_apple.c index dc8de14b2..764489974 100644 --- a/src/detection/bootmgr/bootmgr_apple.c +++ b/src/detection/bootmgr/bootmgr_apple.c @@ -4,8 +4,9 @@ #include -FF_MAYBE_UNUSED static const char* detectFromIokit(bool* secureBoot) +static const char* detectSecureBoot(bool* result) { + #if __aarch64__ FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/chosen"); if (!entryDevice) return "IORegistryEntryFromPath() failed"; @@ -17,7 +18,22 @@ FF_MAYBE_UNUSED static const char* detectFromIokit(bool* secureBoot) if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0) return "Invalid secure-boot property"; - *secureBoot = (bool) *CFDataGetBytePtr((CFDataRef) prop); + *result = (bool) *CFDataGetBytePtr((CFDataRef) prop); + #else + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/options"); + if (!entryDevice) + return "IORegistryEntryFromPath() failed"; + + FF_CFTYPE_AUTO_RELEASE CFTypeRef prop = IORegistryEntryCreateCFProperty(entryDevice, CFSTR("94b73556-2197-4702-82a8-3e1337dafbfb:AppleSecureBootPolicy"), kCFAllocatorDefault, 0); + if (!prop) + return "IORegistryEntryCreateCFProperty() failed"; + + if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0) + return "Invalid secure-boot property"; + + *result = *CFDataGetBytePtr((CFDataRef) prop) != 0x02 /* Permissive Security */; + #endif + return NULL; } @@ -28,7 +44,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) ffStrbufSetStatic(&result->name, "iBoot"); - detectFromIokit(&result->secureBoot); + detectSecureBoot(&result->secureBoot); return NULL; }