- 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;
IoControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode; 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;
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);
@ -184,26 +195,27 @@ IoSecondStageCompletion(
{ {
case IRP_MJ_CREATE: case IRP_MJ_CREATE:
case IRP_MJ_FLUSH_BUFFERS: case IRP_MJ_FLUSH_BUFFERS:
/* NOP */ /* NOP */
break; break;
case IRP_MJ_READ: case IRP_MJ_READ:
case IRP_MJ_WRITE: case IRP_MJ_WRITE:
IoReadWriteCompletion(DeviceObject,Irp,IoStack); IoReadWriteCompletion(DeviceObject,Irp,IoStack);
break; break;
case IRP_MJ_DEVICE_CONTROL: case IRP_MJ_DEVICE_CONTROL:
case IRP_MJ_INTERNAL_DEVICE_CONTROL: case IRP_MJ_INTERNAL_DEVICE_CONTROL:
IoDeviceControlCompletion(DeviceObject, Irp, IoStack); case IRP_MJ_FILE_SYSTEM_CONTROL:
break; IoDeviceControlCompletion(DeviceObject, Irp, IoStack);
break;
case IRP_MJ_QUERY_VOLUME_INFORMATION: case IRP_MJ_QUERY_VOLUME_INFORMATION:
case IRP_MJ_SET_VOLUME_INFORMATION: case IRP_MJ_SET_VOLUME_INFORMATION:
IoVolumeInformationCompletion(DeviceObject, Irp, IoStack); IoVolumeInformationCompletion(DeviceObject, Irp, IoStack);
break; break;
default: default:
break; break;
} }
if (Irp->UserIosb!=NULL) if (Irp->UserIosb!=NULL)