aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hardware_functions.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp
index 5d6b6ffa..bd6a6c3c 100644
--- a/src/hardware_functions.cpp
+++ b/src/hardware_functions.cpp
@@ -50,10 +50,31 @@ QString get_hdid()
}
#elif defined __APPLE__
+#include <CoreFoundation/CoreFoundation.h>
+#include <IOKit/IOKitLib.h>
+
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