From 693bbd79b6e170fb68270e0ec01bd08c55bacc42 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 14 Jun 2003 01:31:56 +0000 Subject: [PATCH] Make it possible to retrieve an inheritable handle in open_named_pipe (spotted by Uwe Bonnes). --- files/file.c | 5 +++-- include/wine/server_protocol.h | 3 ++- server/named_pipe.c | 2 +- server/protocol.def | 1 + server/trace.c | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/files/file.c b/files/file.c index 99b739d878f..5603a424012 100644 --- a/files/file.c +++ b/files/file.c @@ -497,7 +497,7 @@ HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa return ret; } -static HANDLE FILE_OpenPipe(LPCWSTR name, DWORD access) +static HANDLE FILE_OpenPipe(LPCWSTR name, DWORD access, LPSECURITY_ATTRIBUTES sa ) { HANDLE ret; DWORD len = 0; @@ -510,6 +510,7 @@ static HANDLE FILE_OpenPipe(LPCWSTR name, DWORD access) SERVER_START_REQ( open_named_pipe ) { req->access = access; + req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); SetLastError(0); wine_server_add_data( req, name, len * sizeof(WCHAR) ); wine_server_call_err( req ); @@ -597,7 +598,7 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing, if(!strncmpiW(filename + 4, pipeW, 5)) { TRACE("Opening a pipe: %s\n", debugstr_w(filename)); - ret = FILE_OpenPipe(filename,access); + ret = FILE_OpenPipe( filename, access, sa ); goto done; } else if (isalphaW(filename[4]) && filename[5] == ':' && filename[6] == '\0') diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 23ce5b994d2..f4a9fc5b5fc 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -2406,6 +2406,7 @@ struct open_named_pipe_request { struct request_header __header; unsigned int access; + int inherit; /* VARARG(name,unicode_str); */ }; struct open_named_pipe_reply @@ -3568,6 +3569,6 @@ union generic_reply struct get_next_hook_reply get_next_hook_reply; }; -#define SERVER_PROTOCOL_VERSION 108 +#define SERVER_PROTOCOL_VERSION 109 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/named_pipe.c b/server/named_pipe.c index 7f517748a93..aafdcbc04d6 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -683,7 +683,7 @@ DECL_HANDLER(open_named_pipe) server->client = client; client->server = server; reply->handle = alloc_handle( current->process, client, - req->access, 0 ); + req->access, req->inherit ); } } else diff --git a/server/protocol.def b/server/protocol.def index b5fdbbfd8ba..51e3bc9c5a4 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1710,6 +1710,7 @@ enum message_type /* Open an existing named pipe */ @REQ(open_named_pipe) unsigned int access; + int inherit; /* inherit flag */ VARARG(name,unicode_str); /* pipe name */ @REPLY obj_handle_t handle; /* handle to the pipe */ diff --git a/server/trace.c b/server/trace.c index 5d10124af6d..0d43904435c 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1967,6 +1967,7 @@ static void dump_create_named_pipe_reply( const struct create_named_pipe_reply * static void dump_open_named_pipe_request( const struct open_named_pipe_request *req ) { fprintf( stderr, " access=%08x,", req->access ); + fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " name=" ); dump_varargs_unicode_str( cur_size ); }