mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-16 04:06:46 +00:00
kernel32: Use the Unicode string length to build the argv array.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
33c3cee817
commit
1a561b640b
|
@ -1483,16 +1483,19 @@ void CDECL __wine_kernel_init(void)
|
||||||
* Build an argv array from a command-line.
|
* Build an argv array from a command-line.
|
||||||
* 'reserved' is the number of args to reserve before the first one.
|
* 'reserved' is the number of args to reserve before the first one.
|
||||||
*/
|
*/
|
||||||
static char **build_argv( const WCHAR *cmdlineW, int reserved )
|
static char **build_argv( const UNICODE_STRING *cmdlineW, int reserved )
|
||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
char** argv;
|
char** argv;
|
||||||
char *arg,*s,*d,*cmdline;
|
char *arg,*s,*d,*cmdline;
|
||||||
int in_quotes,bcount,len;
|
int in_quotes,bcount,len;
|
||||||
|
|
||||||
len = WideCharToMultiByte( CP_UNIXCP, 0, cmdlineW, -1, NULL, 0, NULL, NULL );
|
len = WideCharToMultiByte( CP_UNIXCP, 0, cmdlineW->Buffer, cmdlineW->Length / sizeof(WCHAR),
|
||||||
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, len ))) return NULL;
|
NULL, 0, NULL, NULL );
|
||||||
WideCharToMultiByte( CP_UNIXCP, 0, cmdlineW, -1, cmdline, len, NULL, NULL );
|
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, len + 1 ))) return NULL;
|
||||||
|
WideCharToMultiByte( CP_UNIXCP, 0, cmdlineW->Buffer, cmdlineW->Length / sizeof(WCHAR),
|
||||||
|
cmdline, len, NULL, NULL );
|
||||||
|
cmdline[len++] = 0;
|
||||||
|
|
||||||
argc=reserved+1;
|
argc=reserved+1;
|
||||||
bcount=0;
|
bcount=0;
|
||||||
|
@ -1689,7 +1692,7 @@ static int fork_and_exec( const RTL_USER_PROCESS_PARAMETERS *params, const char
|
||||||
wine_server_handle_to_fd( params->hStdOutput, FILE_WRITE_DATA, &stdout_fd, NULL );
|
wine_server_handle_to_fd( params->hStdOutput, FILE_WRITE_DATA, &stdout_fd, NULL );
|
||||||
wine_server_handle_to_fd( params->hStdError, FILE_WRITE_DATA, &stderr_fd, NULL );
|
wine_server_handle_to_fd( params->hStdError, FILE_WRITE_DATA, &stderr_fd, NULL );
|
||||||
|
|
||||||
argv = build_argv( params->CommandLine.Buffer, 0 );
|
argv = build_argv( ¶ms->CommandLine, 0 );
|
||||||
envp = build_envp( params->Environment );
|
envp = build_envp( params->Environment );
|
||||||
|
|
||||||
if (!(pid = fork())) /* child */
|
if (!(pid = fork())) /* child */
|
||||||
|
@ -2045,7 +2048,7 @@ static pid_t spawn_loader( const RTL_USER_PROCESS_PARAMETERS *params, int socket
|
||||||
const char *loader = NULL;
|
const char *loader = NULL;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
||||||
argv = build_argv( params->CommandLine.Buffer, 1 );
|
argv = build_argv( ¶ms->CommandLine, 1 );
|
||||||
|
|
||||||
if (!is_win64 ^ !is_64bit_arch( pe_info->cpu ))
|
if (!is_win64 ^ !is_64bit_arch( pe_info->cpu ))
|
||||||
loader = get_alternate_loader( &wineloader );
|
loader = get_alternate_loader( &wineloader );
|
||||||
|
@ -2132,7 +2135,7 @@ static NTSTATUS exec_loader( const RTL_USER_PROCESS_PARAMETERS *params, int sock
|
||||||
ULONGLONG res_start = pe_info->base;
|
ULONGLONG res_start = pe_info->base;
|
||||||
ULONGLONG res_end = pe_info->base + pe_info->map_size;
|
ULONGLONG res_end = pe_info->base + pe_info->map_size;
|
||||||
|
|
||||||
if (!(argv = build_argv( params->CommandLine.Buffer, 1 ))) return STATUS_NO_MEMORY;
|
if (!(argv = build_argv( ¶ms->CommandLine, 1 ))) return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
if (!is_win64 ^ !is_64bit_arch( pe_info->cpu ))
|
if (!is_win64 ^ !is_64bit_arch( pe_info->cpu ))
|
||||||
loader = get_alternate_loader( &wineloader );
|
loader = get_alternate_loader( &wineloader );
|
||||||
|
|
Loading…
Reference in a new issue