[Wine-patches] [3/3] mountmgr.sys: Fix METHOD_BUFFERED IOCTLs.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Окт 31 14:56:24 MSK 2008


----------- следующая часть -----------
From b9f0a3debc37150916635be02f81f79860c4bcaf Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 31 Oct 2008 13:52:53 +0300
Subject: [PATCH] mountmgr.sys: Fix METHOD_BUFFERED IOCTLs.

---
 dlls/mountmgr.sys/device.c   |    4 ++--
 dlls/mountmgr.sys/mountmgr.c |   36 +++++++++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 3377563..a0e7cf0 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -615,7 +615,7 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
         info.TracksPerCylinder = 255;
         info.SectorsPerTrack = 63;
         info.BytesPerSector = 512;
-        memcpy( irp->MdlAddress->StartVa, &info, len );
+        memcpy( irp->AssociatedIrp.SystemBuffer, &info, len );
         irp->IoStatus.Information = len;
         irp->IoStatus.u.Status = STATUS_SUCCESS;
         break;
@@ -624,7 +624,7 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
     {
         DWORD len = min( sizeof(drive->devnum), irpsp->Parameters.DeviceIoControl.OutputBufferLength );
 
-        memcpy( irp->MdlAddress->StartVa, &drive->devnum, len );
+        memcpy( irp->AssociatedIrp.SystemBuffer, &drive->devnum, len );
         irp->IoStatus.Information = len;
         irp->IoStatus.u.Status = STATUS_SUCCESS;
         break;
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index 3c1aa88..ab9363d 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -333,30 +333,48 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp )
     switch(irpsp->Parameters.DeviceIoControl.IoControlCode)
     {
     case IOCTL_MOUNTMGR_QUERY_POINTS:
-        if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(MOUNTMGR_MOUNT_POINT))
+    {
+        void *in_buff;
+        ULONG in_size = irpsp->Parameters.DeviceIoControl.InputBufferLength;
+
+        if (in_size < sizeof(MOUNTMGR_MOUNT_POINT))
             return STATUS_INVALID_PARAMETER;
-        irp->IoStatus.u.Status = query_mount_points( irpsp->Parameters.DeviceIoControl.Type3InputBuffer,
-                                                     irpsp->Parameters.DeviceIoControl.InputBufferLength,
-                                                     irp->MdlAddress->StartVa,
+        in_buff = ExAllocatePool( NonPagedPool, in_size );
+        if (!in_buff)
+            return STATUS_INSUFFICIENT_RESOURCES;
+        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 );
+        ExFreePool( in_buff );
         break;
+    }
     case IOCTL_MOUNTMGR_DEFINE_UNIX_DRIVE:
         if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_unix_drive))
             return STATUS_INVALID_PARAMETER;
         irp->IoStatus.Information = 0;
-        irp->IoStatus.u.Status = define_unix_drive( irpsp->Parameters.DeviceIoControl.Type3InputBuffer,
+        irp->IoStatus.u.Status = define_unix_drive( irp->AssociatedIrp.SystemBuffer,
                                                     irpsp->Parameters.DeviceIoControl.InputBufferLength );
         break;
     case IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE:
-        if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_unix_drive))
+    {
+        void *in_buff;
+        ULONG in_size = irpsp->Parameters.DeviceIoControl.InputBufferLength;
+
+        if (in_size < sizeof(struct mountmgr_unix_drive))
             return STATUS_INVALID_PARAMETER;
-        irp->IoStatus.u.Status = query_unix_drive( irpsp->Parameters.DeviceIoControl.Type3InputBuffer,
-                                                   irpsp->Parameters.DeviceIoControl.InputBufferLength,
-                                                   irp->MdlAddress->StartVa,
+        in_buff = ExAllocatePool( NonPagedPool, in_size );
+        if (!in_buff)
+            return STATUS_INSUFFICIENT_RESOURCES;
+        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 );
+        ExFreePool( in_buff );
         break;
+    }
     default:
         FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode );
         irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
-- 
1.5.6.5.GIT



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