From: Joris van der Wel Subject: [2/4] server: Support sending process and thread security descriptors for the "new_process" request in the protocol. Message-Id: Date: Wed, 9 Jul 2014 00:58:47 +0200 server: Support sending process and thread security descriptors for the "new_process" request in the protocol. --- dlls/kernel32/process.c | 30 +++++++++++++++++------------- server/process.c | 33 ++++++++++++++++++++------------- server/protocol.def | 41 +++++++++++++++++++++++------------------ 3 files changed, 60 insertions(+), 44 deletions(-) From 800b9c4b2bf4696fb80faef5c81545478cb72a71 Mon Sep 17 00:00:00 2001 From: Joris van der Wel Date: Tue, 8 Jul 2014 23:24:38 +0200 Subject: server: Support sending process and thread security descriptors for the "new_process" request in the protocol. --- dlls/kernel32/process.c | 30 +++++++++++++++++------------- server/process.c | 33 ++++++++++++++++++++------------- server/protocol.def | 41 +++++++++++++++++++++++------------------ 3 files changed, 60 insertions(+), 44 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 2566ac4..8bf1934 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -2025,19 +2025,23 @@ static BOOL create_process( HANDLE hFile, LPCWSTR filename, LPWSTR cmd_line, LPW SERVER_START_REQ( new_process ) { - req->inherit_all = inherit; - req->create_flags = flags; - req->socket_fd = socketfd[1]; - req->exe_file = wine_server_obj_handle( hFile ); - req->process_access = PROCESS_ALL_ACCESS; - req->process_attr = (psa && (psa->nLength >= sizeof(*psa)) && psa->bInheritHandle) ? OBJ_INHERIT : 0; - req->thread_access = THREAD_ALL_ACCESS; - req->thread_attr = (tsa && (tsa->nLength >= sizeof(*tsa)) && tsa->bInheritHandle) ? OBJ_INHERIT : 0; - req->cpu = cpu; - req->info_size = startup_info_size; - - wine_server_add_data( req, startup_info, startup_info_size ); - wine_server_add_data( req, env, (env_end - env) * sizeof(WCHAR) ); + req->inherit_all = inherit; + req->create_flags = flags; + req->socket_fd = socketfd[1]; + req->exe_file = wine_server_obj_handle( hFile ); + req->process_access = PROCESS_ALL_ACCESS; + req->process_attr = (psa && (psa->nLength >= sizeof(*psa)) && psa->bInheritHandle) ? OBJ_INHERIT : 0; + req->thread_access = THREAD_ALL_ACCESS; + req->thread_attr = (tsa && (tsa->nLength >= sizeof(*tsa)) && tsa->bInheritHandle) ? OBJ_INHERIT : 0; + req->cpu = cpu; + req->process_sd_size = 0; + req->thread_sd_size = 0; + req->info_size = startup_info_size; + req->env_size = (env_end - env) * sizeof(WCHAR); + + wine_server_add_data( req, startup_info, req->info_size ); + wine_server_add_data( req, env , req->env_size ); + if (!(status = wine_server_call( req ))) { info->dwProcessId = (DWORD)reply->pid; diff --git a/server/process.c b/server/process.c index 7b9a3b2..9942eb3 100644 --- a/server/process.c +++ b/server/process.c @@ -880,6 +880,9 @@ DECL_HANDLER(new_process) struct process *process; struct process *parent = current->process; int socket_fd = thread_get_inflight_fd( current, req->socket_fd ); + const startup_info_t *req_info; + data_size_t req_info_size; + const WCHAR *req_env; if (socket_fd == -1) { @@ -903,6 +906,12 @@ DECL_HANDLER(new_process) close( socket_fd ); return; } + + req_info = (const startup_info_t *) + ((char*)get_req_data() + req->process_sd_size + req->thread_sd_size); + + req_env = (const WCHAR *) + ((char*)get_req_data() + req->process_sd_size + req->thread_sd_size + req->info_size); if (!req->info_size) /* create an orphaned process */ { @@ -920,27 +929,25 @@ DECL_HANDLER(new_process) !(info->exe_file = get_file_obj( current->process, req->exe_file, FILE_READ_DATA ))) goto done; - info->data_size = get_req_data_size(); - info->info_size = min( req->info_size, info->data_size ); - if (req->info_size < sizeof(*info->data)) { /* make sure we have a full startup_info_t structure */ - data_size_t env_size = info->data_size - info->info_size; - data_size_t info_size = min( req->info_size, FIELD_OFFSET( startup_info_t, curdir_len )); - - if (!(info->data = mem_alloc( sizeof(*info->data) + env_size ))) goto done; - memcpy( info->data, get_req_data(), info_size ); - memset( (char *)info->data + info_size, 0, sizeof(*info->data) - info_size ); - memcpy( info->data + 1, (const char *)get_req_data() + req->info_size, env_size ); - info->info_size = sizeof(startup_info_t); - info->data_size = info->info_size + env_size; + info->info_size = sizeof(*info->data); + info->data_size = sizeof(*info->data) + req->env_size; + + req_info_size = min( req->info_size, FIELD_OFFSET( startup_info_t, curdir_len )); + if (!(info->data = mem_alloc( info->data_size ))) goto done; + memset( info->data, 0, info->data_size ); + memcpy( info->data, req_info, req_info_size ); + memcpy( info->data + 1, req_env, req->env_size ); } else { data_size_t pos = sizeof(*info->data); + info->info_size = req->info_size; + info->data_size = req->info_size + req->env_size; - if (!(info->data = memdup( get_req_data(), info->data_size ))) goto done; + if (!(info->data = memdup( req_info, info->data_size ))) goto done; #define FIXUP_LEN(len) do { (len) = min( (len), info->info_size - pos ); pos += (len); } while(0) FIXUP_LEN( info->data->curdir_len ); FIXUP_LEN( info->data->dllpath_len ); diff --git a/server/protocol.def b/server/protocol.def index a8c1fb9..7b0b769 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -661,24 +661,29 @@ struct rawinput_device /* Create a new process from the context of the parent */ @REQ(new_process) - int inherit_all; /* inherit all handles from parent */ - unsigned int create_flags; /* creation flags */ - int socket_fd; /* file descriptor for process socket */ - obj_handle_t exe_file; /* file handle for main exe */ - unsigned int process_access; /* access rights for process object */ - unsigned int process_attr; /* attributes for process object */ - unsigned int thread_access; /* access rights for thread object */ - unsigned int thread_attr; /* attributes for thread object */ - cpu_type_t cpu; /* CPU that the new process will use */ - data_size_t info_size; /* size of startup info */ - VARARG(info,startup_info,info_size); /* startup information */ - VARARG(env,unicode_str); /* environment for new process */ -@REPLY - obj_handle_t info; /* new process info handle */ - process_id_t pid; /* process id */ - obj_handle_t phandle; /* process handle (in the current process) */ - thread_id_t tid; /* thread id */ - obj_handle_t thandle; /* thread handle (in the current process) */ + int inherit_all; /* inherit all handles from parent */ + unsigned int create_flags; /* creation flags */ + int socket_fd; /* file descriptor for process socket */ + obj_handle_t exe_file; /* file handle for main exe */ + unsigned int process_access; /* access rights for process object */ + unsigned int process_attr; /* attributes for process object */ + unsigned int thread_access; /* access rights for thread object */ + unsigned int thread_attr; /* attributes for thread object */ + cpu_type_t cpu; /* CPU that the new process will use */ + data_size_t process_sd_size; /* size of the process security descriptor */ + data_size_t thread_sd_size; /* size of the thread security descriptor */ + data_size_t info_size; /* size of startup info */ + data_size_t env_size; /* size of the environment */ + VARARG(process_sd,security_descriptor,process_sd_size); /* security descriptor to set on the process */ + VARARG(thread_sd,security_descriptor,thread_sd_size); /* security descriptor to set on the thread */ + VARARG(info,startup_info,info_size); /* startup information */ + VARARG(env,unicode_str,env_size); /* environment for new process */ +@REPLY + obj_handle_t info; /* new process info handle */ + process_id_t pid; /* process id */ + obj_handle_t phandle; /* process handle (in the current process) */ + thread_id_t tid; /* thread id */ + obj_handle_t thandle; /* thread handle (in the current process) */ @END -- 1.8.1.msysgit.1