Commit be367c72 authored by Alexandre Julliard's avatar Alexandre Julliard

Added wine_server_fd_to_handle to replace FILE_DupUnixHandle.

parent 9851f7a9
......@@ -1023,6 +1023,7 @@ name ntdll
# Server interface
@ cdecl -norelay wine_server_call(ptr) wine_server_call
@ cdecl wine_server_fd_to_handle(long long long ptr) wine_server_fd_to_handle
@ cdecl wine_server_handle_to_fd(long long ptr ptr ptr) wine_server_handle_to_fd
# Codepages
......
......@@ -36,15 +36,15 @@
#include "wine/winbase16.h"
#include "winreg.h"
#include "wine/debug.h"
#include "gdi.h"
#include "file.h"
#include "user.h"
#include "win.h"
#include "wine_gl.h"
#include "x11drv.h"
#include "xvidmode.h"
#include "dga2.h"
#include "wine/server.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
......@@ -449,8 +449,12 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */
if (synchronous) XSynchronize( data->display, True );
wine_tsx11_unlock();
data->display_fd = FILE_DupUnixHandle( ConnectionNumber(data->display),
GENERIC_READ | SYNCHRONIZE, FALSE );
if (wine_server_fd_to_handle( ConnectionNumber(data->display), GENERIC_READ | SYNCHRONIZE,
FALSE, &data->display_fd ))
{
MESSAGE( "x11drv: Can't allocate handle for display fd\n" );
ExitProcess(1);
}
data->process_event_count = 0;
NtCurrentTeb()->driver_data = data;
return data;
......
......@@ -307,31 +307,6 @@ void FILE_SetDosError(void)
/***********************************************************************
* FILE_DupUnixHandle
*
* Duplicate a Unix handle into a task handle.
* Returns 0 on failure.
*/
HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit )
{
HANDLE ret;
wine_server_send_fd( fd );
SERVER_START_REQ( alloc_file_handle )
{
req->access = access;
req->inherit = inherit;
req->fd = fd;
wine_server_call( req );
ret = reply->handle;
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* FILE_GetUnixHandleType
*
* Retrieve the Unix handle corresponding to a file handle.
......
......@@ -69,7 +69,6 @@ extern mode_t FILE_umask;
extern int FILE_strcasecmp( const char *str1, const char *str2 );
extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
extern void FILE_SetDosError(void);
extern HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit );
extern int FILE_GetUnixHandle( HANDLE handle, DWORD access );
extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );
......
......@@ -51,6 +51,7 @@ struct __server_request_info
extern unsigned int wine_server_call( void *req_ptr );
extern void wine_server_send_fd( int fd );
extern int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle );
extern int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *unix_fd,
enum fd_type *type, int *flags );
......
......@@ -365,6 +365,30 @@ inline static int store_cached_fd( int fd, obj_handle_t handle )
/***********************************************************************
* wine_server_fd_to_handle (NTDLL.@)
*
* Allocate a file handle for a Unix fd.
*/
int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle )
{
int ret;
*handle = 0;
wine_server_send_fd( fd );
SERVER_START_REQ( alloc_file_handle )
{
req->access = access;
req->inherit = inherit;
req->fd = fd;
if (!(ret = wine_server_call( req ))) *handle = reply->handle;
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* wine_server_handle_to_fd (NTDLL.@)
*
* Retrieve the Unix fd corresponding to a file handle.
......
......@@ -403,9 +403,13 @@ static BOOL process_init( char *argv[] )
/* no parent, and no new console requested, create a simple console with bare handles to
* unix stdio input & output streams (aka simple console)
*/
SetStdHandle( STD_INPUT_HANDLE, FILE_DupUnixHandle( 0, GENERIC_READ|SYNCHRONIZE, TRUE ));
SetStdHandle( STD_OUTPUT_HANDLE, FILE_DupUnixHandle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE ));
SetStdHandle( STD_ERROR_HANDLE, FILE_DupUnixHandle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE ));
HANDLE handle;
wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, TRUE, &handle );
SetStdHandle( STD_INPUT_HANDLE, handle );
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, &handle );
SetStdHandle( STD_OUTPUT_HANDLE, handle );
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, &handle );
SetStdHandle( STD_ERROR_HANDLE, handle );
}
else if (!(main_create_flags & (DETACHED_PROCESS|CREATE_NEW_CONSOLE)))
{
......
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