From 2340c2afd726877f93d44f89d431940c90a9ef67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 5 Jan 2024 16:15:53 +0800 Subject: [PATCH] Board (macOS): print internal name instead of model indentifier and actually detect the vendor --- src/detection/board/board_apple.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/detection/board/board_apple.c b/src/detection/board/board_apple.c index 56f582215..6381590d8 100644 --- a/src/detection/board/board_apple.c +++ b/src/detection/board/board_apple.c @@ -1,13 +1,21 @@ #include "board.h" #include "common/sysctl.h" +#include "util/apple/cf_helpers.h" const char* ffDetectBoard(FFBoardResult* result) { - const char* error = ffSysctlGetString("hw.model", &result->name); - if (error) - return error; + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t service = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceMatching("IOPlatformExpertDevice")); + if (!service) + return "No IOPlatformExpertDevice found"; + + io_name_t name; + if (IORegistryEntryGetName(service, name) == kIOReturnSuccess) + ffStrbufSetS(&result->name, name); + + FF_CFTYPE_AUTO_RELEASE CFTypeRef manufacturer = IORegistryEntryCreateCFProperty(service, CFSTR("manufacturer"), kCFAllocatorDefault, kNilOptions); + if (manufacturer) + ffCfStrGetString(manufacturer, &result->vendor); - ffStrbufSetStatic(&result->vendor, "Apple"); return NULL; }