- Use IoBuildAsynchronousFsdRequest instead IoBuildSynchronousFsdRequest
in NtRead/WriteFile.
- Guard the calls to IoBuildAsynchronousFsdRequest with an exception
frame.
Modified: trunk/reactos/ntoskrnl/io/rw.c
_____
Modified: trunk/reactos/ntoskrnl/io/rw.c
--- trunk/reactos/ntoskrnl/io/rw.c 2005-04-01 18:19:46 UTC (rev
14420)
+++ trunk/reactos/ntoskrnl/io/rw.c 2005-04-01 18:22:17 UTC (rev
14421)
@@ -44,7 +44,7 @@
{
NTSTATUS Status;
PFILE_OBJECT FileObject;
- PIRP Irp;
+ PIRP Irp = NULL;
PIO_STACK_LOCATION StackPtr;
KPROCESSOR_MODE PreviousMode;
PKEVENT EventObject = NULL;
@@ -92,25 +92,53 @@
PreviousMode,
(PVOID*)&EventObject,
NULL);
- if (!NT_SUCCESS(Status))
- {
- ObDereferenceObject(FileObject);
- return Status;
- }
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject(FileObject);
+ return Status;
+ }
KeClearEvent(EventObject);
}
+ _SEH_TRY
+ {
+ Irp = IoBuildAsynchronousFsdRequest(IRP_MJ_READ,
+ FileObject->DeviceObject,
+ Buffer,
+ Length,
+ ByteOffset,
+ IoStatusBlock);
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
+ if (!NT_SUCCESS(Status) || Irp == NULL)
+ {
+ if (Event)
+ {
+ ObDereferenceObject(&EventObject);
+ }
+ ObDereferenceObject(FileObject);
+ if (Irp)
+ {
+ IoFreeIrp(Irp);
+ }
+ return NT_SUCCESS(Status) ? STATUS_INSUFFICIENT_RESOURCES :
Status;
+ }
+
+ Irp->UserEvent = Event;
+ if (FileObject->Flags & FO_SYNCHRONOUS_IO)
+ {
+ /* synchronous irp's are queued to requestor thread's irp
cancel/cleanup list */
+ IoQueueThreadIrp(Irp);
+ }
+
KeClearEvent(&FileObject->Event);
- Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
- FileObject->DeviceObject,
- Buffer,
- Length,
- ByteOffset,
- EventObject,
- IoStatusBlock);
-
/* Trigger FileObject/Event dereferencing */
Irp->Tail.Overlay.OriginalFileObject = FileObject;
@@ -172,7 +200,7 @@
OBJECT_HANDLE_INFORMATION HandleInformation;
NTSTATUS Status;
PFILE_OBJECT FileObject;
- PIRP Irp;
+ PIRP Irp = NULL;
PIO_STACK_LOCATION StackPtr;
KPROCESSOR_MODE PreviousMode;
PKEVENT EventObject = NULL;
@@ -253,16 +281,44 @@
KeClearEvent(EventObject);
}
+ _SEH_TRY
+ {
+ Irp = IoBuildAsynchronousFsdRequest(IRP_MJ_WRITE,
+ FileObject->DeviceObject,
+ Buffer,
+ Length,
+ ByteOffset,
+ IoStatusBlock);
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
+ if (!NT_SUCCESS(Status) || Irp == NULL)
+ {
+ if (Event)
+ {
+ ObDereferenceObject(&EventObject);
+ }
+ ObDereferenceObject(FileObject);
+ if (Irp)
+ {
+ IoFreeIrp(Irp);
+ }
+ return NT_SUCCESS(Status) ? STATUS_INSUFFICIENT_RESOURCES :
Status;
+ }
+
+ Irp->UserEvent = Event;
+ if (FileObject->Flags & FO_SYNCHRONOUS_IO)
+ {
+ /* synchronous irp's are queued to requestor thread's irp
cancel/cleanup list */
+ IoQueueThreadIrp(Irp);
+ }
+
KeClearEvent(&FileObject->Event);
- Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
- FileObject->DeviceObject,
- Buffer,
- Length,
- ByteOffset,
- EventObject,
- IoStatusBlock);
-
/* Trigger FileObject/Event dereferencing */
Irp->Tail.Overlay.OriginalFileObject = FileObject;