diff --git a/src/common/small_string.h b/src/common/small_string.h index 9fc6ace4c..c059f3c7e 100644 --- a/src/common/small_string.h +++ b/src/common/small_string.h @@ -71,17 +71,17 @@ public: // append hex string void append_hex(const void* data, size_t len, bool comma_separate = false); - // append a single character to this string + // prepend a single character to this string void prepend(char c); - // append a string to this string + // prepend a string to this string void prepend(const char* str); void prepend(const char* str, u32 length); void prepend(const std::string& str); void prepend(const std::string_view str); void prepend(const SmallStringBase& str); - // append formatted string to this string + // prepend formatted string to this string void prepend_sprintf(const char* format, ...) PRINTFLIKE(2, 3); void prepend_vsprintf(const char* format, va_list ap); diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index 760ee503f..6434d5e9a 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -3709,7 +3709,6 @@ static TinyString GetLoginEncryptionMachineKey() TinyString ret; #ifdef _WIN32 - HKEY hKey; DWORD error; if ((error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey)) != @@ -3741,12 +3740,18 @@ static TinyString GetLoginEncryptionMachineKey() ret.resize(machine_guid_length); RegCloseKey(hKey); -#elif !defined(__ANDROID__) -#ifdef __linux__ +#else +#if defined(__linux__) // use /etc/machine-id on Linux std::optional machine_id = FileSystem::ReadFileToString("/etc/machine-id"); if (machine_id.has_value()) ret = std::string_view(machine_id.value()); +#elif defined(__APPLE__) + // use gethostuuid(2) on macOS + const struct timespec ts{}; + uuid_t uuid{}; + if (gethostuuid(uuid, &ts) == 0) + ret.append_hex(uuid, sizeof(uuid), false); #endif if (ret.empty())