Alexandre Julliard : ntdll: Move retrieving the startup info to the Unix library.
Alexandre Julliard
julliard at winehq.org
Mon Jun 29 14:59:20 CDT 2020
Module: wine
Branch: master
Commit: 15c3eaafbb3a376998e9c5eb36cb24816dad5447
URL: https://source.winehq.org/git/wine.git/?a=commit;h=15c3eaafbb3a376998e9c5eb36cb24816dad5447
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Jun 29 12:10:58 2020 +0200
ntdll: Move retrieving the startup info to the Unix library.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/env.c | 20 +++++---------------
dlls/ntdll/loader.c | 4 ++--
dlls/ntdll/ntdll_misc.h | 2 +-
dlls/ntdll/unix/env.c | 27 +++++++++++++++++++++++++++
dlls/ntdll/unix/loader.c | 1 +
dlls/ntdll/unix/process.c | 2 ++
dlls/ntdll/unix/thread.c | 5 ++---
dlls/ntdll/unix/unix_private.h | 2 ++
dlls/ntdll/unixlib.h | 3 ++-
9 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index a68ef5786e..89c0fcac7f 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -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 );
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 76df995581..aa7b58b732 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -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:
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 3691d338d0..d3aa0eb145 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -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 */
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index 1ffe45ea3b..e260e5c338 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -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;
@@ -903,6 +904,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
*
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 600a2b0e39..10b483a95a 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -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,
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index 758f47a1e9..578c79bf89 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -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:
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 129410f8d7..2a8801457d 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -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;
}
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 54254632e7..713cd4145e 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -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;
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
index c8bcac3836..71d8ffba1b 100644
--- a/dlls/ntdll/unixlib.h
+++ b/dlls/ntdll/unixlib.h
@@ -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 );
More information about the wine-cvs
mailing list