Author: pschweitzer
Date: Tue Oct 28 21:59:57 2014
New Revision: 65090
URL: http://svn.reactos.org/svn/reactos?rev=65090&view=rev
Log:
[DISK]
Get ready to enter into the 10th dimension... So:
- Implement support for IRP_MJ_FILE_SYSTEM_CONTROL. Yes... You read well! So, implemented a ScsiDiskFileSystemControl() function. The way it is added to the DriverObject is a big hack, class2 is not supposed to have such requests, so, we do it in its back. Fear!
- Stubplement the NtfsRussinovichism() function. This is the only function we're supposed to call with IRP MJ FSCTRL and with IRP MN USRFSRQST. Its purpose (when its implemented) is to reply back to the M. Russinovich tools (NFI & NTFSInfo) so that they can directly dump NTFS information without going into NTFS driver. They kind of bypass it.
We do all agree this is a ugly hack. But it exists in Windows, as these tools work in Windows. And it would be useful they actually work in ReactOS.
Soon, we'll be able to publish a book "ReactOS Internals" where we speak about undocumented FS controls to dump NTFS information to show how well our NTFS works ;-).
Modified:
trunk/reactos/drivers/storage/class/disk/disk.c
Modified: trunk/reactos/drivers/storage/class/disk/disk.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/class/disk…
==============================================================================
--- trunk/reactos/drivers/storage/class/disk/disk.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/storage/class/disk/disk.c [iso-8859-1] Tue Oct 28 21:59:57 2014
@@ -310,6 +310,11 @@
IN PDEVICE_OBJECT DeviceObject
);
+NTSTATUS
+NTAPI
+ScsiDiskFileSystemControl(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, DriverEntry)
#pragma alloc_text(PAGE, FindScsiDisks)
@@ -379,6 +384,11 @@
InitializationData.ClassDeviceControl = ScsiDiskDeviceControl;
InitializationData.ClassShutdownFlush = ScsiDiskShutdownFlush;
InitializationData.ClassCreateClose = NULL;
+
+ //
+ // HACK! Please check below to the implementation of the function
+ //
+ DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = ScsiDiskFileSystemControl;
//
// Call the class init routine
@@ -5202,3 +5212,56 @@
}
} // end UpdateDeviceObjects()
+
+//
+// This function is supposed only to support NTFS tools
+// from M. Russinovich. This is kind of huge hack and is
+// totally undocumented :-).
+//
+NTSTATUS
+NtfsRussinovichism(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+//
+// Hack: this function is not supposed to be implemented
+// Even though it's required to enable some M. Russinovich
+// to directly request disks so that they can dump NTFS data
+// without going through the driver.
+// We don't expect doing more from here, hence the limited
+// implementation and support.
+//
+NTSTATUS
+NTAPI
+ScsiDiskFileSystemControl(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PIO_STACK_LOCATION Stack;
+ NTSTATUS Status;
+
+ DPRINT1("ScsiDiskFileSystemControl(%p, %p)\n", DeviceObject, Irp);
+
+ Stack = IoGetCurrentIrpStackLocation(Irp);
+
+ switch (Stack->MinorFunction)
+ {
+ case IRP_MN_USER_FS_REQUEST:
+ Status = NtfsRussinovichism(DeviceObject, Irp);
+ break;
+
+ default:
+ DPRINT("MinorFunction %d\n", Stack->MinorFunction);
+ Status = STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return Status;
+}