master ohmu/fastfetch-openbsd / src / common / impl / kmod_apple.c
ohmu  ·  2026-10-15
 1#include "common/kmod.h"
 2#include "common/apple/cf_helpers.h"
 3#include <IOKit/kext/KextManager.h>
 4#include <CoreFoundation/CoreFoundation.h>
 5
 6bool ffKmodLoaded(const char* modName) {
 7    FF_CFTYPE_AUTO_RELEASE CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, modName, kCFStringEncodingUTF8);
 8    FF_CFTYPE_AUTO_RELEASE CFArrayRef identifiers = CFArrayCreate(kCFAllocatorDefault, (const void**) &name, 1, &kCFTypeArrayCallBacks);
 9    FF_CFTYPE_AUTO_RELEASE CFArrayRef keys = CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr);
10    FF_CFTYPE_AUTO_RELEASE CFDictionaryRef kextInfo = KextManagerCopyLoadedKextInfo(identifiers, keys);
11    return CFDictionaryContainsKey(kextInfo, name);
12}