diff options
Diffstat (limited to 'src/hardware_functions.cpp')
| -rw-r--r-- | src/hardware_functions.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index 4dbc4380..c898aefe 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -51,8 +51,25 @@ QString get_hdid() #elif defined __APPLE__ QString get_hdid() { - // hdids are broken at this point anyways - return "just a mac passing by"; + CFStringRef serial; + char buffer[64] = {0}; + QString hdid; + io_service_t platformExpert = IOServiceGetMatchingService( + kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) { + CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty( + platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, + 0); + if (serialNumberAsCFString) { + serial = (CFStringRef)serialNumberAsCFString; + } + if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) { + hdid = buffer; + } + + IOObjectRelease(platformExpert); + } + return hdid; } #else |
