[PATCH] wineboot: Automatically create ProfileList key for current user.

Dmitry Timoshkov dmitry at baikal.ru
Wed Nov 20 04:27:38 CST 2019


This patch aims to replace the appropriate patchset from wine-staging.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 programs/wineboot/wineboot.c | 54 ++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index cd5c9505b3..4615f62a74 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -1174,6 +1174,59 @@ static void install_root_pnp_devices(void)
     SetupDiDestroyDeviceInfoList(set);
 }
 
+static void update_user_profile(void)
+{
+    static const WCHAR pfx[] = {'S',0};
+    static const WCHAR fmt[] = {'-','%','u',0};
+    static const WCHAR profile_list[] = {'S','o','f','t','w','a','r','e','\\',
+                                         'M','i','c','r','o','s','o','f','t','\\',
+                                         'W','i','n','d','o','w','s',' ','N','T','\\',
+                                         'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+                                         'P','r','o','f','i','l','e','L','i','s','t',0};
+    static const WCHAR profile_image_path[] = {'P','r','o','f','i','l','e','I','m','a','g','e','P','a','t','h',0};
+    char token_buf[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD) * SID_MAX_SUB_AUTHORITIES];
+    HANDLE token;
+    PISID sid;
+    WCHAR sid_buf[1 + 10 + 10 + 10 * SID_MAX_SUB_AUTHORITIES], profile[MAX_PATH], *p;
+    DWORD size, i;
+    HKEY hkey, profile_hkey;
+
+    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token))
+        return;
+
+    size = sizeof(token_buf);
+    GetTokenInformation(token, TokenUser, token_buf, size, &size);
+    CloseHandle(token);
+
+    sid = ((TOKEN_USER *)token_buf)->User.Sid;
+
+    p = sid_buf;
+    lstrcpyW(p, pfx);
+    p += lstrlenW(pfx);
+    p += wsprintfW(p, fmt, sid->Revision);
+    p += wsprintfW(p, fmt, MAKELONG(MAKEWORD(sid->IdentifierAuthority.Value[5],
+                                             sid->IdentifierAuthority.Value[4]),
+                                    MAKEWORD(sid->IdentifierAuthority.Value[3],
+                                             sid->IdentifierAuthority.Value[2])));
+    for (i = 0; i < sid->SubAuthorityCount; i++)
+        p += wsprintfW(p, fmt, sid->SubAuthority[i]);
+
+    if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_list, 0, NULL, 0,
+                         KEY_ALL_ACCESS, NULL, &hkey, NULL))
+    {
+        if (!RegCreateKeyExW(hkey, sid_buf, 0, NULL, 0,
+                             KEY_ALL_ACCESS, NULL, &profile_hkey, NULL))
+        {
+            if (SHGetSpecialFolderPathW(NULL, profile, CSIDL_PROFILE, TRUE))
+                set_reg_value(profile_hkey, profile_image_path, profile);
+
+            RegCloseKey(profile_hkey);
+        }
+
+        RegCloseKey(hkey);
+    }
+}
+
 /* execute rundll32 on the wine.inf file if necessary */
 static void update_wineprefix( BOOL force )
 {
@@ -1218,6 +1271,7 @@ static void update_wineprefix( BOOL force )
             DestroyWindow( hwnd );
         }
         install_root_pnp_devices();
+        update_user_profile();
 
         WINE_MESSAGE( "wine: configuration in '%s' has been updated.\n", prettyprint_configdir() );
     }
-- 
2.20.1




More information about the wine-devel mailing list