From 4e5811637ad027d01cc5033f76b03e6e8cfdd287 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 25 Aug 2020 13:54:32 +0200 Subject: [PATCH] ntdll: Use syscalls for the server functions. Signed-off-by: Alexandre Julliard --- dlls/ntdll/Makefile.in | 1 - dlls/ntdll/loader.c | 2 + dlls/ntdll/ntdll.spec | 10 +-- dlls/ntdll/server.c | 139 ----------------------------------------- dlls/ntdll/unix/env.c | 6 +- dlls/ntdll/unix/loader.c | 5 -- dlls/ntdll/unix/process.c | 14 ++--- dlls/ntdll/unix/server.c | 24 +++---- dlls/ntdll/unix/thread.c | 2 +- dlls/ntdll/unix/unix_private.h | 6 -- dlls/ntdll/unixlib.h | 9 +-- 11 files changed, 31 insertions(+), 187 deletions(-) delete mode 100644 dlls/ntdll/server.c diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index bc8215b6bfb..bf1755c879a 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -34,7 +34,6 @@ C_SRCS = \ rtlbitmap.c \ rtlstr.c \ sec.c \ - server.c \ signal_arm.c \ signal_arm64.c \ signal_i386.c \ diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 54d56f4e148..7c06016f486 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -68,6 +68,8 @@ const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\', const WCHAR syswow64_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','w','o','w','6','4','\\',0}; +BOOL is_wow64 = FALSE; + /* system search path */ static const WCHAR system_path[] = {'C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m','3','2',';', diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 9981c57bd7d..8a1890ac095 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1581,11 +1581,11 @@ # or 'wine_' (for user-visible functions) to avoid namespace conflicts. # Server interface -@ cdecl -norelay wine_server_call(ptr) -@ cdecl wine_server_fd_to_handle(long long long ptr) -@ cdecl wine_server_handle_to_fd(long long ptr ptr) -@ cdecl wine_server_release_fd(long long) -@ cdecl wine_server_send_fd(long) +@ cdecl -syscall -norelay wine_server_call(ptr) +@ cdecl -syscall wine_server_fd_to_handle(long long long ptr) +@ cdecl -syscall wine_server_handle_to_fd(long long ptr ptr) +@ cdecl -syscall wine_server_release_fd(long long) +@ cdecl -syscall wine_server_send_fd(long) @ cdecl __wine_make_process_system() @ cdecl __wine_set_unix_funcs(long ptr) @ extern __wine_syscall_dispatcher diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c deleted file mode 100644 index a3ad3e68871..00000000000 --- a/dlls/ntdll/server.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Wine server communication - * - * Copyright (C) 1998 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winnt.h" -#include "wine/server.h" -#include "wine/debug.h" -#include "ntdll_misc.h" - -BOOL is_wow64 = FALSE; - -/*********************************************************************** - * wine_server_call (NTDLL.@) - * - * Perform a server call. - * - * PARAMS - * req_ptr [I/O] Function dependent data - * - * RETURNS - * Depends on server function being called, but usually an NTSTATUS code. - * - * NOTES - * Use the SERVER_START_REQ and SERVER_END_REQ to help you fill out the - * server request structure for the particular call. E.g: - *| SERVER_START_REQ( event_op ) - *| { - *| req->handle = handle; - *| req->op = SET_EVENT; - *| ret = wine_server_call( req ); - *| } - *| SERVER_END_REQ; - */ -unsigned int CDECL wine_server_call( void *req_ptr ) -{ - return unix_funcs->server_call( req_ptr ); -} - - -/*********************************************************************** - * wine_server_send_fd (NTDLL.@) - * - * Send a file descriptor to the server. - * - * PARAMS - * fd [I] file descriptor to send - * - * RETURNS - * nothing - */ -void CDECL wine_server_send_fd( int fd ) -{ - unix_funcs->server_send_fd( fd ); -} - - -/*********************************************************************** - * wine_server_fd_to_handle (NTDLL.@) - * - * Allocate a file handle for a Unix file descriptor. - * - * PARAMS - * fd [I] Unix file descriptor. - * access [I] Win32 access flags. - * attributes [I] Object attributes. - * handle [O] Address where Wine file handle will be stored. - * - * RETURNS - * NTSTATUS code - */ -int CDECL wine_server_fd_to_handle( int fd, unsigned int access, unsigned int attributes, HANDLE *handle ) -{ - return unix_funcs->server_fd_to_handle( fd, access, attributes, handle ); -} - - -/*********************************************************************** - * wine_server_handle_to_fd (NTDLL.@) - * - * Retrieve the file descriptor corresponding to a file handle. - * - * PARAMS - * handle [I] Wine file handle. - * access [I] Win32 file access rights requested. - * unix_fd [O] Address where Unix file descriptor will be stored. - * options [O] Address where the file open options will be stored. Optional. - * - * RETURNS - * NTSTATUS code - */ -int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, - unsigned int *options ) -{ - return unix_funcs->server_handle_to_fd( handle, access, unix_fd, options ); -} - - -/*********************************************************************** - * wine_server_release_fd (NTDLL.@) - * - * Release the Unix file descriptor returned by wine_server_handle_to_fd. - * - * PARAMS - * handle [I] Wine file handle. - * unix_fd [I] Unix file descriptor to release. - * - * RETURNS - * nothing - */ -void CDECL wine_server_release_fd( HANDLE handle, int unix_fd ) -{ - unix_funcs->server_release_fd( handle, unix_fd ); -} diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index d157465edbf..43920135a01 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1159,9 +1159,9 @@ void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, { *handle = *std_in = *std_out = *std_err = 0; if (isatty(0) || isatty(1) || isatty(2)) *handle = (HANDLE)2; /* see kernel32/kernel_private.h */ - if (!isatty(0)) server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, std_in ); - if (!isatty(1)) server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_out ); - if (!isatty(2)) server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_err ); + if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, std_in ); + if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_out ); + if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_err ); } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 69ea69ad530..8ce7b22ddd8 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1353,11 +1353,6 @@ static struct unix_funcs unix_funcs = virtual_locked_recvmsg, virtual_release_address_space, exec_process, - wine_server_call, - server_send_fd, - server_fd_to_handle, - server_handle_to_fd, - server_release_fd, server_init_process_done, wine_nt_to_unix_file_name, wine_unix_to_nt_file_name, diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 37d0af19817..9e48982839e 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -511,7 +511,7 @@ static int get_unix_curdir( const RTL_USER_PROCESS_PARAMETERS *params ) FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ); free( nt_name.Buffer ); if (status) return -1; - server_handle_to_fd( handle, FILE_TRAVERSE, &fd, NULL ); + wine_server_handle_to_fd( handle, FILE_TRAVERSE, &fd, NULL ); NtClose( handle ); return fd; } @@ -548,8 +548,8 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so pid_t pid; char **argv; - server_handle_to_fd( params->hStdInput, FILE_READ_DATA, &stdin_fd, NULL ); - server_handle_to_fd( params->hStdOutput, FILE_WRITE_DATA, &stdout_fd, NULL ); + wine_server_handle_to_fd( params->hStdInput, FILE_READ_DATA, &stdin_fd, NULL ); + wine_server_handle_to_fd( params->hStdOutput, FILE_WRITE_DATA, &stdout_fd, NULL ); if (!(pid = fork())) /* child */ { @@ -640,7 +640,7 @@ NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTST setsockopt( socketfd[0], SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable) ); } #endif - server_send_fd( socketfd[1] ); + wine_server_send_fd( socketfd[1] ); close( socketfd[1] ); SERVER_START_REQ( exec_process ) @@ -701,8 +701,8 @@ static NTSTATUS fork_and_exec( UNICODE_STRING *path, int unixdir, fcntl( fd[1], F_SETFD, FD_CLOEXEC ); } - server_handle_to_fd( params->hStdInput, FILE_READ_DATA, &stdin_fd, NULL ); - server_handle_to_fd( params->hStdOutput, FILE_WRITE_DATA, &stdout_fd, NULL ); + wine_server_handle_to_fd( params->hStdInput, FILE_READ_DATA, &stdin_fd, NULL ); + wine_server_handle_to_fd( params->hStdOutput, FILE_WRITE_DATA, &stdout_fd, NULL ); if (!(pid = fork())) /* child */ { @@ -861,7 +861,7 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ } #endif - server_send_fd( socketfd[1] ); + wine_server_send_fd( socketfd[1] ); close( socketfd[1] ); /* create the process on the server side */ diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index d6eb528bf2a..6d96f581b7e 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -751,11 +751,11 @@ unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *call, a /*********************************************************************** - * server_send_fd + * wine_server_send_fd * * Send a file descriptor to the server. */ -void CDECL server_send_fd( int fd ) +void CDECL wine_server_send_fd( int fd ) { struct send_fd data; struct msghdr msghdr; @@ -1038,14 +1038,14 @@ done: /*********************************************************************** - * server_fd_to_handle + * wine_server_fd_to_handle */ -NTSTATUS CDECL server_fd_to_handle( int fd, unsigned int access, unsigned int attributes, HANDLE *handle ) +NTSTATUS CDECL wine_server_fd_to_handle( int fd, unsigned int access, unsigned int attributes, HANDLE *handle ) { NTSTATUS ret; *handle = 0; - server_send_fd( fd ); + wine_server_send_fd( fd ); SERVER_START_REQ( alloc_file_handle ) { @@ -1060,12 +1060,12 @@ NTSTATUS CDECL server_fd_to_handle( int fd, unsigned int access, unsigned int at /*********************************************************************** - * server_handle_to_fd + * wine_server_handle_to_fd * * Retrieve the file descriptor corresponding to a file handle. */ -NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, - unsigned int *options ) +NTSTATUS CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, + unsigned int *options ) { int needs_close; NTSTATUS ret = server_get_unix_fd( handle, access, unix_fd, &needs_close, NULL, options ); @@ -1079,9 +1079,9 @@ NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, int *uni /*********************************************************************** - * server_release_fd + * wine_server_release_fd */ -void CDECL server_release_fd( HANDLE handle, int unix_fd ) +void CDECL wine_server_release_fd( HANDLE handle, int unix_fd ) { close( unix_fd ); } @@ -1519,8 +1519,8 @@ size_t server_init_thread( void *entry_point, BOOL *suspend ) /* create the server->client communication pipes */ if (server_pipe( reply_pipe ) == -1) server_protocol_perror( "pipe" ); if (server_pipe( ntdll_get_thread_data()->wait_fd ) == -1) server_protocol_perror( "pipe" ); - server_send_fd( reply_pipe[1] ); - server_send_fd( ntdll_get_thread_data()->wait_fd[1] ); + wine_server_send_fd( reply_pipe[1] ); + wine_server_send_fd( ntdll_get_thread_data()->wait_fd[1] ); ntdll_get_thread_data()->reply_fd = reply_pipe[0]; close( reply_pipe[1] ); diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 28c7d816b72..1b0a68bf696 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -187,7 +187,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT free( objattr ); return STATUS_TOO_MANY_OPENED_FILES; } - server_send_fd( request_pipe[0] ); + wine_server_send_fd( request_pipe[0] ); if (!access) access = THREAD_ALL_ACCESS; diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index b55eb571283..a87657096db 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -121,12 +121,6 @@ extern NTSTATUS CDECL virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsig extern ssize_t CDECL virtual_locked_recvmsg( int fd, struct msghdr *hdr, int flags ) DECLSPEC_HIDDEN; extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN; -extern void CDECL server_send_fd( int fd ) DECLSPEC_HIDDEN; -extern NTSTATUS CDECL server_fd_to_handle( int fd, unsigned int access, unsigned int attributes, - HANDLE *handle ) DECLSPEC_HIDDEN; -extern NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, - unsigned int *options ) DECLSPEC_HIDDEN; -extern void CDECL server_release_fd( HANDLE handle, int unix_fd ) DECLSPEC_HIDDEN; extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch, diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 508b83a5e50..1c48864a0ef 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 94 +#define NTDLL_UNIXLIB_VERSION 95 struct unix_funcs { @@ -93,13 +93,6 @@ struct unix_funcs NTSTATUS (CDECL *exec_process)( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ); /* server functions */ - unsigned int (CDECL *server_call)( void *req_ptr ); - void (CDECL *server_send_fd)( int fd ); - NTSTATUS (CDECL *server_fd_to_handle)( int fd, unsigned int access, unsigned int attributes, - HANDLE *handle ); - NTSTATUS (CDECL *server_handle_to_fd)( HANDLE handle, unsigned int access, int *unix_fd, - unsigned int *options ); - void (CDECL *server_release_fd)( HANDLE handle, int unix_fd ); void (CDECL *server_init_process_done)( void *relay ); /* file functions */ -- 2.11.4.GIT