diff --git a/reactos/drivers/fs/vfat/blockdev.c b/reactos/drivers/fs/vfat/blockdev.c index 546ac417fe2..7de0fae949a 100644 --- a/reactos/drivers/fs/vfat/blockdev.c +++ b/reactos/drivers/fs/vfat/blockdev.c @@ -19,6 +19,29 @@ /* 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; + IoFreeMdl(Mdl); + } + + *Irp->UserIosb = Irp->IoStatus; + KeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, FALSE); + IoFreeIrp(Irp); + + return STATUS_MORE_PROCESSING_REQUIRED; +} + NTSTATUS VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject, IN PLARGE_INTEGER ReadOffset, @@ -57,6 +80,13 @@ VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject, Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME; } + IoSetCompletionRoutine(Irp, + VfatReadWriteCompletion, + NULL, + TRUE, + TRUE, + TRUE); + DPRINT ("Calling IO Driver... with irp %x\n", Irp); Status = IoCallDriver (pDeviceObject, Irp); @@ -111,6 +141,13 @@ VfatWriteDisk (IN PDEVICE_OBJECT pDeviceObject, return (STATUS_UNSUCCESSFUL); } + IoSetCompletionRoutine(Irp, + VfatReadWriteCompletion, + NULL, + TRUE, + TRUE, + TRUE); + DPRINT ("Calling IO Driver...\n"); Status = IoCallDriver (pDeviceObject, Irp);