Alexandre Julliard : ntdll: Also create the initial process parameters with RtlCreateProcessParametersEx ().
Alexandre Julliard
julliard at winehq.org
Wed Feb 13 15:30:40 CST 2019
Module: wine
Branch: master
Commit: 50f0ed75efc16d4fd3f0e786242829808407fce0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=50f0ed75efc16d4fd3f0e786242829808407fce0
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Feb 13 12:48:36 2019 +0100
ntdll: Also create the initial process parameters with RtlCreateProcessParametersEx().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/env.c | 35 +++++++++++++++++++++++++++++------
dlls/ntdll/thread.c | 23 +----------------------
2 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index bf57ab9..d2b40bd 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -22,6 +22,9 @@
#include <assert.h>
#include <stdarg.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -34,6 +37,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(environ);
+static WCHAR empty[] = {0};
+static const UNICODE_STRING empty_str = { 0, sizeof(empty), empty };
+static const UNICODE_STRING null_str = { 0, 0, NULL };
+
/******************************************************************************
* NtQuerySystemEnvironmentValue [NTDLL.@]
*/
@@ -454,10 +461,6 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
const UNICODE_STRING *RuntimeInfo,
ULONG flags )
{
- static WCHAR empty[] = {0};
- static const UNICODE_STRING empty_str = { 0, sizeof(empty), empty };
- static const UNICODE_STRING null_str = { 0, 0, NULL };
-
UNICODE_STRING curdir;
const RTL_USER_PROCESS_PARAMETERS *cur_params;
SIZE_T size, env_size = 0;
@@ -479,7 +482,7 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
curdir.MaximumLength = MAX_PATH * sizeof(WCHAR);
if (!CommandLine) CommandLine = ImagePathName;
- if (!Environment) Environment = cur_params->Environment;
+ if (!Environment && cur_params) Environment = cur_params->Environment;
if (!WindowTitle) WindowTitle = &empty_str;
if (!Desktop) Desktop = &empty_str;
if (!ShellInfo) ShellInfo = &empty_str;
@@ -509,7 +512,7 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
params->AllocationSize = size;
params->Size = size;
params->Flags = PROCESS_PARAMS_FLAG_NORMALIZED;
- params->ConsoleFlags = cur_params->ConsoleFlags;
+ if (cur_params) params->ConsoleFlags = cur_params->ConsoleFlags;
/* all other fields are zero */
ptr = params + 1;
@@ -584,6 +587,26 @@ void init_user_process_params( SIZE_T data_size )
RTL_USER_PROCESS_PARAMETERS *params = NULL;
UNICODE_STRING curdir, dllpath, imagepath, cmdline, title, desktop, shellinfo, runtime;
+ if (!data_size)
+ {
+ if (RtlCreateProcessParametersEx( ¶ms, &null_str, &null_str, &empty_str, &null_str, NULL,
+ &null_str, &null_str, &null_str, &null_str,
+ PROCESS_PARAMS_FLAG_NORMALIZED ))
+ return;
+
+ NtCurrentTeb()->Peb->ProcessParameters = params;
+ if (isatty(0) || isatty(1) || isatty(2))
+ params->ConsoleHandle = (HANDLE)2; /* see kernel32/kernel_private.h */
+ if (!isatty(0))
+ wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput );
+ if (!isatty(1))
+ wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput );
+ if (!isatty(2))
+ wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError );
+ params->wShowWindow = 1; /* SW_SHOWNORMAL */
+ return;
+ }
+
if (!(info = RtlAllocateHeap( GetProcessHeap(), 0, data_size ))) return;
SERVER_START_REQ( get_startup_info )
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 8dc903a..9f4a08f 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -67,8 +67,6 @@ struct startup_info
static PEB *peb;
static PEB_LDR_DATA ldr;
-static RTL_USER_PROCESS_PARAMETERS params; /* default parameters if no parent */
-static WCHAR current_dir[MAX_PATH];
static RTL_BITMAP tls_bitmap;
static RTL_BITMAP tls_expansion_bitmap;
static RTL_BITMAP fls_bitmap;
@@ -192,7 +190,6 @@ void thread_init(void)
peb = addr;
peb->FastPebLock = &peb_lock;
- peb->ProcessParameters = ¶ms;
peb->TlsBitmap = &tls_bitmap;
peb->TlsExpansionBitmap = &tls_expansion_bitmap;
peb->FlsBitmap = &fls_bitmap;
@@ -201,9 +198,6 @@ void thread_init(void)
peb->OSMinorVersion = 1;
peb->OSBuildNumber = 0xA28;
peb->OSPlatformId = VER_PLATFORM_WIN32_NT;
- params.CurrentDirectory.DosPath.Buffer = current_dir;
- params.CurrentDirectory.DosPath.MaximumLength = sizeof(current_dir);
- params.wShowWindow = 1; /* SW_SHOWNORMAL */
ldr.Length = sizeof(ldr);
ldr.Initialized = TRUE;
RtlInitializeBitMap( &tls_bitmap, peb->TlsBitmapBits, sizeof(peb->TlsBitmapBits) * 8 );
@@ -257,22 +251,7 @@ void thread_init(void)
exit(1);
}
- /* allocate user parameters */
- if (info_size)
- {
- init_user_process_params( info_size );
- }
- else
- {
- if (isatty(0) || isatty(1) || isatty(2))
- params.ConsoleHandle = (HANDLE)2; /* see kernel32/kernel_private.h */
- if (!isatty(0))
- wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdInput );
- if (!isatty(1))
- wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdOutput );
- if (!isatty(2))
- wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms.hStdError );
- }
+ init_user_process_params( info_size );
/* initialize time values in user_shared_data */
NtQuerySystemTime( &now );
More information about the wine-cvs
mailing list