wow64: Add thunks for the I/O completion syscalls.
[wine.git] / dlls / ntdll / env.c
blobbb8931a556b79b41acedd5eaf544fe5674ddb14b
1 /*
2 * Ntdll environment functions
4 * Copyright 1996, 1998 Alexandre Julliard
5 * Copyright 2003 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <assert.h>
23 #include <stdarg.h>
24 #include <sys/types.h>
26 #include "ntstatus.h"
27 #define WIN32_NO_STATUS
28 #include "windef.h"
29 #include "winternl.h"
30 #include "wine/debug.h"
31 #include "ntdll_misc.h"
32 #include "winnt.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(environ);
36 static WCHAR empty[] = L"";
37 static const UNICODE_STRING empty_str = { 0, sizeof(empty), empty };
38 static const UNICODE_STRING null_str = { 0, 0, NULL };
40 static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
42 static inline SIZE_T get_env_length( const WCHAR *env )
44 const WCHAR *end = env;
45 while (*end) end += wcslen(end) + 1;
46 return end + 1 - env;
50 /***********************************************************************
51 * set_wow64_environment
53 * Set the environment variables that change across 32/64/Wow64.
55 static void set_wow64_environment( WCHAR **env )
57 static WCHAR archW[] = L"PROCESSOR_ARCHITECTURE";
58 static WCHAR arch6432W[] = L"PROCESSOR_ARCHITEW6432";
60 WCHAR buf[256];
61 UNICODE_STRING arch_strW = { sizeof(archW) - sizeof(WCHAR), sizeof(archW), archW };
62 UNICODE_STRING arch6432_strW = { sizeof(arch6432W) - sizeof(WCHAR), sizeof(arch6432W), arch6432W };
63 UNICODE_STRING valW = { 0, sizeof(buf), buf };
64 UNICODE_STRING nameW;
66 /* set the PROCESSOR_ARCHITECTURE variable */
68 if (!RtlQueryEnvironmentVariable_U( *env, &arch6432_strW, &valW ))
70 if (is_win64)
72 RtlSetEnvironmentVariable( env, &arch_strW, &valW );
73 RtlSetEnvironmentVariable( env, &arch6432_strW, NULL );
76 else if (NtCurrentTeb64() && !RtlQueryEnvironmentVariable_U( *env, &arch_strW, &valW ))
78 RtlSetEnvironmentVariable( env, &arch6432_strW, &valW );
79 RtlInitUnicodeString( &nameW, L"x86" );
80 RtlSetEnvironmentVariable( env, &arch_strW, &nameW );
83 /* set the ProgramFiles variables */
85 RtlInitUnicodeString( &nameW, is_win64 ? L"ProgramW6432" : L"ProgramFiles(x86)" );
86 if (!RtlQueryEnvironmentVariable_U( *env, &nameW, &valW ))
88 RtlInitUnicodeString( &nameW, L"ProgramFiles" );
89 RtlSetEnvironmentVariable( env, &nameW, &valW );
92 /* set the CommonProgramFiles variables */
94 RtlInitUnicodeString( &nameW, is_win64 ? L"CommonProgramW6432" : L"CommonProgramFiles(x86)" );
95 if (!RtlQueryEnvironmentVariable_U( *env, &nameW, &valW ))
97 RtlInitUnicodeString( &nameW, L"CommonProgramFiles" );
98 RtlSetEnvironmentVariable( env, &nameW, &valW );
101 RtlReAllocateHeap( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, *env,
102 get_env_length(*env) * sizeof(WCHAR) );
106 /******************************************************************************
107 * RtlCreateEnvironment [NTDLL.@]
109 NTSTATUS WINAPI RtlCreateEnvironment(BOOLEAN inherit, PWSTR* env)
111 SIZE_T size;
113 TRACE("(%u,%p)!\n", inherit, env);
115 if (inherit)
117 RtlAcquirePebLock();
118 size = get_env_length( NtCurrentTeb()->Peb->ProcessParameters->Environment ) * sizeof(WCHAR);
119 if ((*env = RtlAllocateHeap( GetProcessHeap(), 0, size )))
120 memcpy( *env, NtCurrentTeb()->Peb->ProcessParameters->Environment, size );
121 RtlReleasePebLock();
123 else *env = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR) );
125 return *env ? STATUS_SUCCESS : STATUS_NO_MEMORY;
128 /******************************************************************************
129 * RtlDestroyEnvironment [NTDLL.@]
131 NTSTATUS WINAPI RtlDestroyEnvironment(PWSTR env)
133 RtlFreeHeap( GetProcessHeap(), 0, env );
134 return STATUS_SUCCESS;
137 static LPCWSTR ENV_FindVariable(PCWSTR var, PCWSTR name, unsigned namelen)
139 while (*var)
141 /* match var names, but avoid setting a var with a name including a '='
142 * (a starting '=' is valid though)
144 unsigned int len = wcslen( var );
145 if (len > namelen &&
146 var[namelen] == '=' &&
147 !RtlCompareUnicodeStrings( var, namelen, name, namelen, TRUE ) &&
148 wcschr(var + 1, '=') == var + namelen)
150 return var + namelen + 1;
152 var += len + 1;
154 return NULL;
157 /******************************************************************
158 * RtlQueryEnvironmentVariable_U [NTDLL.@]
160 * NOTES: when the buffer is too small, the string is not written, but if the
161 * terminating null char is the only char that cannot be written, then
162 * all chars (except the null) are written and success is returned
163 * (behavior of Win2k at least)
165 NTSTATUS WINAPI RtlQueryEnvironmentVariable_U(PWSTR env,
166 PUNICODE_STRING name,
167 PUNICODE_STRING value)
169 NTSTATUS nts = STATUS_VARIABLE_NOT_FOUND;
170 PCWSTR var;
171 unsigned namelen;
173 TRACE("%p %s %p\n", env, debugstr_us(name), value);
175 value->Length = 0;
176 namelen = name->Length / sizeof(WCHAR);
177 if (!namelen) return nts;
179 if (!env)
181 RtlAcquirePebLock();
182 var = NtCurrentTeb()->Peb->ProcessParameters->Environment;
184 else var = env;
186 var = ENV_FindVariable(var, name->Buffer, namelen);
187 if (var != NULL)
189 value->Length = wcslen(var) * sizeof(WCHAR);
191 if (value->Length <= value->MaximumLength)
193 memmove(value->Buffer, var, min(value->Length + sizeof(WCHAR), value->MaximumLength));
194 nts = STATUS_SUCCESS;
196 else nts = STATUS_BUFFER_TOO_SMALL;
199 if (!env) RtlReleasePebLock();
201 return nts;
205 /******************************************************************
206 * RtlQueryEnvironmentVariable [NTDLL.@]
208 NTSTATUS WINAPI RtlQueryEnvironmentVariable( WCHAR *env, const WCHAR *name, SIZE_T namelen,
209 WCHAR *value, SIZE_T value_length, SIZE_T *return_length )
211 NTSTATUS nts = STATUS_VARIABLE_NOT_FOUND;
212 SIZE_T len = 0;
213 const WCHAR *var;
215 if (!namelen) return nts;
217 if (!env)
219 RtlAcquirePebLock();
220 var = NtCurrentTeb()->Peb->ProcessParameters->Environment;
222 else var = env;
224 var = ENV_FindVariable(var, name, namelen);
225 if (var != NULL)
227 len = wcslen(var);
228 if (len <= value_length)
230 memcpy(value, var, min(len + 1, value_length) * sizeof(WCHAR));
231 nts = STATUS_SUCCESS;
233 else
235 len++;
236 nts = STATUS_BUFFER_TOO_SMALL;
239 *return_length = len;
241 if (!env) RtlReleasePebLock();
243 return nts;
246 /******************************************************************
247 * RtlSetCurrentEnvironment [NTDLL.@]
250 void WINAPI RtlSetCurrentEnvironment(PWSTR new_env, PWSTR* old_env)
252 WCHAR *prev;
254 TRACE("(%p %p)\n", new_env, old_env);
256 RtlAcquirePebLock();
258 prev = NtCurrentTeb()->Peb->ProcessParameters->Environment;
259 NtCurrentTeb()->Peb->ProcessParameters->Environment = new_env;
260 NtCurrentTeb()->Peb->ProcessParameters->EnvironmentSize = RtlSizeHeap( GetProcessHeap(), 0, new_env );
262 RtlReleasePebLock();
264 if (old_env)
265 *old_env = prev;
266 else
267 RtlDestroyEnvironment( prev );
271 /******************************************************************************
272 * RtlSetEnvironmentVariable [NTDLL.@]
274 NTSTATUS WINAPI RtlSetEnvironmentVariable(PWSTR* penv, PUNICODE_STRING name,
275 PUNICODE_STRING value)
277 INT varlen, len, old_size;
278 LPWSTR p, env;
279 NTSTATUS nts = STATUS_SUCCESS;
281 TRACE("(%p, %s, %s)\n", penv, debugstr_us(name), debugstr_us(value));
283 if (!name || !name->Buffer || !name->Length)
284 return STATUS_INVALID_PARAMETER_1;
286 len = name->Length / sizeof(WCHAR);
288 /* variable names can't contain a '=' except as a first character */
289 for (p = name->Buffer + 1; p < name->Buffer + len; p++)
290 if (*p == '=') return STATUS_INVALID_PARAMETER;
292 if (!penv)
294 RtlAcquirePebLock();
295 env = NtCurrentTeb()->Peb->ProcessParameters->Environment;
296 } else env = *penv;
298 old_size = get_env_length( env );
300 /* Find a place to insert the string */
301 for (p = env; *p; p += varlen + 1)
303 varlen = wcslen(p);
304 if (varlen > len && p[len] == '=' &&
305 !RtlCompareUnicodeStrings( name->Buffer, len, p, len, TRUE )) break;
307 if (!value && !*p) goto done; /* Value to remove doesn't exist */
309 /* Realloc the buffer */
310 len = value ? len + value->Length / sizeof(WCHAR) + 2 : 0;
311 if (*p) len -= wcslen(p) + 1; /* The name already exists */
313 if (len < 0)
315 LPWSTR next = p + wcslen(p) + 1; /* We know there is a next one */
316 memmove(next + len, next, (old_size - (next - env)) * sizeof(WCHAR));
319 if ((old_size + len) * sizeof(WCHAR) > RtlSizeHeap( GetProcessHeap(), 0, env ))
321 SIZE_T new_size = (old_size + len) * sizeof(WCHAR);
322 LPWSTR new_env = RtlAllocateHeap( GetProcessHeap(), 0, new_size );
324 if (!new_env)
326 nts = STATUS_NO_MEMORY;
327 goto done;
329 memcpy(new_env, env, (p - env) * sizeof(WCHAR));
330 memcpy(new_env + (p - env) + len, p, (old_size - (p - env)) * sizeof(WCHAR));
331 p = new_env + (p - env);
333 RtlDestroyEnvironment(env);
334 if (!penv)
336 NtCurrentTeb()->Peb->ProcessParameters->Environment = new_env;
337 NtCurrentTeb()->Peb->ProcessParameters->EnvironmentSize = new_size;
339 else *penv = new_env;
341 else
343 if (len > 0) memmove(p + len, p, (old_size - (p - env)) * sizeof(WCHAR));
346 /* Set the new string */
347 if (value)
349 memcpy( p, name->Buffer, name->Length );
350 p += name->Length / sizeof(WCHAR);
351 *p++ = '=';
352 memcpy( p, value->Buffer, value->Length );
353 p[value->Length / sizeof(WCHAR)] = 0;
356 done:
357 if (!penv) RtlReleasePebLock();
359 return nts;
362 /******************************************************************************
363 * RtlExpandEnvironmentStrings (NTDLL.@)
365 NTSTATUS WINAPI RtlExpandEnvironmentStrings( const WCHAR *renv, WCHAR *src, SIZE_T src_len,
366 WCHAR *dst, SIZE_T count, SIZE_T *plen )
368 SIZE_T len, total_size = 1; /* 1 for terminating '\0' */
369 LPCWSTR env, var;
371 if (!renv)
373 RtlAcquirePebLock();
374 env = NtCurrentTeb()->Peb->ProcessParameters->Environment;
376 else env = renv;
378 while (src_len)
380 if (*src != '%')
382 for (len = 0; len < src_len; len++) if (src[len] == '%') break;
383 var = src;
384 src += len;
385 src_len -= len;
387 else /* we are at the start of a variable */
389 for (len = 1; len < src_len; len++) if (src[len] == '%') break;
390 if (len < src_len)
392 if ((var = ENV_FindVariable( env, src + 1, len - 1 )))
394 src += len + 1; /* Skip the variable name */
395 src_len -= len + 1;
396 len = wcslen(var);
398 else
400 var = src; /* Copy original name instead */
401 len++;
402 src += len;
403 src_len -= len;
406 else /* unfinished variable name, ignore it */
408 var = src;
409 src += len;
410 src_len = 0;
413 total_size += len;
414 if (dst)
416 if (count < len) len = count;
417 memcpy(dst, var, len * sizeof(WCHAR));
418 count -= len;
419 dst += len;
423 if (!renv) RtlReleasePebLock();
425 if (dst && count) *dst = '\0';
426 if (plen) *plen = total_size;
428 return (count) ? STATUS_SUCCESS : STATUS_BUFFER_TOO_SMALL;
431 /******************************************************************
432 * RtlExpandEnvironmentStrings_U (NTDLL.@)
434 NTSTATUS WINAPI RtlExpandEnvironmentStrings_U( const WCHAR *env, const UNICODE_STRING *src,
435 UNICODE_STRING *dst, ULONG *plen )
437 SIZE_T len;
438 NTSTATUS ret;
440 ret = RtlExpandEnvironmentStrings( env, src->Buffer, src->Length / sizeof(WCHAR),
441 dst->Buffer, dst->MaximumLength / sizeof(WCHAR), &len );
442 if (plen) *plen = len * sizeof(WCHAR); /* FIXME: check for overflow? */
443 if (len > UNICODE_STRING_MAX_CHARS) ret = STATUS_BUFFER_TOO_SMALL;
444 if (!ret) dst->Length = (len - 1) * sizeof(WCHAR);
445 return ret;
448 static inline void normalize( void *base, WCHAR **ptr )
450 if (*ptr) *ptr = (WCHAR *)((char *)base + (UINT_PTR)*ptr);
453 /******************************************************************************
454 * RtlNormalizeProcessParams [NTDLL.@]
456 PRTL_USER_PROCESS_PARAMETERS WINAPI RtlNormalizeProcessParams( RTL_USER_PROCESS_PARAMETERS *params )
458 if (params && !(params->Flags & PROCESS_PARAMS_FLAG_NORMALIZED))
460 normalize( params, &params->CurrentDirectory.DosPath.Buffer );
461 normalize( params, &params->DllPath.Buffer );
462 normalize( params, &params->ImagePathName.Buffer );
463 normalize( params, &params->CommandLine.Buffer );
464 normalize( params, &params->WindowTitle.Buffer );
465 normalize( params, &params->Desktop.Buffer );
466 normalize( params, &params->ShellInfo.Buffer );
467 normalize( params, &params->RuntimeInfo.Buffer );
468 params->Flags |= PROCESS_PARAMS_FLAG_NORMALIZED;
470 return params;
474 static inline void denormalize( const void *base, WCHAR **ptr )
476 if (*ptr) *ptr = (WCHAR *)(UINT_PTR)((char *)*ptr - (const char *)base);
479 /******************************************************************************
480 * RtlDeNormalizeProcessParams [NTDLL.@]
482 PRTL_USER_PROCESS_PARAMETERS WINAPI RtlDeNormalizeProcessParams( RTL_USER_PROCESS_PARAMETERS *params )
484 if (params && (params->Flags & PROCESS_PARAMS_FLAG_NORMALIZED))
486 denormalize( params, &params->CurrentDirectory.DosPath.Buffer );
487 denormalize( params, &params->DllPath.Buffer );
488 denormalize( params, &params->ImagePathName.Buffer );
489 denormalize( params, &params->CommandLine.Buffer );
490 denormalize( params, &params->WindowTitle.Buffer );
491 denormalize( params, &params->Desktop.Buffer );
492 denormalize( params, &params->ShellInfo.Buffer );
493 denormalize( params, &params->RuntimeInfo.Buffer );
494 params->Flags &= ~PROCESS_PARAMS_FLAG_NORMALIZED;
496 return params;
500 #define ROUND_SIZE(size) (((size) + sizeof(void *) - 1) & ~(sizeof(void *) - 1))
502 /* append a unicode string to the process params data; helper for RtlCreateProcessParameters */
503 static void append_unicode_string( void **data, const UNICODE_STRING *src,
504 UNICODE_STRING *dst )
506 dst->Length = src->Length;
507 dst->MaximumLength = src->MaximumLength;
508 if (dst->MaximumLength)
510 dst->Buffer = *data;
511 memcpy( dst->Buffer, src->Buffer, dst->Length );
512 *data = (char *)dst->Buffer + ROUND_SIZE( dst->MaximumLength );
514 else dst->Buffer = NULL;
518 /******************************************************************************
519 * RtlCreateProcessParametersEx [NTDLL.@]
521 NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **result,
522 const UNICODE_STRING *ImagePathName,
523 const UNICODE_STRING *DllPath,
524 const UNICODE_STRING *CurrentDirectoryName,
525 const UNICODE_STRING *CommandLine,
526 PWSTR Environment,
527 const UNICODE_STRING *WindowTitle,
528 const UNICODE_STRING *Desktop,
529 const UNICODE_STRING *ShellInfo,
530 const UNICODE_STRING *RuntimeInfo,
531 ULONG flags )
533 UNICODE_STRING curdir;
534 const RTL_USER_PROCESS_PARAMETERS *cur_params;
535 SIZE_T size, env_size = 0;
536 void *ptr;
537 NTSTATUS status = STATUS_SUCCESS;
539 RtlAcquirePebLock();
540 cur_params = NtCurrentTeb()->Peb->ProcessParameters;
541 if (!DllPath) DllPath = &null_str;
542 if (!CurrentDirectoryName)
544 if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
545 curdir = ((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir.DosPath;
546 else
547 curdir = cur_params->CurrentDirectory.DosPath;
549 else curdir = *CurrentDirectoryName;
550 curdir.MaximumLength = MAX_PATH * sizeof(WCHAR);
552 if (!CommandLine) CommandLine = ImagePathName;
553 if (!Environment && cur_params) Environment = cur_params->Environment;
554 if (!WindowTitle) WindowTitle = &empty_str;
555 if (!Desktop) Desktop = &empty_str;
556 if (!ShellInfo) ShellInfo = &empty_str;
557 if (!RuntimeInfo) RuntimeInfo = &null_str;
559 if (Environment) env_size = get_env_length( Environment ) * sizeof(WCHAR);
561 size = (sizeof(RTL_USER_PROCESS_PARAMETERS)
562 + ROUND_SIZE( ImagePathName->MaximumLength )
563 + ROUND_SIZE( DllPath->MaximumLength )
564 + ROUND_SIZE( curdir.MaximumLength )
565 + ROUND_SIZE( CommandLine->MaximumLength )
566 + ROUND_SIZE( WindowTitle->MaximumLength )
567 + ROUND_SIZE( Desktop->MaximumLength )
568 + ROUND_SIZE( ShellInfo->MaximumLength )
569 + ROUND_SIZE( RuntimeInfo->MaximumLength ));
571 if ((ptr = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, size + ROUND_SIZE( env_size ) )))
573 RTL_USER_PROCESS_PARAMETERS *params = ptr;
574 params->AllocationSize = size;
575 params->Size = size;
576 params->Flags = PROCESS_PARAMS_FLAG_NORMALIZED;
577 params->EnvironmentSize = ROUND_SIZE( env_size );
578 if (cur_params) params->ConsoleFlags = cur_params->ConsoleFlags;
579 /* all other fields are zero */
581 ptr = params + 1;
582 append_unicode_string( &ptr, &curdir, &params->CurrentDirectory.DosPath );
583 append_unicode_string( &ptr, DllPath, &params->DllPath );
584 append_unicode_string( &ptr, ImagePathName, &params->ImagePathName );
585 append_unicode_string( &ptr, CommandLine, &params->CommandLine );
586 append_unicode_string( &ptr, WindowTitle, &params->WindowTitle );
587 append_unicode_string( &ptr, Desktop, &params->Desktop );
588 append_unicode_string( &ptr, ShellInfo, &params->ShellInfo );
589 append_unicode_string( &ptr, RuntimeInfo, &params->RuntimeInfo );
590 if (Environment) params->Environment = memcpy( ptr, Environment, env_size );
591 *result = params;
592 if (!(flags & PROCESS_PARAMS_FLAG_NORMALIZED)) RtlDeNormalizeProcessParams( params );
594 else status = STATUS_NO_MEMORY;
596 RtlReleasePebLock();
597 return status;
601 /******************************************************************************
602 * RtlCreateProcessParameters [NTDLL.@]
604 NTSTATUS WINAPI RtlCreateProcessParameters( RTL_USER_PROCESS_PARAMETERS **result,
605 const UNICODE_STRING *image,
606 const UNICODE_STRING *dllpath,
607 const UNICODE_STRING *curdir,
608 const UNICODE_STRING *cmdline,
609 PWSTR env,
610 const UNICODE_STRING *title,
611 const UNICODE_STRING *desktop,
612 const UNICODE_STRING *shellinfo,
613 const UNICODE_STRING *runtime )
615 return RtlCreateProcessParametersEx( result, image, dllpath, curdir, cmdline,
616 env, title, desktop, shellinfo, runtime, 0 );
620 /******************************************************************************
621 * RtlDestroyProcessParameters [NTDLL.@]
623 void WINAPI RtlDestroyProcessParameters( RTL_USER_PROCESS_PARAMETERS *params )
625 RtlFreeHeap( GetProcessHeap(), 0, params );
629 /***********************************************************************
630 * init_user_process_params
632 * Fill the initial RTL_USER_PROCESS_PARAMETERS structure from the server.
634 void init_user_process_params(void)
636 WCHAR *env;
637 SIZE_T size = 0, env_size;
638 RTL_USER_PROCESS_PARAMETERS *new_params, *params = NtCurrentTeb()->Peb->ProcessParameters;
639 UNICODE_STRING curdir;
641 /* environment needs to be a separate memory block */
642 env_size = params->EnvironmentSize;
643 if ((env = RtlAllocateHeap( GetProcessHeap(), 0, max( env_size, sizeof(WCHAR) ))))
645 if (env_size) memcpy( env, params->Environment, env_size );
646 else env[0] = 0;
649 params->Environment = NULL; /* avoid copying it */
650 if (RtlCreateProcessParametersEx( &new_params, &params->ImagePathName, &params->DllPath,
651 &params->CurrentDirectory.DosPath,
652 &params->CommandLine, NULL, &params->WindowTitle, &params->Desktop,
653 &params->ShellInfo, &params->RuntimeInfo,
654 PROCESS_PARAMS_FLAG_NORMALIZED ))
655 return;
657 new_params->Environment = env;
658 new_params->DebugFlags = params->DebugFlags;
659 new_params->ConsoleHandle = params->ConsoleHandle;
660 new_params->ConsoleFlags = params->ConsoleFlags;
661 new_params->hStdInput = params->hStdInput;
662 new_params->hStdOutput = params->hStdOutput;
663 new_params->hStdError = params->hStdError;
664 new_params->dwX = params->dwX;
665 new_params->dwY = params->dwY;
666 new_params->dwXSize = params->dwXSize;
667 new_params->dwYSize = params->dwYSize;
668 new_params->dwXCountChars = params->dwXCountChars;
669 new_params->dwYCountChars = params->dwYCountChars;
670 new_params->dwFillAttribute = params->dwFillAttribute;
671 new_params->dwFlags = params->dwFlags;
672 new_params->wShowWindow = params->wShowWindow;
674 NtCurrentTeb()->Peb->ProcessParameters = new_params;
675 NtFreeVirtualMemory( GetCurrentProcess(), (void **)&params, &size, MEM_RELEASE );
677 if (RtlSetCurrentDirectory_U( &new_params->CurrentDirectory.DosPath ))
679 MESSAGE("wine: could not open working directory %s, starting in the Windows directory.\n",
680 debugstr_w( new_params->CurrentDirectory.DosPath.Buffer ));
681 RtlInitUnicodeString( &curdir, windows_dir );
682 RtlSetCurrentDirectory_U( &curdir );
684 set_wow64_environment( &new_params->Environment );
685 new_params->EnvironmentSize = RtlSizeHeap( GetProcessHeap(), 0, new_params->Environment );