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
24 #include <sys/types.h>
27 #define WIN32_NO_STATUS
30 #include "wine/debug.h"
31 #include "ntdll_misc.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;
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";
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
};
66 /* set the PROCESSOR_ARCHITECTURE variable */
68 if (!RtlQueryEnvironmentVariable_U( *env
, &arch6432_strW
, &valW
))
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
)
113 TRACE("(%u,%p)!\n", inherit
, env
);
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
);
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
)
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
);
146 var
[namelen
] == '=' &&
147 !RtlCompareUnicodeStrings( var
, namelen
, name
, namelen
, TRUE
) &&
148 wcschr(var
+ 1, '=') == var
+ namelen
)
150 return var
+ namelen
+ 1;
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
;
173 TRACE("%p %s %p\n", env
, debugstr_us(name
), value
);
176 namelen
= name
->Length
/ sizeof(WCHAR
);
177 if (!namelen
) return nts
;
182 var
= NtCurrentTeb()->Peb
->ProcessParameters
->Environment
;
186 var
= ENV_FindVariable(var
, name
->Buffer
, namelen
);
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();
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
;
215 if (!namelen
) return nts
;
220 var
= NtCurrentTeb()->Peb
->ProcessParameters
->Environment
;
224 var
= ENV_FindVariable(var
, name
, namelen
);
228 if (len
<= value_length
)
230 memcpy(value
, var
, min(len
+ 1, value_length
) * sizeof(WCHAR
));
231 nts
= STATUS_SUCCESS
;
236 nts
= STATUS_BUFFER_TOO_SMALL
;
239 *return_length
= len
;
241 if (!env
) RtlReleasePebLock();
246 /******************************************************************
247 * RtlSetCurrentEnvironment [NTDLL.@]
250 void WINAPI
RtlSetCurrentEnvironment(PWSTR new_env
, PWSTR
* old_env
)
254 TRACE("(%p %p)\n", new_env
, old_env
);
258 prev
= NtCurrentTeb()->Peb
->ProcessParameters
->Environment
;
259 NtCurrentTeb()->Peb
->ProcessParameters
->Environment
= new_env
;
260 NtCurrentTeb()->Peb
->ProcessParameters
->EnvironmentSize
= RtlSizeHeap( GetProcessHeap(), 0, new_env
);
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
;
279 NTSTATUS nts
= STATUS_VARIABLE_NOT_FOUND
;
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
;
295 env
= NtCurrentTeb()->Peb
->ProcessParameters
->Environment
;
298 old_size
= get_env_length( env
);
300 /* Find a place to insert the string */
301 for (p
= env
; *p
; p
+= varlen
+ 1)
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 */
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
);
326 nts
= STATUS_NO_MEMORY
;
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
);
336 NtCurrentTeb()->Peb
->ProcessParameters
->Environment
= new_env
;
337 NtCurrentTeb()->Peb
->ProcessParameters
->EnvironmentSize
= new_size
;
339 else *penv
= new_env
;
343 if (len
> 0) memmove(p
+ len
, p
, (old_size
- (p
- env
)) * sizeof(WCHAR
));
346 /* Set the new string */
349 memcpy( p
, name
->Buffer
, name
->Length
);
350 p
+= name
->Length
/ sizeof(WCHAR
);
352 memcpy( p
, value
->Buffer
, value
->Length
);
353 p
[value
->Length
/ sizeof(WCHAR
)] = 0;
355 nts
= STATUS_SUCCESS
;
358 if (!penv
) RtlReleasePebLock();
363 /******************************************************************************
364 * RtlExpandEnvironmentStrings (NTDLL.@)
366 NTSTATUS WINAPI
RtlExpandEnvironmentStrings( const WCHAR
*renv
, WCHAR
*src
, SIZE_T src_len
,
367 WCHAR
*dst
, SIZE_T count
, SIZE_T
*plen
)
369 SIZE_T len
, total_size
= 1; /* 1 for terminating '\0' */
375 env
= NtCurrentTeb()->Peb
->ProcessParameters
->Environment
;
383 for (len
= 0; len
< src_len
; len
++) if (src
[len
] == '%') break;
388 else /* we are at the start of a variable */
390 for (len
= 1; len
< src_len
; len
++) if (src
[len
] == '%') break;
393 if ((var
= ENV_FindVariable( env
, src
+ 1, len
- 1 )))
395 src
+= len
+ 1; /* Skip the variable name */
401 var
= src
; /* Copy original name instead */
407 else /* unfinished variable name, ignore it */
417 if (count
< len
) len
= count
;
418 memcpy(dst
, var
, len
* sizeof(WCHAR
));
424 if (!renv
) RtlReleasePebLock();
426 if (dst
&& count
) *dst
= '\0';
427 if (plen
) *plen
= total_size
;
429 return (count
) ? STATUS_SUCCESS
: STATUS_BUFFER_TOO_SMALL
;
432 /******************************************************************
433 * RtlExpandEnvironmentStrings_U (NTDLL.@)
435 NTSTATUS WINAPI
RtlExpandEnvironmentStrings_U( const WCHAR
*env
, const UNICODE_STRING
*src
,
436 UNICODE_STRING
*dst
, ULONG
*plen
)
441 ret
= RtlExpandEnvironmentStrings( env
, src
->Buffer
, src
->Length
/ sizeof(WCHAR
),
442 dst
->Buffer
, dst
->MaximumLength
/ sizeof(WCHAR
), &len
);
443 if (plen
) *plen
= len
* sizeof(WCHAR
); /* FIXME: check for overflow? */
444 if (len
> UNICODE_STRING_MAX_CHARS
) ret
= STATUS_BUFFER_TOO_SMALL
;
445 if (!ret
) dst
->Length
= (len
- 1) * sizeof(WCHAR
);
449 static inline void normalize( void *base
, WCHAR
**ptr
)
451 if (*ptr
) *ptr
= (WCHAR
*)((char *)base
+ (UINT_PTR
)*ptr
);
454 /******************************************************************************
455 * RtlNormalizeProcessParams [NTDLL.@]
457 PRTL_USER_PROCESS_PARAMETERS WINAPI
RtlNormalizeProcessParams( RTL_USER_PROCESS_PARAMETERS
*params
)
459 if (params
&& !(params
->Flags
& PROCESS_PARAMS_FLAG_NORMALIZED
))
461 normalize( params
, ¶ms
->CurrentDirectory
.DosPath
.Buffer
);
462 normalize( params
, ¶ms
->DllPath
.Buffer
);
463 normalize( params
, ¶ms
->ImagePathName
.Buffer
);
464 normalize( params
, ¶ms
->CommandLine
.Buffer
);
465 normalize( params
, ¶ms
->WindowTitle
.Buffer
);
466 normalize( params
, ¶ms
->Desktop
.Buffer
);
467 normalize( params
, ¶ms
->ShellInfo
.Buffer
);
468 normalize( params
, ¶ms
->RuntimeInfo
.Buffer
);
469 params
->Flags
|= PROCESS_PARAMS_FLAG_NORMALIZED
;
475 static inline void denormalize( const void *base
, WCHAR
**ptr
)
477 if (*ptr
) *ptr
= (WCHAR
*)(UINT_PTR
)((char *)*ptr
- (const char *)base
);
480 /******************************************************************************
481 * RtlDeNormalizeProcessParams [NTDLL.@]
483 PRTL_USER_PROCESS_PARAMETERS WINAPI
RtlDeNormalizeProcessParams( RTL_USER_PROCESS_PARAMETERS
*params
)
485 if (params
&& (params
->Flags
& PROCESS_PARAMS_FLAG_NORMALIZED
))
487 denormalize( params
, ¶ms
->CurrentDirectory
.DosPath
.Buffer
);
488 denormalize( params
, ¶ms
->DllPath
.Buffer
);
489 denormalize( params
, ¶ms
->ImagePathName
.Buffer
);
490 denormalize( params
, ¶ms
->CommandLine
.Buffer
);
491 denormalize( params
, ¶ms
->WindowTitle
.Buffer
);
492 denormalize( params
, ¶ms
->Desktop
.Buffer
);
493 denormalize( params
, ¶ms
->ShellInfo
.Buffer
);
494 denormalize( params
, ¶ms
->RuntimeInfo
.Buffer
);
495 params
->Flags
&= ~PROCESS_PARAMS_FLAG_NORMALIZED
;
501 #define ROUND_SIZE(size) (((size) + sizeof(void *) - 1) & ~(sizeof(void *) - 1))
503 /* append a unicode string to the process params data; helper for RtlCreateProcessParameters */
504 static void append_unicode_string( void **data
, const UNICODE_STRING
*src
,
505 UNICODE_STRING
*dst
)
507 dst
->Length
= src
->Length
;
508 dst
->MaximumLength
= src
->MaximumLength
;
509 if (dst
->MaximumLength
)
512 memcpy( dst
->Buffer
, src
->Buffer
, dst
->Length
);
513 *data
= (char *)dst
->Buffer
+ ROUND_SIZE( dst
->MaximumLength
);
515 else dst
->Buffer
= NULL
;
519 /******************************************************************************
520 * RtlCreateProcessParametersEx [NTDLL.@]
522 NTSTATUS WINAPI
RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS
**result
,
523 const UNICODE_STRING
*ImagePathName
,
524 const UNICODE_STRING
*DllPath
,
525 const UNICODE_STRING
*CurrentDirectoryName
,
526 const UNICODE_STRING
*CommandLine
,
528 const UNICODE_STRING
*WindowTitle
,
529 const UNICODE_STRING
*Desktop
,
530 const UNICODE_STRING
*ShellInfo
,
531 const UNICODE_STRING
*RuntimeInfo
,
534 UNICODE_STRING curdir
;
535 const RTL_USER_PROCESS_PARAMETERS
*cur_params
;
536 SIZE_T size
, env_size
= 0;
538 NTSTATUS status
= STATUS_SUCCESS
;
541 cur_params
= NtCurrentTeb()->Peb
->ProcessParameters
;
542 if (!DllPath
) DllPath
= &null_str
;
543 if (!CurrentDirectoryName
)
545 if (NtCurrentTeb()->Tib
.SubSystemTib
) /* FIXME: hack */
546 curdir
= ((WIN16_SUBSYSTEM_TIB
*)NtCurrentTeb()->Tib
.SubSystemTib
)->curdir
.DosPath
;
548 curdir
= cur_params
->CurrentDirectory
.DosPath
;
550 else curdir
= *CurrentDirectoryName
;
551 curdir
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
553 if (!CommandLine
) CommandLine
= ImagePathName
;
554 if (!Environment
&& cur_params
) Environment
= cur_params
->Environment
;
555 if (!WindowTitle
) WindowTitle
= &empty_str
;
556 if (!Desktop
) Desktop
= &empty_str
;
557 if (!ShellInfo
) ShellInfo
= &empty_str
;
558 if (!RuntimeInfo
) RuntimeInfo
= &null_str
;
560 if (Environment
) env_size
= get_env_length( Environment
) * sizeof(WCHAR
);
562 size
= (sizeof(RTL_USER_PROCESS_PARAMETERS
)
563 + ROUND_SIZE( ImagePathName
->MaximumLength
)
564 + ROUND_SIZE( DllPath
->MaximumLength
)
565 + ROUND_SIZE( curdir
.MaximumLength
)
566 + ROUND_SIZE( CommandLine
->MaximumLength
)
567 + ROUND_SIZE( WindowTitle
->MaximumLength
)
568 + ROUND_SIZE( Desktop
->MaximumLength
)
569 + ROUND_SIZE( ShellInfo
->MaximumLength
)
570 + ROUND_SIZE( RuntimeInfo
->MaximumLength
));
572 if ((ptr
= RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY
, size
+ ROUND_SIZE( env_size
) )))
574 RTL_USER_PROCESS_PARAMETERS
*params
= ptr
;
575 params
->AllocationSize
= size
;
577 params
->Flags
= PROCESS_PARAMS_FLAG_NORMALIZED
;
578 params
->EnvironmentSize
= ROUND_SIZE( env_size
);
579 if (cur_params
) params
->ConsoleFlags
= cur_params
->ConsoleFlags
;
580 /* all other fields are zero */
583 append_unicode_string( &ptr
, &curdir
, ¶ms
->CurrentDirectory
.DosPath
);
584 append_unicode_string( &ptr
, DllPath
, ¶ms
->DllPath
);
585 append_unicode_string( &ptr
, ImagePathName
, ¶ms
->ImagePathName
);
586 append_unicode_string( &ptr
, CommandLine
, ¶ms
->CommandLine
);
587 append_unicode_string( &ptr
, WindowTitle
, ¶ms
->WindowTitle
);
588 append_unicode_string( &ptr
, Desktop
, ¶ms
->Desktop
);
589 append_unicode_string( &ptr
, ShellInfo
, ¶ms
->ShellInfo
);
590 append_unicode_string( &ptr
, RuntimeInfo
, ¶ms
->RuntimeInfo
);
591 if (Environment
) params
->Environment
= memcpy( ptr
, Environment
, env_size
);
593 if (!(flags
& PROCESS_PARAMS_FLAG_NORMALIZED
)) RtlDeNormalizeProcessParams( params
);
595 else status
= STATUS_NO_MEMORY
;
602 /******************************************************************************
603 * RtlCreateProcessParameters [NTDLL.@]
605 NTSTATUS WINAPI
RtlCreateProcessParameters( RTL_USER_PROCESS_PARAMETERS
**result
,
606 const UNICODE_STRING
*image
,
607 const UNICODE_STRING
*dllpath
,
608 const UNICODE_STRING
*curdir
,
609 const UNICODE_STRING
*cmdline
,
611 const UNICODE_STRING
*title
,
612 const UNICODE_STRING
*desktop
,
613 const UNICODE_STRING
*shellinfo
,
614 const UNICODE_STRING
*runtime
)
616 return RtlCreateProcessParametersEx( result
, image
, dllpath
, curdir
, cmdline
,
617 env
, title
, desktop
, shellinfo
, runtime
, 0 );
621 /******************************************************************************
622 * RtlDestroyProcessParameters [NTDLL.@]
624 void WINAPI
RtlDestroyProcessParameters( RTL_USER_PROCESS_PARAMETERS
*params
)
626 RtlFreeHeap( GetProcessHeap(), 0, params
);
630 /***********************************************************************
631 * init_user_process_params
633 * Fill the initial RTL_USER_PROCESS_PARAMETERS structure from the server.
635 void init_user_process_params(void)
639 RTL_USER_PROCESS_PARAMETERS
*new_params
, *params
= NtCurrentTeb()->Peb
->ProcessParameters
;
640 UNICODE_STRING curdir
;
642 /* environment needs to be a separate memory block */
643 env_size
= params
->EnvironmentSize
;
644 if ((env
= RtlAllocateHeap( GetProcessHeap(), 0, max( env_size
, sizeof(WCHAR
) ))))
646 if (env_size
) memcpy( env
, params
->Environment
, env_size
);
650 params
->Environment
= NULL
; /* avoid copying it */
651 if (RtlCreateProcessParametersEx( &new_params
, ¶ms
->ImagePathName
, ¶ms
->DllPath
,
652 ¶ms
->CurrentDirectory
.DosPath
,
653 ¶ms
->CommandLine
, NULL
, ¶ms
->WindowTitle
, ¶ms
->Desktop
,
654 ¶ms
->ShellInfo
, ¶ms
->RuntimeInfo
,
655 PROCESS_PARAMS_FLAG_NORMALIZED
))
658 new_params
->Environment
= env
;
659 new_params
->DebugFlags
= params
->DebugFlags
;
660 new_params
->ConsoleHandle
= params
->ConsoleHandle
;
661 new_params
->ConsoleFlags
= params
->ConsoleFlags
;
662 new_params
->hStdInput
= params
->hStdInput
;
663 new_params
->hStdOutput
= params
->hStdOutput
;
664 new_params
->hStdError
= params
->hStdError
;
665 new_params
->dwX
= params
->dwX
;
666 new_params
->dwY
= params
->dwY
;
667 new_params
->dwXSize
= params
->dwXSize
;
668 new_params
->dwYSize
= params
->dwYSize
;
669 new_params
->dwXCountChars
= params
->dwXCountChars
;
670 new_params
->dwYCountChars
= params
->dwYCountChars
;
671 new_params
->dwFillAttribute
= params
->dwFillAttribute
;
672 new_params
->dwFlags
= params
->dwFlags
;
673 new_params
->wShowWindow
= params
->wShowWindow
;
675 NtCurrentTeb()->Peb
->ProcessParameters
= params
= new_params
;
677 if (RtlSetCurrentDirectory_U( ¶ms
->CurrentDirectory
.DosPath
))
679 MESSAGE("wine: could not open working directory %s, starting in the Windows directory.\n",
680 debugstr_w( params
->CurrentDirectory
.DosPath
.Buffer
));
681 RtlInitUnicodeString( &curdir
, windows_dir
);
682 RtlSetCurrentDirectory_U( &curdir
);
684 set_wow64_environment( ¶ms
->Environment
);
685 params
->EnvironmentSize
= RtlSizeHeap( GetProcessHeap(), 0, params
->Environment
);