ntdll: Add a helper to launch start.exe always as builtin.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-03-25 11:29:37 +01:00
parent 967100258f
commit aef821ccbd
3 changed files with 30 additions and 9 deletions

View File

@ -1880,23 +1880,17 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params(void)
if (status) /* try launching it through start.exe */
{
static const WCHAR startW[] = {'C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\','s','t','a','r','t','.','e','x','e',0};
static const WCHAR slashwW[] = {'/','w',0};
static const WCHAR slashbW[] = {'/','b',0};
const WCHAR *args[] = { startW, slashwW, slashbW };
const WCHAR *args[] = { NULL, slashwW, slashbW };
free( image );
prepend_main_wargv( args, 3 );
if ((status = load_main_exe( startW, NULL, curdir, &image, &module, &image_info )))
{
MESSAGE( "wine: failed to start %s\n", debugstr_w(main_wargv[2]) );
NtTerminateProcess( GetCurrentProcess(), status );
load_start_exe( &image, &module, &image_info );
}
}
else main_wargv[0] = get_dos_path( image );
NtCurrentTeb()->Peb->ImageBaseAddress = module;
main_wargv[0] = get_dos_path( image );
cmdline = build_command_line( main_wargv );
TRACE( "image %s cmdline %s dir %s\n",

View File

@ -1544,6 +1544,32 @@ failed:
}
/***********************************************************************
* load_start_exe
*
* Load start.exe as main image.
*/
NTSTATUS load_start_exe( WCHAR **image, void **module, SECTION_IMAGE_INFORMATION *image_info )
{
static const WCHAR startW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\','s','t','a','r','t','.','e','x','e',0};
UNICODE_STRING nt_name;
NTSTATUS status;
SIZE_T size;
init_unicode_string( &nt_name, startW );
status = find_builtin_dll( &nt_name, module, &size, image_info, current_machine, FALSE );
if (status)
{
MESSAGE( "wine: failed to load start.exe: %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
*image = malloc( sizeof(startW) );
memcpy( *image, startW, sizeof(startW) );
return status;
}
#ifdef __FreeBSD__
/* The PT_LOAD segments are sorted in increasing order, and the first
* starts at the beginning of the ELF file. By parsing the file, we can

View File

@ -145,6 +145,7 @@ extern NTSTATUS load_builtin( const pe_image_info_t *image_info, const WCHAR *fi
void **addr_ptr, SIZE_T *size_ptr ) DECLSPEC_HIDDEN;
extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir, WCHAR **image,
void **module, SECTION_IMAGE_INFORMATION *image_info ) DECLSPEC_HIDDEN;
extern NTSTATUS load_start_exe( WCHAR **image, void **module, SECTION_IMAGE_INFORMATION *image_info ) DECLSPEC_HIDDEN;
extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
extern ULONG_PTR get_image_address(void) DECLSPEC_HIDDEN;