Commit 15c3eaaf authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move retrieving the startup info to the Unix library.

parent f1ff598e
......@@ -1247,16 +1247,16 @@ wait:
*
* Fill the initial RTL_USER_PROCESS_PARAMETERS structure from the server.
*/
void init_user_process_params( SIZE_T data_size )
void init_user_process_params(void)
{
WCHAR *src, *load_path, *dummy;
SIZE_T info_size, env_size;
NTSTATUS status;
SIZE_T info_size, env_size, data_size = 0;
startup_info_t *info = NULL;
RTL_USER_PROCESS_PARAMETERS *params = NULL;
UNICODE_STRING curdir, dllpath, imagepath, cmdline, title, desktop, shellinfo, runtime;
WCHAR **wargv;
unix_funcs->get_startup_info( NULL, &data_size, &info_size );
if (!data_size)
{
RTL_USER_PROCESS_PARAMETERS initial_params = {0};
......@@ -1296,18 +1296,7 @@ void init_user_process_params( SIZE_T data_size )
if (!(info = RtlAllocateHeap( GetProcessHeap(), 0, data_size ))) return;
SERVER_START_REQ( get_startup_info )
{
wine_server_set_reply( req, info, data_size );
if (!(status = wine_server_call( req )))
{
data_size = wine_server_reply_size( reply );
info_size = reply->info_size;
env_size = data_size - info_size;
}
}
SERVER_END_REQ;
if (status) goto done;
if (unix_funcs->get_startup_info( info, &data_size, &info_size )) goto done;
src = (WCHAR *)(info + 1);
get_unicode_string( &curdir, &src, info->curdir_len );
......@@ -1344,6 +1333,7 @@ void init_user_process_params( SIZE_T data_size )
params->wShowWindow = info->show;
/* environment needs to be a separate memory block */
env_size = data_size - info_size;
if ((params->Environment = RtlAllocateHeap( GetProcessHeap(), 0, max( env_size, sizeof(WCHAR) ))))
{
if (env_size) memcpy( params->Environment, (char *)info + info_size, env_size );
......
......@@ -3960,7 +3960,7 @@ void __wine_process_init(void)
init_unix_codepage();
init_directories();
init_user_process_params( info_size );
init_user_process_params();
params = peb->ProcessParameters;
load_global_options();
......@@ -4000,7 +4000,7 @@ void __wine_process_init(void)
}
else
{
if (!info_size) status = restart_process( params, status );
status = restart_process( params, status );
switch (status)
{
case STATUS_INVALID_IMAGE_WIN_64:
......
......@@ -69,7 +69,7 @@ extern void actctx_init(void) DECLSPEC_HIDDEN;
extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN;
extern void init_unix_codepage(void) DECLSPEC_HIDDEN;
extern void init_locale( HMODULE module ) DECLSPEC_HIDDEN;
extern void init_user_process_params( SIZE_T data_size ) DECLSPEC_HIDDEN;
extern void init_user_process_params(void) DECLSPEC_HIDDEN;
extern NTSTATUS restart_process( RTL_USER_PROCESS_PARAMETERS *params, NTSTATUS status ) DECLSPEC_HIDDEN;
/* server support */
......
......@@ -66,6 +66,7 @@ extern char **__wine_main_environ;
extern WCHAR **__wine_main_wargv;
USHORT *uctable = NULL, *lctable = NULL;
SIZE_T startup_info_size = 0;
int main_argc = 0;
char **main_argv = NULL;
......@@ -904,6 +905,32 @@ static void add_path_var( WCHAR *env, SIZE_T *pos, const char *name, const char
/*************************************************************************
* get_startup_info
*
* Get the startup information from the server.
*/
NTSTATUS CDECL get_startup_info( startup_info_t *info, SIZE_T *total_size, SIZE_T *info_size )
{
NTSTATUS status;
if (*total_size < startup_info_size)
{
*total_size = startup_info_size;
return STATUS_BUFFER_TOO_SMALL;
}
SERVER_START_REQ( get_startup_info )
{
wine_server_set_reply( req, info, *total_size );
status = wine_server_call( req );
*total_size = wine_server_reply_size( reply );
*info_size = reply->info_size;
}
SERVER_END_REQ;
return status;
}
/*************************************************************************
* get_dynamic_environment
*
* Get the environment variables that can differ between processes.
......
......@@ -1497,6 +1497,7 @@ static struct unix_funcs unix_funcs =
ntdll_sqrt,
ntdll_tan,
get_initial_environment,
get_startup_info,
get_dynamic_environment,
get_initial_console,
get_initial_directory,
......
......@@ -591,6 +591,8 @@ NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTST
char **argv;
HANDLE handle;
if (startup_info_size) return status; /* started from another Win32 process */
switch (status)
{
case STATUS_CONFLICTING_ADDRESSES:
......
......@@ -90,7 +90,6 @@ TEB * CDECL init_threading( SIZE_T *size )
{
TEB *teb;
BOOL suspend;
SIZE_T info_size;
teb = virtual_alloc_first_teb();
......@@ -99,14 +98,14 @@ TEB * CDECL init_threading( SIZE_T *size )
signal_init_thread( teb );
dbg_init();
server_init_process();
info_size = server_init_thread( teb->Peb, &suspend );
startup_info_size = server_init_thread( teb->Peb, &suspend );
virtual_map_user_shared_data();
virtual_create_builtin_view( ntdll_module );
init_cpu_info();
init_files();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
if (size) *size = info_size;
if (size) *size = startup_info_size;
return teb;
}
......
......@@ -96,6 +96,7 @@ int CDECL mmap_is_in_reserved_area( void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T size, void *arg), void *arg,
int top_down ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL get_initial_environment( WCHAR **wargv[], WCHAR *env, SIZE_T *size ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL get_startup_info( startup_info_t *info, SIZE_T *total_size, SIZE_T *info_size ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size ) DECLSPEC_HIDDEN;
extern void CDECL get_initial_directory( UNICODE_STRING *dir ) DECLSPEC_HIDDEN;
extern void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, HANDLE *std_err ) DECLSPEC_HIDDEN;
......@@ -137,6 +138,7 @@ extern const char **dll_paths DECLSPEC_HIDDEN;
extern HMODULE ntdll_module DECLSPEC_HIDDEN;
extern USHORT *uctable DECLSPEC_HIDDEN;
extern USHORT *lctable DECLSPEC_HIDDEN;
extern SIZE_T startup_info_size DECLSPEC_HIDDEN;
extern int main_argc DECLSPEC_HIDDEN;
extern char **main_argv DECLSPEC_HIDDEN;
extern char **main_envp DECLSPEC_HIDDEN;
......
......@@ -28,7 +28,7 @@ struct msghdr;
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 67
#define NTDLL_UNIXLIB_VERSION 68
struct unix_funcs
{
......@@ -298,6 +298,7 @@ struct unix_funcs
/* environment functions */
NTSTATUS (CDECL *get_initial_environment)( WCHAR **wargv[], WCHAR *env, SIZE_T *size );
NTSTATUS (CDECL *get_startup_info)( startup_info_t *info, SIZE_T *total_size, SIZE_T *info_size );
NTSTATUS (CDECL *get_dynamic_environment)( WCHAR *env, SIZE_T *size );
void (CDECL *get_initial_console)( HANDLE *handle, HANDLE *std_in,
HANDLE *std_out, HANDLE *std_err );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment