[Wine-patches] [6/8] mountmgr: Use wine_complete_request before returning from IOCTL handler.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Чт Дек 11 11:47:30 MSK 2008


----------- следующая часть -----------
From 74f789145600a6bcc7b8e7feb6f1bb9ecbe1b728 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 5 Dec 2008 13:33:28 +0300
Subject: [PATCH] mountmgr: Use wine_complete_request before returning from IOCTL handler.

---
 dlls/mountmgr.sys/device.c   |   23 +++++++++++-------
 dlls/mountmgr.sys/mountmgr.c |   54 ++++++++++++++++++++++++++++-------------
 2 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index fc92f22..4e19dfb 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -45,6 +45,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
 
+extern void wine_complete_request( IRP *irp, UCHAR priority_boost );
+
 #define MAX_DOS_DRIVES 26
 
 static const WCHAR drive_types[][8] =
@@ -731,6 +733,7 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
 {
     IO_STACK_LOCATION *irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation;
     struct dos_drive *drive = device->DeviceExtension;
+    NTSTATUS status;
 
     TRACE( "ioctl %x insize %u outsize %u\n",
            irpsp->Parameters.DeviceIoControl.IoControlCode,
@@ -751,7 +754,7 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
         info.BytesPerSector = 512;
         memcpy( irp->AssociatedIrp.SystemBuffer, &info, len );
         irp->IoStatus.Information = len;
-        irp->IoStatus.u.Status = STATUS_SUCCESS;
+        status = STATUS_SUCCESS;
         break;
     }
     case IOCTL_STORAGE_GET_DEVICE_NUMBER:
@@ -760,11 +763,11 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
 
         memcpy( irp->AssociatedIrp.SystemBuffer, &drive->devnum, len );
         irp->IoStatus.Information = len;
-        irp->IoStatus.u.Status = STATUS_SUCCESS;
+        status = STATUS_SUCCESS;
         break;
     }
     case IOCTL_CDROM_READ_TOC:
-        irp->IoStatus.u.Status = STATUS_INVALID_DEVICE_REQUEST;
+        status = STATUS_INVALID_DEVICE_REQUEST;
         break;
     case IOCTL_STORAGE_QUERY_PROPERTY:
     {
@@ -781,14 +784,14 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
             if (irpsp->Parameters.DeviceIoControl.InputBufferLength
                     < sizeof(STORAGE_PROPERTY_QUERY))
             {
-                irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER;
+                status = STATUS_INVALID_PARAMETER;
                 break;
             }
             spq = irp->AssociatedIrp.SystemBuffer;
             if (spq->PropertyId != StorageDeviceProperty ||
                     spq->QueryType != PropertyStandardQuery)
             {
-                irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
+                status = STATUS_NOT_SUPPORTED;
                 break;
             }
             RtlZeroMemory( &sdd, sdd_size );
@@ -796,19 +799,21 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
             sdd.BusType = drive->bus_type;
             memcpy( irp->AssociatedIrp.SystemBuffer, &sdd, len );
             irp->IoStatus.Information = len;
-            irp->IoStatus.u.Status = STATUS_SUCCESS;
+            status = STATUS_SUCCESS;
             break;
         default:
-            irp->IoStatus.u.Status = STATUS_INVALID_DEVICE_REQUEST;
+            status = STATUS_INVALID_DEVICE_REQUEST;
         }
         break;
     }
     default:
         FIXME( "unsupported ioctl %x\n", irpsp->Parameters.DeviceIoControl.IoControlCode );
-        irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
+        status = STATUS_NOT_SUPPORTED;
         break;
     }
-    return irp->IoStatus.u.Status;
+    irp->IoStatus.u.Status = status;
+    wine_complete_request( irp, IO_NO_INCREMENT );
+    return status;
 }
 
 /* driver entry point for the harddisk driver */
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index e5aa0f9..3581b68 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -33,6 +33,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
 
+extern void wine_complete_request( IRP *irp, UCHAR priority_boost );
+
 #define MIN_ID_LEN     4
 
 struct mount_point
@@ -353,6 +355,7 @@ static NTSTATUS query_unix_drive( const void *in_buff, SIZE_T insize,
 static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp )
 {
     IO_STACK_LOCATION *irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation;
+    NTSTATUS status;
 
     TRACE( "ioctl %x insize %u outsize %u\n",
            irpsp->Parameters.DeviceIoControl.IoControlCode,
@@ -367,24 +370,33 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp )
         ULONG in_size = irpsp->Parameters.DeviceIoControl.InputBufferLength;
 
         if (in_size < sizeof(MOUNTMGR_MOUNT_POINT))
-            return STATUS_INVALID_PARAMETER;
+        {
+            status = STATUS_INVALID_PARAMETER;
+            break;
+        }
         in_buff = ExAllocatePool( NonPagedPool, in_size );
         if (!in_buff)
-            return STATUS_INSUFFICIENT_RESOURCES;
+        {
+            status = STATUS_INSUFFICIENT_RESOURCES;
+            break;
+        }
         memcpy( in_buff, irp->AssociatedIrp.SystemBuffer, in_size );
-        irp->IoStatus.u.Status = query_mount_points( in_buff, in_size,
-                                                     irp->AssociatedIrp.SystemBuffer,
-                                                     irpsp->Parameters.DeviceIoControl.OutputBufferLength,
-                                                     &irp->IoStatus );
+        status = query_mount_points( in_buff, in_size,
+                                     irp->AssociatedIrp.SystemBuffer,
+                                     irpsp->Parameters.DeviceIoControl.OutputBufferLength,
+                                     &irp->IoStatus );
         ExFreePool( in_buff );
         break;
     }
     case IOCTL_MOUNTMGR_DEFINE_UNIX_DRIVE:
         if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_unix_drive))
-            return STATUS_INVALID_PARAMETER;
+        {
+            status = STATUS_INVALID_PARAMETER;
+            break;
+        }
         irp->IoStatus.Information = 0;
-        irp->IoStatus.u.Status = define_unix_drive( irp->AssociatedIrp.SystemBuffer,
-                                                    irpsp->Parameters.DeviceIoControl.InputBufferLength );
+        status = define_unix_drive( irp->AssociatedIrp.SystemBuffer,
+                                    irpsp->Parameters.DeviceIoControl.InputBufferLength );
         break;
     case IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE:
     {
@@ -392,24 +404,32 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp )
         ULONG in_size = irpsp->Parameters.DeviceIoControl.InputBufferLength;
 
         if (in_size < sizeof(struct mountmgr_unix_drive))
-            return STATUS_INVALID_PARAMETER;
+        {
+            status = STATUS_INVALID_PARAMETER;
+            break;
+        }
         in_buff = ExAllocatePool( NonPagedPool, in_size );
         if (!in_buff)
-            return STATUS_INSUFFICIENT_RESOURCES;
+        {
+            status = STATUS_INSUFFICIENT_RESOURCES;
+            break;
+        }
         memcpy( in_buff, irp->AssociatedIrp.SystemBuffer, in_size );
-        irp->IoStatus.u.Status = query_unix_drive( in_buff, in_size,
-                                                   irp->AssociatedIrp.SystemBuffer,
-                                                   irpsp->Parameters.DeviceIoControl.OutputBufferLength,
-                                                   &irp->IoStatus );
+        status = query_unix_drive( in_buff, in_size,
+                                   irp->AssociatedIrp.SystemBuffer,
+                                   irpsp->Parameters.DeviceIoControl.OutputBufferLength,
+                                   &irp->IoStatus );
         ExFreePool( in_buff );
         break;
     }
     default:
         FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode );
-        irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
+        status = STATUS_NOT_SUPPORTED;
         break;
     }
-    return irp->IoStatus.u.Status;
+    irp->IoStatus.u.Status = status;
+    wine_complete_request( irp, IO_NO_INCREMENT );
+    return status;
 }
 
 /* main entry point for the mount point manager driver */
-- 
1.6.0.2.GIT



Подробная информация о списке рассылки Wine-patches