VOID
NTAPI
IopCleanupAfterException(IN PFILE_OBJECT FileObject,
- IN PIRP Irp,
+ IN PIRP Irp OPTIONAL,
IN PKEVENT Event OPTIONAL,
IN PKEVENT LocalEvent OPTIONAL)
{
PAGED_CODE();
IOTRACE(IO_API_DEBUG, "IRP: %p. FO: %p \n", Irp, FileObject);
- /* Check if we had a buffer */
- if (Irp->AssociatedIrp.SystemBuffer)
+ if (Irp)
{
- /* Free it */
- ExFreePool(Irp->AssociatedIrp.SystemBuffer);
- }
+ /* Check if we had a buffer */
+ if (Irp->AssociatedIrp.SystemBuffer)
+ {
+ /* Free it */
+ ExFreePool(Irp->AssociatedIrp.SystemBuffer);
+ }
- /* Free the mdl */
- if (Irp->MdlAddress) IoFreeMdl(Irp->MdlAddress);
+ /* Free the mdl */
+ if (Irp->MdlAddress) IoFreeMdl(Irp->MdlAddress);
- /* Free the IRP */
- IoFreeIrp(Irp);
+ /* Free the IRP */
+ IoFreeIrp(Irp);
+ }
/* Check if we had a file lock */
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
ACCESS_MASK DesiredAccess;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
ULONG BufferLength;
+
+ PAGED_CODE();
+
IOTRACE(IO_CTL_DEBUG, "Handle: %p. CTL: %lx. Type: %lx \n",
DeviceHandle, IoControlCode, IsDevIoCtl);
DeviceObject = IoGetRelatedDeviceObject(FileObject);
}
- /* If that's FS I/O, try to do it with FastIO path */
- if (!IsDevIoCtl)
+ /* If this is a device I/O, try to do it with FastIO path */
+ if (IsDevIoCtl)
{
PFAST_IO_DISPATCH FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Use deferred completion for FS I/O */
Irp->Flags |= (!IsDevIoCtl) ? IRP_DEFER_IO_COMPLETION : 0;
+ /* If we're to dismount a volume, increaase the dismount count */
+ if (IoControlCode == FSCTL_DISMOUNT_VOLUME)
+ {
+ InterlockedExchangeAdd((PLONG)&SharedUserData->DismountCount, 1);
+ }
+
/* Perform the call */
return IopPerformSynchronousRequest(DeviceObject,
Irp,