47c4eb527ffce65643cce30919ec46f4a9eb0fd8
[reactos.git] / reactos / drivers / filters / fltmgr / Dispatch.c
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
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_LOAD_FILTER:
51 Status = HandleLoadUnloadIoctl(DeviceObject, Irp);
52 break;
53
54 case IOCTL_UNLOAD_FILTER:
55 Status = HandleLoadUnloadIoctl(DeviceObject, Irp);
56 break;
57
58 case IOCTL_FIND_FIRST_FILTER:
59 Status = HandleFindFirstIoctl(DeviceObject, Irp);
60 break;
61
62 default:
63 Status = STATUS_INVALID_PARAMETER;
64 break;
65 }
66
67 return Status;
68 }
69
70 NTSTATUS
71 FltpDispatchHandler(_In_ PDEVICE_OBJECT DeviceObject,
72 _Inout_ PIRP Irp)
73 {
74 PIO_STACK_LOCATION StackPtr;
75 StackPtr = IoGetCurrentIrpStackLocation(Irp);
76 UNREFERENCED_PARAMETER(StackPtr);
77
78 // implement me
79
80 return STATUS_SUCCESS;
81 }
82
83
84 /* INTERNAL FUNCTIONS ******************************************************/
85
86 NTSTATUS
87 HandleLoadUnloadIoctl(_In_ PDEVICE_OBJECT DeviceObject,
88 _Inout_ PIRP Irp)
89 {
90 PIO_STACK_LOCATION StackPtr;
91 UNICODE_STRING Name;
92 PFILTER_NAME FilterName;
93 ULONG BufferLength;
94 ULONG ControlCode;
95
96 /* Get the IOCTL data from the stack pointer */
97 StackPtr = IoGetCurrentIrpStackLocation(Irp);
98 BufferLength = StackPtr->Parameters.DeviceIoControl.InputBufferLength;
99 ControlCode = StackPtr->Parameters.DeviceIoControl.IoControlCode;
100
101 FLT_ASSERT(ControlCode == IOCTL_LOAD_FILTER || ControlCode == IOCTL_UNLOAD_FILTER);
102
103 /* Make sure the buffer is valid */
104 if (BufferLength < sizeof(FILTER_NAME))
105 return STATUS_INVALID_PARAMETER;
106
107 /* Convert the file name buffer into a string */
108 FilterName = (PFILTER_NAME)Irp->AssociatedIrp.SystemBuffer;
109 Name.Length = FilterName->Length;
110 Name.MaximumLength = FilterName->Length;
111 Name.Buffer = (PWCH)((PCHAR)FilterName + FIELD_OFFSET(FILTER_NAME, FilterName[0]));
112
113 /* Forward the request to our Flt routines */
114 if (ControlCode == IOCTL_LOAD_FILTER)
115 {
116 return FltLoadFilter(&Name);
117 }
118 else
119 {
120 return FltUnloadFilter(&Name);
121 }
122 }
123
124 NTSTATUS
125 HandleFindFirstIoctl(_In_ PDEVICE_OBJECT DeviceObject,
126 _Inout_ PIRP Irp)
127 {
128 return STATUS_NOT_SUPPORTED;
129 }