Alexandre Julliard : ntdll: Fixup size of the current directory in RtlCreateProcessParametersEx().
Alexandre Julliard
julliard at winehq.org
Tue Oct 16 15:53:07 CDT 2018
Module: wine
Branch: master
Commit: ae7ccbba48b99ca6e7f9ee4564082c2d331fa205
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ae7ccbba48b99ca6e7f9ee4564082c2d331fa205
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Oct 16 20:43:42 2018 +0200
ntdll: Fixup size of the current directory in RtlCreateProcessParametersEx().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/env.c | 10 +++++++---
dlls/ntdll/thread.c | 8 ++++----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index fdd5d4f..417efb6 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -452,6 +452,7 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
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, total_size;
void *ptr;
@@ -464,10 +465,13 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
if (!CurrentDirectoryName)
{
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
- CurrentDirectoryName = &((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir.DosPath;
+ curdir = ((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir.DosPath;
else
- CurrentDirectoryName = &cur_params->CurrentDirectory.DosPath;
+ curdir = cur_params->CurrentDirectory.DosPath;
}
+ else curdir = *CurrentDirectoryName;
+ curdir.MaximumLength = MAX_PATH * sizeof(WCHAR);
+
if (!CommandLine) CommandLine = ImagePathName;
if (!Environment) Environment = cur_params->Environment;
if (!WindowTitle) WindowTitle = &empty_str;
@@ -503,7 +507,7 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
/* all other fields are zero */
ptr = params + 1;
- append_unicode_string( &ptr, CurrentDirectoryName, ¶ms->CurrentDirectory.DosPath );
+ append_unicode_string( &ptr, &curdir, ¶ms->CurrentDirectory.DosPath );
append_unicode_string( &ptr, DllPath, ¶ms->DllPath );
append_unicode_string( &ptr, ImagePathName, ¶ms->ImagePathName );
append_unicode_string( &ptr, CommandLine, ¶ms->CommandLine );
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 9b23fbf..c4e02da 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -68,7 +68,7 @@ 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_NT_PATH_LENGTH];
+static WCHAR current_dir[MAX_PATH];
static RTL_BITMAP tls_bitmap;
static RTL_BITMAP tls_expansion_bitmap;
static RTL_BITMAP fls_bitmap;
@@ -130,7 +130,7 @@ static NTSTATUS init_user_process_params( SIZE_T data_size )
if (status != STATUS_SUCCESS) goto done;
size = sizeof(*params);
- size += MAX_NT_PATH_LENGTH * sizeof(WCHAR);
+ size += sizeof(current_dir);
size += info->dllpath_len + sizeof(WCHAR);
size += info->imagepath_len + sizeof(WCHAR);
size += info->cmdline_len + sizeof(WCHAR);
@@ -169,8 +169,8 @@ static NTSTATUS init_user_process_params( SIZE_T data_size )
/* current directory needs more space */
get_unicode_string( ¶ms->CurrentDirectory.DosPath, &src, &dst, info->curdir_len );
- params->CurrentDirectory.DosPath.MaximumLength = MAX_NT_PATH_LENGTH * sizeof(WCHAR);
- dst = (WCHAR *)(params + 1) + MAX_NT_PATH_LENGTH;
+ params->CurrentDirectory.DosPath.MaximumLength = sizeof(current_dir);
+ dst = (WCHAR *)(params + 1) + ARRAY_SIZE(current_dir);
get_unicode_string( ¶ms->DllPath, &src, &dst, info->dllpath_len );
get_unicode_string( ¶ms->ImagePathName, &src, &dst, info->imagepath_len );
More information about the wine-cvs
mailing list