Skip to content

Commit 0801e22

Browse files
committed
Bios: support macOS
1 parent 5efd7b9 commit 0801e22

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Features:
2525
* Supports GPU detection on Android
2626
* Supports Kitty Terminal terminal font
2727
* Supports bar output for percentage values
28+
* Supports Bios module on macOS
2829
* Supports eopkg package manager detection
2930
* Supports iTerm image logo protocol
3031
* Supports image logo printing on macOS

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ elseif(APPLE)
420420
src/common/processing_linux.c
421421
src/common/sysctl.c
422422
src/detection/battery/battery_apple.c
423-
src/detection/bios/bios_nosupport.c
423+
src/detection/bios/bios_apple.c
424424
src/detection/board/board_nosupport.c
425425
src/detection/chassis/chassis_nosupport.c
426426
src/detection/cpu/cpu_apple.c

src/detection/bios/bios_apple.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include "bios.h"
2+
#include "util/apple/cf_helpers.h"
3+
4+
#include <IOKit/IOKitLib.h>
5+
6+
void ffDetectBios(FFBiosResult* bios)
7+
{
8+
ffStrbufInit(&bios->error);
9+
ffStrbufInit(&bios->biosDate);
10+
ffStrbufInit(&bios->biosRelease);
11+
ffStrbufInit(&bios->biosVendor);
12+
ffStrbufInit(&bios->biosVersion);
13+
14+
io_registry_entry_t registryEntry;
15+
16+
#ifndef __aarch64__
17+
18+
//https://github.com/osquery/osquery/blob/master/osquery/tables/system/darwin/smbios_tables.cpp
19+
//For Intel
20+
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/rom")))
21+
{
22+
CFMutableDictionaryRef properties;
23+
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
24+
{
25+
IOObjectRelease(registryEntry);
26+
ffStrbufAppendS(&bios->error, "IORegistryEntryCreateCFProperties(registryEntry) failed");
27+
return;
28+
}
29+
30+
ffCfDictGetString(properties, CFSTR("vendor"), &bios->biosVendor);
31+
ffCfDictGetString(properties, CFSTR("version"), &bios->biosVersion);
32+
ffCfDictGetString(properties, CFSTR("release-date"), &bios->biosDate);
33+
if(!ffStrbufContainC(&bios->biosDate, '-'))
34+
ffStrbufAppendS(&bios->biosRelease, "Efi-");
35+
ffStrbufAppend(&bios->biosRelease, &bios->biosVersion);
36+
37+
CFRelease(properties);
38+
IOObjectRelease(registryEntry);
39+
return;
40+
}
41+
42+
#else
43+
44+
//For arm64
45+
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/")))
46+
{
47+
CFMutableDictionaryRef properties;
48+
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
49+
{
50+
ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->biosVendor);
51+
CFRelease(properties);
52+
}
53+
IOObjectRelease(registryEntry);
54+
}
55+
56+
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen")))
57+
{
58+
CFMutableDictionaryRef properties;
59+
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
60+
{
61+
ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->biosRelease);
62+
ffStrbufAppend(&bios->biosVersion, &bios->biosRelease);
63+
ffStrbufSubstrAfterFirstC(&bios->biosVersion, '-');
64+
CFRelease(properties);
65+
}
66+
IOObjectRelease(registryEntry);
67+
}
68+
69+
#endif
70+
}

0 commit comments

Comments
 (0)