From 5eccabcad15a52691228aded1d9c1fd5074fb70e Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 12 Jul 2019 23:00:25 +0000 Subject: Less insane debugging; minor refactoring (!75) --- src/hardware_functions.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/hardware_functions.cpp') diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index ebba6ab7..5d6b6ffa 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -5,12 +5,12 @@ #if (defined (_WIN32) || defined (_WIN64)) #include -DWORD dwVolSerial; -BOOL bIsRetrieved; +static DWORD dwVolSerial; +static BOOL bIsRetrieved; QString get_hdid() { - bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL); + bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0); if (bIsRetrieved) return QString::number(dwVolSerial, 16); @@ -18,7 +18,6 @@ QString get_hdid() //a totally random string //what could possibly go wrong return "gxsps32sa9fnwic92mfbs0"; - } #elif (defined (LINUX) || defined (__linux__)) -- cgit From 2509cc5e0bf4d9c4bbd6798f71886e34cc8476b2 Mon Sep 17 00:00:00 2001 From: mac builder Date: Tue, 13 Aug 2019 20:01:42 +0200 Subject: get mac serial for hdid --- src/hardware_functions.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/hardware_functions.cpp') 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 +#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 -- cgit