mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +00:00
- Remove completion routine for VfatReadDisk. IRPs build with IoBuildSynchronousFsdRequest mustn't be freed by IoFreeIrp, because they're still associated with a thread.
- Don't call IoBuildAsynchronousFsdRequest with NULL buffer for read/write requests. It's explicitly prohibited per DDK documentation and causes crashes on Windows (R) NT systems. svn path=/trunk/; revision=10395
This commit is contained in:
parent
8db63af2d6
commit
f167814f32
1 changed files with 39 additions and 58 deletions
|
@ -19,35 +19,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
VfatReadWriteCompletion (IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
PMDL Mdl;
|
|
||||||
|
|
||||||
DPRINT("VfatReadBlockDeviceCompletion(DeviceObject %x, Irp %x, Context %x)\n",
|
|
||||||
DeviceObject, Irp, Context);
|
|
||||||
|
|
||||||
while ((Mdl = Irp->MdlAddress))
|
|
||||||
{
|
|
||||||
Irp->MdlAddress = Mdl->Next;
|
|
||||||
|
|
||||||
MmUnlockPages(Mdl);
|
|
||||||
IoFreeMdl(Mdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
*Irp->UserIosb = Irp->IoStatus;
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
{
|
|
||||||
KeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
IoFreeIrp(Irp);
|
|
||||||
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
VfatReadWritePartialCompletion (IN PDEVICE_OBJECT DeviceObject,
|
VfatReadWritePartialCompletion (IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
|
@ -123,13 +94,6 @@ VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject,
|
||||||
Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
|
Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp,
|
|
||||||
VfatReadWriteCompletion,
|
|
||||||
NULL,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
DPRINT ("Calling IO Driver... with irp %x\n", Irp);
|
DPRINT ("Calling IO Driver... with irp %x\n", Irp);
|
||||||
Status = IoCallDriver (pDeviceObject, Irp);
|
Status = IoCallDriver (pDeviceObject, Irp);
|
||||||
|
|
||||||
|
@ -161,29 +125,38 @@ VfatReadDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
||||||
IN BOOLEAN Wait)
|
IN BOOLEAN Wait)
|
||||||
{
|
{
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
|
|
||||||
DPRINT ("VfatReadDiskPartial(IrpContext %x, ReadOffset %I64x, ReadLength %d, BufferOffset %x, Wait %d)\n",
|
DPRINT ("VfatReadDiskPartial(IrpContext %x, ReadOffset %I64x, ReadLength %d, BufferOffset %x, Wait %d)\n",
|
||||||
IrpContext, ReadOffset->QuadPart, ReadLength, BufferOffset, Wait);
|
IrpContext, ReadOffset->QuadPart, ReadLength, BufferOffset, Wait);
|
||||||
|
|
||||||
DPRINT ("Building synchronous FSD Request...\n");
|
DPRINT ("Building asynchronous FSD Request...\n");
|
||||||
|
|
||||||
Buffer = MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
|
Buffer = MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
|
||||||
|
|
||||||
Irp = IoBuildSynchronousFsdRequest (IRP_MJ_READ,
|
Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
|
||||||
IrpContext->DeviceExt->StorageDevice,
|
|
||||||
NULL,
|
|
||||||
ReadLength,
|
|
||||||
ReadOffset,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if (Irp == NULL)
|
if (Irp == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("IoBuildSynchronousFsdRequest failed\n");
|
DPRINT("IoAllocateIrp failed\n");
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Irp->UserIosb = NULL;
|
||||||
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = IRP_MJ_READ;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = IrpContext->DeviceExt->StorageDevice;
|
||||||
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->CompletionRoutine = NULL;
|
||||||
|
StackPtr->Parameters.Read.Length = ReadLength;
|
||||||
|
StackPtr->Parameters.Read.ByteOffset = *ReadOffset;
|
||||||
|
|
||||||
if (!IoAllocateMdl(Buffer, ReadLength, FALSE, FALSE, Irp))
|
if (!IoAllocateMdl(Buffer, ReadLength, FALSE, FALSE, Irp))
|
||||||
{
|
{
|
||||||
DPRINT("IoAllocateMdl failed\n");
|
DPRINT("IoAllocateMdl failed\n");
|
||||||
|
@ -232,6 +205,7 @@ VfatWriteDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
||||||
IN BOOLEAN Wait)
|
IN BOOLEAN Wait)
|
||||||
{
|
{
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
|
|
||||||
|
@ -240,21 +214,28 @@ VfatWriteDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
||||||
|
|
||||||
Buffer = MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
|
Buffer = MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
|
||||||
|
|
||||||
DPRINT ("Building synchronous FSD Request...\n");
|
DPRINT ("Building asynchronous FSD Request...\n");
|
||||||
Irp = IoBuildSynchronousFsdRequest (IRP_MJ_WRITE,
|
Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
|
||||||
IrpContext->DeviceExt->StorageDevice,
|
if (Irp == NULL)
|
||||||
NULL,
|
|
||||||
WriteLength,
|
|
||||||
WriteOffset,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (!Irp)
|
|
||||||
{
|
{
|
||||||
DPRINT ("WRITE failed!!!\n");
|
DPRINT("IoAllocateIrp failed\n");
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Irp->UserIosb = NULL;
|
||||||
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = IRP_MJ_WRITE;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = IrpContext->DeviceExt->StorageDevice;
|
||||||
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->CompletionRoutine = NULL;
|
||||||
|
StackPtr->Parameters.Read.Length = WriteLength;
|
||||||
|
StackPtr->Parameters.Read.ByteOffset = *WriteOffset;
|
||||||
|
|
||||||
if (!IoAllocateMdl(Buffer, WriteLength, FALSE, FALSE, Irp))
|
if (!IoAllocateMdl(Buffer, WriteLength, FALSE, FALSE, Irp))
|
||||||
{
|
{
|
||||||
DPRINT("IoAllocateMdl failed\n");
|
DPRINT("IoAllocateMdl failed\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue