From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/ntdll/unix/process.c | 14 -------------- server/process.c | 6 +++++- server/thread.c | 15 +++------------ 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 8ebb5a3e376..2fe507d5f53 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -872,20 +872,6 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ goto done; } - if ((status = alloc_object_attributes( thread_attr, &objattr, &attr_len ))) goto done; - - SERVER_START_REQ( new_thread ) - { - req->process = wine_server_obj_handle( process_handle ); - req->flags = thread_flags; - req->request_fd = -1; - wine_server_add_data( req, objattr, attr_len ); - status = wine_server_call( req ); - } - SERVER_END_REQ; - free( objattr ); - if (status) goto done; - /* create the child process */ if ((status = spawn_process( params, socketfd[0], unixdir, winedebug, &pe_info ))) goto done; diff --git a/server/process.c b/server/process.c index 78727080e9d..4c778d800db 100644 --- a/server/process.c +++ b/server/process.c @@ -1161,7 +1161,7 @@ DECL_HANDLER(new_process) struct token *token = NULL; struct debug_obj *debug_obj = NULL; struct process *parent; - struct thread *parent_thread = current; + struct thread *thread, *parent_thread = current; int socket_fd = thread_get_inflight_fd( current, req->socket_fd ); const obj_handle_t *handles = NULL; const obj_handle_t *job_handles = NULL; @@ -1415,6 +1415,10 @@ DECL_HANDLER(new_process) info->data->process_group_id = process->group_id; info->process = (struct process *)grab_object( process ); + + if (!(thread = create_thread( -1, process, process->thread_flags, process->thread_sd ))) goto done; + thread->system_regs = current->system_regs; + reply->info = alloc_handle( current->process, info, SYNCHRONIZE, 0 ); reply->pid = get_process_id( process ); reply->handle = alloc_handle_no_access_check( current->process, process, req->access, objattr->attributes ); diff --git a/server/thread.c b/server/thread.c index 472fd85790a..54b1b5e2c00 100644 --- a/server/thread.c +++ b/server/thread.c @@ -1676,17 +1676,9 @@ DECL_HANDLER(new_thread) if (process != current->process) { - if (request_fd != -1) /* can't create a request fd in a different process */ - { - close( request_fd ); - set_error( STATUS_INVALID_PARAMETER ); - goto done; - } - if (process->running_threads) /* only the initial thread can be created in another process */ - { - set_error( STATUS_ACCESS_DENIED ); - goto done; - } + if (request_fd != -1) close( request_fd ); + set_error( STATUS_ACCESS_DENIED ); + goto done; } else if (request_fd == -1 || fcntl( request_fd, F_SETFL, O_NONBLOCK ) == -1) { @@ -1705,7 +1697,6 @@ DECL_HANDLER(new_thread) { thread->system_regs = current->system_regs; reply->tid = get_thread_id( thread ); - if (request_fd == -1) goto done; /* thread handle will be returned from get_new_process_info */ if ((reply->handle = alloc_handle_no_access_check( current->process, thread, req->access, objattr->attributes ))) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10058