From 630edc66479db789c7541e2c356a41090524d838 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 4 Aug 2014 00:29:26 +0200
Subject: server: Show warning if message mode is not supported.

This patch changes the create_named_pipe wineserver call to return
which flags were supported. This allows to show a FIXME in ntdll for
missing message mode support.
---
 dlls/ntdll/file.c   | 14 ++++++++++----
 server/named_pipe.c |  2 ++
 server/protocol.def |  1 +
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 3883e5a..9e98f36 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -3507,6 +3507,7 @@ NTSTATUS WINAPI NtCreateNamedPipeFile( PHANDLE handle, ULONG access,
     NTSTATUS status;
     data_size_t len;
     struct object_attributes *objattr;
+    unsigned int flags;
 
     TRACE("(%p %x %s %p %x %d %x %d %d %d %d %d %d %p)\n",
           handle, access, debugstr_w(attr->ObjectName->Buffer), iosb, sharing, dispo,
@@ -3521,15 +3522,16 @@ NTSTATUS WINAPI NtCreateNamedPipeFile( PHANDLE handle, ULONG access,
 
     if ((status = alloc_object_attributes( attr, &objattr, &len ))) return status;
 
+    flags = (pipe_type ? NAMED_PIPE_MESSAGE_STREAM_WRITE   : 0) |
+            (read_mode ? NAMED_PIPE_MESSAGE_STREAM_READ    : 0) |
+            (completion_mode ? NAMED_PIPE_NONBLOCKING_MODE : 0);
+
     SERVER_START_REQ( create_named_pipe )
     {
         req->access  = access;
         req->options = options;
         req->sharing = sharing;
-        req->flags = 
-            (pipe_type ? NAMED_PIPE_MESSAGE_STREAM_WRITE   : 0) |
-            (read_mode ? NAMED_PIPE_MESSAGE_STREAM_READ    : 0) |
-            (completion_mode ? NAMED_PIPE_NONBLOCKING_MODE : 0);
+        req->flags   = flags;
         req->maxinstances = max_inst;
         req->outsize = outbound_quota;
         req->insize  = inbound_quota;
@@ -3537,9 +3539,13 @@ NTSTATUS WINAPI NtCreateNamedPipeFile( PHANDLE handle, ULONG access,
         wine_server_add_data( req, objattr, len );
         status = wine_server_call( req );
         if (!status) *handle = wine_server_ptr_handle( reply->handle );
+        flags &= ~reply->flags; /* contains now all unsupported flags */
     }
     SERVER_END_REQ;
 
+    if (!status && (flags & (NAMED_PIPE_MESSAGE_STREAM_WRITE | NAMED_PIPE_MESSAGE_STREAM_READ)))
+        FIXME("Message mode not supported, falling back to byte mode.\n");
+
     RtlFreeHeap( GetProcessHeap(), 0, objattr );
     return status;
 }
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 7a97e35..ee6008c 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -934,6 +934,8 @@ DECL_HANDLER(create_named_pipe)
         return;
     }
 
+    reply->flags = req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_WRITE | NAMED_PIPE_MESSAGE_STREAM_READ);
+
     if (!name.len)  /* pipes need a root directory even without a name */
     {
         if (!objattr->rootdir)
diff --git a/server/protocol.def b/server/protocol.def
index a5a45eb..2d87f03 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -2370,6 +2370,7 @@ enum message_type
     unsigned int   flags;
     VARARG(objattr,object_attributes); /* object attributes */
 @REPLY
+    unsigned int   flags;
     obj_handle_t   handle;       /* handle to the pipe */
 @END
 
-- 
2.7.0

