diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index 5d6b6ff..bd6a6c3 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -50,10 +50,31 @@ QString get_hdid() } #elif defined __APPLE__ +#include +#include + 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