Bootmgr (macOS): supports secure boot detection on Intel

This commit is contained in:
李通洲
2025-12-27 18:12:23 +08:00
parent d01fc56ea2
commit 01917b781b
+19 -3
View File
@@ -4,8 +4,9 @@
#include <IOKit/IOKitLib.h>
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;
}