- Fix for completion of file system control IRPs.

svn path=/trunk/; revision=5883
This commit is contained in:
David Welch 2003-08-27 20:57:09 +00:00
parent 927f2ae503
commit 9768ea066d

View file

@ -20,13 +20,26 @@
#include <internal/debug.h> #include <internal/debug.h>
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject, VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject,
PIRP Irp, PIRP Irp,
PIO_STACK_LOCATION IoStack) PIO_STACK_LOCATION IoStack)
{ {
ULONG IoControlCode; ULONG IoControlCode;
ULONG OutputBufferLength;
if (IoStack->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL)
{
IoControlCode =
((PEXTENDED_IO_STACK_LOCATION)IoStack)->Parameters.FileSystemControl.FsControlCode;
OutputBufferLength =
((PEXTENDED_IO_STACK_LOCATION)IoStack)->Parameters.FileSystemControl.OutputBufferLength;
}
else
{
IoControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode; IoControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
OutputBufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
}
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode)) switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
{ {
@ -36,11 +49,10 @@ VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject,
/* copy output buffer back and free it */ /* copy output buffer back and free it */
if (Irp->AssociatedIrp.SystemBuffer) if (Irp->AssociatedIrp.SystemBuffer)
{ {
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength) if (OutputBufferLength)
{ {
RtlCopyMemory(Irp->UserBuffer, RtlCopyMemory(Irp->UserBuffer,
Irp->AssociatedIrp.SystemBuffer, Irp->AssociatedIrp.SystemBuffer,
IoStack->Parameters.DeviceIoControl.
OutputBufferLength); OutputBufferLength);
} }
ExFreePool (Irp->AssociatedIrp.SystemBuffer); ExFreePool (Irp->AssociatedIrp.SystemBuffer);
@ -53,11 +65,10 @@ VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject,
/* copy output buffer back and free it */ /* copy output buffer back and free it */
if (Irp->AssociatedIrp.SystemBuffer) if (Irp->AssociatedIrp.SystemBuffer)
{ {
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength) if (OutputBufferLength)
{ {
RtlCopyMemory(Irp->UserBuffer, RtlCopyMemory(Irp->UserBuffer,
Irp->AssociatedIrp.SystemBuffer, Irp->AssociatedIrp.SystemBuffer,
IoStack->Parameters.DeviceIoControl.
OutputBufferLength); OutputBufferLength);
} }
ExFreePool (Irp->AssociatedIrp.SystemBuffer); ExFreePool (Irp->AssociatedIrp.SystemBuffer);
@ -194,6 +205,7 @@ IoSecondStageCompletion(
case IRP_MJ_DEVICE_CONTROL: case IRP_MJ_DEVICE_CONTROL:
case IRP_MJ_INTERNAL_DEVICE_CONTROL: case IRP_MJ_INTERNAL_DEVICE_CONTROL:
case IRP_MJ_FILE_SYSTEM_CONTROL:
IoDeviceControlCompletion(DeviceObject, Irp, IoStack); IoDeviceControlCompletion(DeviceObject, Irp, IoStack);
break; break;