[ros-diffs] [ion] 24996: - Fix critical I/O bugs in IopParseFile which were causing the file object's device object pointer to be associated to the FSD (File System Device) instead of the Disk Driver, as well as the dereference of the FSD after the Disk Driver had been referenced (causing too many derefs for one, and to many refs for the other). Also fix a bug in IopQueryDeviceInformation which was querying the Disk Driver instead of the FSD. - This also fixes IopQueryNameFile to properly return the entire name of the file now, instead of only the FSD part (probably fixes a dozen regressions).

ion at svn.reactos.org ion at svn.reactos.org
Thu Nov 30 19:04:22 CET 2006


Author: ion
Date: Thu Nov 30 21:04:22 2006
New Revision: 24996

URL: http://svn.reactos.org/svn/reactos?rev=24996&view=rev
Log:
- Fix critical I/O bugs in IopParseFile which were causing the file object's device object pointer to be associated to the FSD (File System Device) instead of the Disk Driver, as well as the dereference of the FSD after the Disk Driver had been referenced (causing too many derefs for one, and to many refs for the other). Also fix a bug in IopQueryDeviceInformation which was querying the Disk Driver instead of the FSD.
- This also fixes IopQueryNameFile to properly return the entire name of the file now, instead of only the FSD part (probably fixes a dozen regressions).

Modified:
    trunk/reactos/ntoskrnl/io/iomgr/file.c
    trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
    trunk/reactos/ntoskrnl/mm/section.c

Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/file.c?rev=24996&r1=24995&r2=24996&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/file.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/file.c Thu Nov 30 21:04:22 2006
@@ -101,7 +101,7 @@
         !(OpenPacket->RelatedFileObject->Flags & FO_DIRECT_DEVICE_OPEN))
     {
         /* The device object is the one we were given */
-        DeviceObject = OriginalDeviceObject;
+        DeviceObject = ParseObject;
 
         /* Check if the related FO had a VPB */
         if (OpenPacket->RelatedFileObject->Vpb)
@@ -119,11 +119,11 @@
         DeviceObject = OriginalDeviceObject;
 
         /* Check if it has a VPB */
-        if ((DeviceObject->Vpb) && !(DirectOpen))
+        if ((OriginalDeviceObject->Vpb) && !(DirectOpen))
         {
             /* Check if the VPB is mounted, and mount it */
             Vpb = IopCheckVpbMounted(OpenPacket,
-                                     DeviceObject,
+                                     OriginalDeviceObject,
                                      RemainingName,
                                      &Status);
             if (!Vpb) return Status;
@@ -145,7 +145,7 @@
     if (!Irp)
     {
         /* Dereference the device and VPB, then fail */
-        IopDereferenceDeviceObject(DeviceObject, FALSE);
+        IopDereferenceDeviceObject(OriginalDeviceObject, FALSE);
         if (Vpb) IopDereferenceVpb(Vpb);
         return STATUS_INSUFFICIENT_RESOURCES;
     }
@@ -243,7 +243,7 @@
             IoFreeIrp(Irp);
 
             /* Dereference the device and VPB */
-            IopDereferenceDeviceObject(DeviceObject, FALSE);
+            IopDereferenceDeviceObject(OriginalDeviceObject, FALSE);
             if (Vpb) IopDereferenceVpb(Vpb);
 
             /* We failed, return status */
@@ -320,7 +320,7 @@
     FileObject->Type = IO_TYPE_FILE;
     FileObject->Size = sizeof(FILE_OBJECT);
     FileObject->RelatedFileObject = OpenPacket->RelatedFileObject;
-    FileObject->DeviceObject = DeviceObject;
+    FileObject->DeviceObject = OriginalDeviceObject;
 
     /* Check if this is a direct device open */
     if (DirectOpen) FileObject->Flags |= FO_DIRECT_DEVICE_OPEN;
@@ -353,7 +353,7 @@
             IoFreeIrp(Irp);
 
             /* Dereference the device object and VPB */
-            IopDereferenceDeviceObject(DeviceObject, FALSE);
+            IopDereferenceDeviceObject(OriginalDeviceObject, FALSE);
             if (Vpb) IopDereferenceVpb(Vpb);
 
             /* Clear the FO and dereference it */
@@ -391,7 +391,7 @@
     {
         /* We'll have to complete it ourselves */
         ASSERT(!Irp->PendingReturned);
-        ASSERT(!Irp->MdlAddress );
+        ASSERT(!Irp->MdlAddress);
 
         /* Completion happens at APC_LEVEL */
         KeRaiseIrql(APC_LEVEL, &OldIrql);
@@ -445,7 +445,10 @@
         /* Dereference the file object */
         if (!UseDummyFile) ObDereferenceObject(FileObject);
 
-        /* Unless the driver canelled the open, dereference the VPB */
+        /* Dereference the device object */
+        IopDereferenceDeviceObject(OriginalDeviceObject, FALSE);
+
+        /* Unless the driver cancelled the open, dereference the VPB */
         if (!(OpenCancelled) && (Vpb)) IopDereferenceVpb(Vpb);
 
         /* Set the status and return */
@@ -929,10 +932,6 @@
     if (!LocalInfo) return STATUS_INSUFFICIENT_RESOURCES;
 
     /* Query the name */
-    DPRINT("Do. Drv, DrvName: %p %p %wZ\n",
-           FileObject->DeviceObject,
-           FileObject->DeviceObject->DriverObject,
-           &FileObject->DeviceObject->DriverObject->DriverName);
     Status = ObQueryNameString(FileObject->DeviceObject,
                                LocalInfo,
                                Length,
@@ -1416,7 +1415,7 @@
         else if ((OpenPacket.FileObject) && (OpenPacket.ParseCheck != 1))
         {
             /*
-             * This can happen in the very bizare case where the parse routine
+             * This can happen in the very bizarre case where the parse routine
              * actually executed more then once (due to a reparse) and ended
              * up failing after already having created the File Object.
              */

Modified: trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iofunc.c?rev=24996&r1=24995&r2=24996&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/iofunc.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/iofunc.c Thu Nov 30 21:04:22 2006
@@ -450,7 +450,7 @@
     //IopQueueIrpToThread(Irp);
 
     /* Call the Driver */
-    Status = IoCallDriver(FileObject->DeviceObject, Irp);
+    Status = IoCallDriver(DeviceObject, Irp);
 
     /* Check if this was synch I/O */
     if (!LocalEvent)

Modified: trunk/reactos/ntoskrnl/mm/section.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=24996&r1=24995&r2=24996&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c (original)
+++ trunk/reactos/ntoskrnl/mm/section.c Thu Nov 30 21:04:22 2006
@@ -3470,7 +3470,6 @@
                             AllocationAttributes,
                             FileHandle,
                             NULL);
-
    if (NT_SUCCESS(Status))
    {
       Status = ObInsertObject ((PVOID)SectionObject,




More information about the Ros-diffs mailing list