2 * PROJECT: Filesystem Filter Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/filters/fltmgr/interface.c
5 * PURPOSE: Implements the driver interface
6 * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
9 /* INCLUDES ******************************************************************/
12 #include "fltmgrint.h"
18 /* DATA *********************************************************************/
20 #define VALID_FAST_IO_DISPATCH_HANDLER(_FastIoDispatchPtr, _FieldName) \
21 (((_FastIoDispatchPtr) != NULL) && \
22 (((_FastIoDispatchPtr)->SizeOfFastIoDispatch) >= \
23 (FIELD_OFFSET(FAST_IO_DISPATCH, _FieldName) + sizeof(void *))) && \
24 ((_FastIoDispatchPtr)->_FieldName != NULL))
26 #define IS_MY_DEVICE_OBJECT(_devObj) \
27 (((_devObj) != NULL) && \
28 ((_devObj)->DriverObject == Dispatcher::DriverObject) && \
29 ((_devObj)->DeviceExtension != NULL))
31 extern PDEVICE_OBJECT CommsDeviceObject
;
32 extern LIST_ENTRY FilterList
;
33 extern ERESOURCE FilterListLock
;
36 DRIVER_INITIALIZE DriverEntry
;
40 _In_ PDRIVER_OBJECT DriverObject
,
41 _In_ PUNICODE_STRING RegistryPath
46 SetupDispatchAndCallbacksTables(
47 _In_ PDRIVER_OBJECT DriverObject
52 FltpAttachDeviceObject(
53 _In_ PDEVICE_OBJECT SourceDevice
,
54 _In_ PDEVICE_OBJECT TargetDevice
,
55 _Out_ PDEVICE_OBJECT
*AttachedToDeviceObject
60 FltpCleanupDeviceObject(
61 _In_ PDEVICE_OBJECT DeviceObject
66 FltpIsAttachedToDevice(
67 _In_ PDEVICE_OBJECT DeviceObject
,
68 _In_opt_ PDEVICE_OBJECT
*AttachedDeviceObject
73 FltpEnumerateFileSystemVolumes(
74 _In_ PDEVICE_OBJECT DeviceObject
79 FltpAttachToFileSystemDevice(
80 _In_ PDEVICE_OBJECT DeviceObject
,
81 _In_ PUNICODE_STRING DeviceName
86 FltpDetachFromFileSystemDevice(
87 _In_ PDEVICE_OBJECT DeviceObject
90 DRIVER_FS_NOTIFICATION FltpFsNotification
;
94 _In_ PDEVICE_OBJECT DeviceObject
,
101 _In_ PDEVICE_OBJECT DeviceObject
,
108 _In_ PDEVICE_OBJECT DeviceObject
,
115 _In_ PDEVICE_OBJECT DeviceObject
,
122 _In_ PDEVICE_OBJECT DeviceObject
,
128 FltpFastIoCheckIfPossible(
129 _In_ PFILE_OBJECT FileObject
,
130 _In_ PLARGE_INTEGER FileOffset
,
134 _In_ BOOLEAN CheckForReadOperation
,
135 _Out_ PIO_STATUS_BLOCK IoStatus
,
136 _In_ PDEVICE_OBJECT DeviceObject
143 _In_ PFILE_OBJECT FileObject
,
144 _In_ PLARGE_INTEGER FileOffset
,
149 _Out_ PIO_STATUS_BLOCK IoStatus
,
150 _In_ PDEVICE_OBJECT DeviceObject
156 _In_ PFILE_OBJECT FileObject
,
157 _In_ PLARGE_INTEGER FileOffset
,
162 _Out_ PIO_STATUS_BLOCK IoStatus
,
163 _In_ PDEVICE_OBJECT DeviceObject
168 FltpFastIoQueryBasicInfo(
169 _In_ PFILE_OBJECT FileObject
,
171 _Out_ PFILE_BASIC_INFORMATION Buffer
,
172 _Out_ PIO_STATUS_BLOCK IoStatus
,
173 _In_ PDEVICE_OBJECT DeviceObject
178 FltpFastIoQueryStandardInfo(
179 _In_ PFILE_OBJECT FileObject
,
181 _Out_ PFILE_STANDARD_INFORMATION Buffer
,
182 _Out_ PIO_STATUS_BLOCK IoStatus
,
183 _In_ PDEVICE_OBJECT DeviceObject
189 _In_ PFILE_OBJECT FileObject
,
190 _In_ PLARGE_INTEGER FileOffset
,
191 _In_ PLARGE_INTEGER Length
,
192 _In_ PEPROCESS ProcessId
,
194 _In_ BOOLEAN FailImmediately
,
195 _In_ BOOLEAN ExclusiveLock
,
196 _Out_ PIO_STATUS_BLOCK IoStatus
,
197 _In_ PDEVICE_OBJECT DeviceObject
202 FltpFastIoUnlockSingle(
203 _In_ PFILE_OBJECT FileObject
,
204 _In_ PLARGE_INTEGER FileOffset
,
205 _In_ PLARGE_INTEGER Length
,
206 _In_ PEPROCESS ProcessId
,
208 _Out_ PIO_STATUS_BLOCK IoStatus
,
209 _In_ PDEVICE_OBJECT DeviceObject
215 _In_ PFILE_OBJECT FileObject
,
216 _In_ PEPROCESS ProcessId
,
217 _Out_ PIO_STATUS_BLOCK IoStatus
,
218 _In_ PDEVICE_OBJECT DeviceObject
223 FltpFastIoUnlockAllByKey(
224 _In_ PFILE_OBJECT FileObject
,
225 _In_ PVOID ProcessId
,
227 _Out_ PIO_STATUS_BLOCK IoStatus
,
228 _In_ PDEVICE_OBJECT DeviceObject
233 FltpFastIoDeviceControl(
234 _In_ PFILE_OBJECT FileObject
,
236 _In_opt_ PVOID InputBuffer
,
237 _In_ ULONG InputBufferLength
,
238 _Out_opt_ PVOID OutputBuffer
,
239 _In_ ULONG OutputBufferLength
,
240 _In_ ULONG IoControlCode
,
241 _Out_ PIO_STATUS_BLOCK IoStatus
,
242 _In_ PDEVICE_OBJECT DeviceObject
247 FltpFastIoDetachDevice(
248 _In_ PDEVICE_OBJECT SourceDevice
,
249 _In_ PDEVICE_OBJECT TargetDevice
254 FltpFastIoQueryNetworkOpenInfo(
255 _In_ PFILE_OBJECT FileObject
,
257 _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer
,
258 _Out_ PIO_STATUS_BLOCK IoStatus
,
259 _In_ PDEVICE_OBJECT DeviceObject
265 _In_ PFILE_OBJECT FileObject
,
266 _In_ PLARGE_INTEGER FileOffset
,
269 _Out_ PMDL
*MdlChain
,
270 _Out_ PIO_STATUS_BLOCK IoStatus
,
271 _In_ PDEVICE_OBJECT DeviceObject
276 FltpFastIoMdlReadComplete(
277 _In_ PFILE_OBJECT FileObject
,
279 _In_ PDEVICE_OBJECT DeviceObject
284 FltpFastIoPrepareMdlWrite(
285 _In_ PFILE_OBJECT FileObject
,
286 _In_ PLARGE_INTEGER FileOffset
,
289 _Out_ PMDL
*MdlChain
,
290 _Out_ PIO_STATUS_BLOCK IoStatus
,
291 _In_ PDEVICE_OBJECT DeviceObject
296 FltpFastIoMdlWriteComplete(
297 _In_ PFILE_OBJECT FileObject
,
298 _In_ PLARGE_INTEGER FileOffset
,
300 _In_ PDEVICE_OBJECT DeviceObject
305 FltpFastIoReadCompressed(
306 _In_ PFILE_OBJECT FileObject
,
307 _In_ PLARGE_INTEGER FileOffset
,
311 _Out_ PMDL
*MdlChain
,
312 _Out_ PIO_STATUS_BLOCK IoStatus
,
313 _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
314 _In_ ULONG CompressedDataInfoLength
,
315 _In_ PDEVICE_OBJECT DeviceObject
320 FltpFastIoWriteCompressed(
321 _In_ PFILE_OBJECT FileObject
,
322 _In_ PLARGE_INTEGER FileOffset
,
326 _Out_ PMDL
*MdlChain
,
327 _Out_ PIO_STATUS_BLOCK IoStatus
,
328 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
329 _In_ ULONG CompressedDataInfoLength
,
330 _In_ PDEVICE_OBJECT DeviceObject
335 FltpFastIoMdlReadCompleteCompressed(
336 _In_ PFILE_OBJECT FileObject
,
338 _In_ PDEVICE_OBJECT DeviceObject
343 FltpFastIoMdlWriteCompleteCompressed(
344 _In_ PFILE_OBJECT FileObject
,
345 _In_ PLARGE_INTEGER FileOffset
,
347 _In_ PDEVICE_OBJECT DeviceObject
354 _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation
,
355 _In_ PDEVICE_OBJECT DeviceObject
361 #pragma alloc_text(INIT, DriverEntry)
362 #pragma alloc_text(INIT, SetupDispatchAndCallbacksTables)
363 #pragma alloc_text(PAGE, FltpAttachDeviceObject)
364 #pragma alloc_text(PAGE, FltpIsAttachedToDevice)
365 #pragma alloc_text(PAGE, FltpEnumerateFileSystemVolumes)
366 #pragma alloc_text(PAGE, FltpAttachToFileSystemDevice)
367 #pragma alloc_text(PAGE, FltpDetachFromFileSystemDevice)
368 #pragma alloc_text(PAGE, FltpFsNotification)
369 #pragma alloc_text(PAGE, FltpCreate)
370 #pragma alloc_text(PAGE, FltpFsControl)
371 #pragma alloc_text(PAGE, FltpDeviceControl)
372 #pragma alloc_text(PAGE, FltpFastIoRead)
373 #pragma alloc_text(PAGE, FltpFastIoWrite)
374 #pragma alloc_text(PAGE, FltpFastIoQueryBasicInfo)
375 #pragma alloc_text(PAGE, FltpFastIoQueryStandardInfo)
376 #pragma alloc_text(PAGE, FltpFastIoLock)
377 #pragma alloc_text(PAGE, FltpFastIoUnlockSingle)
378 #pragma alloc_text(PAGE, FltpFastIoUnlockAll)
379 #pragma alloc_text(PAGE, FltpFastIoUnlockAllByKey)
380 #pragma alloc_text(PAGE, FltpFastIoDeviceControl)
381 #pragma alloc_text(PAGE, FltpFastIoDetachDevice)
382 #pragma alloc_text(PAGE, FltpFastIoQueryNetworkOpenInfo)
383 #pragma alloc_text(PAGE, FltpFastIoMdlRead)
384 #pragma alloc_text(PAGE, FltpFastIoMdlReadComplete)
385 #pragma alloc_text(PAGE, FltpFastIoPrepareMdlWrite)
386 #pragma alloc_text(PAGE, FltpFastIoMdlWriteComplete)
387 #pragma alloc_text(PAGE, FltpFastIoReadCompressed)
388 #pragma alloc_text(PAGE, FltpFastIoWriteCompressed)
389 #pragma alloc_text(PAGE, FltpFastIoMdlReadCompleteCompressed)
390 #pragma alloc_text(PAGE, FltpFastIoMdlWriteCompleteCompressed)
391 #pragma alloc_text(PAGE, FltpFastIoQueryOpen)
396 DRIVER_DATA DriverData
;
399 typedef struct _DETACH_DEVICE_WORK_ITEM
401 WORK_QUEUE_ITEM WorkItem
;
402 PDEVICE_OBJECT SourceDevice
;
403 PDEVICE_OBJECT TargetDevice
;
405 } DETACH_DEVICE_WORK_ITEM
, *PDETACH_DEVICE_WORK_ITEM
;
408 /* DISPATCH ROUTINES **********************************************/
412 FltpPreFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data
,
413 _Out_ PVOID
*CompletionContext
)
415 UNREFERENCED_PARAMETER(Data
);
416 UNREFERENCED_PARAMETER(CompletionContext
);
418 return STATUS_SUCCESS
;
423 FltpPostFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data
,
424 _In_ NTSTATUS OperationStatus
,
425 _In_ PVOID CompletionContext
)
427 UNREFERENCED_PARAMETER(Data
);
428 UNREFERENCED_PARAMETER(OperationStatus
);
429 UNREFERENCED_PARAMETER(CompletionContext
);
435 FltpDispatch(_In_ PDEVICE_OBJECT DeviceObject
,
438 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
439 PIO_STACK_LOCATION StackPtr
;
442 DeviceExtension
= DeviceObject
->DeviceExtension
;
444 /* Check if this is a request for us */
445 if (DeviceObject
== DriverData
.DeviceObject
)
447 FLT_ASSERT(DeviceObject
->DriverObject
== DriverData
.DriverObject
);
448 FLT_ASSERT(DeviceExtension
== NULL
);
450 /* Hand it off to our internal handler */
451 Status
= FltpDispatchHandler(DeviceObject
, Irp
);
452 if (Status
!= STATUS_REPARSE
)
454 Irp
->IoStatus
.Status
= Status
;
455 Irp
->IoStatus
.Information
= 0;
456 IoCompleteRequest(Irp
, 0);
461 /* Check if this is a request for a the messaging device */
462 if (DeviceObject
== CommsDeviceObject
)
464 /* Hand off to our internal routine */
465 return FltpMsgDispatch(DeviceObject
, Irp
);
468 FLT_ASSERT(DeviceExtension
&&
469 DeviceExtension
->AttachedToDeviceObject
);
471 StackPtr
= IoGetCurrentIrpStackLocation(Irp
);
472 if (StackPtr
->MajorFunction
== IRP_MJ_SHUTDOWN
)
474 // handle shutdown request
477 DPRINT1("Received %X from %wZ\n", StackPtr
->MajorFunction
, &DeviceExtension
->DeviceName
);
479 /* Just pass the IRP down the stack */
480 IoSkipCurrentIrpStackLocation(Irp
);
481 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
486 FltpCreate(_In_ PDEVICE_OBJECT DeviceObject
,
489 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
493 DeviceExtension
= DeviceObject
->DeviceExtension
;
495 /* Check if this is a request for us */
496 if (DeviceObject
== DriverData
.DeviceObject
)
498 FLT_ASSERT(DeviceObject
->DriverObject
== DriverData
.DriverObject
);
499 FLT_ASSERT(DeviceExtension
== NULL
);
501 /* Someone wants a handle to the fltmgr, allow it */
502 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
503 Irp
->IoStatus
.Information
= 0;
504 IofCompleteRequest(Irp
, 0);
505 return STATUS_SUCCESS
;
508 /* Check if this is a request for a the new comms connection */
509 if (DeviceObject
== CommsDeviceObject
)
511 /* Hand off to our internal routine */
512 return FltpMsgCreate(DeviceObject
, Irp
);
515 FLT_ASSERT(DeviceExtension
&&
516 DeviceExtension
->AttachedToDeviceObject
);
518 DPRINT1("Received create from %wZ (%lu)\n", &DeviceExtension
->DeviceName
, PsGetCurrentProcessId());
520 /* Just pass the IRP down the stack */
521 IoSkipCurrentIrpStackLocation(Irp
);
522 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
527 FltpFsControl(_In_ PDEVICE_OBJECT DeviceObject
,
530 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
534 /* Check if this is a request for us */
535 if (DeviceObject
== DriverData
.DeviceObject
)
537 /* We don't handle this request */
538 Irp
->IoStatus
.Information
= 0;
539 Irp
->IoStatus
.Status
= STATUS_INVALID_DEVICE_REQUEST
;
540 IofCompleteRequest(Irp
, 0);
541 return STATUS_INVALID_DEVICE_REQUEST
;
544 DeviceExtension
= DeviceObject
->DeviceExtension
;
546 FLT_ASSERT(DeviceExtension
&&
547 DeviceExtension
->AttachedToDeviceObject
);
549 /* Just pass the IRP down the stack */
550 IoSkipCurrentIrpStackLocation(Irp
);
551 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
556 FltpDeviceControl(_In_ PDEVICE_OBJECT DeviceObject
,
559 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
562 /* Check if the request was meant for us */
563 if (DeviceObject
== DriverData
.DeviceObject
)
565 Status
= FltpDeviceControlHandler(DeviceObject
, Irp
);
566 if (Status
!= STATUS_REPARSE
)
568 Irp
->IoStatus
.Status
= Status
;
569 Irp
->IoStatus
.Information
= 0;
570 IoCompleteRequest(Irp
, 0);
576 DeviceExtension
= DeviceObject
->DeviceExtension
;
578 FLT_ASSERT(DeviceExtension
&&
579 DeviceExtension
->AttachedToDeviceObject
);
581 /* Just pass the IRP down the stack */
582 IoSkipCurrentIrpStackLocation(Irp
);
583 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
588 /* FASTIO ROUTINES ************************************************/
592 FltpFastIoCheckIfPossible(_In_ PFILE_OBJECT FileObject
,
593 _In_ PLARGE_INTEGER FileOffset
,
597 _In_ BOOLEAN CheckForReadOperation
,
598 _Out_ PIO_STATUS_BLOCK IoStatus
,
599 _In_ PDEVICE_OBJECT DeviceObject
)
602 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
603 PDEVICE_OBJECT AttachedDeviceObject
;
604 PFAST_IO_DISPATCH FastIoDispatch
;
608 /* If it doesn't have a device extension, then it's not our device object */
609 if (DeviceObject
->DeviceExtension
== NULL
)
612 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
613 IoStatus
->Information
= 0;
617 DeviceExtension
= DeviceObject
->DeviceExtension
;
618 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
620 /* Get the device that we attached to */
621 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
622 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
624 /* Make sure our FastIo table is valid */
625 if (FastIoDispatch
&& FastIoDispatch
->FastIoCheckIfPossible
)
627 /* Forward the call onto the device we attached to */
628 return FastIoDispatch
->FastIoCheckIfPossible(FileObject
,
633 CheckForReadOperation
,
635 AttachedDeviceObject
);
638 /* We failed to handle the request, send it down the slow path */
645 FltpFastIoRead(_In_ PFILE_OBJECT FileObject
,
646 _In_ PLARGE_INTEGER FileOffset
,
651 _Out_ PIO_STATUS_BLOCK IoStatus
,
652 _In_ PDEVICE_OBJECT DeviceObject
)
654 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
655 PDEVICE_OBJECT AttachedDeviceObject
;
656 PFAST_IO_DISPATCH FastIoDispatch
;
660 /* If it doesn't have a device extension, then it's not our device object */
661 if (DeviceObject
->DeviceExtension
== NULL
)
664 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
665 IoStatus
->Information
= 0;
669 DeviceExtension
= DeviceObject
->DeviceExtension
;
670 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
672 /* Get the device that we attached to */
673 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
674 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
676 /* Make sure our FastIo table is valid */
677 if (FastIoDispatch
&& FastIoDispatch
->FastIoRead
)
679 /* Forward the call onto the device we attached to */
680 return FastIoDispatch
->FastIoRead(FileObject
,
687 AttachedDeviceObject
);
690 /* We failed to handle the request, send it down the slow path */
697 FltpFastIoWrite(_In_ PFILE_OBJECT FileObject
,
698 _In_ PLARGE_INTEGER FileOffset
,
703 _Out_ PIO_STATUS_BLOCK IoStatus
,
704 _In_ PDEVICE_OBJECT DeviceObject
)
706 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
707 PDEVICE_OBJECT AttachedDeviceObject
;
708 PFAST_IO_DISPATCH FastIoDispatch
;
712 /* If it doesn't have a device extension, then it's not our device object */
713 if (DeviceObject
->DeviceExtension
== NULL
)
716 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
717 IoStatus
->Information
= 0;
721 DeviceExtension
= DeviceObject
->DeviceExtension
;
722 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
724 /* Get the device that we attached to */
725 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
726 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
728 /* Make sure our FastIo table is valid */
729 if (FastIoDispatch
&& FastIoDispatch
->FastIoWrite
)
731 /* Forward the call onto the device we attached to */
732 return FastIoDispatch
->FastIoWrite(FileObject
,
739 AttachedDeviceObject
);
742 /* We failed to handle the request, send it down the slow path */
749 FltpFastIoQueryBasicInfo(_In_ PFILE_OBJECT FileObject
,
751 _Out_ PFILE_BASIC_INFORMATION Buffer
,
752 _Out_ PIO_STATUS_BLOCK IoStatus
,
753 _In_ PDEVICE_OBJECT DeviceObject
)
755 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
756 PDEVICE_OBJECT AttachedDeviceObject
;
757 PFAST_IO_DISPATCH FastIoDispatch
;
761 /* If it doesn't have a device extension, then it's not our device object */
762 if (DeviceObject
->DeviceExtension
== NULL
)
765 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
766 IoStatus
->Information
= 0;
770 DeviceExtension
= DeviceObject
->DeviceExtension
;
771 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
773 /* Get the device that we attached to */
774 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
775 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
777 /* Make sure our FastIo table is valid */
778 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryBasicInfo
)
780 /* Forward the call onto the device we attached to */
781 return FastIoDispatch
->FastIoQueryBasicInfo(FileObject
,
785 AttachedDeviceObject
);
788 /* We failed to handle the request, send it down the slow path */
795 FltpFastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject
,
797 _Out_ PFILE_STANDARD_INFORMATION Buffer
,
798 _Out_ PIO_STATUS_BLOCK IoStatus
,
799 _In_ PDEVICE_OBJECT DeviceObject
)
801 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
802 PDEVICE_OBJECT AttachedDeviceObject
;
803 PFAST_IO_DISPATCH FastIoDispatch
;
807 /* If it doesn't have a device extension, then it's not our device object */
808 if (DeviceObject
->DeviceExtension
== NULL
)
811 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
812 IoStatus
->Information
= 0;
816 DeviceExtension
= DeviceObject
->DeviceExtension
;
817 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
819 /* Get the device that we attached to */
820 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
821 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
823 /* Make sure our FastIo table is valid */
824 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryStandardInfo
)
826 /* Forward the call onto the device we attached to */
827 return FastIoDispatch
->FastIoQueryStandardInfo(FileObject
,
831 AttachedDeviceObject
);
834 /* We failed to handle the request, send it down the slow path */
841 FltpFastIoLock(_In_ PFILE_OBJECT FileObject
,
842 _In_ PLARGE_INTEGER FileOffset
,
843 _In_ PLARGE_INTEGER Length
,
844 _In_ PEPROCESS ProcessId
,
846 _In_ BOOLEAN FailImmediately
,
847 _In_ BOOLEAN ExclusiveLock
,
848 _Out_ PIO_STATUS_BLOCK IoStatus
,
849 _In_ PDEVICE_OBJECT DeviceObject
)
851 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
852 PDEVICE_OBJECT AttachedDeviceObject
;
853 PFAST_IO_DISPATCH FastIoDispatch
;
857 /* If it doesn't have a device extension, then it's not our device object */
858 if (DeviceObject
->DeviceExtension
== NULL
)
861 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
862 IoStatus
->Information
= 0;
866 DeviceExtension
= DeviceObject
->DeviceExtension
;
867 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
869 /* Get the device that we attached to */
870 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
871 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
873 /* Make sure our FastIo table is valid */
874 if (FastIoDispatch
&& FastIoDispatch
->FastIoLock
)
876 /* Forward the call onto the device we attached to */
877 return FastIoDispatch
->FastIoLock(FileObject
,
885 AttachedDeviceObject
);
888 /* We failed to handle the request, send it down the slow path */
895 FltpFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject
,
896 _In_ PLARGE_INTEGER FileOffset
,
897 _In_ PLARGE_INTEGER Length
,
898 _In_ PEPROCESS ProcessId
,
900 _Out_ PIO_STATUS_BLOCK IoStatus
,
901 _In_ PDEVICE_OBJECT DeviceObject
)
903 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
904 PDEVICE_OBJECT AttachedDeviceObject
;
905 PFAST_IO_DISPATCH FastIoDispatch
;
909 /* If it doesn't have a device extension, then it's not our device object */
910 if (DeviceObject
->DeviceExtension
== NULL
)
913 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
914 IoStatus
->Information
= 0;
918 DeviceExtension
= DeviceObject
->DeviceExtension
;
919 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
921 /* Get the device that we attached to */
922 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
923 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
925 /* Make sure our FastIo table is valid */
926 if (FastIoDispatch
&& FastIoDispatch
->FastIoUnlockSingle
)
928 /* Forward the call onto the device we attached to */
929 return FastIoDispatch
->FastIoUnlockSingle(FileObject
,
935 AttachedDeviceObject
);
938 /* We failed to handle the request, send it down the slow path */
945 FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject
,
946 _In_ PEPROCESS ProcessId
,
947 _Out_ PIO_STATUS_BLOCK IoStatus
,
948 _In_ PDEVICE_OBJECT DeviceObject
)
951 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
952 PDEVICE_OBJECT AttachedDeviceObject
;
953 PFAST_IO_DISPATCH FastIoDispatch
;
957 /* If it doesn't have a device extension, then it's not our device object */
958 if (DeviceObject
->DeviceExtension
== NULL
)
961 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
962 IoStatus
->Information
= 0;
966 DeviceExtension
= DeviceObject
->DeviceExtension
;
967 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
969 /* Get the device that we attached to */
970 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
971 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
973 /* Make sure our FastIo table is valid */
974 if (FastIoDispatch
&& FastIoDispatch
->FastIoUnlockAll
)
976 /* Forward the call onto the device we attached to */
977 return FastIoDispatch
->FastIoUnlockAll(FileObject
,
980 AttachedDeviceObject
);
983 /* We failed to handle the request, send it down the slow path */
990 FltpFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject
,
991 _In_ PVOID ProcessId
,
993 _Out_ PIO_STATUS_BLOCK IoStatus
,
994 _In_ PDEVICE_OBJECT DeviceObject
)
996 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
997 PDEVICE_OBJECT AttachedDeviceObject
;
998 PFAST_IO_DISPATCH FastIoDispatch
;
1002 /* If it doesn't have a device extension, then it's not our device object */
1003 if (DeviceObject
->DeviceExtension
== NULL
)
1006 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1007 IoStatus
->Information
= 0;
1011 DeviceExtension
= DeviceObject
->DeviceExtension
;
1012 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1014 /* Get the device that we attached to */
1015 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1016 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1018 /* Make sure our FastIo table is valid */
1019 if (FastIoDispatch
&& FastIoDispatch
->FastIoUnlockAllByKey
)
1021 /* Forward the call onto the device we attached to */
1022 return FastIoDispatch
->FastIoUnlockAllByKey(FileObject
,
1026 AttachedDeviceObject
);
1029 /* We failed to handle the request, send it down the slow path */
1036 FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject
,
1038 _In_opt_ PVOID InputBuffer
,
1039 _In_ ULONG InputBufferLength
,
1040 _Out_opt_ PVOID OutputBuffer
,
1041 _In_ ULONG OutputBufferLength
,
1042 _In_ ULONG IoControlCode
,
1043 _Out_ PIO_STATUS_BLOCK IoStatus
,
1044 _In_ PDEVICE_OBJECT DeviceObject
)
1046 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1047 PDEVICE_OBJECT AttachedDeviceObject
;
1048 PFAST_IO_DISPATCH FastIoDispatch
;
1052 /* If it doesn't have a device extension, then it's not our device object */
1053 if (DeviceObject
->DeviceExtension
== NULL
)
1055 /* Fail the request, send it down the slow path */
1059 DeviceExtension
= DeviceObject
->DeviceExtension
;
1060 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1062 /* Get the device that we attached to */
1063 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1064 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1066 /* Make sure our FastIo table is valid */
1067 if (FastIoDispatch
&& FastIoDispatch
->FastIoDeviceControl
)
1069 /* Forward the call onto the device we attached to */
1070 return FastIoDispatch
->FastIoDeviceControl(FileObject
,
1078 AttachedDeviceObject
);
1081 /* We failed to handle the request, send it down the slow path */
1088 FltpFastIoDetachDeviceWorker(_In_ PVOID Parameter
)
1090 PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem
= Parameter
;
1092 /* Run any cleanup routines */
1093 FltpCleanupDeviceObject(DetachDeviceWorkItem
->SourceDevice
);
1095 /* Detach from the target device */
1096 IoDetachDevice(DetachDeviceWorkItem
->TargetDevice
);
1098 /* Delete the source */
1099 IoDeleteDevice(DetachDeviceWorkItem
->SourceDevice
);
1101 /* Free the pool we allocated in FltpFastIoDetachDevice */
1102 ExFreePoolWithTag(DetachDeviceWorkItem
, 0x1234);
1107 FltpFastIoDetachDevice(_In_ PDEVICE_OBJECT SourceDevice
,
1108 _In_ PDEVICE_OBJECT TargetDevice
)
1110 PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem
;
1115 * Detaching and deleting devices is a lot of work and takes too long
1116 * to be a worthwhile FastIo candidate, so we defer this call to speed
1117 * it up. There's no return value so we're okay to do this.
1120 /* Allocate the work item and it's corresponding data */
1121 DetachDeviceWorkItem
= ExAllocatePoolWithTag(NonPagedPool
,
1122 sizeof(DETACH_DEVICE_WORK_ITEM
),
1124 if (DetachDeviceWorkItem
)
1126 /* Initialize the work item */
1127 ExInitializeWorkItem(&DetachDeviceWorkItem
->WorkItem
,
1128 FltpFastIoDetachDeviceWorker
,
1129 DetachDeviceWorkItem
);
1131 /* Queue the work item and return the call */
1132 ExQueueWorkItem(&DetachDeviceWorkItem
->WorkItem
,
1137 /* We failed to defer, just cleanup here */
1138 FltpCleanupDeviceObject(SourceDevice
);
1139 IoDetachDevice(TargetDevice
);
1140 IoDeleteDevice(SourceDevice
);
1147 FltpFastIoQueryNetworkOpenInfo(_In_ PFILE_OBJECT FileObject
,
1149 _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer
,
1150 _Out_ PIO_STATUS_BLOCK IoStatus
,
1151 _In_ PDEVICE_OBJECT DeviceObject
)
1153 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1154 PDEVICE_OBJECT AttachedDeviceObject
;
1155 PFAST_IO_DISPATCH FastIoDispatch
;
1159 /* If it doesn't have a device extension, then it's not our device object */
1160 if (DeviceObject
->DeviceExtension
== NULL
)
1163 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1164 IoStatus
->Information
= 0;
1168 DeviceExtension
= DeviceObject
->DeviceExtension
;
1169 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1171 /* Get the device that we attached to */
1172 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1173 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1175 /* Make sure our FastIo table is valid */
1176 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryNetworkOpenInfo
)
1178 /* Forward the call onto the device we attached to */
1179 return FastIoDispatch
->FastIoQueryNetworkOpenInfo(FileObject
,
1183 AttachedDeviceObject
);
1186 /* We failed to handle the request, send it down the slow path */
1193 FltpFastIoMdlRead(_In_ PFILE_OBJECT FileObject
,
1194 _In_ PLARGE_INTEGER FileOffset
,
1197 _Out_ PMDL
*MdlChain
,
1198 _Out_ PIO_STATUS_BLOCK IoStatus
,
1199 _In_ PDEVICE_OBJECT DeviceObject
)
1201 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1202 PDEVICE_OBJECT AttachedDeviceObject
;
1203 PFAST_IO_DISPATCH FastIoDispatch
;
1207 /* If it doesn't have a device extension, then it's not our device object */
1208 if (DeviceObject
->DeviceExtension
== NULL
)
1211 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1212 IoStatus
->Information
= 0;
1216 DeviceExtension
= DeviceObject
->DeviceExtension
;
1217 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1219 /* Get the device that we attached to */
1220 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1221 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1223 /* Make sure our FastIo table is valid */
1224 if (FastIoDispatch
&& FastIoDispatch
->MdlRead
)
1226 /* Forward the call onto the device we attached to */
1227 return FastIoDispatch
->MdlRead(FileObject
,
1233 AttachedDeviceObject
);
1236 /* We failed to handle the request, send it down the slow path */
1243 FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject
,
1245 _In_ PDEVICE_OBJECT DeviceObject
)
1248 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1249 PDEVICE_OBJECT AttachedDeviceObject
;
1250 PFAST_IO_DISPATCH FastIoDispatch
;
1254 /* If it doesn't have a device extension, then it's not our device object */
1255 if (DeviceObject
->DeviceExtension
== NULL
)
1257 /* Fail the request, send it down the slow path */
1261 DeviceExtension
= DeviceObject
->DeviceExtension
;
1262 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1264 /* Get the device that we attached to */
1265 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1266 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1268 /* Make sure our FastIo table is valid */
1269 if (FastIoDispatch
&& FastIoDispatch
->MdlReadComplete
)
1271 /* Forward the call onto the device we attached to */
1272 return FastIoDispatch
->MdlReadComplete(FileObject
,
1274 AttachedDeviceObject
);
1277 /* We failed to handle the request, send it down the slow path */
1284 FltpFastIoPrepareMdlWrite(_In_ PFILE_OBJECT FileObject
,
1285 _In_ PLARGE_INTEGER FileOffset
,
1288 _Out_ PMDL
*MdlChain
,
1289 _Out_ PIO_STATUS_BLOCK IoStatus
,
1290 _In_ PDEVICE_OBJECT DeviceObject
)
1292 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1293 PDEVICE_OBJECT AttachedDeviceObject
;
1294 PFAST_IO_DISPATCH FastIoDispatch
;
1298 /* If it doesn't have a device extension, then it's not our device object */
1299 if (DeviceObject
->DeviceExtension
== NULL
)
1302 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1303 IoStatus
->Information
= 0;
1307 DeviceExtension
= DeviceObject
->DeviceExtension
;
1308 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1310 /* Get the device that we attached to */
1311 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1312 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1314 /* Make sure our FastIo table is valid */
1315 if (FastIoDispatch
&& FastIoDispatch
->PrepareMdlWrite
)
1317 /* Forward the call onto the device we attached to */
1318 return FastIoDispatch
->PrepareMdlWrite(FileObject
,
1324 AttachedDeviceObject
);
1327 /* We failed to handle the request, send it down the slow path */
1334 FltpFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject
,
1335 _In_ PLARGE_INTEGER FileOffset
,
1337 _In_ PDEVICE_OBJECT DeviceObject
)
1339 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1340 PDEVICE_OBJECT AttachedDeviceObject
;
1341 PFAST_IO_DISPATCH FastIoDispatch
;
1345 /* If it doesn't have a device extension, then it's not our device object */
1346 if (DeviceObject
->DeviceExtension
== NULL
)
1348 /* Fail the request, send it down the slow path */
1352 DeviceExtension
= DeviceObject
->DeviceExtension
;
1353 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1355 /* Get the device that we attached to */
1356 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1357 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1359 /* Make sure our FastIo table is valid */
1360 if (FastIoDispatch
&& FastIoDispatch
->MdlWriteComplete
)
1362 /* Forward the call onto the device we attached to */
1363 return FastIoDispatch
->MdlWriteComplete(FileObject
,
1366 AttachedDeviceObject
);
1369 /* We failed to handle the request, send it down the slow path */
1376 FltpFastIoReadCompressed(_In_ PFILE_OBJECT FileObject
,
1377 _In_ PLARGE_INTEGER FileOffset
,
1381 _Out_ PMDL
*MdlChain
,
1382 _Out_ PIO_STATUS_BLOCK IoStatus
,
1383 _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
1384 _In_ ULONG CompressedDataInfoLength
,
1385 _In_ PDEVICE_OBJECT DeviceObject
)
1387 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1388 PDEVICE_OBJECT AttachedDeviceObject
;
1389 PFAST_IO_DISPATCH FastIoDispatch
;
1393 /* If it doesn't have a device extension, then it's not our device object */
1394 if (DeviceObject
->DeviceExtension
== NULL
)
1396 /* Fail the request, send it down the slow path */
1400 DeviceExtension
= DeviceObject
->DeviceExtension
;
1401 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1403 /* Get the device that we attached to */
1404 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1405 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1407 /* Make sure our FastIo table is valid */
1408 if (FastIoDispatch
&& FastIoDispatch
->FastIoReadCompressed
)
1410 /* Forward the call onto the device we attached to */
1411 return FastIoDispatch
->FastIoReadCompressed(FileObject
,
1419 CompressedDataInfoLength
,
1420 AttachedDeviceObject
);
1423 /* We failed to handle the request, send it down the slow path */
1430 FltpFastIoWriteCompressed(_In_ PFILE_OBJECT FileObject
,
1431 _In_ PLARGE_INTEGER FileOffset
,
1435 _Out_ PMDL
*MdlChain
,
1436 _Out_ PIO_STATUS_BLOCK IoStatus
,
1437 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
1438 _In_ ULONG CompressedDataInfoLength
,
1439 _In_ PDEVICE_OBJECT DeviceObject
)
1441 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1442 PDEVICE_OBJECT AttachedDeviceObject
;
1443 PFAST_IO_DISPATCH FastIoDispatch
;
1447 /* If it doesn't have a device extension, then it's not our device object */
1448 if (DeviceObject
->DeviceExtension
== NULL
)
1450 /* Fail the request, send it down the slow path */
1454 DeviceExtension
= DeviceObject
->DeviceExtension
;
1455 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1457 /* Get the device that we attached to */
1458 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1459 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1461 /* Make sure our FastIo table is valid */
1462 if (FastIoDispatch
&& FastIoDispatch
->FastIoWriteCompressed
)
1464 /* Forward the call onto the device we attached to */
1465 return FastIoDispatch
->FastIoWriteCompressed(FileObject
,
1473 CompressedDataInfoLength
,
1474 AttachedDeviceObject
);
1477 /* We failed to handle the request, send it down the slow path */
1484 FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject
,
1486 _In_ PDEVICE_OBJECT DeviceObject
)
1488 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1489 PDEVICE_OBJECT AttachedDeviceObject
;
1490 PFAST_IO_DISPATCH FastIoDispatch
;
1494 /* If it doesn't have a device extension, then it's not our device object */
1495 if (DeviceObject
->DeviceExtension
== NULL
)
1500 DeviceExtension
= DeviceObject
->DeviceExtension
;
1501 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1503 /* Get the device that we attached to */
1504 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1505 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1507 /* Make sure our FastIo table is valid */
1508 if (FastIoDispatch
&& FastIoDispatch
->MdlReadCompleteCompressed
)
1510 /* Forward the call onto the device we attached to */
1511 return FastIoDispatch
->MdlReadCompleteCompressed(FileObject
,
1513 AttachedDeviceObject
);
1516 /* We failed to handle the request, send it down the slow path */
1523 FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT FileObject
,
1524 _In_ PLARGE_INTEGER FileOffset
,
1526 _In_ PDEVICE_OBJECT DeviceObject
)
1528 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1529 PDEVICE_OBJECT AttachedDeviceObject
;
1530 PFAST_IO_DISPATCH FastIoDispatch
;
1534 /* If it doesn't have a device extension, then it's not our device object */
1535 if (DeviceObject
->DeviceExtension
== NULL
)
1540 DeviceExtension
= DeviceObject
->DeviceExtension
;
1541 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1543 /* Get the device that we attached to */
1544 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1545 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1547 /* Make sure our FastIo table is valid */
1548 if (FastIoDispatch
&& FastIoDispatch
->MdlWriteCompleteCompressed
)
1550 /* Forward the call onto the device we attached to */
1551 return FastIoDispatch
->MdlWriteCompleteCompressed(FileObject
,
1554 AttachedDeviceObject
);
1557 /* We failed to handle the request, send it down the slow path */
1564 FltpFastIoQueryOpen(_Inout_ PIRP Irp
,
1565 _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation
,
1566 _In_ PDEVICE_OBJECT DeviceObject
)
1568 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1569 PDEVICE_OBJECT AttachedDeviceObject
;
1570 PFAST_IO_DISPATCH FastIoDispatch
;
1575 /* If it doesn't have a device extension, then it's not our device object */
1576 if (DeviceObject
->DeviceExtension
== NULL
)
1581 DeviceExtension
= DeviceObject
->DeviceExtension
;
1582 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1584 /* Get the device that we attached to */
1585 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1586 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1588 /* Make sure our FastIo table is valid */
1589 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryOpen
)
1591 PIO_STACK_LOCATION StackPtr
= IoGetCurrentIrpStackLocation(Irp
);
1593 /* Update the stack to contain the correct device for the next filter */
1594 StackPtr
->DeviceObject
= AttachedDeviceObject
;
1596 /* Now forward the call */
1597 Success
= FastIoDispatch
->FastIoQueryOpen(Irp
,
1599 AttachedDeviceObject
);
1601 /* Restore the DeviceObject as we found it */
1602 StackPtr
->DeviceObject
= DeviceObject
;
1606 /* We failed to handle the request, send it down the slow path */
1613 /* FUNCTIONS **********************************************/
1617 FltpCleanupDeviceObject(_In_ PDEVICE_OBJECT DeviceObject
)
1619 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1621 DeviceExtension
= DeviceObject
->DeviceExtension
;
1622 if (DeviceExtension
)
1624 // cleanup device extension
1630 FltpAttachDeviceObject(_In_ PDEVICE_OBJECT SourceDevice
,
1631 _In_ PDEVICE_OBJECT TargetDevice
,
1632 _Out_ PDEVICE_OBJECT
*AttachedToDeviceObject
)
1638 /* Before attaching, copy the flags from the device we're going to attach to */
1639 if (FlagOn(SourceDevice
->Flags
, DO_BUFFERED_IO
))
1641 SetFlag(TargetDevice
->Flags
, DO_BUFFERED_IO
);
1643 if (FlagOn(SourceDevice
->Flags
, DO_DIRECT_IO
))
1645 SetFlag(TargetDevice
->Flags
, DO_DIRECT_IO
);
1647 if (FlagOn(SourceDevice
->Flags
, DO_SYSTEM_BOOT_PARTITION
))
1649 SetFlag(TargetDevice
->Characteristics
, FILE_DEVICE_SECURE_OPEN
);
1652 /* Attach this device to the top of the driver stack */
1653 Status
= IoAttachDeviceToDeviceStackSafe(SourceDevice
,
1655 AttachedToDeviceObject
);
1662 FltpIsAttachedToDevice(_In_ PDEVICE_OBJECT DeviceObject
,
1663 _In_opt_ PDEVICE_OBJECT
*AttachedDeviceObject
)
1665 PDEVICE_OBJECT CurrentDeviceObject
;
1666 PDEVICE_OBJECT NextDeviceObject
;
1670 /* Initialize the return pointer */
1671 if (AttachedDeviceObject
) *AttachedDeviceObject
= NULL
;
1673 /* Start by getting the top level device in the chain */
1674 CurrentDeviceObject
= IoGetAttachedDeviceReference(DeviceObject
);
1676 /* Loop while there are attached devices */
1677 while (CurrentDeviceObject
)
1679 /* Check if this device driver matches ours */
1680 if (CurrentDeviceObject
->DriverObject
== DriverData
.DriverObject
)
1682 FLT_ASSERT(CurrentDeviceObject
->DeviceExtension
!= NULL
);
1684 /* We're attached, return the device object if the caller asked for it */
1685 if (AttachedDeviceObject
)
1687 *AttachedDeviceObject
= CurrentDeviceObject
;
1691 /* We aren't returning the reference, so decrement the count */
1692 ObDereferenceObject(CurrentDeviceObject
);
1698 /* Get the next device in the chain */
1699 NextDeviceObject
= IoGetLowerDeviceObject(CurrentDeviceObject
);
1701 /* Decrement the count on the last device before we update the pointer */
1702 ObDereferenceObject(CurrentDeviceObject
);
1703 CurrentDeviceObject
= NextDeviceObject
;
1711 FltpEnumerateFileSystemVolumes(_In_ PDEVICE_OBJECT DeviceObject
)
1713 PFLTMGR_DEVICE_EXTENSION NewDeviceExtension
;
1714 PDEVICE_OBJECT BaseDeviceObject
;
1715 PDEVICE_OBJECT NewDeviceObject
;
1716 PDEVICE_OBJECT
*DeviceList
;
1717 PDEVICE_OBJECT StorageStackDeviceObject
;
1718 UNICODE_STRING DeviceName
;
1725 /* Get the base device */
1726 BaseDeviceObject
= IoGetDeviceAttachmentBaseRef(DeviceObject
);
1728 /* get the number of device object linked to the base file system */
1729 Status
= IoEnumerateDeviceObjectList(BaseDeviceObject
->DriverObject
,
1733 if (Status
!= STATUS_BUFFER_TOO_SMALL
) return Status
;
1735 /* Add a few more slots in case the size changed between calls and allocate some memory to hold the pointers */
1737 DeviceList
= ExAllocatePoolWithTag(NonPagedPool
,
1738 (NumDevices
* sizeof(PDEVICE_OBJECT
)),
1739 FM_TAG_DEV_OBJ_PTRS
);
1740 if (DeviceList
== NULL
) return STATUS_INSUFFICIENT_RESOURCES
;
1742 /* Now get all the device objects that this base driver has created */
1743 Status
= IoEnumerateDeviceObjectList(BaseDeviceObject
->DriverObject
,
1745 (NumDevices
* sizeof(PDEVICE_OBJECT
)),
1747 if (!NT_SUCCESS(Status
))
1749 ExFreePoolWithTag(DeviceList
, FM_TAG_DEV_OBJ_PTRS
);
1753 /* Loop through all the devices looking for ones to attach to */
1754 for (i
= 0; i
< NumDevices
; i
++)
1756 RtlInitUnicodeString(&DeviceName
, NULL
);
1757 StorageStackDeviceObject
= NULL
;
1758 NewDeviceObject
= NULL
;
1760 /* Ignore the device we passed in, and devices of the wrong type */
1761 if ((DeviceList
[i
] == BaseDeviceObject
) ||
1762 (DeviceList
[i
]->DeviceType
!= BaseDeviceObject
->DeviceType
))
1764 goto CleanupAndNext
;
1767 /* Ignore this device if we're already attached to it */
1768 if (FltpIsAttachedToDevice(DeviceList
[i
], NULL
) == FALSE
)
1770 goto CleanupAndNext
;
1775 * If the device has a name, it must be a control device.
1776 * This handles drivers with more then one control device (like FastFat)
1778 FltpGetBaseDeviceObjectName(DeviceList
[i
], &DeviceName
);
1779 if (NT_SUCCESS(Status
) && DeviceName
.Length
> 0)
1781 goto CleanupAndNext
;
1785 * Try to get the storage stack (disk) device object associated with
1786 * this file system device object. Ignore the device if we don't have one
1788 Status
= IoGetDiskDeviceObject(DeviceList
[i
],
1789 &StorageStackDeviceObject
);
1790 if (!NT_SUCCESS(Status
))
1792 goto CleanupAndNext
;
1797 * TODO: Don't attach to shadow copy volumes,
1798 * ros doesn't have any so it's not an issues yet
1802 * We're far enough to be ready to attach, create a device
1803 * object which we'll use to do so
1805 Status
= IoCreateDevice(DriverData
.DriverObject
,
1806 sizeof(FLTMGR_DEVICE_EXTENSION
),
1808 DeviceList
[i
]->DeviceType
,
1812 if (!NT_SUCCESS(Status
))
1814 goto CleanupAndNext
;
1817 /* Get the device extension for this new object and store our disk object there */
1818 NewDeviceExtension
= NewDeviceObject
->DeviceExtension
;
1819 NewDeviceExtension
->StorageStackDeviceObject
= StorageStackDeviceObject
;
1821 /* Lookup and store the device name for the storage stack */
1822 RtlInitEmptyUnicodeString(&NewDeviceExtension
->DeviceName
,
1823 NewDeviceExtension
->DeviceNameBuffer
,
1824 sizeof(NewDeviceExtension
->DeviceNameBuffer
));
1825 FltpGetObjectName(StorageStackDeviceObject
,
1826 &NewDeviceExtension
->DeviceName
);
1829 /* Grab the attach lock before we attempt to attach */
1830 ExAcquireFastMutex(&DriverData
.FilterAttachLock
);
1832 /* Check again that we aren't already attached. It may have changed since our last check */
1833 if (FltpIsAttachedToDevice(DeviceList
[i
], NULL
) == FALSE
)
1835 FLT_ASSERT(NewDeviceObject
->DriverObject
== DriverData
.DriverObject
);
1837 /* Finally, attach to the volume */
1838 Status
= FltpAttachDeviceObject(DeviceList
[i
],
1840 &NewDeviceExtension
->AttachedToDeviceObject
);
1841 if (NT_SUCCESS(Status
))
1843 /* Clean the initializing flag so other filters can attach to our device object */
1844 ClearFlag(NewDeviceObject
->Flags
, DO_DEVICE_INITIALIZING
);
1849 /* We're already attached. Just cleanup */
1850 Status
= STATUS_DEVICE_ALREADY_ATTACHED
;
1853 ExReleaseFastMutex(&DriverData
.FilterAttachLock
);
1857 if (!NT_SUCCESS(Status
))
1859 if (NewDeviceObject
)
1861 FltpCleanupDeviceObject(NewDeviceObject
);
1862 IoDeleteDevice(NewDeviceObject
);
1866 if (StorageStackDeviceObject
)
1868 /* A ref was added for us when we attached, so we can deref ours now */
1869 ObDereferenceObject(StorageStackDeviceObject
);
1872 /* Remove the ref which was added by IoEnumerateDeviceObjectList */
1873 ObDereferenceObject(DeviceList
[i
]);
1875 /* Free the buffer that FltpGetBaseDeviceObjectName added */
1876 FltpFreeUnicodeString(&DeviceName
);
1880 /* Free the memory we allocated for the list */
1881 ExFreePoolWithTag(DeviceList
, FM_TAG_DEV_OBJ_PTRS
);
1883 return STATUS_SUCCESS
;
1888 FltpAttachToFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject
,
1889 _In_ PUNICODE_STRING DeviceName
)
1891 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1892 PDEVICE_OBJECT NewDeviceObject
;
1893 WCHAR Buffer
[MAX_DEVNAME_LENGTH
];
1894 UNICODE_STRING FileSystemDeviceName
;
1895 UNICODE_STRING FsRecDeviceName
;
1900 /* Only handle device types we're interested in */
1901 if (DeviceObject
->DeviceType
!= FILE_DEVICE_DISK_FILE_SYSTEM
&&
1902 DeviceObject
->DeviceType
!= FILE_DEVICE_CD_ROM_FILE_SYSTEM
&&
1903 DeviceObject
->DeviceType
!= FILE_DEVICE_NETWORK_FILE_SYSTEM
)
1905 return STATUS_SUCCESS
;
1908 /* Setup the buffer to hold the device name */
1909 RtlInitEmptyUnicodeString(&FileSystemDeviceName
,
1911 MAX_DEVNAME_LENGTH
* sizeof(WCHAR
));
1913 /* Get the the name of the file system device */
1914 Status
= FltpGetObjectName(DeviceObject
->DriverObject
, &FileSystemDeviceName
);
1915 if (!NT_SUCCESS(Status
)) return Status
;
1917 DPRINT("Found device %wZ, checking if we need to attach...\n", &FileSystemDeviceName
);
1919 /* Build up the name of the file system recognizer device */
1920 RtlInitUnicodeString(&FsRecDeviceName
, L
"\\FileSystem\\Fs_Rec");
1922 /* We don't attach to recognizer devices, so bail if this is one */
1923 if (RtlCompareUnicodeString(&FileSystemDeviceName
, &FsRecDeviceName
, TRUE
) == 0)
1925 return STATUS_SUCCESS
;
1928 /* Create a device object which we can attach to this file system */
1929 Status
= IoCreateDevice(DriverData
.DriverObject
,
1930 sizeof(FLTMGR_DEVICE_EXTENSION
),
1932 DeviceObject
->DeviceType
,
1936 if (!NT_SUCCESS(Status
))
1938 DPRINT1("Failed to create a DO for attaching to a FS : 0x%X\n", Status
);
1942 /* Cast the device extension to something we understand */
1943 DeviceExtension
= NewDeviceObject
->DeviceExtension
;
1945 /* Attach this device to the top of the driver stack and store the DO we attached to in the DE */
1946 Status
= FltpAttachDeviceObject(NewDeviceObject
,
1948 &DeviceExtension
->AttachedToDeviceObject
);
1949 if (NT_SUCCESS(Status
))
1951 DPRINT("Attached to %wZ\n", &FileSystemDeviceName
);
1955 DPRINT1("Failed to attach to the driver stack : 0x%X\n", Status
);
1959 /* Setup the unicode string buffer and copy the device name to the device extension */
1960 RtlInitEmptyUnicodeString(&DeviceExtension
->DeviceName
,
1961 DeviceExtension
->DeviceNameBuffer
,
1962 MAX_DEVNAME_LENGTH
* sizeof(WCHAR
));
1963 RtlCopyUnicodeString(&DeviceExtension
->DeviceName
, DeviceName
);
1965 /* We're done, remove the initializing flag */
1966 ClearFlag(NewDeviceObject
->Flags
, DO_DEVICE_INITIALIZING
);
1968 /* Look for existing mounted devices for this file system */
1969 Status
= FltpEnumerateFileSystemVolumes(DeviceObject
);
1970 if (!NT_SUCCESS(Status
))
1972 DPRINT1("Failed to enumerate file system volumes for this file system : 0x%X\n", Status
);
1973 IoDetachDevice(DeviceExtension
->AttachedToDeviceObject
);
1978 if (!NT_SUCCESS(Status
))
1980 IoDeleteDevice(NewDeviceObject
);
1988 FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject
)
1990 PDEVICE_OBJECT AttachedDevice
, NextDevice
;
1991 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1996 /* Get the top device in the chain and increment the ref count on it */
1997 AttachedDevice
= IoGetAttachedDeviceReference(DeviceObject
);
1999 /* Loop all attached devices looking for our file system driver */
2000 while (AttachedDevice
->DriverObject
!= DriverData
.DriverObject
)
2002 FLT_ASSERT(AttachedDevice
!= NULL
);
2004 /* Get the next lower device object. This adds a ref on NextDevice */
2005 NextDevice
= IoGetLowerDeviceObject(AttachedDevice
);
2007 /* Remove the reference we added */
2008 Count
= ObfDereferenceObject(AttachedDevice
);
2010 /* Bail if this is the last one */
2011 if (NextDevice
== NULL
) return Count
;
2013 /* Try the next one */
2014 AttachedDevice
= NextDevice
;
2018 DeviceExtension
= AttachedDevice
->DeviceExtension
;
2019 if (DeviceExtension
)
2022 // FIXME: Put any device extension cleanup code here
2026 /* Detach the device from the chain and delete the object */
2027 IoDetachDevice(DeviceObject
);
2028 IoDeleteDevice(AttachedDevice
);
2030 /* Remove the reference we added so the delete can complete */
2031 return ObfDereferenceObject(AttachedDevice
);
2034 DRIVER_FS_NOTIFICATION FltpFsNotification
;
2037 FltpFsNotification(_In_ PDEVICE_OBJECT DeviceObject
,
2038 _In_ BOOLEAN FsActive
)
2040 UNICODE_STRING DeviceName
;
2045 /* Set an empty string */
2046 RtlInitUnicodeString(&DeviceName
, NULL
);
2048 /* Get the name of the lowest device object on the stack */
2049 Status
= FltpGetBaseDeviceObjectName(DeviceObject
, &DeviceName
);
2050 if (NT_SUCCESS(Status
))
2052 /* Check if it's attaching or detaching */
2055 /* Run the attach routine */
2056 FltpAttachToFileSystemDevice(DeviceObject
, &DeviceName
);
2060 /* Run the detach routine */
2061 FltpDetachFromFileSystemDevice(DeviceObject
);
2064 /* Free the buffer which FltpGetBaseDeviceObjectName allocated */
2065 FltpFreeUnicodeString(&DeviceName
);
2069 DRIVER_INITIALIZE DriverEntry
;
2072 DriverEntry(_In_ PDRIVER_OBJECT DriverObject
,
2073 _In_ PUNICODE_STRING RegistryPath
)
2075 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\FileSystem\\Filters\\"DRIVER_NAME
);
2076 PDEVICE_OBJECT RawDeviceObject
;
2077 PDEVICE_OBJECT DeviceObject
;
2078 PFILE_OBJECT RawFileObject
;
2079 UNICODE_STRING ObjectName
;
2080 UNICODE_STRING SymLink
;
2084 RtlZeroMemory(&DriverData
, sizeof(DRIVER_DATA
));
2085 DriverData
.DriverObject
= DriverObject
;
2087 /* Save the registry key for this driver */
2088 DriverData
.ServiceKey
.Length
= RegistryPath
->Length
;
2089 DriverData
.ServiceKey
.MaximumLength
= RegistryPath
->MaximumLength
;
2090 DriverData
.ServiceKey
.Buffer
= (PWCHAR
)ExAllocatePoolWithTag(NonPagedPool
,
2091 RegistryPath
->MaximumLength
,
2092 FM_TAG_REGISTRY_DATA
);
2093 if (!DriverData
.ServiceKey
.Buffer
) return STATUS_INSUFFICIENT_RESOURCES
;
2094 RtlCopyUnicodeString(&DriverData
.ServiceKey
, RegistryPath
);
2096 /* Do some initialization */
2097 ExInitializeFastMutex(&DriverData
.FilterAttachLock
);
2099 /* Create the main filter manager device object */
2100 Status
= IoCreateDevice(DriverObject
,
2103 FILE_DEVICE_DISK_FILE_SYSTEM
,
2104 FILE_DEVICE_SECURE_OPEN
,
2107 if (!NT_SUCCESS(Status
))
2109 DPRINT1("fltmgr IoCreateDevice failed. Status = %X\n", Status
);
2113 /* Store a global reference so we can access from callbacks */
2114 DriverData
.DeviceObject
= DeviceObject
;
2116 /* Generate the symbolic link name */
2117 RtlInitUnicodeString(&SymLink
, L
"\\??\\"DRIVER_NAME
);
2118 Status
= IoCreateSymbolicLink(&SymLink
, &DeviceName
);
2119 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2121 /* Create the callbacks for the dispatch table, FastIo and FS callbacks */
2122 Status
= SetupDispatchAndCallbacksTables(DriverObject
);
2123 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2125 /* Initialize the comms objects */
2126 Status
= FltpSetupCommunicationObjects(DriverObject
);
2127 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2129 /* Register for notifications when a new file system is loaded. This also enumerates any existing file systems */
2130 Status
= IoRegisterFsRegistrationChange(DriverObject
, FltpFsNotification
);
2131 FLT_ASSERT(Status
!= STATUS_DEVICE_ALREADY_ATTACHED
); // Windows checks for this, I'm not sure how it can happen. Needs investigation??
2132 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2134 InitializeListHead(&FilterList
);
2135 ExInitializeResourceLite(&FilterListLock
);
2137 /* IoRegisterFsRegistrationChange isn't notified about the raw file systems, so we attach to them manually */
2138 RtlInitUnicodeString(&ObjectName
, L
"\\Device\\RawDisk");
2139 Status
= IoGetDeviceObjectPointer(&ObjectName
,
2140 FILE_READ_ATTRIBUTES
,
2143 if (NT_SUCCESS(Status
))
2145 FltpFsNotification(RawDeviceObject
, TRUE
);
2146 ObfDereferenceObject(RawFileObject
);
2149 RtlInitUnicodeString(&ObjectName
, L
"\\Device\\RawCdRom");
2150 Status
= IoGetDeviceObjectPointer(&ObjectName
,
2151 FILE_READ_ATTRIBUTES
,
2154 if (NT_SUCCESS(Status
))
2156 FltpFsNotification(RawDeviceObject
, TRUE
);
2157 ObfDereferenceObject(RawFileObject
);
2160 /* We're done, clear the initializing flag */
2161 ClearFlag(DeviceObject
->Flags
, DO_DEVICE_INITIALIZING
);
2162 Status
= STATUS_SUCCESS
;
2166 if (!NT_SUCCESS(Status
))
2168 if (DriverData
.FastIoDispatch
)
2170 DriverObject
->FastIoDispatch
= NULL
;
2171 ExFreePoolWithTag(DriverData
.FastIoDispatch
, FM_TAG_DISPATCH_TABLE
);
2174 IoDeleteSymbolicLink(&SymLink
);
2177 IoDeleteDevice(DeviceObject
);
2179 if (DriverData
.ServiceKey
.Buffer
)
2180 ExFreePoolWithTag(DriverData
.ServiceKey
.Buffer
, FM_TAG_REGISTRY_DATA
);
2189 SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject
)
2191 PFAST_IO_DISPATCH FastIoDispatch
;
2192 FS_FILTER_CALLBACKS Callbacks
;
2195 /* Plug all the IRPs */
2196 for (i
= 0; i
<= IRP_MJ_MAXIMUM_FUNCTION
; i
++)
2198 DriverObject
->MajorFunction
[i
] = FltpDispatch
;
2201 /* Override the ones we're interested in */
2202 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = FltpCreate
;
2203 DriverObject
->MajorFunction
[IRP_MJ_CREATE_NAMED_PIPE
] = FltpCreate
;
2204 DriverObject
->MajorFunction
[IRP_MJ_CREATE_MAILSLOT
] = FltpCreate
;
2205 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = FltpFsControl
;
2206 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = FltpDeviceControl
;
2208 /* The FastIo dispatch table is stored in the pool along with a tag */
2209 FastIoDispatch
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(FAST_IO_DISPATCH
), FM_TAG_DISPATCH_TABLE
);
2210 if (FastIoDispatch
== NULL
) return STATUS_INSUFFICIENT_RESOURCES
;
2212 /* Fill out the FastIo table */
2213 RtlZeroMemory(FastIoDispatch
, sizeof(FAST_IO_DISPATCH
));
2214 FastIoDispatch
->SizeOfFastIoDispatch
= sizeof(FAST_IO_DISPATCH
);
2215 FastIoDispatch
->FastIoCheckIfPossible
= FltpFastIoCheckIfPossible
;
2216 FastIoDispatch
->FastIoRead
= FltpFastIoRead
;
2217 FastIoDispatch
->FastIoWrite
= FltpFastIoWrite
;
2218 FastIoDispatch
->FastIoQueryBasicInfo
= FltpFastIoQueryBasicInfo
;
2219 FastIoDispatch
->FastIoQueryStandardInfo
= FltpFastIoQueryStandardInfo
;
2220 FastIoDispatch
->FastIoLock
= FltpFastIoLock
;
2221 FastIoDispatch
->FastIoUnlockSingle
= FltpFastIoUnlockSingle
;
2222 FastIoDispatch
->FastIoUnlockAll
= FltpFastIoUnlockAll
;
2223 FastIoDispatch
->FastIoUnlockAllByKey
= FltpFastIoUnlockAllByKey
;
2224 FastIoDispatch
->FastIoDeviceControl
= FltpFastIoDeviceControl
;
2225 FastIoDispatch
->FastIoDetachDevice
= FltpFastIoDetachDevice
;
2226 FastIoDispatch
->FastIoQueryNetworkOpenInfo
= FltpFastIoQueryNetworkOpenInfo
;
2227 FastIoDispatch
->MdlRead
= FltpFastIoMdlRead
;
2228 FastIoDispatch
->MdlReadComplete
= FltpFastIoMdlReadComplete
;
2229 FastIoDispatch
->PrepareMdlWrite
= FltpFastIoPrepareMdlWrite
;
2230 FastIoDispatch
->MdlWriteComplete
= FltpFastIoMdlWriteComplete
;
2231 FastIoDispatch
->FastIoReadCompressed
= FltpFastIoReadCompressed
;
2232 FastIoDispatch
->FastIoWriteCompressed
= FltpFastIoWriteCompressed
;
2233 FastIoDispatch
->MdlReadCompleteCompressed
= FltpFastIoMdlReadCompleteCompressed
;
2234 FastIoDispatch
->MdlWriteCompleteCompressed
= FltpFastIoMdlWriteCompleteCompressed
;
2235 FastIoDispatch
->FastIoQueryOpen
= FltpFastIoQueryOpen
;
2237 /* Store the FastIo table for internal and our access */
2238 DriverObject
->FastIoDispatch
= FastIoDispatch
;
2239 DriverData
.FastIoDispatch
= FastIoDispatch
;
2241 /* Initialize the callback table */
2242 Callbacks
.SizeOfFsFilterCallbacks
= sizeof(FS_FILTER_CALLBACKS
);
2243 Callbacks
.PreAcquireForSectionSynchronization
= FltpPreFsFilterOperation
;
2244 Callbacks
.PostAcquireForSectionSynchronization
= FltpPostFsFilterOperation
;
2245 Callbacks
.PreReleaseForSectionSynchronization
= FltpPreFsFilterOperation
;
2246 Callbacks
.PostReleaseForSectionSynchronization
= FltpPostFsFilterOperation
;
2247 Callbacks
.PreAcquireForCcFlush
= FltpPreFsFilterOperation
;
2248 Callbacks
.PostAcquireForCcFlush
= FltpPostFsFilterOperation
;
2249 Callbacks
.PreReleaseForCcFlush
= FltpPreFsFilterOperation
;
2250 Callbacks
.PostReleaseForCcFlush
= FltpPostFsFilterOperation
;
2251 Callbacks
.PreAcquireForModifiedPageWriter
= FltpPreFsFilterOperation
;
2252 Callbacks
.PostAcquireForModifiedPageWriter
= FltpPostFsFilterOperation
;
2253 Callbacks
.PreReleaseForModifiedPageWriter
= FltpPreFsFilterOperation
;
2254 Callbacks
.PostReleaseForModifiedPageWriter
= FltpPostFsFilterOperation
;
2256 /* Register our callbacks */
2257 return FsRtlRegisterFileSystemFilterCallbacks(DriverObject
, &Callbacks
);