[PATCH 1/2] wineboot: Create user profile registry key
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=15670 Signed-off-by: Alex Henrie <alexhenrie24(a)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
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38659 Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- programs/wineboot/Makefile.in | 2 +- programs/wineboot/wineboot.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/programs/wineboot/Makefile.in b/programs/wineboot/Makefile.in index 2006067c4e..1069626b87 100644 --- a/programs/wineboot/Makefile.in +++ b/programs/wineboot/Makefile.in @@ -1,6 +1,6 @@ MODULE = wineboot.exe APPMODE = -mconsole -IMPORTS = uuid advapi32 +IMPORTS = uuid advapi32 userenv DELAYIMPORTS = shell32 shlwapi version user32 C_SRCS = \ diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 043cc64ab6..cf9c04b6c2 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -82,6 +82,7 @@ #include <shlwapi.h> #include <shellapi.h> #include <sddl.h> +#include <userenv.h> #include "resource.h" WINE_DEFAULT_DEBUG_CHANNEL(wineboot); @@ -426,6 +427,9 @@ static void create_volatile_environment_registry_key(void) /* create a profile key for the current user */ static void create_user_profile_registry_key(void) { + static const WCHAR FlagsW[] = {'F','l','a','g','s',0}; + static const WCHAR ProfileImagePathW[] = {'P','r','o','f','i','l','e','I','m','a','g','e','P','a','t','h',0}; + static const DWORD flags = 0; 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','\\', @@ -435,6 +439,8 @@ static void create_user_profile_registry_key(void) char buffer[512]; WCHAR *sid_str; HKEY profile_key; + WCHAR profile_dir[MAX_PATH]; + DWORD profile_dir_len = ARRAY_SIZE(profile_dir); OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token); GetTokenInformation(token, TokenUser, buffer, sizeof(buffer), NULL); @@ -444,6 +450,11 @@ static void create_user_profile_registry_key(void) RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_key_path, 0, NULL, 0, KEY_WRITE, NULL, &profile_key, NULL); + RegSetValueExW(profile_key, FlagsW, 0, REG_DWORD, (BYTE *)&flags, sizeof(flags)); + + GetUserProfileDirectoryW(token, profile_dir, &profile_dir_len); + RegSetValueExW(profile_key, ProfileImagePathW, 0, REG_SZ, (BYTE *)profile_dir, (profile_dir_len + 1) * sizeof(WCHAR)); + RegCloseKey(profile_key); CloseHandle(token); } -- 2.19.0
Alex Henrie <alexhenrie24(a)gmail.com> writes:
@@ -444,6 +450,11 @@ static void create_user_profile_registry_key(void)
RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_key_path, 0, NULL, 0, KEY_WRITE, NULL, &profile_key, NULL);
+ RegSetValueExW(profile_key, FlagsW, 0, REG_DWORD, (BYTE *)&flags, sizeof(flags)); + + GetUserProfileDirectoryW(token, profile_dir, &profile_dir_len); + RegSetValueExW(profile_key, ProfileImagePathW, 0, REG_SZ, (BYTE *)profile_dir, (profile_dir_len + 1) * sizeof(WCHAR));
I think GetUserProfileDirectoryW() should be getting the value from the registry, which would be set without using userenv.dll. This could be done in wineboot, but maybe shell32 would be more appropriate. -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alex Henrie -
Alexandre Julliard