[PATCH v2 0/1] MR11055: loader: Add default SQMClient registry key
On Windows the key `HKLM\SOFTWARE\Microsoft\SQMClient` is populated with a random UUID when SQM is first used to identify each device. This MR makes wineboot fill it with a random UUID on initialization. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54021 -- v2: loader: Add default SQMClient registry key https://gitlab.winehq.org/wine/wine/-/merge_requests/11055
From: Rose Hellsing <rose@pinkro.se> On Windows the key HKLM\SOFTWARE\Microsoft\SQMClient is populated with a random UUID when SQM is first used to identify each device. In wine this is now done on wineboot initialization. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54021 --- programs/wineboot/Makefile.in | 2 +- programs/wineboot/wineboot.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/programs/wineboot/Makefile.in b/programs/wineboot/Makefile.in index d346b8984b1..2d3b4dc2bde 100644 --- a/programs/wineboot/Makefile.in +++ b/programs/wineboot/Makefile.in @@ -1,5 +1,5 @@ MODULE = wineboot.exe -IMPORTS = uuid advapi32 ws2_32 kernelbase +IMPORTS = uuid rpcrt4 advapi32 ws2_32 kernelbase DELAYIMPORTS = shell32 shlwapi version user32 gdi32 setupapi newdev wininet EXTRADLLFLAGS = -mconsole diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 6ffcbe1266c..c7744300567 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -912,6 +912,35 @@ static void create_volatile_environment_registry_key(void) RegCloseKey( hkey ); } +static void create_sqmclient_registry_key(void) +{ + HKEY hkey; + LONG r; + + r = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\SQMClient", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &hkey, NULL); + if (r) + return; + + r = RegQueryValueExW(hkey, L"MachineId", NULL, NULL, NULL, NULL); + if (r == ERROR_FILE_NOT_FOUND) + { + UUID uuid; + WCHAR buf[37]; + + if (UuidCreate(&uuid) == S_OK) + { + swprintf(buf, ARRAY_SIZE(buf), + L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uuid.Data1, uuid.Data2, uuid.Data3, + uuid.Data4[0], uuid.Data4[1], uuid.Data4[2], uuid.Data4[3], + uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]); + set_reg_value(hkey, L"MachineId", buf); + } + } + RegCloseKey(hkey); +} + static const WCHAR *get_known_dll_ntdir( WORD machine ) { switch (machine) @@ -1900,6 +1929,7 @@ int __cdecl main( int argc, char *argv[] ) start_services_process(); } if (init || update) update_wineprefix( update ); + create_sqmclient_registry_key(); create_volatile_environment_registry_key(); create_known_dlls(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11055
On Tue Jun 2 16:28:54 2026 +0000, Paul Gofman wrote:
(a constant value could still be added in wine.inf.in) and then having the compatible properties which is probably not too hard in this case: unique per system instance (Wine prefix in our case). To clarify, I don't mean adding it to both wine.inf and wineboot. Just that if wineboot will be considered too much of hassle for such a case it is better to have some UUID in compatible format hardcoded in wine.inf than empty string. Yep makes sense, I updated the commit to have it populate the key with a random UUID through wineboot now using UuidCreate.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142009
Paul Gofman (@gofman) commented about programs/wineboot/wineboot.c:
RegCloseKey( hkey ); }
+static void create_sqmclient_registry_key(void) +{ + HKEY hkey; + LONG r; + + r = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\SQMClient", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &hkey, NULL);
Here and below, formatting: spaces around function call parameters (look at the style of the existing code in this file): \`\`\` ``` r = RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\SQMClient", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL ); ``` \`\`\` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142010
Paul Gofman (@gofman) commented about programs/wineboot/wineboot.c:
+ if (r) + return; + + r = RegQueryValueExW(hkey, L"MachineId", NULL, NULL, NULL, NULL); + if (r == ERROR_FILE_NOT_FOUND) + { + UUID uuid; + WCHAR buf[37]; + + if (UuidCreate(&uuid) == S_OK) + { + swprintf(buf, ARRAY_SIZE(buf), + L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uuid.Data1, uuid.Data2, uuid.Data3, + uuid.Data4[0], uuid.Data4[1], uuid.Data4[2], uuid.Data4[3], + uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]); Since rpcrt4 import is added anyway UuidToStringW() can probably work instead of swprintf()?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142012
A bit of mostly stylistic comments. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142013
Paul Gofman (@gofman) commented about programs/wineboot/wineboot.c:
RegCloseKey( hkey ); }
+static void create_sqmclient_registry_key(void) +{ + HKEY hkey; + LONG r; + + r = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\SQMClient", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &hkey, NULL); + if (r) + return;
'return' may go to the same line as 'if (r)' (see the style in, e.g., create_computer_name_keys()). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142011
participants (3)
-
Paul Gofman (@gofman) -
Rose Hellsing -
Rose Hellsing (@axtlos)