[PATCH v3 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 -- v3: 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 | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 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..15c14b9f5b0 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -912,6 +912,33 @@ 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; + + if (UuidCreate( &uuid ) == S_OK) + { + RPC_WSTR guid_str; + if (UuidToStringW( &uuid, &guid_str ) == RPC_S_OK) + { + set_reg_value( hkey, L"MachineId", guid_str ); + RpcStringFreeW( &guid_str ); + } + } + } + RegCloseKey( hkey ); +} + static const WCHAR *get_known_dll_ntdir( WORD machine ) { switch (machine) @@ -1900,6 +1927,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 17:02:44 2026 +0000, Paul Gofman wrote:
A bit of mostly stylistic comments. Thanks, should all be fixed now.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142020
Paul Gofman (@gofman) commented about programs/wineboot/wineboot.c:
+{ + 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; + + if (UuidCreate( &uuid ) == S_OK) + { + RPC_WSTR guid_str; No need to scope each variable. In previous variant it was just one sub-scope but now it feels like too much. I'd suggest to define everything at function start. Also while we are here strictly speaking this is not guid so I'd suggest to rename to uuid_str or just str. And we can remove some unneeded nesting, like this:
```` ``` if (r == ERROR_FILE_NOT_FOUND && !UuidCreate( &uuid ) && !UuidToStringW( &uuid, &str )) { set_reg_value( hkey, L"MachineId", str ); RpcStringFreeW( &str ); } ```` The patch subject is now obsolete, should be something like "wineboot: Create SQMClient registry key". -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11055#note_142023
participants (3)
-
Paul Gofman (@gofman) -
Rose Hellsing -
Rose Hellsing (@axtlos)