xref: /reactos/drivers/filters/fltmgr/Dispatch.c (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck * PROJECT:         Filesystem Filter Manager
3*c2c66affSColin Finck * LICENSE:         GPL - See COPYING in the top level directory
4*c2c66affSColin Finck * FILE:            drivers/filters/fltmgr/Dispatch.c
5*c2c66affSColin Finck * PURPOSE:         Contains dispatch handler routines
6*c2c66affSColin Finck * PROGRAMMERS:     Ged Murphy (gedmurphy@reactos.org)
7*c2c66affSColin Finck */
8*c2c66affSColin Finck 
9*c2c66affSColin Finck /* INCLUDES ******************************************************************/
10*c2c66affSColin Finck 
11*c2c66affSColin Finck #include "fltmgr.h"
12*c2c66affSColin Finck #include "fltmgrint.h"
13*c2c66affSColin Finck #include "fltmgr_shared.h"
14*c2c66affSColin Finck 
15*c2c66affSColin Finck #define NDEBUG
16*c2c66affSColin Finck #include <debug.h>
17*c2c66affSColin Finck 
18*c2c66affSColin Finck 
19*c2c66affSColin Finck /* DATA *********************************************************************/
20*c2c66affSColin Finck 
21*c2c66affSColin Finck NTSTATUS
22*c2c66affSColin Finck HandleLoadUnloadIoctl(
23*c2c66affSColin Finck     _In_ PDEVICE_OBJECT DeviceObject,
24*c2c66affSColin Finck     _Inout_ PIRP Irp
25*c2c66affSColin Finck );
26*c2c66affSColin Finck 
27*c2c66affSColin Finck NTSTATUS
28*c2c66affSColin Finck HandleFindFirstIoctl(
29*c2c66affSColin Finck     _In_ PDEVICE_OBJECT DeviceObject,
30*c2c66affSColin Finck     _Inout_ PIRP Irp
31*c2c66affSColin Finck );
32*c2c66affSColin Finck 
33*c2c66affSColin Finck 
34*c2c66affSColin Finck /* sdsfds *******************************************************************/
35*c2c66affSColin Finck 
36*c2c66affSColin Finck NTSTATUS
FltpDeviceControlHandler(_In_ PDEVICE_OBJECT DeviceObject,_Inout_ PIRP Irp)37*c2c66affSColin Finck FltpDeviceControlHandler(_In_ PDEVICE_OBJECT DeviceObject,
38*c2c66affSColin Finck                          _Inout_ PIRP Irp)
39*c2c66affSColin Finck {
40*c2c66affSColin Finck     PIO_STACK_LOCATION StackPtr;
41*c2c66affSColin Finck     ULONG ControlCode;
42*c2c66affSColin Finck     NTSTATUS Status;
43*c2c66affSColin Finck 
44*c2c66affSColin Finck     StackPtr = IoGetCurrentIrpStackLocation(Irp);
45*c2c66affSColin Finck     FLT_ASSERT(StackPtr->MajorFunction == IRP_MJ_DEVICE_CONTROL);
46*c2c66affSColin Finck 
47*c2c66affSColin Finck     ControlCode = StackPtr->Parameters.DeviceIoControl.IoControlCode;
48*c2c66affSColin Finck     switch (ControlCode)
49*c2c66affSColin Finck     {
50*c2c66affSColin Finck         case IOCTL_FILTER_LOAD:
51*c2c66affSColin Finck             Status = HandleLoadUnloadIoctl(DeviceObject, Irp);
52*c2c66affSColin Finck             break;
53*c2c66affSColin Finck 
54*c2c66affSColin Finck         case IOCTL_FILTER_UNLOAD:
55*c2c66affSColin Finck             Status = HandleLoadUnloadIoctl(DeviceObject, Irp);
56*c2c66affSColin Finck             break;
57*c2c66affSColin Finck 
58*c2c66affSColin Finck         case IOCTL_FILTER_CREATE:
59*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
60*c2c66affSColin Finck             break;
61*c2c66affSColin Finck 
62*c2c66affSColin Finck         case IOCTL_FILTER_ATTATCH:
63*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
64*c2c66affSColin Finck             break;
65*c2c66affSColin Finck 
66*c2c66affSColin Finck         case IOCTL_FILTER_DETATCH:
67*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
68*c2c66affSColin Finck             break;
69*c2c66affSColin Finck 
70*c2c66affSColin Finck         case IOCTL_FILTER_SEND_MESSAGE:
71*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
72*c2c66affSColin Finck             break;
73*c2c66affSColin Finck 
74*c2c66affSColin Finck         case IOCTL_FILTER_GET_MESSAGE:
75*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
76*c2c66affSColin Finck             break;
77*c2c66affSColin Finck 
78*c2c66affSColin Finck         case IOCTL_FILTER_REPLY_MESSAGE:
79*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
80*c2c66affSColin Finck             break;
81*c2c66affSColin Finck 
82*c2c66affSColin Finck         case IOCTL_FILTER_FIND_FIRST:
83*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
84*c2c66affSColin Finck             break;
85*c2c66affSColin Finck 
86*c2c66affSColin Finck         case IOCTL_FILTER_FIND_NEXT:
87*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
88*c2c66affSColin Finck             break;
89*c2c66affSColin Finck 
90*c2c66affSColin Finck         case IOCTL_FILTER_GET_INFO:
91*c2c66affSColin Finck             Status = STATUS_NOT_SUPPORTED;
92*c2c66affSColin Finck             break;
93*c2c66affSColin Finck 
94*c2c66affSColin Finck         default:
95*c2c66affSColin Finck             Status = STATUS_INVALID_PARAMETER;
96*c2c66affSColin Finck             break;
97*c2c66affSColin Finck     }
98*c2c66affSColin Finck 
99*c2c66affSColin Finck     return Status;
100*c2c66affSColin Finck }
101*c2c66affSColin Finck 
102*c2c66affSColin Finck NTSTATUS
FltpDispatchHandler(_In_ PDEVICE_OBJECT DeviceObject,_Inout_ PIRP Irp)103*c2c66affSColin Finck FltpDispatchHandler(_In_ PDEVICE_OBJECT DeviceObject,
104*c2c66affSColin Finck                     _Inout_ PIRP Irp)
105*c2c66affSColin Finck {
106*c2c66affSColin Finck     PIO_STACK_LOCATION StackPtr;
107*c2c66affSColin Finck     StackPtr = IoGetCurrentIrpStackLocation(Irp);
108*c2c66affSColin Finck     UNREFERENCED_PARAMETER(StackPtr);
109*c2c66affSColin Finck 
110*c2c66affSColin Finck     // implement me
111*c2c66affSColin Finck 
112*c2c66affSColin Finck     return STATUS_SUCCESS;
113*c2c66affSColin Finck }
114*c2c66affSColin Finck 
115*c2c66affSColin Finck 
116*c2c66affSColin Finck /* INTERNAL FUNCTIONS ******************************************************/
117*c2c66affSColin Finck 
118*c2c66affSColin Finck NTSTATUS
HandleLoadUnloadIoctl(_In_ PDEVICE_OBJECT DeviceObject,_Inout_ PIRP Irp)119*c2c66affSColin Finck HandleLoadUnloadIoctl(_In_ PDEVICE_OBJECT DeviceObject,
120*c2c66affSColin Finck                       _Inout_ PIRP Irp)
121*c2c66affSColin Finck {
122*c2c66affSColin Finck     PIO_STACK_LOCATION StackPtr;
123*c2c66affSColin Finck     UNICODE_STRING Name;
124*c2c66affSColin Finck     PFILTER_NAME FilterName;
125*c2c66affSColin Finck     ULONG BufferLength;
126*c2c66affSColin Finck     ULONG ControlCode;
127*c2c66affSColin Finck     NTSTATUS Status;
128*c2c66affSColin Finck 
129*c2c66affSColin Finck     /* Get the IOCTL data from the stack pointer */
130*c2c66affSColin Finck     StackPtr = IoGetCurrentIrpStackLocation(Irp);
131*c2c66affSColin Finck     BufferLength = StackPtr->Parameters.DeviceIoControl.InputBufferLength;
132*c2c66affSColin Finck     ControlCode = StackPtr->Parameters.DeviceIoControl.IoControlCode;
133*c2c66affSColin Finck 
134*c2c66affSColin Finck     FLT_ASSERT(ControlCode == IOCTL_FILTER_LOAD || ControlCode == IOCTL_FILTER_UNLOAD);
135*c2c66affSColin Finck 
136*c2c66affSColin Finck     /* Make sure the buffer is valid */
137*c2c66affSColin Finck     if (BufferLength < sizeof(FILTER_NAME))
138*c2c66affSColin Finck         return STATUS_INVALID_PARAMETER;
139*c2c66affSColin Finck 
140*c2c66affSColin Finck     /* Convert the file name buffer into a string */
141*c2c66affSColin Finck     FilterName = (PFILTER_NAME)Irp->AssociatedIrp.SystemBuffer;
142*c2c66affSColin Finck     Name.Length = FilterName->Length;
143*c2c66affSColin Finck     Name.MaximumLength = FilterName->Length;
144*c2c66affSColin Finck     Name.Buffer = (PWCH)((PCHAR)FilterName + FIELD_OFFSET(FILTER_NAME, FilterName[0]));
145*c2c66affSColin Finck 
146*c2c66affSColin Finck     /* Forward the request to our Flt routines */
147*c2c66affSColin Finck     if (ControlCode == IOCTL_FILTER_LOAD)
148*c2c66affSColin Finck     {
149*c2c66affSColin Finck         Status = FltLoadFilter(&Name);
150*c2c66affSColin Finck     }
151*c2c66affSColin Finck     else
152*c2c66affSColin Finck     {
153*c2c66affSColin Finck         Status = FltUnloadFilter(&Name);
154*c2c66affSColin Finck     }
155*c2c66affSColin Finck 
156*c2c66affSColin Finck     return Status;
157*c2c66affSColin Finck }
158