mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
fixed bugs and cleaned up (direct io is working now)
svn path=/trunk/; revision=372
This commit is contained in:
@@ -230,6 +230,7 @@ PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||
{
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
ULONG BufferLength;
|
||||
|
||||
DPRINT("IoBuildDeviceIoRequest(IoControlCode %x, DeviceObject %x, "
|
||||
"InputBuffer %x, InputBufferLength %x, OutputBuffer %x, "
|
||||
@@ -259,93 +260,94 @@ PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||
StackPtr->Parameters.DeviceIoControl.InputBufferLength = InputBufferLength;
|
||||
StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferLength;
|
||||
|
||||
if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_BUFFERED)
|
||||
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
|
||||
{
|
||||
ULONG BufferLength;
|
||||
DPRINT("Using METHOD_BUFFERED!\n");
|
||||
case METHOD_BUFFERED:
|
||||
DPRINT("Using METHOD_BUFFERED!\n");
|
||||
|
||||
BufferLength = (InputBufferLength>OutputBufferLength)?InputBufferLength:OutputBufferLength;
|
||||
if (BufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
BufferLength = (InputBufferLength>OutputBufferLength)?InputBufferLength:OutputBufferLength;
|
||||
if (BufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,BufferLength);
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
}
|
||||
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_IN_DIRECT)
|
||||
{
|
||||
DPRINT("Using METHOD_IN_DIRECT!\n");
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
break;
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
case METHOD_IN_DIRECT:
|
||||
DPRINT("Using METHOD_IN_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,InputBufferLength);
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
}
|
||||
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
PMDL Mdl = IoAllocateMdl (OutputBuffer,OutputBufferLength, FALSE, FALSE, Irp);
|
||||
MmProbeAndLockPages (Mdl, UserMode,IoReadAccess);
|
||||
}
|
||||
}
|
||||
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_OUT_DIRECT)
|
||||
{
|
||||
DPRINT("Using METHOD_OUT_DIRECT!\n");
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl (OutputBuffer,OutputBufferLength,FALSE,FALSE,Irp);
|
||||
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoReadAccess);
|
||||
}
|
||||
break;
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
case METHOD_OUT_DIRECT:
|
||||
DPRINT("Using METHOD_OUT_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,InputBufferLength);
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
}
|
||||
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
PMDL Mdl = IoAllocateMdl (OutputBuffer,OutputBufferLength, FALSE, FALSE, Irp);
|
||||
MmProbeAndLockPages (Mdl, UserMode,IoWriteAccess);
|
||||
}
|
||||
}
|
||||
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_NEITHER)
|
||||
{
|
||||
DPRINT("Using METHOD_NEITHER!\n");
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl (OutputBuffer,OutputBufferLength,FALSE,FALSE,Irp);
|
||||
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||
}
|
||||
break;
|
||||
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
StackPtr->Parameters.DeviceIoControl.Type3InputBuffer = InputBuffer;
|
||||
case METHOD_NEITHER:
|
||||
DPRINT("Using METHOD_NEITHER!\n");
|
||||
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
StackPtr->Parameters.DeviceIoControl.Type3InputBuffer = InputBuffer;
|
||||
break;
|
||||
}
|
||||
|
||||
return(Irp);
|
||||
|
||||
@@ -119,57 +119,58 @@ ZwDeviceIoControlFile(
|
||||
StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferSize;
|
||||
|
||||
Status = IoCallDriver(DeviceObject,Irp);
|
||||
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&KEvent,Executive,KernelMode,FALSE,NULL);
|
||||
return(IoStatusBlock->Status);
|
||||
}
|
||||
|
||||
if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_BUFFERED)
|
||||
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
|
||||
{
|
||||
DPRINT ("Using METHOD_BUFFERED!\n");
|
||||
case METHOD_BUFFERED:
|
||||
DPRINT ("Using METHOD_BUFFERED!\n");
|
||||
|
||||
/* copy output buffer back and free it */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
{
|
||||
if (OutputBuffer && OutputBufferSize)
|
||||
/* copy output buffer back and free it */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
{
|
||||
RtlCopyMemory(OutputBuffer,
|
||||
if (OutputBuffer && OutputBufferSize)
|
||||
{
|
||||
RtlCopyMemory(OutputBuffer,
|
||||
Irp->AssociatedIrp.SystemBuffer,
|
||||
OutputBufferSize);
|
||||
}
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
}
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
}
|
||||
}
|
||||
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_IN_DIRECT)
|
||||
{
|
||||
DPRINT ("Using METHOD_IN_DIRECT!\n");
|
||||
break;
|
||||
|
||||
/* free input buffer (control buffer) */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
case METHOD_IN_DIRECT:
|
||||
DPRINT ("Using METHOD_IN_DIRECT!\n");
|
||||
|
||||
/* free output buffer (data transfer buffer) */
|
||||
if (Irp->MdlAddress)
|
||||
IoFreeMdl (Irp->MdlAddress);
|
||||
}
|
||||
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_OUT_DIRECT)
|
||||
{
|
||||
DPRINT ("Using METHOD_OUT_DIRECT!\n");
|
||||
/* free input buffer (control buffer) */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
|
||||
/* free input buffer (control buffer) */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
/* free output buffer (data transfer buffer) */
|
||||
if (Irp->MdlAddress)
|
||||
IoFreeMdl (Irp->MdlAddress);
|
||||
break;
|
||||
|
||||
/* free output buffer (data transfer buffer) */
|
||||
if (Irp->MdlAddress)
|
||||
IoFreeMdl (Irp->MdlAddress);
|
||||
}
|
||||
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_NEITHER)
|
||||
{
|
||||
DPRINT ("Using METHOD_NEITHER!\n");
|
||||
case METHOD_OUT_DIRECT:
|
||||
DPRINT ("Using METHOD_OUT_DIRECT!\n");
|
||||
|
||||
/* nothing to do */
|
||||
/* free input buffer (control buffer) */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
|
||||
/* free output buffer (data transfer buffer) */
|
||||
if (Irp->MdlAddress)
|
||||
IoFreeMdl (Irp->MdlAddress);
|
||||
break;
|
||||
|
||||
case METHOD_NEITHER:
|
||||
DPRINT ("Using METHOD_NEITHER!\n");
|
||||
/* nothing to do */
|
||||
break;
|
||||
}
|
||||
|
||||
return(Status);
|
||||
|
||||
Reference in New Issue
Block a user