Module: wine Branch: master Commit: 2475cb767d5878b70f0ea4519d3918cc18483968 URL: https://source.winehq.org/git/wine.git/?a=commit;h=2475cb767d5878b70f0ea4519...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Oct 8 16:27:42 2018 +0200
kernel32: Make a copy of the process environment in CreateProcessW().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/process.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index f7808af..18c0f08 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -2626,7 +2626,19 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A if (GetCurrentDirectoryW(MAX_PATH, buf)) unixdir = wine_get_unix_file_name( buf ); }
- if (env && !(flags & CREATE_UNICODE_ENVIRONMENT)) /* convert environment to unicode */ + if (!env) + { + WCHAR *e; + + RtlAcquirePebLock(); + e = env = NtCurrentTeb()->Peb->ProcessParameters->Environment; + while (*e) e += strlenW(e) + 1; + e++; /* final null */ + envW = HeapAlloc( GetProcessHeap(), 0, (e - (WCHAR *)env) * sizeof(WCHAR) ); + memcpy( envW, env, (e - (WCHAR *)env) * sizeof(WCHAR) ); + RtlReleasePebLock(); + } + else if (!(flags & CREATE_UNICODE_ENVIRONMENT)) /* convert environment to unicode */ { char *e = env; DWORD lenW; @@ -2636,8 +2648,8 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A lenW = MultiByteToWideChar( CP_ACP, 0, env, e - (char*)env, NULL, 0 ); envW = HeapAlloc( GetProcessHeap(), 0, lenW * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, env, e - (char*)env, envW, lenW ); - flags |= CREATE_UNICODE_ENVIRONMENT; } + flags |= CREATE_UNICODE_ENVIRONMENT;
info->hThread = info->hProcess = 0; info->dwProcessId = info->dwThreadId = 0;