[ros-diffs] [ekohl] 49701: [NPFS/KERNEL32] Switch back to the old pipe wait code but keep the new code in place (disabled).

ekohl at svn.reactos.org ekohl at svn.reactos.org
Sun Nov 21 23:15:12 UTC 2010


Author: ekohl
Date: Sun Nov 21 23:15:11 2010
New Revision: 49701

URL: http://svn.reactos.org/svn/reactos?rev=49701&view=rev
Log:
[NPFS/KERNEL32]
Switch back to the old pipe wait code but keep the new code in place (disabled).

Modified:
    trunk/reactos/dll/win32/kernel32/file/npipe.c
    trunk/reactos/drivers/filesystems/npfs/create.c
    trunk/reactos/drivers/filesystems/npfs/fsctrl.c

Modified: trunk/reactos/dll/win32/kernel32/file/npipe.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/npipe.c?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/npipe.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/npipe.c [iso-8859-1] Sun Nov 21 23:15:11 2010
@@ -14,7 +14,7 @@
 #include <debug.h>
 DEBUG_CHANNEL(kernel32file);
 
-#define USING_PROPER_NPFS_WAIT_SEMANTICS
+//#define USING_PROPER_NPFS_WAIT_SEMANTICS
 
 /* FUNCTIONS ****************************************************************/
 
@@ -265,6 +265,16 @@
 
 
 /*
+ * When NPFS will work properly, use this code instead. It is compatible with
+ * Microsoft's NPFS.SYS. The main difference is that:
+ *      - This code actually respects the timeout instead of ignoring it!
+ *      - This code validates and creates the proper names for both UNC and local pipes
+ *      - On NT, you open the *root* pipe directory (either \DosDevices\Pipe or
+ *        \DosDevices\Unc\Server\Pipe) and then send the pipe to wait on in the
+ *        FILE_PIPE_WAIT_FOR_BUFFER structure.
+ */
+#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
+/*
  * @implemented
  */
 BOOL
@@ -448,6 +458,95 @@
     /* Success */
     return TRUE;
 }
+#else
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+WaitNamedPipeW(LPCWSTR lpNamedPipeName,
+               DWORD nTimeOut)
+{
+    UNICODE_STRING NamedPipeName;
+    NTSTATUS Status;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
+    HANDLE FileHandle;
+    IO_STATUS_BLOCK Iosb;
+
+    if (RtlDosPathNameToNtPathName_U(lpNamedPipeName,
+                                     &NamedPipeName,
+                                     NULL,
+                                     NULL) == FALSE)
+    {
+        return FALSE;
+    }
+
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &NamedPipeName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+    Status = NtOpenFile(&FileHandle,
+                        FILE_READ_ATTRIBUTES | SYNCHRONIZE,
+                        &ObjectAttributes,
+                        &Iosb,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE,
+                        FILE_SYNCHRONOUS_IO_NONALERT);
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
+        RtlFreeUnicodeString(&NamedPipeName);
+        return FALSE;
+    }
+
+    /* Check what timeout we got */
+    if (nTimeOut == NMPWAIT_USE_DEFAULT_WAIT)
+    {
+        /* Don't use a timeout */
+        WaitPipe.TimeoutSpecified = FALSE;
+    }
+    else
+    {
+        /* Check if we should wait forever */
+        if (nTimeOut == NMPWAIT_WAIT_FOREVER)
+        {
+            /* Set the max */
+            WaitPipe.Timeout.LowPart = 0;
+            WaitPipe.Timeout.HighPart = 0x80000000;
+        }
+        else
+        {
+            /* Convert to NT format */
+            WaitPipe.Timeout.QuadPart = UInt32x32To64(-10000, nTimeOut);
+        }
+
+        /* In both cases, we do have a timeout */
+        WaitPipe.TimeoutSpecified = TRUE;
+    }
+
+    Status = NtFsControlFile(FileHandle,
+                             NULL,
+                             NULL,
+                             NULL,
+                             &Iosb,
+                             FSCTL_PIPE_WAIT,
+                             &WaitPipe,
+                             sizeof(WaitPipe),
+                             NULL,
+                             0);
+    NtClose(FileHandle);
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
+        RtlFreeUnicodeString(&NamedPipeName);
+        return FALSE;
+    }
+
+    RtlFreeUnicodeString(&NamedPipeName);
+    return TRUE;
+}
+#endif
 
 
 /*

Modified: trunk/reactos/drivers/filesystems/npfs/create.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/create.c?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] Sun Nov 21 23:15:11 2010
@@ -12,6 +12,8 @@
 
 #define NDEBUG
 #include <debug.h>
+
+//#define USING_PROPER_NPFS_WAIT_SEMANTICS
 
 /* FUNCTIONS *****************************************************************/
 
@@ -146,6 +148,9 @@
     PNPFS_VCB Vcb;
     ACCESS_MASK DesiredAccess;
     NTSTATUS Status;
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
+    BOOLEAN SpecialAccess;
+#endif
 
     DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
 
@@ -160,6 +165,14 @@
     DPRINT("FileName %wZ\n", &FileObject->FileName);
 
     Irp->IoStatus.Information = 0;
+
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
+    SpecialAccess = ((DesiredAccess & SPECIFIC_RIGHTS_ALL) == FILE_READ_ATTRIBUTES);
+    if (SpecialAccess)
+    {
+        DPRINT("NpfsCreate() open client end for special use!\n");
+    }
+#endif
 
     if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL)
     {
@@ -217,8 +230,11 @@
     ClientCcb->Fcb = Fcb;
     ClientCcb->PipeEnd = FILE_PIPE_CLIENT_END;
     ClientCcb->OtherSide = NULL;
-//    ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
+    ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
+#else
     ClientCcb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
+#endif
     InitializeListHead(&ClientCcb->ReadRequestListHead);
 
     DPRINT("CCB: %p\n", ClientCcb);
@@ -256,10 +272,10 @@
     /*
     * Step 3. Search for listening server CCB.
     */
-/*
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
     if (!SpecialAccess)
     {
-*/
+#endif
         /*
         * WARNING: Point of no return! Once we get the server CCB it's
         * possible that we completed a wait request and so we have to
@@ -315,7 +331,7 @@
             /* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
             NpfsSignalAndRemoveListeningServerInstance(Fcb, ServerCcb);
         }
-/*
+#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
     }
     else if (IsListEmpty(&Fcb->ServerCcbListHead))
     {
@@ -333,7 +349,7 @@
         IoCompleteRequest(Irp, IO_NO_INCREMENT);
         return STATUS_UNSUCCESSFUL;
     }
-*/
+#endif
 
     /*
     * Step 4. Add the client CCB to a list and connect it if possible.

Modified: trunk/reactos/drivers/filesystems/npfs/fsctrl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/fsctrl.c?rev=49701&r1=49700&r2=49701&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] Sun Nov 21 23:15:11 2010
@@ -15,6 +15,8 @@
 #define NDEBUG
 #include <debug.h>
 
+//#define USING_PROPER_NPFS_WAIT_SEMANTICS
+
 /* FUNCTIONS *****************************************************************/
 
 static DRIVER_CANCEL NpfsListeningCancelRoutine;
@@ -293,18 +295,21 @@
              PNPFS_CCB Ccb)
 {
     PLIST_ENTRY current_entry;
-    PNPFS_VCB Vcb;
     PNPFS_FCB Fcb;
     PNPFS_CCB ServerCcb;
     PFILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
     LARGE_INTEGER TimeOut;
+    NTSTATUS Status;
+#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
+    PNPFS_VCB Vcb;
     UNICODE_STRING PipeName;
-    NTSTATUS Status;
+#endif
 
     DPRINT("NpfsWaitPipe\n");
 
     WaitPipe = (PFILE_PIPE_WAIT_FOR_BUFFER)Irp->AssociatedIrp.SystemBuffer;
 
+#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
     /* Fail, if the CCB does not represent the root directory */
     if (Ccb->Type != CCB_DIRECTORY)
         return STATUS_ILLEGAL_FUNCTION;
@@ -352,6 +357,15 @@
     }
 
     DPRINT("Fcb %p\n", Fcb);
+#else
+    Fcb = Ccb->Fcb;
+
+    if (Ccb->PipeState != 0)
+    {
+        DPRINT("Pipe is not in passive (waiting) state!\n");
+        return STATUS_UNSUCCESSFUL;
+    }
+#endif
 
     /* search for listening server */
     current_entry = Fcb->ServerCcbListHead.Flink;




More information about the Ros-diffs mailing list