diff --git a/src/detection/bootmgr/bootmgr_apple.c b/src/detection/bootmgr/bootmgr_apple.c index bd4c5dc98..dc8de14b2 100644 --- a/src/detection/bootmgr/bootmgr_apple.c +++ b/src/detection/bootmgr/bootmgr_apple.c @@ -1,5 +1,25 @@ #include "bootmgr.h" #include "common/io/io.h" +#include "util/apple/cf_helpers.h" + +#include + +FF_MAYBE_UNUSED static const char* detectFromIokit(bool* secureBoot) +{ + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/chosen"); + if (!entryDevice) + return "IORegistryEntryFromPath() failed"; + + FF_CFTYPE_AUTO_RELEASE CFTypeRef prop = IORegistryEntryCreateCFProperty(entryDevice, CFSTR("secure-boot"), kCFAllocatorDefault, 0); + if (!prop) + return "IORegistryEntryCreateCFProperty() failed"; + + if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0) + return "Invalid secure-boot property"; + + *secureBoot = (bool) *CFDataGetBytePtr((CFDataRef) prop); + return NULL; +} const char* ffDetectBootmgr(FFBootmgrResult* result) { @@ -8,5 +28,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) ffStrbufSetStatic(&result->name, "iBoot"); + detectFromIokit(&result->secureBoot); + return NULL; }