forked from Mirrors/wine-wine
ntdll: Move NtClose() and NtDuplicateObject() to the Unix library.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>feature/deterministic
parent
09fcfe27ac
commit
04f41e87a3
|
@ -351,28 +351,8 @@ NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
|
|||
HANDLE dest_process, PHANDLE dest,
|
||||
ACCESS_MASK access, ULONG attributes, ULONG options )
|
||||
{
|
||||
NTSTATUS ret;
|
||||
SERVER_START_REQ( dup_handle )
|
||||
{
|
||||
req->src_process = wine_server_obj_handle( source_process );
|
||||
req->src_handle = wine_server_obj_handle( source );
|
||||
req->dst_process = wine_server_obj_handle( dest_process );
|
||||
req->access = access;
|
||||
req->attributes = attributes;
|
||||
req->options = options;
|
||||
|
||||
if (!(ret = wine_server_call( req )))
|
||||
{
|
||||
if (dest) *dest = wine_server_ptr_handle( reply->handle );
|
||||
if (reply->closed && reply->self)
|
||||
{
|
||||
int fd = unix_funcs->server_remove_fd_from_cache( source );
|
||||
if (fd != -1) close( fd );
|
||||
}
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
return ret;
|
||||
return unix_funcs->NtDuplicateObject( source_process, source, dest_process,
|
||||
dest, access, attributes, options );
|
||||
}
|
||||
|
||||
static LONG WINAPI invalid_handle_exception_handler( EXCEPTION_POINTERS *eptr )
|
||||
|
@ -384,16 +364,7 @@ static LONG WINAPI invalid_handle_exception_handler( EXCEPTION_POINTERS *eptr )
|
|||
/* Everquest 2 / Pirates of the Burning Sea hooks NtClose, so we need a wrapper */
|
||||
NTSTATUS close_handle( HANDLE handle )
|
||||
{
|
||||
NTSTATUS ret;
|
||||
int fd = unix_funcs->server_remove_fd_from_cache( handle );
|
||||
|
||||
SERVER_START_REQ( close_handle )
|
||||
{
|
||||
req->handle = wine_server_obj_handle( handle );
|
||||
ret = wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
if (fd != -1) close( fd );
|
||||
NTSTATUS ret = unix_funcs->NtClose( handle );
|
||||
|
||||
if (ret == STATUS_INVALID_HANDLE && handle && NtCurrentTeb()->Peb->BeingDebugged)
|
||||
{
|
||||
|
|
|
@ -983,6 +983,8 @@ static HMODULE load_ntdll(void)
|
|||
*/
|
||||
static struct unix_funcs unix_funcs =
|
||||
{
|
||||
NtClose,
|
||||
NtDuplicateObject,
|
||||
get_main_args,
|
||||
get_paths,
|
||||
get_dll_path,
|
||||
|
@ -999,7 +1001,6 @@ static struct unix_funcs unix_funcs =
|
|||
server_call_unlocked,
|
||||
wine_server_call,
|
||||
server_send_fd,
|
||||
server_remove_fd_from_cache,
|
||||
server_get_unix_fd,
|
||||
server_fd_to_handle,
|
||||
server_handle_to_fd,
|
||||
|
|
|
@ -542,9 +542,9 @@ static inline NTSTATUS get_cached_fd( HANDLE handle, int *fd, enum server_fd_typ
|
|||
|
||||
|
||||
/***********************************************************************
|
||||
* server_remove_fd_from_cache
|
||||
* remove_fd_from_cache
|
||||
*/
|
||||
int CDECL server_remove_fd_from_cache( HANDLE handle )
|
||||
static int remove_fd_from_cache( HANDLE handle )
|
||||
{
|
||||
unsigned int entry, idx = handle_to_index( handle, &entry );
|
||||
int fd = -1;
|
||||
|
@ -1122,3 +1122,53 @@ size_t CDECL server_init_thread( void *entry_point, BOOL *suspend, unsigned int
|
|||
server_protocol_error( "init_thread failed with status %x\n", ret );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NtDuplicateObject
|
||||
*/
|
||||
NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source, HANDLE dest_process, HANDLE *dest,
|
||||
ACCESS_MASK access, ULONG attributes, ULONG options )
|
||||
{
|
||||
NTSTATUS ret;
|
||||
|
||||
SERVER_START_REQ( dup_handle )
|
||||
{
|
||||
req->src_process = wine_server_obj_handle( source_process );
|
||||
req->src_handle = wine_server_obj_handle( source );
|
||||
req->dst_process = wine_server_obj_handle( dest_process );
|
||||
req->access = access;
|
||||
req->attributes = attributes;
|
||||
req->options = options;
|
||||
if (!(ret = wine_server_call( req )))
|
||||
{
|
||||
if (dest) *dest = wine_server_ptr_handle( reply->handle );
|
||||
if (reply->closed && reply->self)
|
||||
{
|
||||
int fd = remove_fd_from_cache( source );
|
||||
if (fd != -1) close( fd );
|
||||
}
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* NtClose
|
||||
*/
|
||||
NTSTATUS WINAPI NtClose( HANDLE handle )
|
||||
{
|
||||
NTSTATUS ret;
|
||||
int fd = remove_fd_from_cache( handle );
|
||||
|
||||
SERVER_START_REQ( close_handle )
|
||||
{
|
||||
req->handle = wine_server_obj_handle( handle );
|
||||
ret = wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
if (fd != -1) close( fd );
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ extern void CDECL dbg_init(void) DECLSPEC_HIDDEN;
|
|||
|
||||
extern unsigned int CDECL server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN;
|
||||
extern void CDECL server_send_fd( int fd ) DECLSPEC_HIDDEN;
|
||||
extern int CDECL server_remove_fd_from_cache( HANDLE handle ) DECLSPEC_HIDDEN;
|
||||
extern int CDECL server_get_unix_fd( HANDLE handle, unsigned int wanted_access, int *unix_fd,
|
||||
int *needs_close, enum server_fd_type *type,
|
||||
unsigned int *options ) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -25,10 +25,16 @@
|
|||
#include "wine/debug.h"
|
||||
|
||||
/* increment this when you change the function table */
|
||||
#define NTDLL_UNIXLIB_VERSION 10
|
||||
#define NTDLL_UNIXLIB_VERSION 11
|
||||
|
||||
struct unix_funcs
|
||||
{
|
||||
/* Nt* functions */
|
||||
NTSTATUS (WINAPI *NtClose)( HANDLE handle );
|
||||
NTSTATUS (WINAPI *NtDuplicateObject)( HANDLE source_process, HANDLE source,
|
||||
HANDLE dest_process, HANDLE *dest,
|
||||
ACCESS_MASK access, ULONG attributes, ULONG options );
|
||||
|
||||
/* environment functions */
|
||||
void (CDECL *get_main_args)( int *argc, char **argv[], char **envp[] );
|
||||
void (CDECL *get_paths)( const char **builddir, const char **datadir, const char **configdir );
|
||||
|
@ -54,7 +60,6 @@ struct unix_funcs
|
|||
unsigned int (CDECL *server_call_unlocked)( void *req_ptr );
|
||||
unsigned int (CDECL *server_call)( void *req_ptr );
|
||||
void (CDECL *server_send_fd)( int fd );
|
||||
int (CDECL *server_remove_fd_from_cache)( HANDLE handle );
|
||||
int (CDECL *server_get_unix_fd)( HANDLE handle, unsigned int wanted_access, int *unix_fd,
|
||||
int *needs_close, enum server_fd_type *type, unsigned int *options );
|
||||
NTSTATUS (CDECL *server_fd_to_handle)( int fd, unsigned int access, unsigned int attributes,
|
||||
|
|
Loading…
Reference in New Issue