[Wine-patches] [8/8] ntoskrnl.exe: Use IoBuildDeviceIoControlRequest in process_ioctl.

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


----------- следующая часть -----------
From 5ecc4125f8bd16d6fa6cc458c3164d547245d5fc Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 5 Dec 2008 17:35:35 +0300
Subject: [PATCH] ntoskrnl.exe: Use IoBuildDeviceIoControlRequest in process_ioctl.

---
 dlls/ntoskrnl.exe/ntoskrnl.c |   60 ++++++-----------------------------------
 1 files changed, 9 insertions(+), 51 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index fad71b9..b3be752 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -232,77 +232,35 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
                                void *out_buff, ULONG *out_size )
 {
     PIRP irp;
-    MDL mdl;
     PIO_STACK_LOCATION irpsp;
     NTSTATUS status;
     LARGE_INTEGER count;
-    CHAR *buf = NULL;
+    IO_STATUS_BLOCK iosb;
 #ifdef __i386__
     PVOID mem_handler;
 #endif
 
     TRACE( "ioctl %x device %p in_size %u out_size %u\n", code, device, in_size, *out_size );
 
-#ifdef __i386__
-    mem_handler = RtlAddVectoredExceptionHandler( FALSE, memory_handler );
-#endif
-
-    irp = IoAllocateIrp( device->StackSize, FALSE );
+    irp = IoBuildDeviceIoControlRequest( code, device, in_buff, in_size,
+            out_buff, *out_size, FALSE, NULL, &iosb );
     if (irp == NULL)
-        return STATUS_UNSUCCESSFUL;
+        return STATUS_NO_MEMORY;
     irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation - 1;
-
-    switch (code & 3)
-    {
-    case METHOD_BUFFERED:
-        buf = ExAllocatePool( NonPagedPool, (*out_size > in_size) ? *out_size : in_size );
-        if (buf == NULL)
-        {
-            IoFreeIrp( irp );
-            return STATUS_UNSUCCESSFUL;
-        }
-        memcpy( buf, in_buff, in_size );
-        irp->AssociatedIrp.SystemBuffer = buf;
-        irp->UserBuffer = out_buff;
-        break;
-    case METHOD_NEITHER:
-        irpsp->Parameters.DeviceIoControl.Type3InputBuffer = in_buff;
-        irp->UserBuffer = out_buff;
-        break;
-    default:
-        irp->AssociatedIrp.SystemBuffer = in_buff;
-        irp->MdlAddress = &mdl;
-        mdl.Next = NULL;
-        mdl.Size = 0;
-        mdl.StartVa = out_buff;
-        mdl.ByteCount = *out_size;
-        mdl.ByteOffset = 0;
-    }
-
     irp->RequestorMode = UserMode;
     irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
-    irpsp->MajorFunction = IRP_MJ_DEVICE_CONTROL;
-    irpsp->Parameters.DeviceIoControl.OutputBufferLength = *out_size;
-    irpsp->Parameters.DeviceIoControl.InputBufferLength = in_size;
-    irpsp->Parameters.DeviceIoControl.IoControlCode = code;
     irpsp->DeviceObject = device;
     device->CurrentIrp = irp;
-
+#ifdef __i386__
+    mem_handler = RtlAddVectoredExceptionHandler( FALSE, memory_handler );
+#endif
     KeQueryTickCount( &count );  /* update the global KeTickCount */
-    __regs_IofCallDriver( device, irp );
-    status = irp->IoStatus.u.Status;
-    *out_size = (status >= 0) ? irp->IoStatus.Information : 0;
-    IoFreeIrp( irp );
-    if (buf != NULL)
-    {
-        memcpy( out_buff, buf, *out_size );
-        ExFreePool( buf );
-    }
+    status = __regs_IofCallDriver( device, irp );
 #ifdef __i386__
     RtlRemoveVectoredExceptionHandler( mem_handler );
     unmap_memory();
 #endif
-
+    *out_size = (status == STATUS_SUCCESS) ? iosb.Information : 0;
     return status;
 }
 
-- 
1.6.0.2.GIT



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