From: Katharina Bogad <katharina@hacked.xyz> Calling CreateOricessAsUserW with a token that has session_id != 0 set should result in the program being started on the token's assoiciated desktop. Currently, WINE doesn't handle multiple users and multiple winstations, so for the moment, if the associated token has a session_id != 0, overwrite the desktop to the default value. This allows serivces started with session_id 0 running non-interactively to get a session_id from wtsapi32 belonging to an interactive session and use CreateProcessAsUserW to open child processes in an interactive environment. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58588 --- dlls/kernelbase/process.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index 3656e40280d..ce03d2ec5da 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -439,6 +439,23 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserA( HANDLE token, const char *ap const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info ) { + DWORD dwSessionId = 0; + DWORD dwReturnLength; + + BOOL success = GetTokenInformation(token, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwReturnLength); + + TRACE("success = %u, dwSessionId = %lu\n", success, dwSessionId); + + if (success && + dwSessionId != 0) + { + /* the created process should be attached to an interactive session. + * So we override the winstation for this process. */ + FIXME( "Child process will be started with default desktop\n"); + + startup_info->lpDesktop = (char*)"winsta0\\default"; + } + return CreateProcessInternalA( token, app_name, cmd_line, process_attr, thread_attr, inherit, flags, env, cur_dir, startup_info, info, NULL ); } @@ -454,6 +471,23 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW( HANDLE token, const WCHAR *a const WCHAR *cur_dir, STARTUPINFOW *startup_info, PROCESS_INFORMATION *info ) { + DWORD dwSessionId = 0; + DWORD dwReturnLength; + + BOOL success = GetTokenInformation(token, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwReturnLength); + + TRACE("success = %u, dwSessionId = %lu\n", success, dwSessionId); + + if (success && + dwSessionId != 0) + { + /* the created process should be attached to an interactive session. + * So we override the winstation for this process. */ + FIXME( "Child process will be started with default desktop\n"); + + startup_info->lpDesktop = (WCHAR*)L"winsta0\\default"; + } + return CreateProcessInternalW( token, app_name, cmd_line, process_attr, thread_attr, inherit, flags, env, cur_dir, startup_info, info, NULL ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9843