From 3fcbd80ef06d656dce75b63642bb9fb2c891bac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 17 Jun 2025 00:02:47 +0800 Subject: [PATCH] Board (macOS): detect board-id if available Ref: https://github.com/GuillaumeGomez/sysinfo/pull/1545 --- src/detection/board/board_apple.c | 16 +++++++++++++--- src/detection/host/host_apple.c | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/detection/board/board_apple.c b/src/detection/board/board_apple.c index 6381590d8..dca906bc3 100644 --- a/src/detection/board/board_apple.c +++ b/src/detection/board/board_apple.c @@ -9,9 +9,19 @@ const char* ffDetectBoard(FFBoardResult* result) if (!service) return "No IOPlatformExpertDevice found"; - io_name_t name; - if (IORegistryEntryGetName(service, name) == kIOReturnSuccess) - ffStrbufSetS(&result->name, name); + FF_CFTYPE_AUTO_RELEASE CFTypeRef boardId = IORegistryEntryCreateCFProperty(service, CFSTR("board-id"), kCFAllocatorDefault, kNilOptions); + if (boardId) + ffCfStrGetString(boardId, &result->name); + else + { + io_name_t name; + if (IORegistryEntryGetName(service, name) == kIOReturnSuccess) + ffStrbufSetS(&result->name, name); + } + + FF_CFTYPE_AUTO_RELEASE CFStringRef version = IORegistryEntryCreateCFProperty(service, CFSTR("version"), kCFAllocatorDefault, kNilOptions); + if (version) + ffCfStrGetString(version, &result->version); FF_CFTYPE_AUTO_RELEASE CFTypeRef manufacturer = IORegistryEntryCreateCFProperty(service, CFSTR("manufacturer"), kCFAllocatorDefault, kNilOptions); if (manufacturer) diff --git a/src/detection/host/host_apple.c b/src/detection/host/host_apple.c index c83b09684..2477ea7e9 100644 --- a/src/detection/host/host_apple.c +++ b/src/detection/host/host_apple.c @@ -36,6 +36,10 @@ const char* getOthersByIokit(FFHostResult* host) if (manufacturer) ffCfStrGetString(manufacturer, &host->vendor); + FF_CFTYPE_AUTO_RELEASE CFStringRef version = IORegistryEntryCreateCFProperty(registryEntry, CFSTR("version"), kCFAllocatorDefault, kNilOptions); + if (version) + ffCfStrGetString(version, &host->version); + return NULL; }