NTSTATUS Status;
PDEVICE_OBJECT DeviceObject;
PVOLUME_DEVICE_OBJECT Volume;
+ PFILE_OBJECT FileObject = NULL;
PAGED_CODE();
/* Remember our owner */
Volume->DeviceObject.SectorSize = DeviceObject->SectorSize;
Volume->DeviceObject.Flags |= DO_DIRECT_IO;
Volume->DeviceObject.Flags &= ~DO_DEVICE_INITIALIZING;
+
+ /* Try to get associated FO (for notification) */
+ _SEH2_TRY
+ {
+ FileObject = IoCreateStreamFileObjectLite(NULL,
+ &(Volume->DeviceObject));
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ /* Get the exception code */
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ /* If failed, delete devive */
+ if (!NT_SUCCESS(Status))
+ {
+ IoDeleteDevice((PDEVICE_OBJECT)Volume);
+ return Status;
+ }
+
+ /* Increment OpenCount by two to avoid dismount when RawClose() will be called on ObDereferenceObject() */
+ Volume->Vcb.OpenCount += 2;
+ /* Notify for sucessful mount */
+ FsRtlNotifyVolumeEvent(FileObject, FSRTL_VOLUME_MOUNT);
+ /* Decrease refcount to 0 to make FileObject being released */
+ ObDereferenceObject(FileObject);
+ /* It's not open anymore, go back to 0 */
+ Volume->Vcb.OpenCount -= 2;
+
return Status;
}
break;
}
- /* Unlock device and return */
+ /* Unlock device */
KeReleaseMutex(&Vcb->Mutex, FALSE);
+
+ /* In case of status change, notify */
+ switch (IoStackLocation->Parameters.FileSystemControl.FsControlCode)
+ {
+ case FSCTL_LOCK_VOLUME:
+ FsRtlNotifyVolumeEvent(IoStackLocation->FileObject, (NT_SUCCESS(Status) ? FSRTL_VOLUME_LOCK : FSRTL_VOLUME_LOCK_FAILED));
+ break;
+ case FSCTL_UNLOCK_VOLUME:
+ if (NT_SUCCESS(Status))
+ {
+ FsRtlNotifyVolumeEvent(IoStackLocation->FileObject, FSRTL_VOLUME_UNLOCK);
+ }
+ break;
+ case FSCTL_DISMOUNT_VOLUME:
+ FsRtlNotifyVolumeEvent(IoStackLocation->FileObject, (NT_SUCCESS(Status) ? FSRTL_VOLUME_DISMOUNT : FSRTL_VOLUME_DISMOUNT_FAILED));
+ break;
+ }
+
return Status;
}
IN PIO_STACK_LOCATION IoStackLocation)
{
NTSTATUS Status = STATUS_INVALID_DEVICE_REQUEST;
- PULONG Length;
PFILE_POSITION_INFORMATION Buffer;
PDEVICE_OBJECT DeviceObject;
PAGED_CODE();
/* Get information from the IRP */
- Length = &IoStackLocation->Parameters.QueryFile.Length;
Buffer = Irp->AssociatedIrp.SystemBuffer;
/* We only handle this request */
NTSTATUS
NTAPI
+INIT_FUNCTION
RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{