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