[PATCH 1/2] wineboot: Create user profile registry key

Alex Henrie alexhenrie24 at gmail.com
Sun Sep 23 15:24:37 CDT 2018


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=15670
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 programs/wineboot/wineboot.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index 075b4c8b08..043cc64ab6 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -81,6 +81,7 @@
 #include <shobjidl.h>
 #include <shlwapi.h>
 #include <shellapi.h>
+#include <sddl.h>
 #include "resource.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wineboot);
@@ -422,6 +423,31 @@ static void create_volatile_environment_registry_key(void)
     RegCloseKey( hkey );
 }
 
+/* create a profile key for the current user */
+static void create_user_profile_registry_key(void)
+{
+    WCHAR profile_key_path[512] = {'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};
+    HANDLE token;
+    char buffer[512];
+    WCHAR *sid_str;
+    HKEY profile_key;
+
+    OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
+    GetTokenInformation(token, TokenUser, buffer, sizeof(buffer), NULL);
+    ConvertSidToStringSidW(((TOKEN_USER *)buffer)->User.Sid, &sid_str);
+    strcatW(profile_key_path, sid_str);
+    LocalFree(sid_str);
+
+    RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_key_path, 0, NULL, 0, KEY_WRITE, NULL, &profile_key, NULL);
+
+    RegCloseKey(profile_key);
+    CloseHandle(token);
+}
+
 /* Performs the rename operations dictated in %SystemRoot%\Wininit.ini.
  * Returns FALSE if there was an error, or otherwise if all is ok.
  */
@@ -1247,6 +1273,7 @@ int main( int argc, char *argv[] )
     if (init || update) update_wineprefix( update );
 
     create_volatile_environment_registry_key();
+    create_user_profile_registry_key();
 
     ProcessRunKeys( HKEY_LOCAL_MACHINE, RunOnceW, TRUE, TRUE );
 
-- 
2.19.0




More information about the wine-devel mailing list