ReactOS  0.4.14-dev-98-gb0d4763
fltmgr_register.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests - Filter Manager
3  * LICENSE: GPLv2+ - See COPYING in the top level directory
4  * PURPOSE: Tests for checking filter registration
5  * PROGRAMMER: Ged Murphy <gedmurphy@reactos.org>
6  */
7 
8 // This tests needs to be run via a standalone driver because FltRegisterFilter
9 // uses the DriverObject in its internal structures, and we don't want it to be
10 // linked to a device object from the test suite itself.
11 
12 #include <kmt_test.h>
13 #include <fltkernel.h>
14 #include <fltmgrint.h>
15 
16 //#define NDEBUG
17 #include <debug.h>
18 
19 #define RESET_REGISTRATION(basic) \
20  do { \
21  RtlZeroMemory(&FilterRegistration, sizeof(FLT_REGISTRATION)); \
22  if (basic) { \
23  FilterRegistration.Size = sizeof(FLT_REGISTRATION); \
24  FilterRegistration.Version = FLT_REGISTRATION_VERSION; \
25  } \
26  } while (0)
27 
28 #define RESET_UNLOAD(DO) DO->DriverUnload = NULL;
29 
30 
32 FLTAPI
35 );
36 
37 /* Globals */
41 
42 
43 
44 
45 BOOLEAN
47 {
51  PFLT_FILTER Temp = NULL;
53 
55 #if 0
56  KmtStartSeh()
59 
60  KmtStartSeh()
63 
64  KmtStartSeh()
67 #endif
68 
70  FilterRegistration.Version = 0x0100;
73 
75  FilterRegistration.Version = 0x0300;
78 
80  FilterRegistration.Version = 0x0200;
84 
85 
86  /* Test invalid sizes. MSDN says this is required, but it doesn't appear to be */
92 
94  FilterRegistration.Size = 0xFFFF;
98 
99 
100  /* Now make a valid registration */
104 
105  /* Try to register again */
108 
109 
111 
112  /* Check we have the right filter name */
113  RtlInitUnicodeString(&Name, L"Kmtest-FltMgrReg");
115 
116  /* And the altitude is corect */
117  RtlInitUnicodeString(&Altitude, L"123456");
119 
120  //
121  // FIXME: More checks
122  //
123 
124  /* Cleanup the valid registration */
126 
127  /*
128  * The last thing we'll do before we exit is to properly register with the filter manager
129  * and set an unload routine. This'll let us test the FltUnregisterFilter routine
130  */
132 
133  /* Set a fake unload routine we'll use to test */
135 
139 
140  /* Test all the unlod routines */
143 
144  // This should equal the fltmgr's private unload routine, but there's no easy way of testing it...
145  //ok_eq_pointer(DriverObject->DriverUnload, FltpMiniFilterDriverUnload);
146 
147  /* Make sure our test address is never actually called */
149 
150  return TRUE;
151 }
152 
153 
154 NTSTATUS
155 FLTAPI
158 {
159  //__debugbreak();
160 
161  ok_irql(PASSIVE_LEVEL);
162  ok(TestFilter != NULL, "Buffer is NULL\n");
163 
164  //
165  // FIXME: Add tests
166  //
167 
169 
170  //
171  // FIXME: Add tests
172  //
173 
174  return STATUS_SUCCESS;
175 }
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 /*
187  * KMT Callback routines
188  */
189 
190 NTSTATUS
195  IN OUT INT *Flags)
196 {
198 
199  PAGED_CODE();
200 
202 
203  DPRINT("FltMgrReg Entry!\n");
204  trace("Entered FltMgrReg tests\n");
205 
206  /* We'll do the work ourselves in this test */
207  *Flags = TESTENTRY_NO_ALL;
208 
209  ok_irql(PASSIVE_LEVEL);
211 
212 
213  /* Run the tests */
215 
216  return Status;
217 }
218 
219 VOID
221  IN ULONG Flags)
222 {
223  PAGED_CODE();
224  ok_irql(PASSIVE_LEVEL);
225 }
226 
227 NTSTATUS
229  _In_ PCFLT_RELATED_OBJECTS FltObjects,
231  _In_ DEVICE_TYPE VolumeDeviceType,
232  _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType,
235  _In_ ULONG ReportedSectorSize
236 )
237 {
239 }
240 
241 VOID
243  _In_ PCFLT_RELATED_OBJECTS FltObjects,
245 {
246  UNREFERENCED_PARAMETER(FltObjects);
248 }
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
ULONG FLT_INSTANCE_QUERY_TEARDOWN_FLAGS
Definition: fltkernel.h:552
#define TRUE
Definition: types.h:120
FLT_OBJECT Base
Definition: fltmgrint.h:98
NTSTATUS FLTAPI TestRegFilterUnload(_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
#define STATUS_FLT_INSTANCE_ALTITUDE_COLLISION
Definition: ntstatus.h:1220
NTSTATUS TestInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType, _In_ PUNICODE_STRING VolumeName, _In_ ULONG SectorSize, _In_ ULONG ReportedSectorSize)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static PDRIVER_OBJECT TestDriverObject
#define ok_eq_pointer(value, expected)
LONG NTSTATUS
Definition: precomp.h:26
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:283
WCHAR DeviceName[]
Definition: adapter.cpp:21
int32_t INT
Definition: typedefs.h:56
PFLT_FILTER_UNLOAD_CALLBACK OldDriverUnload
Definition: fltmgrint.h:119
#define PAGED_CODE()
Definition: video.h:57
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2145
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VOID TestFilterUnload(IN ULONG Flags)
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
NTSTATUS TestEntry(IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT PCWSTR *DeviceName, IN OUT INT *Flags)
struct NameRec_ * Name
Definition: cdprocs.h:464
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
VOID FLTAPI FltUnregisterFilter(_In_ PFLT_FILTER Filter)
Definition: Filter.c:319
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_ PCUNICODE_STRING Altitude
Definition: fltkernel.h:1172
BOOLEAN TestFltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject)
#define trace
Definition: atltest.h:70
#define RESET_REGISTRATION(basic)
#define STATUS_FLT_DO_NOT_ATTACH
Definition: ntstatus.h:1218
PFLT_FILTER_UNLOAD_CALLBACK FilterUnloadCallback
Definition: fltkernel.h:734
static PFLT_FILTER TestFilter
static const WCHAR L[]
Definition: oid.c:1250
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2180
#define VOID
Definition: acefi.h:82
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
NTSTATUS(FLTAPI * PFLT_FILTER_UNLOAD_CALLBACK)(FLT_FILTER_UNLOAD_FLAGS Flags)
Definition: fltkernel.h:654
#define KmtStartSeh()
Definition: kmt_test.h:277
volatile FLT_OBJECT_FLAGS Flags
Definition: fltmgrint.h:27
PFLT_FILTER_UNLOAD_CALLBACK FilterUnload
Definition: fltmgrint.h:106
Status
Definition: gdiplustypes.h:24
#define _In_
Definition: no_sal2.h:204
UNICODE_STRING Name
Definition: fltmgrint.h:100
static FLT_REGISTRATION FilterRegistration
ULONG FLT_INSTANCE_SETUP_FLAGS
Definition: fltkernel.h:527
#define ok(value,...)
Definition: atltest.h:57
#define DEVICE_TYPE
Definition: guid.c:10
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
NTSTATUS NTAPI FltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject, _In_ const FLT_REGISTRATION *Registration, _Out_ PFLT_FILTER *RetFilter)
Definition: Filter.c:112
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define ok_eq_hex(value, expected)
_In_ ULONG SectorSize
Definition: halfuncs.h:291
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define ok_eq_long(value, expected)
Definition: kmt_test.h:240
ULONG FLT_FILTER_UNLOAD_FLAGS
Definition: fltkernel.h:649
UNICODE_STRING DefaultAltitude
Definition: fltmgrint.h:101