ReactOS 0.4.15-dev-8096-ga0eec98
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
32FLTAPI
35);
36
37/* Globals */
41
42
43
44
47{
51 PFLT_FILTER Temp = NULL;
53
55#if 0
59
63
67#endif
68
73
78
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 */
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 */
134 DriverObject->DriverUnload = (PDRIVER_UNLOAD)0x1234FFFF;
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
155FLTAPI
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
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
219VOID
221 IN ULONG Flags)
222{
223 PAGED_CODE();
224 ok_irql(PASSIVE_LEVEL);
225}
226
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
241VOID
243 _In_ PCFLT_RELATED_OBJECTS FltObjects,
245{
246 UNREFERENCED_PARAMETER(FltObjects);
248}
#define PAGED_CODE()
VOID FLTAPI FltUnregisterFilter(_In_ PFLT_FILTER Filter)
Definition: Filter.c:319
NTSTATUS NTAPI FltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject, _In_ const FLT_REGISTRATION *Registration, _Out_ PFLT_FILTER *RetFilter)
Definition: Filter.c:112
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
struct NameRec_ * Name
Definition: cdprocs.h:460
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_long(value, expected)
Definition: apitest.h:62
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DEVICE_TYPE
Definition: guid.c:10
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
ULONG FLT_INSTANCE_SETUP_FLAGS
Definition: fltkernel.h:527
ULONG FLT_FILTER_UNLOAD_FLAGS
Definition: fltkernel.h:649
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
ULONG FLT_INSTANCE_QUERY_TEARDOWN_FLAGS
Definition: fltkernel.h:552
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_ PCUNICODE_STRING Altitude
Definition: fltkernel.h:1173
NTSTATUS(FLTAPI * PFLT_FILTER_UNLOAD_CALLBACK)(FLT_FILTER_UNLOAD_FLAGS Flags)
Definition: fltkernel.h:654
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
static FLT_REGISTRATION FilterRegistration
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)
VOID TestFilterUnload(IN ULONG Flags)
#define RESET_REGISTRATION(basic)
static PDRIVER_OBJECT TestDriverObject
NTSTATUS TestEntry(IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT PCWSTR *DeviceName, IN OUT INT *Flags)
static PFLT_FILTER TestFilter
BOOLEAN TestFltRegisterFilter(_In_ PDRIVER_OBJECT DriverObject)
NTSTATUS FLTAPI TestRegFilterUnload(_In_ FLT_FILTER_UNLOAD_FLAGS Flags)
@ FLT_OBFL_TYPE_FILTER
Definition: fltmgrint.h:13
Status
Definition: gdiplustypes.h:25
#define KmtStartSeh()
Definition: kmt_test.h:282
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:288
#define _In_
Definition: ms_sal.h:308
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_FLT_DO_NOT_ATTACH
Definition: ntstatus.h:1436
#define STATUS_FLT_INSTANCE_ALTITUDE_COLLISION
Definition: ntstatus.h:1438
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
FLT_OBJECT Base
Definition: fltmgrint.h:98
PFLT_FILTER_UNLOAD_CALLBACK OldDriverUnload
Definition: fltmgrint.h:119
PFLT_FILTER_UNLOAD_CALLBACK FilterUnload
Definition: fltmgrint.h:106
UNICODE_STRING Name
Definition: fltmgrint.h:100
UNICODE_STRING DefaultAltitude
Definition: fltmgrint.h:101
volatile FLT_OBJECT_FLAGS Flags
Definition: fltmgrint.h:27
PFLT_FILTER_UNLOAD_CALLBACK FilterUnloadCallback
Definition: fltkernel.h:734
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG SectorSize
Definition: halfuncs.h:291
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2253