WDK Mini Filter Example
CdoOperations.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1999 - 2002 Microsoft Corporation
4 
5 Module Name:
6 
7  operations.c
8 
9 Abstract:
10 
11  This is the CDO i/o operations module of the kernel mode filter driver implementing
12  CDO sample
13 
14 
15 Environment:
16 
17  Kernel mode
18 
19 
20 --*/
21 
22 #include "pch.h"
23 
24 
25 //
26 // Assign text sections for each routine.
27 //
28 
29 #ifdef ALLOC_PRAGMA
30  #pragma alloc_text( PAGE, CdoCreateControlDeviceObject)
31  #pragma alloc_text( PAGE, CdoDeleteControlDeviceObject)
32  #pragma alloc_text( PAGE, CdoMajorFunction)
33  #pragma alloc_text( PAGE, CdoHandlePrivateOpen)
34  #pragma alloc_text( PAGE, CdoHandlePrivateCleanup)
35  #pragma alloc_text( PAGE, CdoHandlePrivateClose)
36  #pragma alloc_text( PAGE, CdoHandlePrivateFsControl)
37  #pragma alloc_text( PAGE, CdoFastIoCheckIfPossible)
38  #pragma alloc_text( PAGE, CdoFastIoRead)
39  #pragma alloc_text( PAGE, CdoFastIoWrite)
40  #pragma alloc_text( PAGE, CdoFastIoQueryBasicInfo)
41  #pragma alloc_text( PAGE, CdoFastIoQueryStandardInfo)
42  #pragma alloc_text( PAGE, CdoFastIoLock)
43  #pragma alloc_text( PAGE, CdoFastIoUnlockSingle)
44  #pragma alloc_text( PAGE, CdoFastIoUnlockAll)
45  #pragma alloc_text( PAGE, CdoFastIoUnlockAllByKey)
46  #pragma alloc_text( PAGE, CdoFastIoDeviceControl)
47  #pragma alloc_text( PAGE, CdoFastIoQueryNetworkOpenInfo)
48  #pragma alloc_text( PAGE, CdoFastIoMdlRead)
49  #pragma alloc_text( NONPAGED, CdoFastIoMdlReadComplete)
50  #pragma alloc_text( PAGE, CdoFastIoPrepareMdlWrite)
51  #pragma alloc_text( NONPAGED, CdoFastIoMdlWriteComplete)
52  #pragma alloc_text( PAGE, CdoFastIoReadCompressed)
53  #pragma alloc_text( PAGE, CdoFastIoWriteCompressed)
54  #pragma alloc_text( NONPAGED, CdoFastIoMdlReadCompleteCompressed)
55  #pragma alloc_text( NONPAGED, CdoFastIoMdlWriteCompleteCompressed)
56  #pragma alloc_text( PAGE, CdoFastIoQueryOpen)
57  #pragma alloc_text( PAGE, CdoHandlePrivateOpen )
58  #pragma alloc_text( PAGE, CdoHandlePrivateCleanup )
59  #pragma alloc_text( PAGE, CdoHandlePrivateClose )
60  #pragma alloc_text( PAGE, CdoHandlePrivateFsControl )
61 
62 #endif
63 
64 
65 //
66 // Fast IO dispatch routines
67 //
68 
69 FAST_IO_DISPATCH CdoFastIoDispatch =
70 {
71  sizeof(FAST_IO_DISPATCH),
72  CdoFastIoCheckIfPossible, // CheckForFastIo
73  CdoFastIoRead, // FastIoRead
74  CdoFastIoWrite, // FastIoWrite
75  CdoFastIoQueryBasicInfo, // FastIoQueryBasicInfo
76  CdoFastIoQueryStandardInfo, // FastIoQueryStandardInfo
77  CdoFastIoLock, // FastIoLock
78  CdoFastIoUnlockSingle, // FastIoUnlockSingle
79  CdoFastIoUnlockAll, // FastIoUnlockAll
80  CdoFastIoUnlockAllByKey, // FastIoUnlockAllByKey
81  CdoFastIoDeviceControl, // FastIoDeviceControl
82  NULL, // AcquireFileForNtCreateSection
83  NULL, // ReleaseFileForNtCreateSection
84  NULL, // FastIoDetachDevice
85  CdoFastIoQueryNetworkOpenInfo, // FastIoQueryNetworkOpenInfo
86  NULL, // AcquireForModWrite
87  CdoFastIoMdlRead, // MdlRead
88  CdoFastIoMdlReadComplete, // MdlReadComplete
89  CdoFastIoPrepareMdlWrite, // PrepareMdlWrite
90  CdoFastIoMdlWriteComplete, // MdlWriteComplete
91  CdoFastIoReadCompressed, // FastIoReadCompressed
92  CdoFastIoWriteCompressed, // FastIoWriteCompressed
93  CdoFastIoMdlReadCompleteCompressed, // MdlReadCompleteCompressed
94  CdoFastIoMdlWriteCompleteCompressed, // MdlWriteCompleteCompressed
95  CdoFastIoQueryOpen, // FastIoQueryOpen
96  NULL, // ReleaseForModWrite
97  NULL, // AcquireForCcFlush
98  NULL, // ReleaseForCcFlush
99 };
100 
101 
102 
103 NTSTATUS
104 _Function_class_(DRIVER_INITIALIZE)
105 CdoCreateControlDeviceObject(
106  _Inout_ PDRIVER_OBJECT DriverObject
107  )
108 /*++
109 
110 Routine Description:
111 
112  This routine handles the IRPs that are directed to the control
113  device object.
114 
115 Arguments:
116 
117  DriverObject - driver object for this driver
118 
119 Return Value:
120 
121  NTSTATUS
122 
123 --*/
124 {
125  NTSTATUS status;
126  UNICODE_STRING nameString;
127  ULONG i;
128 
129  PAGED_CODE();
130 
131  //
132  // Create our control device object
133  //
134 
135  DebugTrace( DEBUG_TRACE_CDO_CREATE_DELETE,
136  ("[Cdo]: Creating CDO ... \n") );
137 
138  RtlInitUnicodeString( &nameString, CONTROL_DEVICE_OBJECT_NAME );
139  status = IoCreateDevice( DriverObject,
140  0,
141  &nameString,
142  FILE_DEVICE_DISK_FILE_SYSTEM,
143  FILE_DEVICE_SECURE_OPEN,
144  FALSE,
145  &Globals.FilterControlDeviceObject);
146 
147  if ( !NT_SUCCESS( status ) ) {
148 
149  DebugTrace( DEBUG_TRACE_CDO_CREATE_DELETE | DEBUG_TRACE_ERROR,
150  ("[Cdo]: Failure to create CDO. IoCreateDevice failed with status 0x%x. \n",
151  status) );
152  return status;
153  }
154 
155  //
156  // Initialize the driver object with this driver's entry points.
157  // Most are simply passed through to some other device driver.
158  //
159 
160  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) {
161 
162 #pragma prefast(suppress:__WARNING_DISPATCH_MISMATCH __WARNING_DISPATCH_MISSING, "CdoMajorFunction is the dispatch routine for every major code, so no tag applies to it.")
163  DriverObject->MajorFunction[i] = CdoMajorFunction;
164  }
165 
166 #pragma prefast(suppress:__WARNING_INACCESSIBLE_MEMBER, "The Cdo sample is allowed to set the FastIo Dispatch routine because he is setting up a Cdo.")
167  DriverObject->FastIoDispatch = &CdoFastIoDispatch;
168 
169  DebugTrace( DEBUG_TRACE_CDO_CREATE_DELETE,
170  ("[Cdo]: Creating CDO successful\n") );
171 
172  return STATUS_SUCCESS;
173 }
174 
175 
176 
177 VOID
179  VOID
180  )
181 /*++
182 
183 Routine Description:
184 
185  This routine deletes the control device object.
186 
187 Arguments:
188 
189  None
190 
191 Return Value:
192 
193  None
194 
195 --*/
196 {
197  PAGED_CODE();
198 
199  //
200  // Delete our control device object
201  //
202 
203  DebugTrace( DEBUG_TRACE_CDO_CREATE_DELETE,
204  ("[Cdo]: Deleting CDO ... \n") );
205 
206  IoDeleteDevice( Globals.FilterControlDeviceObject );
207 
208  DebugTrace( DEBUG_TRACE_CDO_CREATE_DELETE,
209  ("[Cdo]: Deleting CDO successful\n") );
210 
211 }
212 
213 
214 DRIVER_DISPATCH CdoMajorFunction;
215 NTSTATUS
217  _In_ PDEVICE_OBJECT DeviceObject,
218  _Inout_ PIRP Irp
219  )
220 /*++
221 
222 Routine Description:
223 
224  This routine handles the IRPs that are directed to the control
225  device object.
226 
227 Arguments:
228 
229  DeviceObject - control device object
230  Irp - the current Irp to process
231 
232 Return Value:
233 
234  Returns STATUS_INVALID_DEVICE_REQUEST if the CDO doesn't support that request
235  type, or the appropriate status otherwise.
236 
237 --*/
238 {
239  NTSTATUS status;
240  PIO_STACK_LOCATION irpSp;
241 
242  UNREFERENCED_PARAMETER( DeviceObject );
243 
244  PAGED_CODE();
245 
246  FLT_ASSERT( IS_MY_CONTROL_DEVICE_OBJECT( DeviceObject ) );
247 
248 
249  //
250  // default to success
251  //
252 
253  status = STATUS_SUCCESS;
254 
255  irpSp = IoGetCurrentIrpStackLocation(Irp);
256 
257  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS,
258  ("[Cdo]: CdoMajorFunction entry ( Irp = %p, irpSp->MajorFunction = 0x%x )\n",
259  Irp,
260  irpSp->MajorFunction) );
261 
262  switch (irpSp->MajorFunction) {
263 
264  //
265  // IRP_MJ_CREATE is called to create a new HANDLE on CDO
266  //
267 
268  case IRP_MJ_CREATE:
269  {
270 
271  //
272  // Handle our private open
273  //
274 
275  status = CdoHandlePrivateOpen(Irp);
276 
277  Irp->IoStatus.Status = status;
278 
279  if(NT_SUCCESS(status))
280  {
281  //
282  // If successful, return the file was opened
283  //
284 
285  Irp->IoStatus.Information = FILE_OPENED;
286  }
287  else
288  {
289  Irp->IoStatus.Information = 0;
290  }
291 
292  IoCompleteRequest( Irp, IO_NO_INCREMENT );
293 
294  break;
295  }
296 
297  //
298  // IRP_MJ_CLOSE is called when all references are gone.
299  // Note: this operation can not be failed. It must succeed.
300  //
301 
302  case IRP_MJ_CLOSE:
303  {
304 
305  CdoHandlePrivateClose( Irp );
306 
307  Irp->IoStatus.Status = STATUS_SUCCESS;
308  Irp->IoStatus.Information = 0;
309 
310  IoCompleteRequest( Irp, IO_NO_INCREMENT );
311 
312  break;
313  }
314 
315  //
316  // IRP_MJ_DEVICE_CONTROL is how most user-mode api's drop into here
317  //
318 
320  {
321  ULONG Operation;
322  ULONG OutputBufferLength;
323  ULONG InputBufferLength;
324  PVOID InputBuffer;
325  PVOID OutputBuffer;
326 
327  Operation = irpSp->Parameters.FileSystemControl.FsControlCode;
328  InputBufferLength = irpSp->Parameters.FileSystemControl.InputBufferLength;
329  OutputBufferLength = irpSp->Parameters.FileSystemControl.OutputBufferLength;
330 
331  InputBuffer = Irp->AssociatedIrp.SystemBuffer;
332  OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
333 
334  //
335  // The caller will update the IO status block
336  //
337 
338  status = CdoHandlePrivateFsControl (DeviceObject,
339  Operation,
340  InputBuffer,
341  InputBufferLength,
342  OutputBuffer,
343  OutputBufferLength,
344  &Irp->IoStatus,
345  Irp );
346 
347  IoCompleteRequest( Irp, IO_NO_INCREMENT );
348 
349  break;
350  }
351 
352  //
353  // IRP_MJ_CLEANUP is called when all handles are closed
354  // Note: this operation can not be failed. It must succeed.
355  //
356 
357  case IRP_MJ_CLEANUP:
358  {
359 
361 
362  Irp->IoStatus.Status = STATUS_SUCCESS;
363  Irp->IoStatus.Information = 0;
364 
365  IoCompleteRequest( Irp, IO_NO_INCREMENT );
366 
367  break;
368  }
369 
370  default:
371  {
372  //
373  // unsupported!
374  //
375 
376  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_ERROR,
377  ("[Cdo]: Unsupported Major Function 0x%x ( Irp = %p )\n",
378  irpSp->MajorFunction,
379  Irp) );
380 
381  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
382  Irp->IoStatus.Information = 0;
383 
384  IoCompleteRequest( Irp, IO_NO_INCREMENT );
385 
386  status = STATUS_INVALID_DEVICE_REQUEST;
387  }
388  }
389 
390 
391  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS,
392  ("[Cdo]: CdoMajorFunction exit ( Irp = %p, irpSp->MajorFunction = 0x%x, status = 0x%x )\n",
393  Irp,
394  irpSp->MajorFunction,
395  status) );
396 
397  return status;
398 
399 
400 }
401 
402 
403 NTSTATUS
405  _In_ PIRP Irp
406  )
407 /*++
408 
409 Routine Description:
410 
411  This routine handles create IRPs that are directed to the control
412  device object.
413 
414 Arguments:
415 
416  Irp - the current Irp to process
417 
418 Return Value:
419 
420  Returns STATUS_DEVICE_ALREADY_ATTACHED if the CDO has already been opened
421  Returns STATUS_SUCCESS otherwise
422 
423 Note:
424 
425  This sample supports only one outstanding create on the CDO at a time
426 
427 --*/
428 {
429  NTSTATUS status;
430 
431  UNREFERENCED_PARAMETER( Irp );
432 
433  PAGED_CODE();
434 
435  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
436  ("[Cdo]: CdoHandlePrivateOpen entry ( Irp = %p )\n",
437  Irp) );
438 
439  CdoAcquireResourceExclusive( &Globals.Resource );
440 
443 
444  //
445  // Sanity - if we have a handle open against this CDO
446  // we must have an outstanding reference as well
447  //
448 
451 
452 
453  //
454  // The CDO is already open - fail this open
455  //
456 
457  status = STATUS_DEVICE_ALREADY_ATTACHED;
458 
459  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS | DEBUG_TRACE_ERROR,
460  ("[Cdo]: CdoHandlePrivateOpen -> Device open failure. Device already opened. ( Irp = %p, Flags = 0x%x, status = 0x%x )\n",
461  Irp,
462  Globals.Flags,
463  status) );
464 
465  } else {
466 
467  //
468  // Flag that the CDO is opened so that we will fail future creates
469  // until the CDO is closed by the current caller
470  //
471  //
472  // If we suceed the create we are guaranteed to get a Cleanup (where we
473  // will reset GLOBAL_DATA_F_CDO_OPEN_HANDLE) and Close (where we will
474  // reset GLOBAL_DATA_F_CDO_OPEN_REF)
475  //
476 
477  SetFlag( Globals.Flags, GLOBAL_DATA_F_CDO_OPEN_REF );
478  SetFlag( Globals.Flags, GLOBAL_DATA_F_CDO_OPEN_HANDLE );
479 
480  status = STATUS_SUCCESS;
481 
482  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS | DEBUG_TRACE_ERROR,
483  ("[Cdo]: CdoHandlePrivateOpen -> Device open successful. ( Irp = %p, Flags = 0x%x, status = 0x%x )\n",
484  Irp,
485  Globals.Flags,
486  status) );
487  }
488 
489 
490  //
491  // The filter may want to do additional processing here to set up the structures it
492  // needs to service this create request.
493  //
494 
495 
496  CdoReleaseResource( &Globals.Resource );
497 
498 
499  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
500  ("[Cdo]: CdoHandlePrivateOpen exit ( Irp = %p, status = 0x%x )\n",
501  Irp,
502  status) );
503 
504 
505  return status;
506 }
507 
508 NTSTATUS
510  _In_ PIRP Irp
511  )
512 /*++
513 
514 Routine Description:
515 
516  This routine handles cleanup IRPs that are directed to the control
517  device object.
518 
519 Arguments:
520 
521  Irp - the current Irp to process
522 
523 Return Value:
524 
525  Returns STATUS_SUCCESS
526 
527 --*/
528 {
529  NTSTATUS status;
530 
531  UNREFERENCED_PARAMETER( Irp );
532 
533  PAGED_CODE();
534 
535 
536  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
537  ("[Cdo]: CdoHandlePrivateCleanup entry ( Irp = %p )\n",
538  Irp) );
539 
540 
541  CdoAcquireResourceExclusive( &Globals.Resource );
542 
543  //
544  // Sanity - the CDO must have a handle and a reference for us to get a cleanup on it
545  //
546 
549 
550 
551  //
552  // Reset the flag that indicates the CDO has a open handle
553  //
554 
555  ClearFlag( Globals.Flags, GLOBAL_DATA_F_CDO_OPEN_HANDLE);
556 
557  status = STATUS_SUCCESS;
558 
559  //
560  // The filter may want to do additional processing here to cleanup up the structures it
561  // needed to service the handle that is being closed.
562  //
563 
564  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS | DEBUG_TRACE_ERROR,
565  ("[Cdo]: CdoHandlePrivateCleanup -> Device cleanup successful. ( Irp = %p, Flags = 0x%x, status = 0x%x )\n",
566  Irp,
567  Globals.Flags,
568  status) );
569 
570 
571  CdoReleaseResource( &Globals.Resource );
572 
573  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
574  ("[Cdo]: CdoHandlePrivateCleanup exit ( Irp = %p, status = 0x%x )\n",
575  Irp,
576  status) );
577 
578 
579 
580  return status;
581 }
582 
583 NTSTATUS
585  _In_ PIRP Irp
586  )
587 /*++
588 
589 Routine Description:
590 
591  This routine handles close IRPs that are directed to the control
592  device object.
593 
594 Arguments:
595 
596  Irp - the current Irp to process
597 
598 Return Value:
599 
600  Returns STATUS_SUCCESS
601 
602 --*/
603 {
604  NTSTATUS status;
605 
606  UNREFERENCED_PARAMETER( Irp );
607 
608  PAGED_CODE();
609 
610  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
611  ("[Cdo]: CdoHandlePrivateClose entry ( Irp = %p )\n",
612  Irp) );
613 
614  CdoAcquireResourceExclusive( &Globals.Resource );
615 
616  //
617  // Sanity - the connection must have a reference but have no handle open,
618  // for us to get a close on it
619  //
620 
623 
624 
625  //
626  // Reset the flag that indicates the CDO is opened so that we will suceed
627  // future creates
628  //
629 
630  ClearFlag( Globals.Flags, GLOBAL_DATA_F_CDO_OPEN_REF );
631 
632 
633  //
634  // The filter may want to do additional processing here to cleanup up the structures it
635  // needed to service the user mode attachment that is being closed.
636  //
637 
638 
639  status = STATUS_SUCCESS;
640 
641  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS | DEBUG_TRACE_ERROR,
642  ("[Cdo]: CdoHandlePrivateClose -> Device close successful. ( Irp = %p, Flags = 0x%x, status = 0x%x )\n",
643  Irp,
644  Globals.Flags,
645  status) );
646 
647  CdoReleaseResource( &Globals.Resource );
648 
649 
650  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
651  ("[Cdo]: CdoHandlePrivateClose exit ( Irp = %p, status = 0x%x )\n",
652  Irp,
653  status) );
654 
655 
656  return status;
657 
658 }
659 
660 NTSTATUS
662  _In_ PDEVICE_OBJECT DeviceObject,
663  _In_ ULONG IoControlCode,
664  _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer,
665  _In_ ULONG InputBufferLength,
666  _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer,
667  _In_ ULONG OutputBufferLength,
668  _Out_ PIO_STATUS_BLOCK IoStatus,
669  _In_opt_ PIRP Irp
670  )
671 /*++
672 
673 Routine Description:
674 
675  This routine is invoked whenever an I/O Request Packet (IRP) w/a major
676  function code of IRP_MJ_FILE_SYSTEM_CONTROL is encountered for the CDO.
677 
678 Arguments:
679 
680  DeviceObject - Pointer to the device object for this driver.
681  IoControlCode - Control code for this IOCTL
682  InputBuffer - Input buffer
683  InputBufferLength - Input buffer length
684  OutputBuffer - Output buffer
685  OutputBufferLength - Output buffer length
686  IoStatus - IO status block for this request
687  Irp - Pointer to the request packet representing the I/O request.
688 
689 Return Value:
690 
691  The function value is the status of the operation.
692 
693 --*/
694 {
695  NTSTATUS status = STATUS_SUCCESS;
696 
697  UNREFERENCED_PARAMETER( DeviceObject );
698  UNREFERENCED_PARAMETER( IoControlCode );
699  UNREFERENCED_PARAMETER( InputBuffer );
700  UNREFERENCED_PARAMETER( InputBufferLength );
701  UNREFERENCED_PARAMETER( OutputBuffer );
702  UNREFERENCED_PARAMETER( OutputBufferLength );
703  UNREFERENCED_PARAMETER( Irp );
704 
705  PAGED_CODE();
706 
707  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
708  ("[Cdo]: CdoHandlePrivateFsControl entry ( Irp = %p )\n"
709  "\tIoControlCode = 0x%x\n"
710  "\tInputBuffer = %p\n"
711  "\tInputBufferLength = 0x%x\n"
712  "\tOutputBuffer = %p\n"
713  "\tOutputBufferLength = 0x%x\n",
714  Irp,
715  IoControlCode,
716  InputBuffer,
717  InputBufferLength,
718  OutputBuffer,
719  OutputBufferLength) );
720 
721  CdoAcquireResourceShared( &Globals.Resource );
722 
723  //
724  // Sanity - there must atleast be a reference open for us to get a IOCTL on the CDO
725  //
726 
728 
729 
731 
732  //
733  // If there is no handle open to the CDO fail the operation
734  //
735 
736  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS | DEBUG_TRACE_ERROR,
737  ("[Cdo]: CdoHandlePrivateFsControl -> Failing IOCTL since no handle to CDO is open. ( Irp = %p, IoControlCode = 0x%x, Flags = 0x%x )\n",
738  Irp,
739  IoControlCode,
740  Globals.Flags) );
741 
742  status = STATUS_INVALID_DEVICE_STATE;
743  CdoReleaseResource( &Globals.Resource );
744  goto CdoHandlePrivateFsControlCleanup;
745  }
746 
747  //
748  // Here the filter may perform any action that requires that
749  // the handle to the CDO still be open
750 
751  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
752  ("[Cdo]: CdoHandlePrivateFsControl -> Processing IOCTL while handle to CDO is definitely open. ( Irp = %p, IoControlCode = 0x%x )\n",
753  Irp,
754  IoControlCode) );
755 
756  CdoReleaseResource( &Globals.Resource );
757 
758  //
759  // Since the resource has been released the CDO may complete a cleanup before we
760  // do any of the following.
761  //
762 
763 
764  //
765  // Here the filter may perform any action that does not require that
766  // the handle to the CDO still be open. For example, the IOCTL may have
767  // been used to trigger off an asynchronous background task that will
768  // continue executing even after the handle has been closed
769  //
770  // Note that the system will still maintain a reference to the CDO. So,
771  // the filter will not see a Close on the CDO until it finishes servicing
772  // IRP_MJ_FILE_SYSTEM_CONTROL
773  //
774 
775  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
776  ("[Cdo]: CdoHandlePrivateFsControl -> Processing IOCTL while handle to CDO may not be open. ( Irp = %p, IoControlCode = 0x%x )\n",
777  Irp,
778  IoControlCode) );
779 
780  status = STATUS_SUCCESS;
781 
782 CdoHandlePrivateFsControlCleanup:
783 
784  IoStatus->Status = status;
785  IoStatus->Information = 0;
786 
787  DebugTrace( DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
788  ("[Cdo]: CdoHandlePrivateFsControl exit ( Irp = %p, IoControlCode = 0x%x, status = 0x%x )\n",
789  Irp,
790  IoControlCode,
791  status) );
792 
793 
794  return status;
795 }
796 
797 
798 
800 //
801 // FastIO Handling routines
802 //
804 
805 
806 
807 BOOLEAN
809  _In_ PFILE_OBJECT FileObject,
810  _In_ PLARGE_INTEGER FileOffset,
811  _In_ ULONG Length,
812  _In_ BOOLEAN Wait,
813  _In_ ULONG LockKey,
814  _In_ BOOLEAN CheckForReadOperation,
815  _Out_ PIO_STATUS_BLOCK IoStatus,
816  _In_ PDEVICE_OBJECT DeviceObject )
817 /*++
818 
819 Routine Description:
820 
821  This routine is the fast I/O "pass through" routine for checking to see
822  whether fast I/O is possible for this file.
823 
824  This function simply invokes the file system's corresponding routine, or
825  returns FALSE if the file system does not implement the function.
826 
827 Arguments:
828 
829  FileObject - Pointer to the file object to be operated on.
830 
831  FileOffset - Byte offset in the file for the operation.
832 
833  Length - Length of the operation to be performed.
834 
835  Wait - Indicates whether or not the caller is willing to wait if the
836  appropriate locks, etc. cannot be acquired
837 
838  LockKey - Provides the caller's key for file locks.
839 
840  CheckForReadOperation - Indicates whether the caller is checking for a
841  read (TRUE) or a write operation.
842 
843  IoStatus - Pointer to a variable to receive the I/O status of the
844  operation.
845 
846  DeviceObject - Pointer to this driver's device object, the device on
847  which the operation is to occur.
848 
849 Return Value:
850 
851  The function value is TRUE or FALSE based on whether or not fast I/O
852  is possible for this file.
853 
854 --*/
855 {
856  PAGED_CODE();
858 
859  UNREFERENCED_PARAMETER(FileObject);
860  UNREFERENCED_PARAMETER(FileOffset);
861  UNREFERENCED_PARAMETER(Length);
863  UNREFERENCED_PARAMETER(LockKey);
864  UNREFERENCED_PARAMETER(CheckForReadOperation);
865  UNREFERENCED_PARAMETER(DeviceObject);
866 
867  //
868  // This is our CDO, fail the operation
869  //
870 
871  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
872  ("[Cdo]: CdoFastIoCheckIfPossible -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
873  FileObject,
874  DeviceObject) );
875 
876  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
877  IoStatus->Information = 0;
878 
879  return TRUE;
880 }
881 
882 
883 BOOLEAN
885  _In_ PFILE_OBJECT FileObject,
886  _In_ PLARGE_INTEGER FileOffset,
887  _In_ ULONG Length,
888  _In_ BOOLEAN Wait,
889  _In_ ULONG LockKey,
890  _Out_writes_bytes_(Length) PVOID Buffer,
891  _Out_ PIO_STATUS_BLOCK IoStatus,
892  _In_ PDEVICE_OBJECT DeviceObject )
893 /*++
894 
895 Routine Description:
896 
897  This routine is the fast I/O "pass through" routine for reading from a
898  file.
899 
900  This function simply invokes the file system's corresponding routine, or
901  returns FALSE if the file system does not implement the function.
902 
903 Arguments:
904 
905  FileObject - Pointer to the file object to be read.
906 
907  FileOffset - Byte offset in the file of the read.
908 
909  Length - Length of the read operation to be performed.
910 
911  Wait - Indicates whether or not the caller is willing to wait if the
912  appropriate locks, etc. cannot be acquired
913 
914  LockKey - Provides the caller's key for file locks.
915 
916  Buffer - Pointer to the caller's buffer to receive the data read.
917 
918  IoStatus - Pointer to a variable to receive the I/O status of the
919  operation.
920 
921  DeviceObject - Pointer to this driver's device object, the device on
922  which the operation is to occur.
923 
924 Return Value:
925 
926  The function value is TRUE or FALSE based on whether or not fast I/O
927  is possible for this file.
928 
929 --*/
930 {
931  PAGED_CODE();
933 
934  UNREFERENCED_PARAMETER(FileObject);
935  UNREFERENCED_PARAMETER(FileOffset);
936  UNREFERENCED_PARAMETER(Length);
938  UNREFERENCED_PARAMETER(LockKey);
939  UNREFERENCED_PARAMETER(Buffer);
940  UNREFERENCED_PARAMETER(DeviceObject);
941 
942  //
943  // This is our CDO, fail the operation
944  //
945 
946  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
947  ("[Cdo]: CdoFastIoRead -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
948  FileObject,
949  DeviceObject) );
950 
951  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
952  IoStatus->Information = 0;
953 
954  return TRUE;
955 }
956 
957 
958 
959 BOOLEAN
961  _In_ PFILE_OBJECT FileObject,
962  _In_ PLARGE_INTEGER FileOffset,
963  _In_ ULONG Length,
964  _In_ BOOLEAN Wait,
965  _In_ ULONG LockKey,
966  _In_reads_bytes_(Length) PVOID Buffer,
967  _Out_ PIO_STATUS_BLOCK IoStatus,
968  _In_ PDEVICE_OBJECT DeviceObject )
969 /*++
970 
971 Routine Description:
972 
973  This routine is the fast I/O "pass through" routine for writing to a
974  file.
975 
976  This function simply invokes the file system's corresponding routine, or
977  returns FALSE if the file system does not implement the function.
978 
979 Arguments:
980 
981  FileObject - Pointer to the file object to be written.
982 
983  FileOffset - Byte offset in the file of the write operation.
984 
985  Length - Length of the write operation to be performed.
986 
987  Wait - Indicates whether or not the caller is willing to wait if the
988  appropriate locks, etc. cannot be acquired
989 
990  LockKey - Provides the caller's key for file locks.
991 
992  Buffer - Pointer to the caller's buffer that contains the data to be
993  written.
994 
995  IoStatus - Pointer to a variable to receive the I/O status of the
996  operation.
997 
998  DeviceObject - Pointer to this driver's device object, the device on
999  which the operation is to occur.
1000 
1001 Return Value:
1002 
1003  The function value is TRUE or FALSE based on whether or not fast I/O
1004  is possible for this file.
1005 
1006 --*/
1007 
1008 {
1009  PAGED_CODE();
1010  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1011 
1012  UNREFERENCED_PARAMETER(FileObject);
1013  UNREFERENCED_PARAMETER(FileOffset);
1014  UNREFERENCED_PARAMETER(Length);
1015  UNREFERENCED_PARAMETER(Wait);
1016  UNREFERENCED_PARAMETER(LockKey);
1017  UNREFERENCED_PARAMETER(Buffer);
1018  UNREFERENCED_PARAMETER(DeviceObject);
1019 
1020  //
1021  // This is our CDO, fail the operation
1022  //
1023 
1024  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1025  ("[Cdo]: CdoFastIoWrite -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1026  FileObject,
1027  DeviceObject) );
1028 
1029  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1030  IoStatus->Information = 0;
1031 
1032  return TRUE;
1033 }
1034 
1035 // This annotation tells the static analyzer that IoStatus->Status is where to check
1036 // whether this routine succeeded or not, not the BOOLEAN return value.
1037 _Success_(IoStatus->Status == 0)
1038 BOOLEAN
1039 CdoFastIoQueryBasicInfo (
1040  _In_ PFILE_OBJECT FileObject,
1041  _In_ BOOLEAN Wait,
1042  _Out_ PFILE_BASIC_INFORMATION Buffer,
1043  _Out_ PIO_STATUS_BLOCK IoStatus,
1044  _In_ PDEVICE_OBJECT DeviceObject )
1045 /*++
1046 
1047 Routine Description:
1048 
1049  This routine is the fast I/O "pass through" routine for querying basic
1050  information about the file.
1051 
1052  This function simply invokes the file system's corresponding routine, or
1053  returns FALSE if the file system does not implement the function.
1054 
1055 Arguments:
1056 
1057  FileObject - Pointer to the file object to be queried.
1058 
1059  Wait - Indicates whether or not the caller is willing to wait if the
1060  appropriate locks, etc. cannot be acquired
1061 
1062  Buffer - Pointer to the caller's buffer to receive the information about
1063  the file.
1064 
1065  IoStatus - Pointer to a variable to receive the I/O status of the
1066  operation.
1067 
1068  DeviceObject - Pointer to this driver's device object, the device on
1069  which the operation is to occur.
1070 
1071 Return Value:
1072 
1073  The function value is TRUE or FALSE based on whether or not fast I/O
1074  is possible for this file.
1075 
1076 --*/
1077 
1079  PAGED_CODE();
1080  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1081 
1082  UNREFERENCED_PARAMETER(FileObject);
1083  UNREFERENCED_PARAMETER(Wait);
1084  UNREFERENCED_PARAMETER(Buffer);
1085  UNREFERENCED_PARAMETER(DeviceObject);
1086 
1087  //
1088  // This is our CDO, fail the operation
1089  //
1090 
1091  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1092  ("[Cdo]: CdoFastIoQueryBasicInfo -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1093  FileObject,
1094  DeviceObject) );
1095 
1096  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1097  IoStatus->Information = 0;
1098 
1099  return TRUE;
1100 }
1101 
1102 
1103 // This annotation tells the static analyzer that IoStatus->Status is where to check
1104 // whether this routine succeeded or not, not the BOOLEAN return value.
1105 _Success_(IoStatus->Status == 0)
1106 BOOLEAN
1107 CdoFastIoQueryStandardInfo (
1108  _In_ PFILE_OBJECT FileObject,
1109  _In_ BOOLEAN Wait,
1110  _Out_ PFILE_STANDARD_INFORMATION Buffer,
1111  _Out_ PIO_STATUS_BLOCK IoStatus,
1112  _In_ PDEVICE_OBJECT DeviceObject )
1113 /*++
1114 
1115 Routine Description:
1116 
1117  This routine is the fast I/O "pass through" routine for querying standard
1118  information about the file.
1119 
1120  This function simply invokes the file system's corresponding routine, or
1121  returns FALSE if the file system does not implement the function.
1122 
1123 Arguments:
1124 
1125  FileObject - Pointer to the file object to be queried.
1126 
1127  Wait - Indicates whether or not the caller is willing to wait if the
1128  appropriate locks, etc. cannot be acquired
1129 
1130  Buffer - Pointer to the caller's buffer to receive the information about
1131  the file.
1132 
1133  IoStatus - Pointer to a variable to receive the I/O status of the
1134  operation.
1135 
1136  DeviceObject - Pointer to this driver's device object, the device on
1137  which the operation is to occur.
1138 
1139 Return Value:
1140 
1141  The function value is TRUE or FALSE based on whether or not fast I/O
1142  is possible for this file.
1143 
1144 --*/
1145 {
1146  PAGED_CODE();
1147  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1148 
1149  UNREFERENCED_PARAMETER(FileObject);
1150  UNREFERENCED_PARAMETER(Wait);
1151  UNREFERENCED_PARAMETER(Buffer);
1152  UNREFERENCED_PARAMETER(DeviceObject);
1153 
1154  //
1155  // This is our CDO, fail the operation
1156  //
1157 
1158  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1159  ("[Cdo]: CdoFastIoQueryStandardInfo -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1160  FileObject,
1161  DeviceObject) );
1162 
1163  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1164  IoStatus->Information = 0;
1165 
1166  return TRUE;
1167 }
1168 
1169 
1170 BOOLEAN
1172  _In_ PFILE_OBJECT FileObject,
1173  _In_ PLARGE_INTEGER FileOffset,
1174  _In_ PLARGE_INTEGER Length,
1175  _In_ PEPROCESS ProcessId,
1176  _In_ ULONG Key,
1177  _In_ BOOLEAN FailImmediately,
1178  _In_ BOOLEAN ExclusiveLock,
1179  _Out_ PIO_STATUS_BLOCK IoStatus,
1180  _In_ PDEVICE_OBJECT DeviceObject )
1181 /*++
1182 
1183 Routine Description:
1184 
1185  This routine is the fast I/O "pass through" routine for locking a byte
1186  range within a file.
1187 
1188  This function simply invokes the file system's corresponding routine, or
1189  returns FALSE if the file system does not implement the function.
1190 
1191 Arguments:
1192 
1193  FileObject - Pointer to the file object to be locked.
1194 
1195  FileOffset - Starting byte offset from the base of the file to be locked.
1196 
1197  Length - Length of the byte range to be locked.
1198 
1199  ProcessId - ID of the process requesting the file lock.
1200 
1201  Key - Lock key to associate with the file lock.
1202 
1203  FailImmediately - Indicates whether or not the lock request is to fail
1204  if it cannot be immediately be granted.
1205 
1206  ExclusiveLock - Indicates whether the lock to be taken is exclusive (TRUE)
1207  or shared.
1208 
1209  IoStatus - Pointer to a variable to receive the I/O status of the
1210  operation.
1211 
1212  DeviceObject - Pointer to this driver's device object, the device on
1213  which the operation is to occur.
1214 
1215 Return Value:
1216 
1217  The function value is TRUE or FALSE based on whether or not fast I/O
1218  is possible for this file.
1219 
1220 --*/
1221 
1222 {
1223  PAGED_CODE();
1224  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1225 
1226  UNREFERENCED_PARAMETER(FileObject);
1227  UNREFERENCED_PARAMETER(FileOffset);
1228  UNREFERENCED_PARAMETER(Length);
1229  UNREFERENCED_PARAMETER(ProcessId);
1231  UNREFERENCED_PARAMETER(FailImmediately);
1232  UNREFERENCED_PARAMETER(ExclusiveLock);
1233  UNREFERENCED_PARAMETER(DeviceObject);
1234 
1235  //
1236  // This is our CDO, fail the operation
1237  //
1238 
1239  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1240  ("[Cdo]: CdoFastIoLock -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1241  FileObject,
1242  DeviceObject) );
1243 
1244  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1245  IoStatus->Information = 0;
1246 
1247  return TRUE;
1248 }
1249 
1250 
1251 BOOLEAN
1253  _In_ PFILE_OBJECT FileObject,
1254  _In_ PLARGE_INTEGER FileOffset,
1255  _In_ PLARGE_INTEGER Length,
1256  _In_ PEPROCESS ProcessId,
1257  _In_ ULONG Key,
1258  _Out_ PIO_STATUS_BLOCK IoStatus,
1259  _In_ PDEVICE_OBJECT DeviceObject )
1260 /*++
1261 
1262 Routine Description:
1263 
1264  This routine is the fast I/O "pass through" routine for unlocking a byte
1265  range within a file.
1266 
1267  This function simply invokes the file system's corresponding routine, or
1268  returns FALSE if the file system does not implement the function.
1269 
1270 Arguments:
1271 
1272  FileObject - Pointer to the file object to be unlocked.
1273 
1274  FileOffset - Starting byte offset from the base of the file to be
1275  unlocked.
1276 
1277  Length - Length of the byte range to be unlocked.
1278 
1279  ProcessId - ID of the process requesting the unlock operation.
1280 
1281  Key - Lock key associated with the file lock.
1282 
1283  IoStatus - Pointer to a variable to receive the I/O status of the
1284  operation.
1285 
1286  DeviceObject - Pointer to this driver's device object, the device on
1287  which the operation is to occur.
1288 
1289 Return Value:
1290 
1291  The function value is TRUE or FALSE based on whether or not fast I/O
1292  is possible for this file.
1293 
1294 --*/
1295 {
1296  PAGED_CODE();
1297  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1298 
1299  UNREFERENCED_PARAMETER(FileObject);
1300  UNREFERENCED_PARAMETER(FileOffset);
1301  UNREFERENCED_PARAMETER(Length);
1302  UNREFERENCED_PARAMETER(ProcessId);
1304  UNREFERENCED_PARAMETER(DeviceObject);
1305 
1306  //
1307  // This is our CDO, fail the operation
1308  //
1309 
1310  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1311  ("[Cdo]: CdoFastIoUnlockSingle -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1312  FileObject,
1313  DeviceObject) );
1314 
1315  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1316  IoStatus->Information = 0;
1317 
1318  return TRUE;
1319 }
1320 
1321 
1322 
1323 BOOLEAN
1325  _In_ PFILE_OBJECT FileObject,
1326  _In_ PEPROCESS ProcessId,
1327  _Out_ PIO_STATUS_BLOCK IoStatus,
1328  _In_ PDEVICE_OBJECT DeviceObject )
1329 /*++
1330 
1331 Routine Description:
1332 
1333  This routine is the fast I/O "pass through" routine for unlocking all
1334  locks within a file.
1335 
1336  This function simply invokes the file system's corresponding routine, or
1337  returns FALSE if the file system does not implement the function.
1338 
1339 Arguments:
1340 
1341  FileObject - Pointer to the file object to be unlocked.
1342 
1343  ProcessId - ID of the process requesting the unlock operation.
1344 
1345  IoStatus - Pointer to a variable to receive the I/O status of the
1346  operation.
1347 
1348  DeviceObject - Pointer to this driver's device object, the device on
1349  which the operation is to occur.
1350 
1351 Return Value:
1352 
1353  The function value is TRUE or FALSE based on whether or not fast I/O
1354  is possible for this file.
1355 
1356 --*/
1357 {
1358  PAGED_CODE();
1359  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1360 
1361  UNREFERENCED_PARAMETER(FileObject);
1362  UNREFERENCED_PARAMETER(ProcessId);
1363  UNREFERENCED_PARAMETER(DeviceObject);
1364 
1365  //
1366  // This is our CDO, fail the operation
1367  //
1368 
1369  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1370  ("[Cdo]: CdoFastIoUnlockAll -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1371  FileObject,
1372  DeviceObject) );
1373 
1374  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1375  IoStatus->Information = 0;
1376 
1377  return TRUE;
1378 }
1379 
1380 
1381 BOOLEAN
1383  _In_ PFILE_OBJECT FileObject,
1384  _In_ PVOID ProcessId,
1385  _In_ ULONG Key,
1386  _Out_ PIO_STATUS_BLOCK IoStatus,
1387  _In_ PDEVICE_OBJECT DeviceObject )
1388 /*++
1389 
1390 Routine Description:
1391 
1392  This routine is the fast I/O "pass through" routine for unlocking all
1393  locks within a file based on a specified key.
1394 
1395  This function simply invokes the file system's corresponding routine, or
1396  returns FALSE if the file system does not implement the function.
1397 
1398 Arguments:
1399 
1400  FileObject - Pointer to the file object to be unlocked.
1401 
1402  ProcessId - ID of the process requesting the unlock operation.
1403 
1404  Key - Lock key associated with the locks on the file to be released.
1405 
1406  IoStatus - Pointer to a variable to receive the I/O status of the
1407  operation.
1408 
1409  DeviceObject - Pointer to this driver's device object, the device on
1410  which the operation is to occur.
1411 
1412 Return Value:
1413 
1414  The function value is TRUE or FALSE based on whether or not fast I/O
1415  is possible for this file.
1416 
1417 --*/
1418 {
1419  PAGED_CODE();
1420  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1421 
1422  UNREFERENCED_PARAMETER(FileObject);
1423  UNREFERENCED_PARAMETER(ProcessId);
1425  UNREFERENCED_PARAMETER(DeviceObject);
1426 
1427  //
1428  // This is our CDO, fail the operation
1429  //
1430 
1431  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1432  ("[Cdo]: CdoFastIoUnlockAllByKey -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1433  FileObject,
1434  DeviceObject) );
1435 
1436  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1437  IoStatus->Information = 0;
1438 
1439  return TRUE;
1440 }
1441 
1442 
1443 
1444 BOOLEAN
1446  _In_ PFILE_OBJECT FileObject,
1447  _In_ BOOLEAN Wait,
1448  _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer,
1449  _In_ ULONG InputBufferLength,
1450  _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer,
1451  _In_ ULONG OutputBufferLength,
1452  _In_ ULONG IoControlCode,
1453  _Out_ PIO_STATUS_BLOCK IoStatus,
1454  _In_ PDEVICE_OBJECT DeviceObject)
1455 /*++
1456 
1457 Routine Description:
1458 
1459  This routine is the fast I/O "pass through" routine for device I/O control
1460  operations on a file.
1461 
1462  This function simply invokes the file system's corresponding routine, or
1463  returns FALSE if the file system does not implement the function.
1464 
1465 Arguments:
1466 
1467  FileObject - Pointer to the file object representing the device to be
1468  serviced.
1469 
1470  Wait - Indicates whether or not the caller is willing to wait if the
1471  appropriate locks, etc. cannot be acquired
1472 
1473  InputBuffer - Optional pointer to a buffer to be passed into the driver.
1474 
1475  InputBufferLength - Length of the optional InputBuffer, if one was
1476  specified.
1477 
1478  OutputBuffer - Optional pointer to a buffer to receive data from the
1479  driver.
1480 
1481  OutputBufferLength - Length of the optional OutputBuffer, if one was
1482  specified.
1483 
1484  IoControlCode - I/O control code indicating the operation to be performed
1485  on the device.
1486 
1487  IoStatus - Pointer to a variable to receive the I/O status of the
1488  operation.
1489 
1490  DeviceObject - Pointer to this driver's device object, the device on
1491  which the operation is to occur.
1492 
1493 Return Value:
1494 
1495  The function value is TRUE or FALSE based on whether or not fast I/O
1496  is possible for this file.
1497 
1498 --*/
1499 {
1500  PAGED_CODE();
1501  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1502 
1503  UNREFERENCED_PARAMETER(FileObject);
1504  UNREFERENCED_PARAMETER(Wait);
1505 
1506  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
1507  ("[Cdo]: CdoFastIoDeviceControl Entry ( FileObject = %p, DeviceObject = %p )\n",
1508  FileObject,
1509  DeviceObject) );
1510 
1511  //
1512  // The caller will update the IO status block
1513  //
1514 
1515  CdoHandlePrivateFsControl ( DeviceObject,
1516  IoControlCode,
1517  InputBuffer,
1518  InputBufferLength,
1519  OutputBuffer,
1520  OutputBufferLength,
1521  IoStatus,
1522  NULL );
1523 
1524  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_CDO_SUPPORTED_OPERATIONS,
1525  ("[Cdo]: CdoFastIoDeviceControl Exit ( FileObject = %p, DeviceObject = %p, Status = 0x%x )\n",
1526  FileObject,
1527  DeviceObject,
1528  IoStatus->Status) );
1529 
1530  return TRUE;
1531 }
1532 
1533 
1534 // This annotation tells the static analyzer that IoStatus->Status is where to check
1535 // whether this routine succeeded or not, not the BOOLEAN return value.
1536 _Success_(IoStatus->Status == 0)
1537 BOOLEAN
1538 CdoFastIoQueryNetworkOpenInfo (
1539  _In_ PFILE_OBJECT FileObject,
1540  _In_ BOOLEAN Wait,
1541  _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer,
1542  _Out_ PIO_STATUS_BLOCK IoStatus,
1543  _In_ PDEVICE_OBJECT DeviceObject )
1544 /*++
1545 
1546 Routine Description:
1547 
1548  This routine is the fast I/O "pass through" routine for querying network
1549  information about a file.
1550 
1551  This function simply invokes the file system's corresponding routine, or
1552  returns FALSE if the file system does not implement the function.
1553 
1554 Arguments:
1555 
1556  FileObject - Pointer to the file object to be queried.
1557 
1558  Wait - Indicates whether or not the caller can handle the file system
1559  having to wait and tie up the current thread.
1560 
1561  Buffer - Pointer to a buffer to receive the network information about the
1562  file.
1563 
1564  IoStatus - Pointer to a variable to receive the final status of the query
1565  operation.
1566 
1567  DeviceObject - Pointer to this driver's device object, the device on
1568  which the operation is to occur.
1569 
1570 Return Value:
1571 
1572  The function value is TRUE or FALSE based on whether or not fast I/O
1573  is possible for this file.
1574 
1575 --*/
1576 
1577 {
1578  PAGED_CODE();
1579  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1580 
1581  UNREFERENCED_PARAMETER(FileObject);
1582  UNREFERENCED_PARAMETER(Wait);
1583  UNREFERENCED_PARAMETER(Buffer);
1584  UNREFERENCED_PARAMETER(DeviceObject);
1585 
1586  //
1587  // This is our CDO, fail the operation
1588  //
1589 
1590  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1591  ("[Cdo]: CdoFastIoQueryNetworkOpenInfo -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1592  FileObject,
1593  DeviceObject) );
1594 
1595  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1596  IoStatus->Information = 0;
1597 
1598  return TRUE;
1599 }
1600 
1601 
1602 // This annotation tells the static analyzer that IoStatus->Status is where to check
1603 // whether this routine succeeded or not, not the BOOLEAN return value.
1604 _Success_(IoStatus->Status == 0)
1605 BOOLEAN
1606 CdoFastIoMdlRead (
1607  _In_ PFILE_OBJECT FileObject,
1608  _In_ PLARGE_INTEGER FileOffset,
1609  _In_ ULONG Length,
1610  _In_ ULONG LockKey,
1611  _Outptr_ PMDL *MdlChain,
1612  _Out_ PIO_STATUS_BLOCK IoStatus,
1613  _In_ PDEVICE_OBJECT DeviceObject )
1614 /*++
1615 
1616 Routine Description:
1617 
1618  This routine is the fast I/O "pass through" routine for reading a file
1619  using MDLs as buffers.
1620 
1621  This function simply invokes the file system's corresponding routine, or
1622  returns FALSE if the file system does not implement the function.
1623 
1624 Arguments:
1625 
1626  FileObject - Pointer to the file object that is to be read.
1627 
1628  FileOffset - Supplies the offset into the file to begin the read operation.
1629 
1630  Length - Specifies the number of bytes to be read from the file.
1631 
1632  LockKey - The key to be used in byte range lock checks.
1633 
1634  MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
1635  chain built to describe the data read.
1636 
1637  IoStatus - Variable to receive the final status of the read operation.
1638 
1639  DeviceObject - Pointer to this driver's device object, the device on
1640  which the operation is to occur.
1641 
1642 Return Value:
1643 
1644  The function value is TRUE or FALSE based on whether or not fast I/O
1645  is possible for this file.
1646 
1647 --*/
1648 {
1649  PAGED_CODE();
1650  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1651 
1652  UNREFERENCED_PARAMETER(FileObject);
1653  UNREFERENCED_PARAMETER(FileOffset);
1654  UNREFERENCED_PARAMETER(Length);
1655  UNREFERENCED_PARAMETER(LockKey);
1656  UNREFERENCED_PARAMETER(MdlChain);
1657  UNREFERENCED_PARAMETER(DeviceObject);
1658 
1659  //
1660  // This is our CDO, fail the operation
1661  //
1662 
1663  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1664  ("[Cdo]: CdoFastIoMdlRead -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1665  FileObject,
1666  DeviceObject) );
1667 
1668  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1669  IoStatus->Information = 0;
1670 
1671  return TRUE;
1672 }
1673 
1674 BOOLEAN
1676  _In_ PFILE_OBJECT FileObject,
1677  _In_ PMDL MdlChain,
1678  _In_ PDEVICE_OBJECT DeviceObject )
1679 /*++
1680 
1681 Routine Description:
1682 
1683  This routine is the fast I/O "pass through" routine for completing an
1684  MDL read operation.
1685 
1686  This function simply invokes the file system's corresponding routine, if
1687  it has one. It should be the case that this routine is invoked only if
1688  the MdlRead function is supported by the underlying file system, and
1689  therefore this function will also be supported, but this is not assumed
1690  by this driver.
1691 
1692 Arguments:
1693 
1694  FileObject - Pointer to the file object to complete the MDL read upon.
1695 
1696  MdlChain - Pointer to the MDL chain used to perform the read operation.
1697 
1698  DeviceObject - Pointer to this driver's device object, the device on
1699  which the operation is to occur.
1700 
1701 Return Value:
1702 
1703  The function value is TRUE or FALSE, depending on whether or not it is
1704  possible to invoke this function on the fast I/O path.
1705 
1706 --*/
1707 
1708 {
1709  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1710 
1711  UNREFERENCED_PARAMETER(FileObject);
1712  UNREFERENCED_PARAMETER(MdlChain);
1713  UNREFERENCED_PARAMETER(DeviceObject);
1714 
1715  //
1716  // This is our CDO, return not supported
1717  //
1718 
1719  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1720  ("[Cdo]: CdoFastIoMdlReadComplete -> Unsupported as FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1721  FileObject,
1722  DeviceObject) );
1723 
1724  return FALSE;
1725 }
1726 
1727 
1728 // This annotation tells the static analyzer that IoStatus->Status is where to check
1729 // whether this routine succeeded or not, not the BOOLEAN return value.
1730 _Success_(IoStatus->Status == 0)
1731 BOOLEAN
1732 CdoFastIoPrepareMdlWrite (
1733  _In_ PFILE_OBJECT FileObject,
1734  _In_ PLARGE_INTEGER FileOffset,
1735  _In_ ULONG Length,
1736  _In_ ULONG LockKey,
1737  _Outptr_ PMDL *MdlChain,
1738  _Out_ PIO_STATUS_BLOCK IoStatus,
1739  _In_ PDEVICE_OBJECT DeviceObject )
1740 /*++
1741 
1742 Routine Description:
1743 
1744  This routine is the fast I/O "pass through" routine for preparing for an
1745  MDL write operation.
1746 
1747  This function simply invokes the file system's corresponding routine, or
1748  returns FALSE if the file system does not implement the function.
1749 
1750 Arguments:
1751 
1752  FileObject - Pointer to the file object that will be written.
1753 
1754  FileOffset - Supplies the offset into the file to begin the write operation.
1755 
1756  Length - Specifies the number of bytes to be write to the file.
1757 
1758  LockKey - The key to be used in byte range lock checks.
1759 
1760  MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
1761  chain built to describe the data written.
1762 
1763  IoStatus - Variable to receive the final status of the write operation.
1764 
1765  DeviceObject - Pointer to this driver's device object, the device on
1766  which the operation is to occur.
1767 
1768 Return Value:
1769 
1770  The function value is TRUE or FALSE based on whether or not fast I/O
1771  is possible for this file.
1772 
1773 --*/
1774 
1775 {
1776  PAGED_CODE();
1777  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1778 
1779  UNREFERENCED_PARAMETER(FileObject);
1780  UNREFERENCED_PARAMETER(FileOffset);
1781  UNREFERENCED_PARAMETER(Length);
1782  UNREFERENCED_PARAMETER(LockKey);
1783  UNREFERENCED_PARAMETER(MdlChain);
1784  UNREFERENCED_PARAMETER(DeviceObject);
1785 
1786  //
1787  // This is our CDO, fail the operation
1788  //
1789 
1790  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1791  ("[Cdo]: CdoFastIoPrepareMdlWrite -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1792  FileObject,
1793  DeviceObject) );
1794 
1795  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1796  IoStatus->Information = 0;
1797 
1798  return TRUE;
1799 }
1800 
1801 
1802 
1803 
1804 BOOLEAN
1806  _In_ PFILE_OBJECT FileObject,
1807  _In_ PLARGE_INTEGER FileOffset,
1808  _In_ PMDL MdlChain,
1809  _In_ PDEVICE_OBJECT DeviceObject )
1810 /*++
1811 
1812 Routine Description:
1813 
1814  This routine is the fast I/O "pass through" routine for completing an
1815  MDL write operation.
1816 
1817  This function simply invokes the file system's corresponding routine, if
1818  it has one. It should be the case that this routine is invoked only if
1819  the PrepareMdlWrite function is supported by the underlying file system,
1820  and therefore this function will also be supported, but this is not
1821  assumed by this driver.
1822 
1823 Arguments:
1824 
1825  FileObject - Pointer to the file object to complete the MDL write upon.
1826 
1827  FileOffset - Supplies the file offset at which the write took place.
1828 
1829  MdlChain - Pointer to the MDL chain used to perform the write operation.
1830 
1831  DeviceObject - Pointer to this driver's device object, the device on
1832  which the operation is to occur.
1833 
1834 Return Value:
1835 
1836  The function value is TRUE or FALSE, depending on whether or not it is
1837  possible to invoke this function on the fast I/O path.
1838 
1839 --*/
1840 {
1841  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1842 
1843  UNREFERENCED_PARAMETER(FileObject);
1844  UNREFERENCED_PARAMETER(FileOffset);
1845  UNREFERENCED_PARAMETER(MdlChain);
1846  UNREFERENCED_PARAMETER(DeviceObject);
1847 
1848  //
1849  // This is our CDO, return not supported
1850  //
1851 
1852  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1853  ("[Cdo]: CdoFastIoMdlWriteComplete -> Unsupported as FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1854  FileObject,
1855  DeviceObject) );
1856 
1857 
1858  return FALSE;
1859 }
1860 
1861 
1862 /*********************************************************************************
1863  UNIMPLEMENTED FAST IO ROUTINES
1864 
1865  The following four Fast IO routines are for compression on the wire
1866  which is not yet implemented in NT.
1867 
1868  NOTE: It is highly recommended that you include these routines (which
1869  do a pass-through call) so your filter will not need to be
1870  modified in the future when this functionality is implemented in
1871  the OS.
1872 
1873  FastIoReadCompressed, FastIoWriteCompressed,
1874  FastIoMdlReadCompleteCompressed, FastIoMdlWriteCompleteCompressed
1875 **********************************************************************************/
1876 
1877 
1878 
1879 // This annotation tells the static analyzer that IoStatus->Status is where to check
1880 // whether this routine succeeded or not, not the BOOLEAN return value.
1881 _Success_(IoStatus->Status == 0)
1882 BOOLEAN
1883 CdoFastIoReadCompressed (
1884  _In_ PFILE_OBJECT FileObject,
1885  _In_ PLARGE_INTEGER FileOffset,
1886  _In_ ULONG Length,
1887  _In_ ULONG LockKey,
1889  _Outptr_ PMDL *MdlChain,
1890  _Out_ PIO_STATUS_BLOCK IoStatus,
1891  _Out_writes_bytes_(CompressedDataInfoLength) struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1892  _In_ ULONG CompressedDataInfoLength,
1893  _In_ PDEVICE_OBJECT DeviceObject)
1894 /*++
1895 
1896 Routine Description:
1897 
1898  This routine is the fast I/O "pass through" routine for reading compressed
1899  data from a file.
1900 
1901  This function simply invokes the file system's corresponding routine, or
1902  returns FALSE if the file system does not implement the function.
1903 
1904 Arguments:
1905 
1906  FileObject - Pointer to the file object that will be read.
1907 
1908  FileOffset - Supplies the offset into the file to begin the read operation.
1909 
1910  Length - Specifies the number of bytes to be read from the file.
1911 
1912  LockKey - The key to be used in byte range lock checks.
1913 
1914  Buffer - Pointer to a buffer to receive the compressed data read.
1915 
1916  MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
1917  chain built to describe the data read.
1918 
1919  IoStatus - Variable to receive the final status of the read operation.
1920 
1921  CompressedDataInfo - A buffer to receive the description of the compressed
1922  data.
1923 
1924  CompressedDataInfoLength - Specifies the size of the buffer described by
1925  the CompressedDataInfo parameter.
1926 
1927  DeviceObject - Pointer to this driver's device object, the device on
1928  which the operation is to occur.
1929 
1930 Return Value:
1931 
1932  The function value is TRUE or FALSE based on whether or not fast I/O
1933  is possible for this file.
1934 
1935 --*/
1936 {
1937  PAGED_CODE();
1938  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
1939 
1940  UNREFERENCED_PARAMETER(FileObject);
1941  UNREFERENCED_PARAMETER(FileOffset);
1942  UNREFERENCED_PARAMETER(Length);
1943  UNREFERENCED_PARAMETER(LockKey);
1944  UNREFERENCED_PARAMETER(Buffer);
1945  UNREFERENCED_PARAMETER(MdlChain);
1946  UNREFERENCED_PARAMETER(CompressedDataInfo);
1947  UNREFERENCED_PARAMETER(CompressedDataInfoLength);
1948  UNREFERENCED_PARAMETER(DeviceObject);
1949 
1950  //
1951  // This is our CDO, fail the operation
1952  //
1953 
1954  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
1955  ("[Cdo]: CdoFastIoReadCompressed -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
1956  FileObject,
1957  DeviceObject) );
1958 
1959  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
1960  IoStatus->Information = 0;
1961 
1962  return TRUE;
1963 }
1964 
1965 
1966 // This annotation tells the static analyzer that IoStatus->Status is where to check
1967 // whether this routine succeeded or not, not the BOOLEAN return value.
1968 _Success_(IoStatus->Status == 0)
1969 BOOLEAN
1970 CdoFastIoWriteCompressed (
1971  _In_ PFILE_OBJECT FileObject,
1972  _In_ PLARGE_INTEGER FileOffset,
1973  _In_ ULONG Length,
1974  _In_ ULONG LockKey,
1975  _In_reads_bytes_(Length) PVOID Buffer,
1976  _Outptr_ PMDL *MdlChain,
1977  _Out_ PIO_STATUS_BLOCK IoStatus,
1978  _In_reads_bytes_(CompressedDataInfoLength) struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1979  _In_ ULONG CompressedDataInfoLength,
1980  _In_ PDEVICE_OBJECT DeviceObject)
1981 /*++
1982 
1983 Routine Description:
1984 
1985  This routine is the fast I/O "pass through" routine for writing compressed
1986  data to a file.
1987 
1988  This function simply invokes the file system's corresponding routine, or
1989  returns FALSE if the file system does not implement the function.
1990 
1991 Arguments:
1992 
1993  FileObject - Pointer to the file object that will be written.
1994 
1995  FileOffset - Supplies the offset into the file to begin the write operation.
1996 
1997  Length - Specifies the number of bytes to be write to the file.
1998 
1999  LockKey - The key to be used in byte range lock checks.
2000 
2001  Buffer - Pointer to the buffer containing the data to be written.
2002 
2003  MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
2004  chain built to describe the data written.
2005 
2006  IoStatus - Variable to receive the final status of the write operation.
2007 
2008  CompressedDataInfo - A buffer to containing the description of the
2009  compressed data.
2010 
2011  CompressedDataInfoLength - Specifies the size of the buffer described by
2012  the CompressedDataInfo parameter.
2013 
2014  DeviceObject - Pointer to this driver's device object, the device on
2015  which the operation is to occur.
2016 
2017 Return Value:
2018 
2019  The function value is TRUE or FALSE based on whether or not fast I/O
2020  is possible for this file.
2021 
2022 --*/
2023 
2024 {
2025  PAGED_CODE();
2026  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
2027 
2028  UNREFERENCED_PARAMETER(FileObject);
2029  UNREFERENCED_PARAMETER(FileOffset);
2030  UNREFERENCED_PARAMETER(Length);
2031  UNREFERENCED_PARAMETER(LockKey);
2032  UNREFERENCED_PARAMETER(Buffer);
2033  UNREFERENCED_PARAMETER(MdlChain);
2034  UNREFERENCED_PARAMETER(CompressedDataInfo);
2035  UNREFERENCED_PARAMETER(CompressedDataInfoLength);
2036  UNREFERENCED_PARAMETER(DeviceObject);
2037 
2038  //
2039  // This is our CDO, fail the operation
2040  //
2041 
2042  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
2043  ("[Cdo]: CdoFastIoWriteCompressed -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\n",
2044  FileObject,
2045  DeviceObject) );
2046 
2047  IoStatus->Status = STATUS_INVALID_DEVICE_REQUEST;
2048  IoStatus->Information = 0;
2049 
2050  return TRUE;
2051 }
2052 
2053 
2054 
2055 
2056 BOOLEAN
2058  _In_ PFILE_OBJECT FileObject,
2059  _In_ PMDL MdlChain,
2060  _In_ PDEVICE_OBJECT DeviceObject)
2061 /*++
2062 
2063 Routine Description:
2064 
2065  This routine is the fast I/O "pass through" routine for completing an
2066  MDL read compressed operation.
2067 
2068  This function simply invokes the file system's corresponding routine, if
2069  it has one. It should be the case that this routine is invoked only if
2070  the read compressed function is supported by the underlying file system,
2071  and therefore this function will also be supported, but this is not assumed
2072  by this driver.
2073 
2074 Arguments:
2075 
2076  FileObject - Pointer to the file object to complete the compressed read
2077  upon.
2078 
2079  MdlChain - Pointer to the MDL chain used to perform the read operation.
2080 
2081  DeviceObject - Pointer to this driver's device object, the device on
2082  which the operation is to occur.
2083 
2084 Return Value:
2085 
2086  The function value is TRUE or FALSE, depending on whether or not it is
2087  possible to invoke this function on the fast I/O path.
2088 
2089 --*/
2090 {
2091  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
2092 
2093  UNREFERENCED_PARAMETER(FileObject);
2094  UNREFERENCED_PARAMETER(MdlChain);
2095  UNREFERENCED_PARAMETER(DeviceObject);
2096 
2097  //
2098  // This is our CDO, return not supported
2099  //
2100 
2101  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
2102  ("[Cdo]: CdoFastIoMdlReadCompleteCompressed -> Unsupported as FastIO call ( FileObject = %p, DeviceObject = %p )\n",
2103  FileObject,
2104  DeviceObject) );
2105 
2106  return FALSE;
2107 }
2108 
2109 
2110 
2111 BOOLEAN
2113  _In_ PFILE_OBJECT FileObject,
2114  _In_ PLARGE_INTEGER FileOffset,
2115  _In_ PMDL MdlChain,
2116  _In_ PDEVICE_OBJECT DeviceObject)
2117 /*++
2118 
2119 Routine Description:
2120 
2121  This routine is the fast I/O "pass through" routine for completing a
2122  write compressed operation.
2123 
2124  This function simply invokes the file system's corresponding routine, if
2125  it has one. It should be the case that this routine is invoked only if
2126  the write compressed function is supported by the underlying file system,
2127  and therefore this function will also be supported, but this is not assumed
2128  by this driver.
2129 
2130 Arguments:
2131 
2132  FileObject - Pointer to the file object to complete the compressed write
2133  upon.
2134 
2135  FileOffset - Supplies the file offset at which the file write operation
2136  began.
2137 
2138  MdlChain - Pointer to the MDL chain used to perform the write operation.
2139 
2140  DeviceObject - Pointer to this driver's device object, the device on
2141  which the operation is to occur.
2142 
2143 Return Value:
2144 
2145  The function value is TRUE or FALSE, depending on whether or not it is
2146  possible to invoke this function on the fast I/O path.
2147 
2148 --*/
2149 {
2150  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
2151 
2152  UNREFERENCED_PARAMETER(FileObject);
2153  UNREFERENCED_PARAMETER(FileOffset);
2154  UNREFERENCED_PARAMETER(MdlChain);
2155  UNREFERENCED_PARAMETER(DeviceObject);
2156 
2157  //
2158  // This is our CDO, return not supported
2159  //
2160 
2161  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
2162  ("[Cdo]: CdoFastIoMdlWriteCompleteCompressed -> Unsupported as FastIO call ( FileObject = %p, DeviceObject = %p )\n",
2163  FileObject,
2164  DeviceObject) );
2165 
2166  return FALSE;
2167 }
2168 
2169 
2170 // This annotation tells the static analyzer that IoStatus->Status is where to check
2171 // whether this routine succeeded or not, not the BOOLEAN return value.
2172 _Success_(Irp->IoStatus.Status == 0)
2173 BOOLEAN
2174 CdoFastIoQueryOpen (
2175  _In_ PIRP Irp,
2176  _Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
2177  _In_ PDEVICE_OBJECT DeviceObject)
2178 /*++
2179 
2180 Routine Description:
2181 
2182  This routine is the fast I/O "pass through" routine for opening a file
2183  and returning network information for it.
2184 
2185  This function simply invokes the file system's corresponding routine, or
2186  returns FALSE if the file system does not implement the function.
2187 
2188 Arguments:
2189 
2190  Irp - Pointer to a create IRP that represents this open operation. It is
2191  to be used by the file system for common open/create code, but not
2192  actually completed.
2193 
2194  NetworkInformation - A buffer to receive the information required by the
2195  network about the file being opened.
2196 
2197  DeviceObject - Pointer to this driver's device object, the device on
2198  which the operation is to occur.
2199 
2200 Return Value:
2201 
2202  The function value is TRUE or FALSE based on whether or not fast I/O
2203  is possible for this file.
2204 
2205 --*/
2206 {
2207  PAGED_CODE();
2208  FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
2209 
2210  UNREFERENCED_PARAMETER(NetworkInformation);
2211  UNREFERENCED_PARAMETER(DeviceObject);
2212 
2213  //
2214  // This is our CDO, fail the operation
2215  //
2216 
2217  DebugTrace( DEBUG_TRACE_CDO_ALL_OPERATIONS | DEBUG_TRACE_CDO_FASTIO_OPERATIONS | DEBUG_TRACE_ERROR,
2218  ("[Cdo]: CdoFastIoQueryOpen -> Unsupported FastIO call ( Irp = %p, DeviceObject = %p )\n",
2219  Irp,
2220  DeviceObject) );
2221 
2222  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
2223  Irp->IoStatus.Information = 0;
2224 
2225  return TRUE;
2226 }
2227 
2228 
2229 
BOOLEAN CdoFastIoMdlReadCompleteCompressed(_In_ PFILE_OBJECT FileObject, _In_ PMDL MdlChain, _In_ PDEVICE_OBJECT DeviceObject)
_In_ PLARGE_INTEGER _In_ ULONG Length
#define GLOBAL_DATA_F_CDO_OPEN_HANDLE
Definition: CdoStruct.h:39
_In_ BOOLEAN _Out_ PFILE_BASIC_INFORMATION _Out_ PIO_STATUS_BLOCK IoStatus
#define IRP_MJ_CLEANUP
Definition: mspyLog.h:302
BOOLEAN CdoFastIoCheckIfPossible(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _In_ BOOLEAN CheckForReadOperation, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
_In_ BOOLEAN Wait
_In_ BOOLEAN _Out_ PFILE_BASIC_INFORMATION _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
BOOLEAN CdoFastIoRead(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _Out_writes_bytes_(Length) PVOID Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
#define IRP_MJ_MAXIMUM_FUNCTION
Definition: mspyLog.h:312
BOOLEAN CdoFastIoMdlReadComplete(_In_ PFILE_OBJECT FileObject, _In_ PMDL MdlChain, _In_ PDEVICE_OBJECT DeviceObject)
FLT_ASSERT(IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject))
NTSTATUS CdoHandlePrivateOpen(_In_ PIRP Irp)
return TRUE
AV_SCANNER_GLOBAL_DATA Globals
Definition: avscan.h:152
_In_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _Outptr_ PMDL _Out_ PIO_STATUS_BLOCK _In_ ULONG CompressedDataInfoLength
Definition: CdoProc.h:237
FAST_IO_DISPATCH CdoFastIoDispatch
Definition: CdoOperations.c:69
BOOLEAN CdoFastIoMdlWriteComplete(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ PMDL MdlChain, _In_ PDEVICE_OBJECT DeviceObject)
#define GLOBAL_DATA_F_CDO_OPEN_REF
Definition: CdoStruct.h:33
NTSTATUS CdoHandlePrivateCleanup(_In_ PIRP Irp)
BOOLEAN CdoFastIoDeviceControl(_In_ PFILE_OBJECT FileObject, _In_ BOOLEAN Wait, _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _In_ ULONG IoControlCode, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
BOOLEAN CdoFastIoUnlockAllByKey(_In_ PFILE_OBJECT FileObject, _In_ PVOID ProcessId, _In_ ULONG Key, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
NTSTATUS _Function_class_(DRIVER_INITIALIZE)
_In_ PLARGE_INTEGER FileOffset
_In_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _Out_writes_bytes_(Length)
_In_ BOOLEAN _Out_ PFILE_BASIC_INFORMATION Buffer
#define FlagOn(_F, _SF)
Definition: minispy.h:247
_In_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_reads_bytes_(Length)
BOOLEAN CdoFastIoMdlWriteCompleteCompressed(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ PMDL MdlChain, _In_ PDEVICE_OBJECT DeviceObject)
BOOLEAN CdoFastIoUnlockAll(_In_ PFILE_OBJECT FileObject, _In_ PEPROCESS ProcessId, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
BOOLEAN CdoFastIoLock(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ PLARGE_INTEGER Length, _In_ PEPROCESS ProcessId, _In_ ULONG Key, _In_ BOOLEAN FailImmediately, _In_ BOOLEAN ExclusiveLock, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
UNREFERENCED_PARAMETER(FileObject)
DebugTrace(DEBUG_TRACE_CDO_ALL_OPERATIONS|DEBUG_TRACE_CDO_FASTIO_OPERATIONS|DEBUG_TRACE_ERROR,("[Cdo]: CdoFastIoQueryBasicInfo -> Unsupported FastIO call ( FileObject = %p, DeviceObject = %p )\, FileObject, DeviceObject))
DRIVER_DISPATCH CdoMajorFunction
NcLoadRegistryStringRetry NULL
Definition: ncinit.c:53
NTSTATUS CdoHandlePrivateFsControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG IoControlCode, _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Out_ PIO_STATUS_BLOCK IoStatus, _In_opt_ PIRP Irp)
_In_ PLARGE_INTEGER _In_ ULONG _In_ ULONG LockKey
#define IRP_MJ_CLOSE
Definition: mspyLog.h:286
_Success_(IoStatus->Status==0) BOOLEAN CdoFastIoQueryBasicInfo(_In_ PFILE_OBJECT FileObject
VOID CdoDeleteControlDeviceObject(VOID)
PAGED_CODE()
#define IRP_MJ_FILE_SYSTEM_CONTROL
Definition: mspyLog.h:297
_Out_ PFILE_NETWORK_OPEN_INFORMATION NetworkInformation
#define CONTROL_DEVICE_OBJECT_NAME
Definition: CdoStruct.h:94
BOOLEAN CdoFastIoWrite(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ ULONG Length, _In_ BOOLEAN Wait, _In_ ULONG LockKey, _In_reads_bytes_(Length) PVOID Buffer, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)
NTSTATUS CdoHandlePrivateClose(_In_ PIRP Irp)
#define IS_MY_CONTROL_DEVICE_OBJECT(_devObj)
Definition: CdoStruct.h:100
_In_opt_ PFILE_OBJECT FileObject
Definition: nc.h:493
_In_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _Outptr_ PMDL * MdlChain
#define IRP_MJ_CREATE
Definition: mspyLog.h:284
BOOLEAN CdoFastIoUnlockSingle(_In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, _In_ PLARGE_INTEGER Length, _In_ PEPROCESS ProcessId, _In_ ULONG Key, _Out_ PIO_STATUS_BLOCK IoStatus, _In_ PDEVICE_OBJECT DeviceObject)

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com