kernel32: Set argv[0] to the full path of the binary when starting from Unix.

This commit is contained in:
Alexandre Julliard 2009-04-02 12:59:32 +02:00
parent 7b7f35aee5
commit fc87182d19
1 changed files with 25 additions and 0 deletions

View File

@ -598,6 +598,30 @@ static void set_library_wargv( char **argv )
}
/***********************************************************************
* update_library_argv0
*
* Update the argv[0] global variable with the binary we have found.
*/
static void update_library_argv0( const WCHAR *argv0 )
{
DWORD len = strlenW( argv0 );
if (len > strlenW( __wine_main_wargv[0] ))
{
__wine_main_wargv[0] = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
}
strcpyW( __wine_main_wargv[0], argv0 );
len = WideCharToMultiByte( CP_ACP, 0, argv0, -1, NULL, 0, NULL, NULL );
if (len > strlen( __wine_main_argv[0] ) + 1)
{
__wine_main_argv[0] = RtlAllocateHeap( GetProcessHeap(), 0, len );
}
WideCharToMultiByte( CP_ACP, 0, argv0, -1, __wine_main_argv[0], len, NULL, NULL );
}
/***********************************************************************
* build_command_line
*
@ -1024,6 +1048,7 @@ void CDECL __wine_kernel_init(void)
MESSAGE( "wine: cannot find '%s'\n", __wine_main_argv[0] );
ExitProcess( GetLastError() );
}
update_library_argv0( main_exe_name );
if (!build_command_line( __wine_main_wargv )) goto error;
boot_event = start_wineboot();
}