Use the share disposition to detect the direction of a pipe.
Modified: trunk/reactos/drivers/fs/np/create.c
Modified: trunk/reactos/lib/kernel32/file/npipe.c
Modified: trunk/reactos/lib/kernel32/file/pipe.c

Modified: trunk/reactos/drivers/fs/np/create.c
--- trunk/reactos/drivers/fs/np/create.c	2005-11-05 21:28:27 UTC (rev 19020)
+++ trunk/reactos/drivers/fs/np/create.c	2005-11-05 22:03:47 UTC (rev 19021)
@@ -329,6 +329,14 @@
 
    Irp->IoStatus.Information = 0;
 
+   if (!(IoStack->Parameters.CreatePipe.ShareAccess & (FILE_SHARE_READ|FILE_SHARE_WRITE)) ||
+       (IoStack->Parameters.CreatePipe.ShareAccess & ~(FILE_SHARE_READ|FILE_SHARE_WRITE)))
+     {
+	Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+	IoCompleteRequest(Irp, IO_NO_INCREMENT);
+	return STATUS_INVALID_PARAMETER;
+     }
+
    Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
    if (Fcb == NULL)
      {
@@ -411,12 +419,23 @@
        Pipe->WriteMode = Buffer->ReadMode;
        Pipe->ReadMode = Buffer->ReadMode;
        Pipe->CompletionMode = Buffer->CompletionMode;
-       Pipe->PipeConfiguration = IoStack->Parameters.CreatePipe.Options & 0x3;
+       switch (IoStack->Parameters.CreatePipe.ShareAccess & (FILE_SHARE_READ|FILE_SHARE_WRITE))
+         {
+           case FILE_SHARE_READ:
+             Pipe->PipeConfiguration = FILE_PIPE_OUTBOUND;
+             break;
+           case FILE_SHARE_WRITE:
+             Pipe->PipeConfiguration = FILE_PIPE_INBOUND;
+             break;
+           case FILE_SHARE_READ|FILE_SHARE_WRITE:
+             Pipe->PipeConfiguration = FILE_PIPE_FULL_DUPLEX;
+             break;
+         }
        Pipe->MaximumInstances = Buffer->MaximumInstances;
        Pipe->CurrentInstances = 0;
        Pipe->TimeOut = Buffer->DefaultTimeout;
-       if (!(IoStack->Parameters.CreatePipe.Options & FILE_PIPE_OUTBOUND) ||
-           IoStack->Parameters.CreatePipe.Options & FILE_PIPE_FULL_DUPLEX)
+       if (!(Pipe->PipeConfiguration & FILE_PIPE_OUTBOUND) ||
+           Pipe->PipeConfiguration & FILE_PIPE_FULL_DUPLEX)
          {
            if (Buffer->InboundQuota == 0)
              {
@@ -440,7 +459,7 @@
            Pipe->InboundQuota = 0;
          }
 
-       if (IoStack->Parameters.CreatePipe.Options & (FILE_PIPE_FULL_DUPLEX|FILE_PIPE_OUTBOUND))
+       if (Pipe->PipeConfiguration & (FILE_PIPE_FULL_DUPLEX|FILE_PIPE_OUTBOUND))
          {
            if (Buffer->OutboundQuota == 0)
              {

Modified: trunk/reactos/lib/kernel32/file/npipe.c
--- trunk/reactos/lib/kernel32/file/npipe.c	2005-11-05 21:28:27 UTC (rev 19020)
+++ trunk/reactos/lib/kernel32/file/npipe.c	2005-11-05 22:03:47 UTC (rev 19021)
@@ -123,27 +123,16 @@
    if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
       CreateOptions = CreateOptions | FILE_SYNCHRONOUS_IO_NONALERT;
 
-   switch (dwOpenMode & PIPE_ACCESS_DUPLEX)
-   {
-      case PIPE_ACCESS_INBOUND:
-         CreateOptions |= FILE_PIPE_INBOUND;
-         ShareAccess |= FILE_SHARE_WRITE;
-         DesiredAccess |= GENERIC_READ;
-         break;
-
-      case PIPE_ACCESS_OUTBOUND:
-         CreateOptions |= FILE_PIPE_OUTBOUND;
-         ShareAccess |= FILE_SHARE_READ;
-         DesiredAccess |= GENERIC_WRITE;
-         break;
-
-      case PIPE_ACCESS_DUPLEX:
-         CreateOptions |= FILE_PIPE_FULL_DUPLEX;
-         ShareAccess |= (FILE_SHARE_READ | FILE_SHARE_WRITE);
-         DesiredAccess |= (GENERIC_READ | GENERIC_WRITE);
-         break;
-   }
-
+   if (dwOpenMode & PIPE_ACCESS_OUTBOUND)
+     {
+       ShareAccess |= FILE_SHARE_READ;
+       DesiredAccess |= GENERIC_WRITE;
+     }
+   if (dwOpenMode & PIPE_ACCESS_INBOUND)
+     {
+       ShareAccess |= FILE_SHARE_WRITE;
+       DesiredAccess |= GENERIC_READ;
+     }
    if (dwPipeMode & PIPE_TYPE_MESSAGE)
       WriteModeMessage = FILE_PIPE_MESSAGE_MODE;
    else

Modified: trunk/reactos/lib/kernel32/file/pipe.c
--- trunk/reactos/lib/kernel32/file/pipe.c	2005-11-05 21:28:27 UTC (rev 19020)
+++ trunk/reactos/lib/kernel32/file/pipe.c	2005-11-05 22:03:47 UTC (rev 19021)
@@ -41,11 +41,11 @@
    ULONG Attributes;
    PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
 
-   DefaultTimeout.QuadPart = 300000000; /* 30 seconds */
+   DefaultTimeout.QuadPart = -300000000; /* 30 seconds */
 
    PipeId = (ULONG)InterlockedIncrement((LONG*)&ProcessPipeId);
    swprintf(Buffer,
-	    L"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
+	    L"\\\\.\\PIPE\\Win32Pipes.%08x.%08x",
 	    NtCurrentTeb()->Cid.UniqueProcess,
 	    PipeId);
    RtlInitUnicodeString (&PipeName,
@@ -73,7 +73,7 @@
 				  FILE_GENERIC_READ |FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
 				  &ObjectAttributes,
 				  &StatusBlock,
-				  FILE_SHARE_READ | FILE_SHARE_WRITE,
+				  FILE_SHARE_WRITE,
 				  FILE_CREATE,
 				  FILE_SYNCHRONOUS_IO_NONALERT,
 				  FALSE,
@@ -93,8 +93,8 @@
 		       FILE_GENERIC_WRITE | SYNCHRONIZE,
 		       &ObjectAttributes,
 		       &StatusBlock,
-		       FILE_SHARE_READ | FILE_SHARE_WRITE,
-		       FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
+		       FILE_SHARE_READ,
+		       FILE_SYNCHRONOUS_IO_NONALERT);
    if (!NT_SUCCESS(Status))
      {
 	NtClose(ReadPipeHandle);