Skip to content
Snippets Groups Projects
Commit dea4adf5 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix compat with older macos

parent 498123fb
No related branches found
No related tags found
No related merge requests found
......@@ -394,9 +394,16 @@ std::string LLAppViewerMacOSX::generateSerialNumber()
// JC: Sample code from http://developer.apple.com/technotes/tn/tn1103.html
CFStringRef serialNumber = NULL;
io_service_t platformExpert = IOServiceGetMatchingService(kIOMainPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
if (platformExpert)
io_service_t platformExpert = NULL;
if (__builtin_available(macOS 12.0, *)) {
platformExpert = IOServiceGetMatchingService(kIOMainPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
} else {
platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
}
if (platformExpert)
{
serialNumber = (CFStringRef) IORegistryEntryCreateCFProperty(platformExpert,
CFSTR(kIOPlatformSerialNumberKey),
......
......@@ -350,8 +350,15 @@ bool LLWMIMethods::getGenericSerialNumber(const BSTR &select, const LPCWSTR &var
bool getSerialNumber(unsigned char *unique_id, size_t len)
{
CFStringRef serial_cf_str = NULL;
io_service_t platformExpert = IOServiceGetMatchingService(kIOMainPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
io_service_t platformExpert = NULL;
if (__builtin_available(macOS 12.0, *)) {
platformExpert = IOServiceGetMatchingService(kIOMainPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
} else {
platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
}
if (platformExpert)
{
serial_cf_str = (CFStringRef) IORegistryEntryCreateCFProperty(platformExpert,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment