Commit 4e581163 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Use syscalls for the server functions.

parent 0e7f6e0e
......@@ -34,7 +34,6 @@ C_SRCS = \
rtlbitmap.c \
rtlstr.c \
sec.c \
server.c \
signal_arm.c \
signal_arm64.c \
signal_i386.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',';',
......
......@@ -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
......
/*
* 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 <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#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 );
}
......@@ -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 );
}
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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,11 +1060,11 @@ 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,
NTSTATUS CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd,
unsigned int *options )
{
int needs_close;
......@@ -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] );
......
......@@ -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;
......
......@@ -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,
......
......@@ -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 */
......
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