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
;
34 DRIVER_INITIALIZE DriverEntry
;
38 _In_ PDRIVER_OBJECT DriverObject
,
39 _In_ PUNICODE_STRING RegistryPath
44 SetupDispatchAndCallbacksTables(
45 _In_ PDRIVER_OBJECT DriverObject
50 FltpAttachDeviceObject(
51 _In_ PDEVICE_OBJECT SourceDevice
,
52 _In_ PDEVICE_OBJECT TargetDevice
,
53 _Out_ PDEVICE_OBJECT
*AttachedToDeviceObject
58 FltpCleanupDeviceObject(
59 _In_ PDEVICE_OBJECT DeviceObject
64 FltpIsAttachedToDevice(
65 _In_ PDEVICE_OBJECT DeviceObject
,
66 _In_opt_ PDEVICE_OBJECT
*AttachedDeviceObject
71 FltpEnumerateFileSystemVolumes(
72 _In_ PDEVICE_OBJECT DeviceObject
77 FltpAttachToFileSystemDevice(
78 _In_ PDEVICE_OBJECT DeviceObject
,
79 _In_ PUNICODE_STRING DeviceName
84 FltpDetachFromFileSystemDevice(
85 _In_ PDEVICE_OBJECT DeviceObject
88 DRIVER_FS_NOTIFICATION FltpFsNotification
;
92 _In_ PDEVICE_OBJECT DeviceObject
,
99 _In_ PDEVICE_OBJECT DeviceObject
,
106 _In_ PDEVICE_OBJECT DeviceObject
,
113 _In_ PDEVICE_OBJECT DeviceObject
,
120 _In_ PDEVICE_OBJECT DeviceObject
,
126 FltpFastIoCheckIfPossible(
127 _In_ PFILE_OBJECT FileObject
,
128 _In_ PLARGE_INTEGER FileOffset
,
132 _In_ BOOLEAN CheckForReadOperation
,
133 _Out_ PIO_STATUS_BLOCK IoStatus
,
134 _In_ PDEVICE_OBJECT DeviceObject
141 _In_ PFILE_OBJECT FileObject
,
142 _In_ PLARGE_INTEGER FileOffset
,
147 _Out_ PIO_STATUS_BLOCK IoStatus
,
148 _In_ PDEVICE_OBJECT DeviceObject
154 _In_ PFILE_OBJECT FileObject
,
155 _In_ PLARGE_INTEGER FileOffset
,
160 _Out_ PIO_STATUS_BLOCK IoStatus
,
161 _In_ PDEVICE_OBJECT DeviceObject
166 FltpFastIoQueryBasicInfo(
167 _In_ PFILE_OBJECT FileObject
,
169 _Out_ PFILE_BASIC_INFORMATION Buffer
,
170 _Out_ PIO_STATUS_BLOCK IoStatus
,
171 _In_ PDEVICE_OBJECT DeviceObject
176 FltpFastIoQueryStandardInfo(
177 _In_ PFILE_OBJECT FileObject
,
179 _Out_ PFILE_STANDARD_INFORMATION Buffer
,
180 _Out_ PIO_STATUS_BLOCK IoStatus
,
181 _In_ PDEVICE_OBJECT DeviceObject
187 _In_ PFILE_OBJECT FileObject
,
188 _In_ PLARGE_INTEGER FileOffset
,
189 _In_ PLARGE_INTEGER Length
,
190 _In_ PEPROCESS ProcessId
,
192 _In_ BOOLEAN FailImmediately
,
193 _In_ BOOLEAN ExclusiveLock
,
194 _Out_ PIO_STATUS_BLOCK IoStatus
,
195 _In_ PDEVICE_OBJECT DeviceObject
200 FltpFastIoUnlockSingle(
201 _In_ PFILE_OBJECT FileObject
,
202 _In_ PLARGE_INTEGER FileOffset
,
203 _In_ PLARGE_INTEGER Length
,
204 _In_ PEPROCESS ProcessId
,
206 _Out_ PIO_STATUS_BLOCK IoStatus
,
207 _In_ PDEVICE_OBJECT DeviceObject
213 _In_ PFILE_OBJECT FileObject
,
214 _In_ PEPROCESS ProcessId
,
215 _Out_ PIO_STATUS_BLOCK IoStatus
,
216 _In_ PDEVICE_OBJECT DeviceObject
221 FltpFastIoUnlockAllByKey(
222 _In_ PFILE_OBJECT FileObject
,
223 _In_ PVOID ProcessId
,
225 _Out_ PIO_STATUS_BLOCK IoStatus
,
226 _In_ PDEVICE_OBJECT DeviceObject
231 FltpFastIoDeviceControl(
232 _In_ PFILE_OBJECT FileObject
,
234 _In_opt_ PVOID InputBuffer
,
235 _In_ ULONG InputBufferLength
,
236 _Out_opt_ PVOID OutputBuffer
,
237 _In_ ULONG OutputBufferLength
,
238 _In_ ULONG IoControlCode
,
239 _Out_ PIO_STATUS_BLOCK IoStatus
,
240 _In_ PDEVICE_OBJECT DeviceObject
245 FltpFastIoDetachDevice(
246 _In_ PDEVICE_OBJECT SourceDevice
,
247 _In_ PDEVICE_OBJECT TargetDevice
252 FltpFastIoQueryNetworkOpenInfo(
253 _In_ PFILE_OBJECT FileObject
,
255 _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer
,
256 _Out_ PIO_STATUS_BLOCK IoStatus
,
257 _In_ PDEVICE_OBJECT DeviceObject
263 _In_ PFILE_OBJECT FileObject
,
264 _In_ PLARGE_INTEGER FileOffset
,
267 _Out_ PMDL
*MdlChain
,
268 _Out_ PIO_STATUS_BLOCK IoStatus
,
269 _In_ PDEVICE_OBJECT DeviceObject
274 FltpFastIoMdlReadComplete(
275 _In_ PFILE_OBJECT FileObject
,
277 _In_ PDEVICE_OBJECT DeviceObject
282 FltpFastIoPrepareMdlWrite(
283 _In_ PFILE_OBJECT FileObject
,
284 _In_ PLARGE_INTEGER FileOffset
,
287 _Out_ PMDL
*MdlChain
,
288 _Out_ PIO_STATUS_BLOCK IoStatus
,
289 _In_ PDEVICE_OBJECT DeviceObject
294 FltpFastIoMdlWriteComplete(
295 _In_ PFILE_OBJECT FileObject
,
296 _In_ PLARGE_INTEGER FileOffset
,
298 _In_ PDEVICE_OBJECT DeviceObject
303 FltpFastIoReadCompressed(
304 _In_ PFILE_OBJECT FileObject
,
305 _In_ PLARGE_INTEGER FileOffset
,
309 _Out_ PMDL
*MdlChain
,
310 _Out_ PIO_STATUS_BLOCK IoStatus
,
311 _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
312 _In_ ULONG CompressedDataInfoLength
,
313 _In_ PDEVICE_OBJECT DeviceObject
318 FltpFastIoWriteCompressed(
319 _In_ PFILE_OBJECT FileObject
,
320 _In_ PLARGE_INTEGER FileOffset
,
324 _Out_ PMDL
*MdlChain
,
325 _Out_ PIO_STATUS_BLOCK IoStatus
,
326 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
327 _In_ ULONG CompressedDataInfoLength
,
328 _In_ PDEVICE_OBJECT DeviceObject
333 FltpFastIoMdlReadCompleteCompressed(
334 _In_ PFILE_OBJECT FileObject
,
336 _In_ PDEVICE_OBJECT DeviceObject
341 FltpFastIoMdlWriteCompleteCompressed(
342 _In_ PFILE_OBJECT FileObject
,
343 _In_ PLARGE_INTEGER FileOffset
,
345 _In_ PDEVICE_OBJECT DeviceObject
352 _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation
,
353 _In_ PDEVICE_OBJECT DeviceObject
359 #pragma alloc_text(INIT, DriverEntry)
360 #pragma alloc_text(INIT, SetupDispatchAndCallbacksTables)
361 #pragma alloc_text(PAGE, FltpAttachDeviceObject)
362 #pragma alloc_text(PAGE, FltpIsAttachedToDevice)
363 #pragma alloc_text(PAGE, FltpEnumerateFileSystemVolumes)
364 #pragma alloc_text(PAGE, FltpAttachToFileSystemDevice)
365 #pragma alloc_text(PAGE, FltpDetachFromFileSystemDevice)
366 #pragma alloc_text(PAGE, FltpFsNotification)
367 #pragma alloc_text(PAGE, FltpCreate)
368 #pragma alloc_text(PAGE, FltpFsControl)
369 #pragma alloc_text(PAGE, FltpDeviceControl)
370 #pragma alloc_text(PAGE, FltpFastIoRead)
371 #pragma alloc_text(PAGE, FltpFastIoWrite)
372 #pragma alloc_text(PAGE, FltpFastIoQueryBasicInfo)
373 #pragma alloc_text(PAGE, FltpFastIoQueryStandardInfo)
374 #pragma alloc_text(PAGE, FltpFastIoLock)
375 #pragma alloc_text(PAGE, FltpFastIoUnlockSingle)
376 #pragma alloc_text(PAGE, FltpFastIoUnlockAll)
377 #pragma alloc_text(PAGE, FltpFastIoUnlockAllByKey)
378 #pragma alloc_text(PAGE, FltpFastIoDeviceControl)
379 #pragma alloc_text(PAGE, FltpFastIoDetachDevice)
380 #pragma alloc_text(PAGE, FltpFastIoQueryNetworkOpenInfo)
381 #pragma alloc_text(PAGE, FltpFastIoMdlRead)
382 #pragma alloc_text(PAGE, FltpFastIoMdlReadComplete)
383 #pragma alloc_text(PAGE, FltpFastIoPrepareMdlWrite)
384 #pragma alloc_text(PAGE, FltpFastIoMdlWriteComplete)
385 #pragma alloc_text(PAGE, FltpFastIoReadCompressed)
386 #pragma alloc_text(PAGE, FltpFastIoWriteCompressed)
387 #pragma alloc_text(PAGE, FltpFastIoMdlReadCompleteCompressed)
388 #pragma alloc_text(PAGE, FltpFastIoMdlWriteCompleteCompressed)
389 #pragma alloc_text(PAGE, FltpFastIoQueryOpen)
394 DRIVER_DATA DriverData
;
397 typedef struct _DETACH_DEVICE_WORK_ITEM
399 WORK_QUEUE_ITEM WorkItem
;
400 PDEVICE_OBJECT SourceDevice
;
401 PDEVICE_OBJECT TargetDevice
;
403 } DETACH_DEVICE_WORK_ITEM
, *PDETACH_DEVICE_WORK_ITEM
;
406 /* DISPATCH ROUTINES **********************************************/
410 FltpPreFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data
,
411 _Out_ PVOID
*CompletionContext
)
413 UNREFERENCED_PARAMETER(Data
);
414 UNREFERENCED_PARAMETER(CompletionContext
);
416 return STATUS_SUCCESS
;
421 FltpPostFsFilterOperation(_In_ PFS_FILTER_CALLBACK_DATA Data
,
422 _In_ NTSTATUS OperationStatus
,
423 _In_ PVOID CompletionContext
)
425 UNREFERENCED_PARAMETER(Data
);
426 UNREFERENCED_PARAMETER(OperationStatus
);
427 UNREFERENCED_PARAMETER(CompletionContext
);
433 FltpDispatch(_In_ PDEVICE_OBJECT DeviceObject
,
436 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
437 PIO_STACK_LOCATION StackPtr
;
440 DeviceExtension
= DeviceObject
->DeviceExtension
;
442 /* Check if this is a request for us */
443 if (DeviceObject
== DriverData
.DeviceObject
)
445 FLT_ASSERT(DeviceObject
->DriverObject
== DriverData
.DriverObject
);
446 FLT_ASSERT(DeviceExtension
== NULL
);
448 /* Hand it off to our internal handler */
449 Status
= FltpDispatchHandler(DeviceObject
, Irp
);
450 if (Status
!= STATUS_REPARSE
)
452 Irp
->IoStatus
.Status
= Status
;
453 Irp
->IoStatus
.Information
= 0;
454 IoCompleteRequest(Irp
, 0);
459 /* Check if this is a request for a the messaging device */
460 if (DeviceObject
== CommsDeviceObject
)
462 /* Hand off to our internal routine */
463 return FltpMsgDispatch(DeviceObject
, Irp
);
466 FLT_ASSERT(DeviceExtension
&&
467 DeviceExtension
->AttachedToDeviceObject
);
469 StackPtr
= IoGetCurrentIrpStackLocation(Irp
);
470 if (StackPtr
->MajorFunction
== IRP_MJ_SHUTDOWN
)
472 // handle shutdown request
475 DPRINT1("Received %X from %wZ\n", StackPtr
->MajorFunction
, &DeviceExtension
->DeviceName
);
477 /* Just pass the IRP down the stack */
478 IoSkipCurrentIrpStackLocation(Irp
);
479 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
484 FltpCreate(_In_ PDEVICE_OBJECT DeviceObject
,
487 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
491 DeviceExtension
= DeviceObject
->DeviceExtension
;
493 /* Check if this is a request for us */
494 if (DeviceObject
== DriverData
.DeviceObject
)
496 FLT_ASSERT(DeviceObject
->DriverObject
== DriverData
.DriverObject
);
497 FLT_ASSERT(DeviceExtension
== NULL
);
499 /* Someone wants a handle to the fltmgr, allow it */
500 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
501 Irp
->IoStatus
.Information
= 0;
502 IofCompleteRequest(Irp
, 0);
503 return STATUS_SUCCESS
;
506 /* Check if this is a request for a the new comms connection */
507 if (DeviceObject
== CommsDeviceObject
)
509 /* Hand off to our internal routine */
510 return FltpMsgCreate(DeviceObject
, Irp
);
513 FLT_ASSERT(DeviceExtension
&&
514 DeviceExtension
->AttachedToDeviceObject
);
516 DPRINT1("Received create from %wZ (%lu)\n", &DeviceExtension
->DeviceName
, PsGetCurrentProcessId());
518 /* Just pass the IRP down the stack */
519 IoSkipCurrentIrpStackLocation(Irp
);
520 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
525 FltpFsControl(_In_ PDEVICE_OBJECT DeviceObject
,
528 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
532 /* Check if this is a request for us */
533 if (DeviceObject
== DriverData
.DeviceObject
)
535 /* We don't handle this request */
536 Irp
->IoStatus
.Information
= 0;
537 Irp
->IoStatus
.Status
= STATUS_INVALID_DEVICE_REQUEST
;
538 IofCompleteRequest(Irp
, 0);
539 return STATUS_INVALID_DEVICE_REQUEST
;
542 DeviceExtension
= DeviceObject
->DeviceExtension
;
544 FLT_ASSERT(DeviceExtension
&&
545 DeviceExtension
->AttachedToDeviceObject
);
547 /* Just pass the IRP down the stack */
548 IoSkipCurrentIrpStackLocation(Irp
);
549 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
554 FltpDeviceControl(_In_ PDEVICE_OBJECT DeviceObject
,
557 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
560 /* Check if the request was meant for us */
561 if (DeviceObject
== DriverData
.DeviceObject
)
563 Status
= FltpDeviceControlHandler(DeviceObject
, Irp
);
564 if (Status
!= STATUS_REPARSE
)
566 Irp
->IoStatus
.Status
= Status
;
567 Irp
->IoStatus
.Information
= 0;
568 IoCompleteRequest(Irp
, 0);
574 DeviceExtension
= DeviceObject
->DeviceExtension
;
576 FLT_ASSERT(DeviceExtension
&&
577 DeviceExtension
->AttachedToDeviceObject
);
579 /* Just pass the IRP down the stack */
580 IoSkipCurrentIrpStackLocation(Irp
);
581 return IoCallDriver(DeviceExtension
->AttachedToDeviceObject
, Irp
);
586 /* FASTIO ROUTINES ************************************************/
590 FltpFastIoCheckIfPossible(_In_ PFILE_OBJECT FileObject
,
591 _In_ PLARGE_INTEGER FileOffset
,
595 _In_ BOOLEAN CheckForReadOperation
,
596 _Out_ PIO_STATUS_BLOCK IoStatus
,
597 _In_ PDEVICE_OBJECT DeviceObject
)
600 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
601 PDEVICE_OBJECT AttachedDeviceObject
;
602 PFAST_IO_DISPATCH FastIoDispatch
;
606 /* If it doesn't have a device extension, then it's not our device object */
607 if (DeviceObject
->DeviceExtension
== NULL
)
610 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
611 IoStatus
->Information
= 0;
615 DeviceExtension
= DeviceObject
->DeviceExtension
;
616 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
618 /* Get the device that we attached to */
619 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
620 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
622 /* Make sure our FastIo table is valid */
623 if (FastIoDispatch
&& FastIoDispatch
->FastIoCheckIfPossible
)
625 /* Forward the call onto the device we attached to */
626 return FastIoDispatch
->FastIoCheckIfPossible(FileObject
,
631 CheckForReadOperation
,
633 AttachedDeviceObject
);
636 /* We failed to handle the request, send it down the slow path */
643 FltpFastIoRead(_In_ PFILE_OBJECT FileObject
,
644 _In_ PLARGE_INTEGER FileOffset
,
649 _Out_ PIO_STATUS_BLOCK IoStatus
,
650 _In_ PDEVICE_OBJECT DeviceObject
)
652 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
653 PDEVICE_OBJECT AttachedDeviceObject
;
654 PFAST_IO_DISPATCH FastIoDispatch
;
658 /* If it doesn't have a device extension, then it's not our device object */
659 if (DeviceObject
->DeviceExtension
== NULL
)
662 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
663 IoStatus
->Information
= 0;
667 DeviceExtension
= DeviceObject
->DeviceExtension
;
668 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
670 /* Get the device that we attached to */
671 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
672 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
674 /* Make sure our FastIo table is valid */
675 if (FastIoDispatch
&& FastIoDispatch
->FastIoRead
)
677 /* Forward the call onto the device we attached to */
678 return FastIoDispatch
->FastIoRead(FileObject
,
685 AttachedDeviceObject
);
688 /* We failed to handle the request, send it down the slow path */
695 FltpFastIoWrite(_In_ PFILE_OBJECT FileObject
,
696 _In_ PLARGE_INTEGER FileOffset
,
701 _Out_ PIO_STATUS_BLOCK IoStatus
,
702 _In_ PDEVICE_OBJECT DeviceObject
)
704 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
705 PDEVICE_OBJECT AttachedDeviceObject
;
706 PFAST_IO_DISPATCH FastIoDispatch
;
710 /* If it doesn't have a device extension, then it's not our device object */
711 if (DeviceObject
->DeviceExtension
== NULL
)
714 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
715 IoStatus
->Information
= 0;
719 DeviceExtension
= DeviceObject
->DeviceExtension
;
720 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
722 /* Get the device that we attached to */
723 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
724 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
726 /* Make sure our FastIo table is valid */
727 if (FastIoDispatch
&& FastIoDispatch
->FastIoWrite
)
729 /* Forward the call onto the device we attached to */
730 return FastIoDispatch
->FastIoWrite(FileObject
,
737 AttachedDeviceObject
);
740 /* We failed to handle the request, send it down the slow path */
747 FltpFastIoQueryBasicInfo(_In_ PFILE_OBJECT FileObject
,
749 _Out_ PFILE_BASIC_INFORMATION Buffer
,
750 _Out_ PIO_STATUS_BLOCK IoStatus
,
751 _In_ PDEVICE_OBJECT DeviceObject
)
753 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
754 PDEVICE_OBJECT AttachedDeviceObject
;
755 PFAST_IO_DISPATCH FastIoDispatch
;
759 /* If it doesn't have a device extension, then it's not our device object */
760 if (DeviceObject
->DeviceExtension
== NULL
)
763 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
764 IoStatus
->Information
= 0;
768 DeviceExtension
= DeviceObject
->DeviceExtension
;
769 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
771 /* Get the device that we attached to */
772 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
773 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
775 /* Make sure our FastIo table is valid */
776 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryBasicInfo
)
778 /* Forward the call onto the device we attached to */
779 return FastIoDispatch
->FastIoQueryBasicInfo(FileObject
,
783 AttachedDeviceObject
);
786 /* We failed to handle the request, send it down the slow path */
793 FltpFastIoQueryStandardInfo(_In_ PFILE_OBJECT FileObject
,
795 _Out_ PFILE_STANDARD_INFORMATION Buffer
,
796 _Out_ PIO_STATUS_BLOCK IoStatus
,
797 _In_ PDEVICE_OBJECT DeviceObject
)
799 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
800 PDEVICE_OBJECT AttachedDeviceObject
;
801 PFAST_IO_DISPATCH FastIoDispatch
;
805 /* If it doesn't have a device extension, then it's not our device object */
806 if (DeviceObject
->DeviceExtension
== NULL
)
809 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
810 IoStatus
->Information
= 0;
814 DeviceExtension
= DeviceObject
->DeviceExtension
;
815 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
817 /* Get the device that we attached to */
818 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
819 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
821 /* Make sure our FastIo table is valid */
822 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryStandardInfo
)
824 /* Forward the call onto the device we attached to */
825 return FastIoDispatch
->FastIoQueryStandardInfo(FileObject
,
829 AttachedDeviceObject
);
832 /* We failed to handle the request, send it down the slow path */
839 FltpFastIoLock(_In_ PFILE_OBJECT FileObject
,
840 _In_ PLARGE_INTEGER FileOffset
,
841 _In_ PLARGE_INTEGER Length
,
842 _In_ PEPROCESS ProcessId
,
844 _In_ BOOLEAN FailImmediately
,
845 _In_ BOOLEAN ExclusiveLock
,
846 _Out_ PIO_STATUS_BLOCK IoStatus
,
847 _In_ PDEVICE_OBJECT DeviceObject
)
849 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
850 PDEVICE_OBJECT AttachedDeviceObject
;
851 PFAST_IO_DISPATCH FastIoDispatch
;
855 /* If it doesn't have a device extension, then it's not our device object */
856 if (DeviceObject
->DeviceExtension
== NULL
)
859 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
860 IoStatus
->Information
= 0;
864 DeviceExtension
= DeviceObject
->DeviceExtension
;
865 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
867 /* Get the device that we attached to */
868 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
869 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
871 /* Make sure our FastIo table is valid */
872 if (FastIoDispatch
&& FastIoDispatch
->FastIoLock
)
874 /* Forward the call onto the device we attached to */
875 return FastIoDispatch
->FastIoLock(FileObject
,
883 AttachedDeviceObject
);
886 /* We failed to handle the request, send it down the slow path */
893 FltpFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject
,
894 _In_ PLARGE_INTEGER FileOffset
,
895 _In_ PLARGE_INTEGER Length
,
896 _In_ PEPROCESS ProcessId
,
898 _Out_ PIO_STATUS_BLOCK IoStatus
,
899 _In_ PDEVICE_OBJECT DeviceObject
)
901 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
902 PDEVICE_OBJECT AttachedDeviceObject
;
903 PFAST_IO_DISPATCH FastIoDispatch
;
907 /* If it doesn't have a device extension, then it's not our device object */
908 if (DeviceObject
->DeviceExtension
== NULL
)
911 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
912 IoStatus
->Information
= 0;
916 DeviceExtension
= DeviceObject
->DeviceExtension
;
917 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
919 /* Get the device that we attached to */
920 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
921 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
923 /* Make sure our FastIo table is valid */
924 if (FastIoDispatch
&& FastIoDispatch
->FastIoUnlockSingle
)
926 /* Forward the call onto the device we attached to */
927 return FastIoDispatch
->FastIoUnlockSingle(FileObject
,
933 AttachedDeviceObject
);
936 /* We failed to handle the request, send it down the slow path */
943 FltpFastIoUnlockAll(_In_ PFILE_OBJECT FileObject
,
944 _In_ PEPROCESS ProcessId
,
945 _Out_ PIO_STATUS_BLOCK IoStatus
,
946 _In_ PDEVICE_OBJECT DeviceObject
)
949 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
950 PDEVICE_OBJECT AttachedDeviceObject
;
951 PFAST_IO_DISPATCH FastIoDispatch
;
955 /* If it doesn't have a device extension, then it's not our device object */
956 if (DeviceObject
->DeviceExtension
== NULL
)
959 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
960 IoStatus
->Information
= 0;
964 DeviceExtension
= DeviceObject
->DeviceExtension
;
965 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
967 /* Get the device that we attached to */
968 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
969 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
971 /* Make sure our FastIo table is valid */
972 if (FastIoDispatch
&& FastIoDispatch
->FastIoUnlockAll
)
974 /* Forward the call onto the device we attached to */
975 return FastIoDispatch
->FastIoUnlockAll(FileObject
,
978 AttachedDeviceObject
);
981 /* We failed to handle the request, send it down the slow path */
988 FltpFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject
,
989 _In_ PVOID ProcessId
,
991 _Out_ PIO_STATUS_BLOCK IoStatus
,
992 _In_ PDEVICE_OBJECT DeviceObject
)
994 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
995 PDEVICE_OBJECT AttachedDeviceObject
;
996 PFAST_IO_DISPATCH FastIoDispatch
;
1000 /* If it doesn't have a device extension, then it's not our device object */
1001 if (DeviceObject
->DeviceExtension
== NULL
)
1004 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1005 IoStatus
->Information
= 0;
1009 DeviceExtension
= DeviceObject
->DeviceExtension
;
1010 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1012 /* Get the device that we attached to */
1013 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1014 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1016 /* Make sure our FastIo table is valid */
1017 if (FastIoDispatch
&& FastIoDispatch
->FastIoUnlockAllByKey
)
1019 /* Forward the call onto the device we attached to */
1020 return FastIoDispatch
->FastIoUnlockAllByKey(FileObject
,
1024 AttachedDeviceObject
);
1027 /* We failed to handle the request, send it down the slow path */
1034 FltpFastIoDeviceControl(_In_ PFILE_OBJECT FileObject
,
1036 _In_opt_ PVOID InputBuffer
,
1037 _In_ ULONG InputBufferLength
,
1038 _Out_opt_ PVOID OutputBuffer
,
1039 _In_ ULONG OutputBufferLength
,
1040 _In_ ULONG IoControlCode
,
1041 _Out_ PIO_STATUS_BLOCK IoStatus
,
1042 _In_ PDEVICE_OBJECT DeviceObject
)
1044 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1045 PDEVICE_OBJECT AttachedDeviceObject
;
1046 PFAST_IO_DISPATCH FastIoDispatch
;
1050 /* If it doesn't have a device extension, then it's not our device object */
1051 if (DeviceObject
->DeviceExtension
== NULL
)
1053 /* Fail the request, send it down the slow path */
1057 DeviceExtension
= DeviceObject
->DeviceExtension
;
1058 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1060 /* Get the device that we attached to */
1061 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1062 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1064 /* Make sure our FastIo table is valid */
1065 if (FastIoDispatch
&& FastIoDispatch
->FastIoDeviceControl
)
1067 /* Forward the call onto the device we attached to */
1068 return FastIoDispatch
->FastIoDeviceControl(FileObject
,
1076 AttachedDeviceObject
);
1079 /* We failed to handle the request, send it down the slow path */
1086 FltpFastIoDetachDeviceWorker(_In_ PVOID Parameter
)
1088 PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem
= Parameter
;
1090 /* Run any cleanup routines */
1091 FltpCleanupDeviceObject(DetachDeviceWorkItem
->SourceDevice
);
1093 /* Detach from the target device */
1094 IoDetachDevice(DetachDeviceWorkItem
->TargetDevice
);
1096 /* Delete the source */
1097 IoDeleteDevice(DetachDeviceWorkItem
->SourceDevice
);
1099 /* Free the pool we allocated in FltpFastIoDetachDevice */
1100 ExFreePoolWithTag(DetachDeviceWorkItem
, 0x1234);
1105 FltpFastIoDetachDevice(_In_ PDEVICE_OBJECT SourceDevice
,
1106 _In_ PDEVICE_OBJECT TargetDevice
)
1108 PDETACH_DEVICE_WORK_ITEM DetachDeviceWorkItem
;
1113 * Detaching and deleting devices is a lot of work and takes too long
1114 * to be a worthwhile FastIo candidate, so we defer this call to speed
1115 * it up. There's no return value so we're okay to do this.
1118 /* Allocate the work item and it's corresponding data */
1119 DetachDeviceWorkItem
= ExAllocatePoolWithTag(NonPagedPool
,
1120 sizeof(DETACH_DEVICE_WORK_ITEM
),
1122 if (DetachDeviceWorkItem
)
1124 /* Initialize the work item */
1125 ExInitializeWorkItem(&DetachDeviceWorkItem
->WorkItem
,
1126 FltpFastIoDetachDeviceWorker
,
1127 DetachDeviceWorkItem
);
1129 /* Queue the work item and return the call */
1130 ExQueueWorkItem(&DetachDeviceWorkItem
->WorkItem
,
1135 /* We failed to defer, just cleanup here */
1136 FltpCleanupDeviceObject(SourceDevice
);
1137 IoDetachDevice(TargetDevice
);
1138 IoDeleteDevice(SourceDevice
);
1145 FltpFastIoQueryNetworkOpenInfo(_In_ PFILE_OBJECT FileObject
,
1147 _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer
,
1148 _Out_ PIO_STATUS_BLOCK IoStatus
,
1149 _In_ PDEVICE_OBJECT DeviceObject
)
1151 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1152 PDEVICE_OBJECT AttachedDeviceObject
;
1153 PFAST_IO_DISPATCH FastIoDispatch
;
1157 /* If it doesn't have a device extension, then it's not our device object */
1158 if (DeviceObject
->DeviceExtension
== NULL
)
1161 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1162 IoStatus
->Information
= 0;
1166 DeviceExtension
= DeviceObject
->DeviceExtension
;
1167 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1169 /* Get the device that we attached to */
1170 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1171 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1173 /* Make sure our FastIo table is valid */
1174 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryNetworkOpenInfo
)
1176 /* Forward the call onto the device we attached to */
1177 return FastIoDispatch
->FastIoQueryNetworkOpenInfo(FileObject
,
1181 AttachedDeviceObject
);
1184 /* We failed to handle the request, send it down the slow path */
1191 FltpFastIoMdlRead(_In_ PFILE_OBJECT FileObject
,
1192 _In_ PLARGE_INTEGER FileOffset
,
1195 _Out_ PMDL
*MdlChain
,
1196 _Out_ PIO_STATUS_BLOCK IoStatus
,
1197 _In_ PDEVICE_OBJECT DeviceObject
)
1199 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1200 PDEVICE_OBJECT AttachedDeviceObject
;
1201 PFAST_IO_DISPATCH FastIoDispatch
;
1205 /* If it doesn't have a device extension, then it's not our device object */
1206 if (DeviceObject
->DeviceExtension
== NULL
)
1209 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1210 IoStatus
->Information
= 0;
1214 DeviceExtension
= DeviceObject
->DeviceExtension
;
1215 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1217 /* Get the device that we attached to */
1218 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1219 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1221 /* Make sure our FastIo table is valid */
1222 if (FastIoDispatch
&& FastIoDispatch
->MdlRead
)
1224 /* Forward the call onto the device we attached to */
1225 return FastIoDispatch
->MdlRead(FileObject
,
1231 AttachedDeviceObject
);
1234 /* We failed to handle the request, send it down the slow path */
1241 FltpFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject
,
1243 _In_ PDEVICE_OBJECT DeviceObject
)
1246 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1247 PDEVICE_OBJECT AttachedDeviceObject
;
1248 PFAST_IO_DISPATCH FastIoDispatch
;
1252 /* If it doesn't have a device extension, then it's not our device object */
1253 if (DeviceObject
->DeviceExtension
== NULL
)
1255 /* Fail the request, send it down the slow path */
1259 DeviceExtension
= DeviceObject
->DeviceExtension
;
1260 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1262 /* Get the device that we attached to */
1263 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1264 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1266 /* Make sure our FastIo table is valid */
1267 if (FastIoDispatch
&& FastIoDispatch
->MdlReadComplete
)
1269 /* Forward the call onto the device we attached to */
1270 return FastIoDispatch
->MdlReadComplete(FileObject
,
1272 AttachedDeviceObject
);
1275 /* We failed to handle the request, send it down the slow path */
1282 FltpFastIoPrepareMdlWrite(_In_ PFILE_OBJECT FileObject
,
1283 _In_ PLARGE_INTEGER FileOffset
,
1286 _Out_ PMDL
*MdlChain
,
1287 _Out_ PIO_STATUS_BLOCK IoStatus
,
1288 _In_ PDEVICE_OBJECT DeviceObject
)
1290 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1291 PDEVICE_OBJECT AttachedDeviceObject
;
1292 PFAST_IO_DISPATCH FastIoDispatch
;
1296 /* If it doesn't have a device extension, then it's not our device object */
1297 if (DeviceObject
->DeviceExtension
== NULL
)
1300 IoStatus
->Status
= STATUS_INVALID_DEVICE_REQUEST
;
1301 IoStatus
->Information
= 0;
1305 DeviceExtension
= DeviceObject
->DeviceExtension
;
1306 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1308 /* Get the device that we attached to */
1309 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1310 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1312 /* Make sure our FastIo table is valid */
1313 if (FastIoDispatch
&& FastIoDispatch
->PrepareMdlWrite
)
1315 /* Forward the call onto the device we attached to */
1316 return FastIoDispatch
->PrepareMdlWrite(FileObject
,
1322 AttachedDeviceObject
);
1325 /* We failed to handle the request, send it down the slow path */
1332 FltpFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject
,
1333 _In_ PLARGE_INTEGER FileOffset
,
1335 _In_ PDEVICE_OBJECT DeviceObject
)
1337 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1338 PDEVICE_OBJECT AttachedDeviceObject
;
1339 PFAST_IO_DISPATCH FastIoDispatch
;
1343 /* If it doesn't have a device extension, then it's not our device object */
1344 if (DeviceObject
->DeviceExtension
== NULL
)
1346 /* Fail the request, send it down the slow path */
1350 DeviceExtension
= DeviceObject
->DeviceExtension
;
1351 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1353 /* Get the device that we attached to */
1354 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1355 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1357 /* Make sure our FastIo table is valid */
1358 if (FastIoDispatch
&& FastIoDispatch
->MdlWriteComplete
)
1360 /* Forward the call onto the device we attached to */
1361 return FastIoDispatch
->MdlWriteComplete(FileObject
,
1364 AttachedDeviceObject
);
1367 /* We failed to handle the request, send it down the slow path */
1374 FltpFastIoReadCompressed(_In_ PFILE_OBJECT FileObject
,
1375 _In_ PLARGE_INTEGER FileOffset
,
1379 _Out_ PMDL
*MdlChain
,
1380 _Out_ PIO_STATUS_BLOCK IoStatus
,
1381 _Out_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
1382 _In_ ULONG CompressedDataInfoLength
,
1383 _In_ PDEVICE_OBJECT DeviceObject
)
1385 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1386 PDEVICE_OBJECT AttachedDeviceObject
;
1387 PFAST_IO_DISPATCH FastIoDispatch
;
1391 /* If it doesn't have a device extension, then it's not our device object */
1392 if (DeviceObject
->DeviceExtension
== NULL
)
1394 /* Fail the request, send it down the slow path */
1398 DeviceExtension
= DeviceObject
->DeviceExtension
;
1399 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1401 /* Get the device that we attached to */
1402 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1403 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1405 /* Make sure our FastIo table is valid */
1406 if (FastIoDispatch
&& FastIoDispatch
->FastIoReadCompressed
)
1408 /* Forward the call onto the device we attached to */
1409 return FastIoDispatch
->FastIoReadCompressed(FileObject
,
1417 CompressedDataInfoLength
,
1418 AttachedDeviceObject
);
1421 /* We failed to handle the request, send it down the slow path */
1428 FltpFastIoWriteCompressed(_In_ PFILE_OBJECT FileObject
,
1429 _In_ PLARGE_INTEGER FileOffset
,
1433 _Out_ PMDL
*MdlChain
,
1434 _Out_ PIO_STATUS_BLOCK IoStatus
,
1435 _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo
,
1436 _In_ ULONG CompressedDataInfoLength
,
1437 _In_ PDEVICE_OBJECT DeviceObject
)
1439 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1440 PDEVICE_OBJECT AttachedDeviceObject
;
1441 PFAST_IO_DISPATCH FastIoDispatch
;
1445 /* If it doesn't have a device extension, then it's not our device object */
1446 if (DeviceObject
->DeviceExtension
== NULL
)
1448 /* Fail the request, send it down the slow path */
1452 DeviceExtension
= DeviceObject
->DeviceExtension
;
1453 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1455 /* Get the device that we attached to */
1456 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1457 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1459 /* Make sure our FastIo table is valid */
1460 if (FastIoDispatch
&& FastIoDispatch
->FastIoWriteCompressed
)
1462 /* Forward the call onto the device we attached to */
1463 return FastIoDispatch
->FastIoWriteCompressed(FileObject
,
1471 CompressedDataInfoLength
,
1472 AttachedDeviceObject
);
1475 /* We failed to handle the request, send it down the slow path */
1482 FltpFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject
,
1484 _In_ PDEVICE_OBJECT DeviceObject
)
1486 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1487 PDEVICE_OBJECT AttachedDeviceObject
;
1488 PFAST_IO_DISPATCH FastIoDispatch
;
1492 /* If it doesn't have a device extension, then it's not our device object */
1493 if (DeviceObject
->DeviceExtension
== NULL
)
1498 DeviceExtension
= DeviceObject
->DeviceExtension
;
1499 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1501 /* Get the device that we attached to */
1502 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1503 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1505 /* Make sure our FastIo table is valid */
1506 if (FastIoDispatch
&& FastIoDispatch
->MdlReadCompleteCompressed
)
1508 /* Forward the call onto the device we attached to */
1509 return FastIoDispatch
->MdlReadCompleteCompressed(FileObject
,
1511 AttachedDeviceObject
);
1514 /* We failed to handle the request, send it down the slow path */
1521 FltpFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT FileObject
,
1522 _In_ PLARGE_INTEGER FileOffset
,
1524 _In_ PDEVICE_OBJECT DeviceObject
)
1526 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1527 PDEVICE_OBJECT AttachedDeviceObject
;
1528 PFAST_IO_DISPATCH FastIoDispatch
;
1532 /* If it doesn't have a device extension, then it's not our device object */
1533 if (DeviceObject
->DeviceExtension
== NULL
)
1538 DeviceExtension
= DeviceObject
->DeviceExtension
;
1539 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1541 /* Get the device that we attached to */
1542 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1543 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1545 /* Make sure our FastIo table is valid */
1546 if (FastIoDispatch
&& FastIoDispatch
->MdlWriteCompleteCompressed
)
1548 /* Forward the call onto the device we attached to */
1549 return FastIoDispatch
->MdlWriteCompleteCompressed(FileObject
,
1552 AttachedDeviceObject
);
1555 /* We failed to handle the request, send it down the slow path */
1562 FltpFastIoQueryOpen(_Inout_ PIRP Irp
,
1563 _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation
,
1564 _In_ PDEVICE_OBJECT DeviceObject
)
1566 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1567 PDEVICE_OBJECT AttachedDeviceObject
;
1568 PFAST_IO_DISPATCH FastIoDispatch
;
1573 /* If it doesn't have a device extension, then it's not our device object */
1574 if (DeviceObject
->DeviceExtension
== NULL
)
1579 DeviceExtension
= DeviceObject
->DeviceExtension
;
1580 FLT_ASSERT(DeviceExtension
->AttachedToDeviceObject
);
1582 /* Get the device that we attached to */
1583 AttachedDeviceObject
= DeviceExtension
->AttachedToDeviceObject
;
1584 FastIoDispatch
= AttachedDeviceObject
->DriverObject
->FastIoDispatch
;
1586 /* Make sure our FastIo table is valid */
1587 if (FastIoDispatch
&& FastIoDispatch
->FastIoQueryOpen
)
1589 PIO_STACK_LOCATION StackPtr
= IoGetCurrentIrpStackLocation(Irp
);
1591 /* Update the stack to contain the correct device for the next filter */
1592 StackPtr
->DeviceObject
= AttachedDeviceObject
;
1594 /* Now forward the call */
1595 Success
= FastIoDispatch
->FastIoQueryOpen(Irp
,
1597 AttachedDeviceObject
);
1599 /* Restore the DeviceObject as we found it */
1600 StackPtr
->DeviceObject
= DeviceObject
;
1604 /* We failed to handle the request, send it down the slow path */
1611 /* FUNCTIONS **********************************************/
1615 FltpCleanupDeviceObject(_In_ PDEVICE_OBJECT DeviceObject
)
1617 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1619 DeviceExtension
= DeviceObject
->DeviceExtension
;
1620 if (DeviceExtension
)
1622 // cleanup device extension
1628 FltpAttachDeviceObject(_In_ PDEVICE_OBJECT SourceDevice
,
1629 _In_ PDEVICE_OBJECT TargetDevice
,
1630 _Out_ PDEVICE_OBJECT
*AttachedToDeviceObject
)
1636 /* Before attaching, copy the flags from the device we're going to attach to */
1637 if (FlagOn(SourceDevice
->Flags
, DO_BUFFERED_IO
))
1639 SetFlag(TargetDevice
->Flags
, DO_BUFFERED_IO
);
1641 if (FlagOn(SourceDevice
->Flags
, DO_DIRECT_IO
))
1643 SetFlag(TargetDevice
->Flags
, DO_DIRECT_IO
);
1645 if (FlagOn(SourceDevice
->Flags
, DO_SYSTEM_BOOT_PARTITION
))
1647 SetFlag(TargetDevice
->Characteristics
, FILE_DEVICE_SECURE_OPEN
);
1650 /* Attach this device to the top of the driver stack */
1651 Status
= IoAttachDeviceToDeviceStackSafe(SourceDevice
,
1653 AttachedToDeviceObject
);
1660 FltpIsAttachedToDevice(_In_ PDEVICE_OBJECT DeviceObject
,
1661 _In_opt_ PDEVICE_OBJECT
*AttachedDeviceObject
)
1663 PDEVICE_OBJECT CurrentDeviceObject
;
1664 PDEVICE_OBJECT NextDeviceObject
;
1668 /* Initialize the return pointer */
1669 if (AttachedDeviceObject
) *AttachedDeviceObject
= NULL
;
1671 /* Start by getting the top level device in the chain */
1672 CurrentDeviceObject
= IoGetAttachedDeviceReference(DeviceObject
);
1674 /* Loop while there are attached devices */
1675 while (CurrentDeviceObject
)
1677 /* Check if this device driver matches ours */
1678 if (CurrentDeviceObject
->DriverObject
== DriverData
.DriverObject
)
1680 FLT_ASSERT(CurrentDeviceObject
->DeviceExtension
!= NULL
);
1682 /* We're attached, return the device object if the caller asked for it */
1683 if (AttachedDeviceObject
)
1685 *AttachedDeviceObject
= CurrentDeviceObject
;
1689 /* We aren't returning the reference, so decrement the count */
1690 ObDereferenceObject(CurrentDeviceObject
);
1696 /* Get the next device in the chain */
1697 NextDeviceObject
= IoGetLowerDeviceObject(CurrentDeviceObject
);
1699 /* Decrement the count on the last device before we update the pointer */
1700 ObDereferenceObject(CurrentDeviceObject
);
1701 CurrentDeviceObject
= NextDeviceObject
;
1709 FltpEnumerateFileSystemVolumes(_In_ PDEVICE_OBJECT DeviceObject
)
1711 PFLTMGR_DEVICE_EXTENSION NewDeviceExtension
;
1712 PDEVICE_OBJECT BaseDeviceObject
;
1713 PDEVICE_OBJECT NewDeviceObject
;
1714 PDEVICE_OBJECT
*DeviceList
;
1715 PDEVICE_OBJECT StorageStackDeviceObject
;
1716 UNICODE_STRING DeviceName
;
1723 /* Get the base device */
1724 BaseDeviceObject
= IoGetDeviceAttachmentBaseRef(DeviceObject
);
1726 /* get the number of device object linked to the base file system */
1727 Status
= IoEnumerateDeviceObjectList(BaseDeviceObject
->DriverObject
,
1731 if (Status
!= STATUS_BUFFER_TOO_SMALL
) return Status
;
1733 /* Add a few more slots in case the size changed between calls and allocate some memory to hold the pointers */
1735 DeviceList
= ExAllocatePoolWithTag(NonPagedPool
,
1736 (NumDevices
* sizeof(PDEVICE_OBJECT
)),
1737 FM_TAG_DEV_OBJ_PTRS
);
1738 if (DeviceList
== NULL
) return STATUS_INSUFFICIENT_RESOURCES
;
1740 /* Now get all the device objects that this base driver has created */
1741 Status
= IoEnumerateDeviceObjectList(BaseDeviceObject
->DriverObject
,
1743 (NumDevices
* sizeof(PDEVICE_OBJECT
)),
1745 if (!NT_SUCCESS(Status
))
1747 ExFreePoolWithTag(DeviceList
, FM_TAG_DEV_OBJ_PTRS
);
1751 /* Loop through all the devices looking for ones to attach to */
1752 for (i
= 0; i
< NumDevices
; i
++)
1754 RtlInitUnicodeString(&DeviceName
, NULL
);
1755 StorageStackDeviceObject
= NULL
;
1756 NewDeviceObject
= NULL
;
1758 /* Ignore the device we passed in, and devices of the wrong type */
1759 if ((DeviceList
[i
] == BaseDeviceObject
) ||
1760 (DeviceList
[i
]->DeviceType
!= BaseDeviceObject
->DeviceType
))
1762 goto CleanupAndNext
;
1765 /* Ignore this device if we're already attached to it */
1766 if (FltpIsAttachedToDevice(DeviceList
[i
], NULL
) == FALSE
)
1768 goto CleanupAndNext
;
1773 * If the device has a name, it must be a control device.
1774 * This handles drivers with more then one control device (like FastFat)
1776 FltpGetBaseDeviceObjectName(DeviceList
[i
], &DeviceName
);
1777 if (NT_SUCCESS(Status
) && DeviceName
.Length
> 0)
1779 goto CleanupAndNext
;
1783 * Try to get the storage stack (disk) device object associated with
1784 * this file system device object. Ignore the device if we don't have one
1786 Status
= IoGetDiskDeviceObject(DeviceList
[i
],
1787 &StorageStackDeviceObject
);
1788 if (!NT_SUCCESS(Status
))
1790 goto CleanupAndNext
;
1795 * TODO: Don't attach to shadow copy volumes,
1796 * ros doesn't have any so it's not an issues yet
1800 * We're far enough to be ready to attach, create a device
1801 * object which we'll use to do so
1803 Status
= IoCreateDevice(DriverData
.DriverObject
,
1804 sizeof(FLTMGR_DEVICE_EXTENSION
),
1806 DeviceList
[i
]->DeviceType
,
1810 if (!NT_SUCCESS(Status
))
1812 goto CleanupAndNext
;
1815 /* Get the device extension for this new object and store our disk object there */
1816 NewDeviceExtension
= NewDeviceObject
->DeviceExtension
;
1817 NewDeviceExtension
->StorageStackDeviceObject
= StorageStackDeviceObject
;
1819 /* Lookup and store the device name for the storage stack */
1820 RtlInitEmptyUnicodeString(&NewDeviceExtension
->DeviceName
,
1821 NewDeviceExtension
->DeviceNameBuffer
,
1822 sizeof(NewDeviceExtension
->DeviceNameBuffer
));
1823 FltpGetObjectName(StorageStackDeviceObject
,
1824 &NewDeviceExtension
->DeviceName
);
1827 /* Grab the attach lock before we attempt to attach */
1828 ExAcquireFastMutex(&DriverData
.FilterAttachLock
);
1830 /* Check again that we aren't already attached. It may have changed since our last check */
1831 if (FltpIsAttachedToDevice(DeviceList
[i
], NULL
) == FALSE
)
1833 FLT_ASSERT(NewDeviceObject
->DriverObject
== DriverData
.DriverObject
);
1835 /* Finally, attach to the volume */
1836 Status
= FltpAttachDeviceObject(DeviceList
[i
],
1838 &NewDeviceExtension
->AttachedToDeviceObject
);
1839 if (NT_SUCCESS(Status
))
1841 /* Clean the initializing flag so other filters can attach to our device object */
1842 ClearFlag(NewDeviceObject
->Flags
, DO_DEVICE_INITIALIZING
);
1847 /* We're already attached. Just cleanup */
1848 Status
= STATUS_DEVICE_ALREADY_ATTACHED
;
1851 ExReleaseFastMutex(&DriverData
.FilterAttachLock
);
1855 if (!NT_SUCCESS(Status
))
1857 if (NewDeviceObject
)
1859 FltpCleanupDeviceObject(NewDeviceObject
);
1860 IoDeleteDevice(NewDeviceObject
);
1864 if (StorageStackDeviceObject
)
1866 /* A ref was added for us when we attached, so we can deref ours now */
1867 ObDereferenceObject(StorageStackDeviceObject
);
1870 /* Remove the ref which was added by IoEnumerateDeviceObjectList */
1871 ObDereferenceObject(DeviceList
[i
]);
1873 /* Free the buffer that FltpGetBaseDeviceObjectName added */
1874 FltpFreeUnicodeString(&DeviceName
);
1878 /* Free the memory we allocated for the list */
1879 ExFreePoolWithTag(DeviceList
, FM_TAG_DEV_OBJ_PTRS
);
1881 return STATUS_SUCCESS
;
1886 FltpAttachToFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject
,
1887 _In_ PUNICODE_STRING DeviceName
)
1889 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1890 PDEVICE_OBJECT NewDeviceObject
;
1891 WCHAR Buffer
[MAX_DEVNAME_LENGTH
];
1892 UNICODE_STRING FileSystemDeviceName
;
1893 UNICODE_STRING FsRecDeviceName
;
1898 /* Only handle device types we're interested in */
1899 if (DeviceObject
->DeviceType
!= FILE_DEVICE_DISK_FILE_SYSTEM
&&
1900 DeviceObject
->DeviceType
!= FILE_DEVICE_CD_ROM_FILE_SYSTEM
&&
1901 DeviceObject
->DeviceType
!= FILE_DEVICE_NETWORK_FILE_SYSTEM
)
1903 return STATUS_SUCCESS
;
1906 /* Setup the buffer to hold the device name */
1907 RtlInitEmptyUnicodeString(&FileSystemDeviceName
,
1909 MAX_DEVNAME_LENGTH
* sizeof(WCHAR
));
1911 /* Get the the name of the file system device */
1912 Status
= FltpGetObjectName(DeviceObject
->DriverObject
, &FileSystemDeviceName
);
1913 if (!NT_SUCCESS(Status
)) return Status
;
1915 DPRINT("Found device %wZ, checking if we need to attach...\n", &FileSystemDeviceName
);
1917 /* Build up the name of the file system recognizer device */
1918 RtlInitUnicodeString(&FsRecDeviceName
, L
"\\FileSystem\\Fs_Rec");
1920 /* We don't attach to recognizer devices, so bail if this is one */
1921 if (RtlCompareUnicodeString(&FileSystemDeviceName
, &FsRecDeviceName
, TRUE
) == 0)
1923 return STATUS_SUCCESS
;
1926 /* Create a device object which we can attach to this file system */
1927 Status
= IoCreateDevice(DriverData
.DriverObject
,
1928 sizeof(FLTMGR_DEVICE_EXTENSION
),
1930 DeviceObject
->DeviceType
,
1934 if (!NT_SUCCESS(Status
))
1936 DPRINT1("Failed to create a DO for attaching to a FS : 0x%X\n", Status
);
1940 /* Cast the device extension to something we understand */
1941 DeviceExtension
= NewDeviceObject
->DeviceExtension
;
1943 /* Attach this device to the top of the driver stack and store the DO we attached to in the DE */
1944 Status
= FltpAttachDeviceObject(NewDeviceObject
,
1946 &DeviceExtension
->AttachedToDeviceObject
);
1947 if (NT_SUCCESS(Status
))
1949 DPRINT("Attached to %wZ\n", &FileSystemDeviceName
);
1953 DPRINT1("Failed to attach to the driver stack : 0x%X\n", Status
);
1957 /* Setup the unicode string buffer and copy the device name to the device extension */
1958 RtlInitEmptyUnicodeString(&DeviceExtension
->DeviceName
,
1959 DeviceExtension
->DeviceNameBuffer
,
1960 MAX_DEVNAME_LENGTH
* sizeof(WCHAR
));
1961 RtlCopyUnicodeString(&DeviceExtension
->DeviceName
, DeviceName
);
1963 /* We're done, remove the initializing flag */
1964 ClearFlag(NewDeviceObject
->Flags
, DO_DEVICE_INITIALIZING
);
1966 /* Look for existing mounted devices for this file system */
1967 Status
= FltpEnumerateFileSystemVolumes(DeviceObject
);
1968 if (!NT_SUCCESS(Status
))
1970 DPRINT1("Failed to enumerate file system volumes for this file system : 0x%X\n", Status
);
1971 IoDetachDevice(DeviceExtension
->AttachedToDeviceObject
);
1976 if (!NT_SUCCESS(Status
))
1978 IoDeleteDevice(NewDeviceObject
);
1986 FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject
)
1988 PDEVICE_OBJECT AttachedDevice
, NextDevice
;
1989 PFLTMGR_DEVICE_EXTENSION DeviceExtension
;
1994 /* Get the top device in the chain and increment the ref count on it */
1995 AttachedDevice
= IoGetAttachedDeviceReference(DeviceObject
);
1997 /* Loop all attached devices looking for our file system driver */
1998 while (AttachedDevice
->DriverObject
!= DriverData
.DriverObject
)
2000 FLT_ASSERT(AttachedDevice
!= NULL
);
2002 /* Get the next lower device object. This adds a ref on NextDevice */
2003 NextDevice
= IoGetLowerDeviceObject(AttachedDevice
);
2005 /* Remove the reference we added */
2006 Count
= ObfDereferenceObject(AttachedDevice
);
2008 /* Bail if this is the last one */
2009 if (NextDevice
== NULL
) return Count
;
2011 /* Try the next one */
2012 AttachedDevice
= NextDevice
;
2016 DeviceExtension
= AttachedDevice
->DeviceExtension
;
2017 if (DeviceExtension
)
2020 // FIXME: Put any device extension cleanup code here
2024 /* Detach the device from the chain and delete the object */
2025 IoDetachDevice(DeviceObject
);
2026 IoDeleteDevice(AttachedDevice
);
2028 /* Remove the reference we added so the delete can complete */
2029 return ObfDereferenceObject(AttachedDevice
);
2032 DRIVER_FS_NOTIFICATION FltpFsNotification
;
2035 FltpFsNotification(_In_ PDEVICE_OBJECT DeviceObject
,
2036 _In_ BOOLEAN FsActive
)
2038 UNICODE_STRING DeviceName
;
2043 /* Set an empty string */
2044 RtlInitUnicodeString(&DeviceName
, NULL
);
2046 /* Get the name of the lowest device object on the stack */
2047 Status
= FltpGetBaseDeviceObjectName(DeviceObject
, &DeviceName
);
2048 if (NT_SUCCESS(Status
))
2050 /* Check if it's attaching or detaching */
2053 /* Run the attach routine */
2054 FltpAttachToFileSystemDevice(DeviceObject
, &DeviceName
);
2058 /* Run the detach routine */
2059 FltpDetachFromFileSystemDevice(DeviceObject
);
2062 /* Free the buffer which FltpGetBaseDeviceObjectName allocated */
2063 FltpFreeUnicodeString(&DeviceName
);
2067 DRIVER_INITIALIZE DriverEntry
;
2070 DriverEntry(_In_ PDRIVER_OBJECT DriverObject
,
2071 _In_ PUNICODE_STRING RegistryPath
)
2073 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\FileSystem\\Filters\\"DRIVER_NAME
);
2074 PDEVICE_OBJECT RawDeviceObject
;
2075 PDEVICE_OBJECT DeviceObject
;
2076 PFILE_OBJECT RawFileObject
;
2077 UNICODE_STRING ObjectName
;
2078 UNICODE_STRING SymLink
;
2082 RtlZeroMemory(&DriverData
, sizeof(DRIVER_DATA
));
2083 DriverData
.DriverObject
= DriverObject
;
2085 /* Save the registry key for this driver */
2086 DriverData
.ServiceKey
.Length
= RegistryPath
->Length
;
2087 DriverData
.ServiceKey
.MaximumLength
= RegistryPath
->MaximumLength
;
2088 DriverData
.ServiceKey
.Buffer
= (PWCHAR
)ExAllocatePoolWithTag(NonPagedPool
,
2089 RegistryPath
->MaximumLength
,
2090 FM_TAG_REGISTRY_DATA
);
2091 if (!DriverData
.ServiceKey
.Buffer
) return STATUS_INSUFFICIENT_RESOURCES
;
2092 RtlCopyUnicodeString(&DriverData
.ServiceKey
, RegistryPath
);
2094 /* Do some initialization */
2095 ExInitializeFastMutex(&DriverData
.FilterAttachLock
);
2097 /* Create the main filter manager device object */
2098 Status
= IoCreateDevice(DriverObject
,
2101 FILE_DEVICE_DISK_FILE_SYSTEM
,
2102 FILE_DEVICE_SECURE_OPEN
,
2105 if (!NT_SUCCESS(Status
))
2107 DPRINT1("fltmgr IoCreateDevice failed. Status = %X\n", Status
);
2111 /* Store a global reference so we can access from callbacks */
2112 DriverData
.DeviceObject
= DeviceObject
;
2114 /* Generate the symbolic link name */
2115 RtlInitUnicodeString(&SymLink
, L
"\\??\\"DRIVER_NAME
);
2116 Status
= IoCreateSymbolicLink(&SymLink
, &DeviceName
);
2117 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2119 /* Create the callbacks for the dispatch table, FastIo and FS callbacks */
2120 Status
= SetupDispatchAndCallbacksTables(DriverObject
);
2121 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2123 /* Initialize the comms objects */
2124 Status
= FltpSetupCommunicationObjects(DriverObject
);
2125 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2127 /* Register for notifications when a new file system is loaded. This also enumerates any existing file systems */
2128 Status
= IoRegisterFsRegistrationChange(DriverObject
, FltpFsNotification
);
2129 FLT_ASSERT(Status
!= STATUS_DEVICE_ALREADY_ATTACHED
); // Windows checks for this, I'm not sure how it can happen. Needs investigation??
2130 if (!NT_SUCCESS(Status
)) goto Cleanup
;
2132 /* IoRegisterFsRegistrationChange isn't notified about the raw file systems, so we attach to them manually */
2133 RtlInitUnicodeString(&ObjectName
, L
"\\Device\\RawDisk");
2134 Status
= IoGetDeviceObjectPointer(&ObjectName
,
2135 FILE_READ_ATTRIBUTES
,
2138 if (NT_SUCCESS(Status
))
2140 FltpFsNotification(RawDeviceObject
, TRUE
);
2141 ObfDereferenceObject(RawFileObject
);
2144 RtlInitUnicodeString(&ObjectName
, L
"\\Device\\RawCdRom");
2145 Status
= IoGetDeviceObjectPointer(&ObjectName
,
2146 FILE_READ_ATTRIBUTES
,
2149 if (NT_SUCCESS(Status
))
2151 FltpFsNotification(RawDeviceObject
, TRUE
);
2152 ObfDereferenceObject(RawFileObject
);
2155 /* We're done, clear the initializing flag */
2156 ClearFlag(DeviceObject
->Flags
, DO_DEVICE_INITIALIZING
);
2157 Status
= STATUS_SUCCESS
;
2161 if (!NT_SUCCESS(Status
))
2163 if (DriverData
.FastIoDispatch
)
2165 DriverObject
->FastIoDispatch
= NULL
;
2166 ExFreePoolWithTag(DriverData
.FastIoDispatch
, FM_TAG_DISPATCH_TABLE
);
2169 IoDeleteSymbolicLink(&SymLink
);
2172 IoDeleteDevice(DeviceObject
);
2174 if (DriverData
.ServiceKey
.Buffer
)
2175 ExFreePoolWithTag(DriverData
.ServiceKey
.Buffer
, FM_TAG_REGISTRY_DATA
);
2184 SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject
)
2186 PFAST_IO_DISPATCH FastIoDispatch
;
2187 FS_FILTER_CALLBACKS Callbacks
;
2190 /* Plug all the IRPs */
2191 for (i
= 0; i
<= IRP_MJ_MAXIMUM_FUNCTION
; i
++)
2193 DriverObject
->MajorFunction
[i
] = FltpDispatch
;
2196 /* Override the ones we're interested in */
2197 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = FltpCreate
;
2198 DriverObject
->MajorFunction
[IRP_MJ_CREATE_NAMED_PIPE
] = FltpCreate
;
2199 DriverObject
->MajorFunction
[IRP_MJ_CREATE_MAILSLOT
] = FltpCreate
;
2200 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = FltpFsControl
;
2201 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = FltpDeviceControl
;
2203 /* The FastIo dispatch table is stored in the pool along with a tag */
2204 FastIoDispatch
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(FAST_IO_DISPATCH
), FM_TAG_DISPATCH_TABLE
);
2205 if (FastIoDispatch
== NULL
) return STATUS_INSUFFICIENT_RESOURCES
;
2207 /* Fill out the FastIo table */
2208 RtlZeroMemory(FastIoDispatch
, sizeof(FAST_IO_DISPATCH
));
2209 FastIoDispatch
->SizeOfFastIoDispatch
= sizeof(FAST_IO_DISPATCH
);
2210 FastIoDispatch
->FastIoCheckIfPossible
= FltpFastIoCheckIfPossible
;
2211 FastIoDispatch
->FastIoRead
= FltpFastIoRead
;
2212 FastIoDispatch
->FastIoWrite
= FltpFastIoWrite
;
2213 FastIoDispatch
->FastIoQueryBasicInfo
= FltpFastIoQueryBasicInfo
;
2214 FastIoDispatch
->FastIoQueryStandardInfo
= FltpFastIoQueryStandardInfo
;
2215 FastIoDispatch
->FastIoLock
= FltpFastIoLock
;
2216 FastIoDispatch
->FastIoUnlockSingle
= FltpFastIoUnlockSingle
;
2217 FastIoDispatch
->FastIoUnlockAll
= FltpFastIoUnlockAll
;
2218 FastIoDispatch
->FastIoUnlockAllByKey
= FltpFastIoUnlockAllByKey
;
2219 FastIoDispatch
->FastIoDeviceControl
= FltpFastIoDeviceControl
;
2220 FastIoDispatch
->FastIoDetachDevice
= FltpFastIoDetachDevice
;
2221 FastIoDispatch
->FastIoQueryNetworkOpenInfo
= FltpFastIoQueryNetworkOpenInfo
;
2222 FastIoDispatch
->MdlRead
= FltpFastIoMdlRead
;
2223 FastIoDispatch
->MdlReadComplete
= FltpFastIoMdlReadComplete
;
2224 FastIoDispatch
->PrepareMdlWrite
= FltpFastIoPrepareMdlWrite
;
2225 FastIoDispatch
->MdlWriteComplete
= FltpFastIoMdlWriteComplete
;
2226 FastIoDispatch
->FastIoReadCompressed
= FltpFastIoReadCompressed
;
2227 FastIoDispatch
->FastIoWriteCompressed
= FltpFastIoWriteCompressed
;
2228 FastIoDispatch
->MdlReadCompleteCompressed
= FltpFastIoMdlReadCompleteCompressed
;
2229 FastIoDispatch
->MdlWriteCompleteCompressed
= FltpFastIoMdlWriteCompleteCompressed
;
2230 FastIoDispatch
->FastIoQueryOpen
= FltpFastIoQueryOpen
;
2232 /* Store the FastIo table for internal and our access */
2233 DriverObject
->FastIoDispatch
= FastIoDispatch
;
2234 DriverData
.FastIoDispatch
= FastIoDispatch
;
2236 /* Initialize the callback table */
2237 Callbacks
.SizeOfFsFilterCallbacks
= sizeof(FS_FILTER_CALLBACKS
);
2238 Callbacks
.PreAcquireForSectionSynchronization
= FltpPreFsFilterOperation
;
2239 Callbacks
.PostAcquireForSectionSynchronization
= FltpPostFsFilterOperation
;
2240 Callbacks
.PreReleaseForSectionSynchronization
= FltpPreFsFilterOperation
;
2241 Callbacks
.PostReleaseForSectionSynchronization
= FltpPostFsFilterOperation
;
2242 Callbacks
.PreAcquireForCcFlush
= FltpPreFsFilterOperation
;
2243 Callbacks
.PostAcquireForCcFlush
= FltpPostFsFilterOperation
;
2244 Callbacks
.PreReleaseForCcFlush
= FltpPreFsFilterOperation
;
2245 Callbacks
.PostReleaseForCcFlush
= FltpPostFsFilterOperation
;
2246 Callbacks
.PreAcquireForModifiedPageWriter
= FltpPreFsFilterOperation
;
2247 Callbacks
.PostAcquireForModifiedPageWriter
= FltpPostFsFilterOperation
;
2248 Callbacks
.PreReleaseForModifiedPageWriter
= FltpPreFsFilterOperation
;
2249 Callbacks
.PostReleaseForModifiedPageWriter
= FltpPostFsFilterOperation
;
2251 /* Register our callbacks */
2252 return FsRtlRegisterFileSystemFilterCallbacks(DriverObject
, &Callbacks
);