[KMTEST]
[reactos.git] / rostests / drivers / kmtest / ntos_fsrtl.c
1 /*
2 * FsRtl Test
3 *
4 * Copyright 2010 Pierre Schweitzer <pierre.schweitzer@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 /* INCLUDES *******************************************************************/
23
24 #include "kmtest.h"
25 #include <ntifs.h>
26
27 #define NDEBUG
28 #include "debug.h"
29
30 /* PRIVATE FUNCTIONS **********************************************************/
31
32 VOID FsRtlIsNameInExpressionTest()
33 {
34 UNICODE_STRING Expression, Name;
35
36 RtlInitUnicodeString(&Expression, L"*");
37 RtlInitUnicodeString(&Name, L"");
38 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
39 RtlInitUnicodeString(&Expression, L"");
40 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
41
42 RtlInitUnicodeString(&Expression, L"ntdll.dll");
43 RtlInitUnicodeString(&Name, L".");
44 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
45 RtlInitUnicodeString(&Name, L"~1");
46 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
47 RtlInitUnicodeString(&Name, L"..");
48 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
49 RtlInitUnicodeString(&Name, L"ntdll.dll");
50 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
51
52 RtlInitUnicodeString(&Expression, L"smss.exe");
53 RtlInitUnicodeString(&Name, L".");
54 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
55 RtlInitUnicodeString(&Name, L"~1");
56 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
57 RtlInitUnicodeString(&Name, L"..");
58 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
59 RtlInitUnicodeString(&Name, L"ntdll.dll");
60 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
61 RtlInitUnicodeString(&Name, L"NTDLL.dll");
62 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
63
64 RtlInitUnicodeString(&Expression, L"nt??krnl.???");
65 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
66 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
67
68 RtlInitUnicodeString(&Expression, L"he*o");
69 RtlInitUnicodeString(&Name, L"hello");
70 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
71 RtlInitUnicodeString(&Name, L"helo");
72 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
73 RtlInitUnicodeString(&Name, L"hella");
74 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
75
76 RtlInitUnicodeString(&Expression, L"he*");
77 RtlInitUnicodeString(&Name, L"hello");
78 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
79 RtlInitUnicodeString(&Name, L"helo");
80 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
81 RtlInitUnicodeString(&Name, L"hella");
82 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
83
84 RtlInitUnicodeString(&Expression, L"*.cpl");
85 RtlInitUnicodeString(&Name, L"kdcom.dll");
86 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
87 RtlInitUnicodeString(&Name, L"bootvid.dll");
88 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
89 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
90 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
91
92 RtlInitUnicodeString(&Expression, L".");
93 RtlInitUnicodeString(&Name, L"NTDLL.DLL");
94 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
95
96 RtlInitUnicodeString(&Expression, L"F0_*.*");
97 RtlInitUnicodeString(&Name, L".");
98 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
99 RtlInitUnicodeString(&Name, L"..");
100 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
101 RtlInitUnicodeString(&Name, L"SETUP.EXE");
102 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
103 RtlInitUnicodeString(&Name, L"F0_001");
104 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
105
106 RtlInitUnicodeString(&Expression, L"*.TTF");
107 RtlInitUnicodeString(&Name, L".");
108 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
109 RtlInitUnicodeString(&Name, L"..");
110 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
111 RtlInitUnicodeString(&Name, L"SETUP.INI");
112 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
113
114 RtlInitUnicodeString(&Expression, L"*");
115 RtlInitUnicodeString(&Name, L".");
116 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
117 RtlInitUnicodeString(&Name, L"..");
118 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
119 RtlInitUnicodeString(&Name, L"SETUP.INI");
120 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
121
122 RtlInitUnicodeString(&Expression, L"\"ntoskrnl.exe");
123 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
124 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
125 RtlInitUnicodeString(&Expression, L"ntoskrnl\"exe");
126 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
127 RtlInitUnicodeString(&Expression, L"ntoskrn\".exe");
128 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
129 RtlInitUnicodeString(&Expression, L"ntoskrn\"\"exe");
130 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
131 RtlInitUnicodeString(&Expression, L"ntoskrnl.\"exe");
132 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
133 RtlInitUnicodeString(&Expression, L"ntoskrnl.exe\"");
134 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
135 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
136 RtlInitUnicodeString(&Name, L"ntoskrnl.exe.");
137 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
138
139 RtlInitUnicodeString(&Expression, L"*.c.d");
140 RtlInitUnicodeString(&Name, L"a.b.c.d");
141 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
142 RtlInitUnicodeString(&Expression, L"*?");
143 RtlInitUnicodeString(&Name, L"");
144 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
145 RtlInitUnicodeString(&Name, L"a");
146 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
147 RtlInitUnicodeString(&Name, L"aa");
148 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
149 RtlInitUnicodeString(&Expression, L"?*?");
150 RtlInitUnicodeString(&Name, L"");
151 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
152 RtlInitUnicodeString(&Name, L"a");
153 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
154 RtlInitUnicodeString(&Name, L"aa");
155 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
156 RtlInitUnicodeString(&Name, L"aaa");
157 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
158 }
159
160 VOID FsRtlIsDbcsInExpressionTest()
161 {
162 ANSI_STRING Expression, Name;
163
164 RtlInitAnsiString(&Expression, "*");
165 RtlInitAnsiString(&Name, "");
166 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
167 RtlInitAnsiString(&Expression, "");
168 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
169
170 RtlInitAnsiString(&Expression, "ntdll.dll");
171 RtlInitAnsiString(&Name, ".");
172 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
173 RtlInitAnsiString(&Name, "~1");
174 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
175 RtlInitAnsiString(&Name, "..");
176 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
177 RtlInitAnsiString(&Name, "ntdll.dll");
178 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
179
180 RtlInitAnsiString(&Expression, "smss.exe");
181 RtlInitAnsiString(&Name, ".");
182 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
183 RtlInitAnsiString(&Name, "~1");
184 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
185 RtlInitAnsiString(&Name, "..");
186 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
187 RtlInitAnsiString(&Name, "ntdll.dll");
188 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
189 RtlInitAnsiString(&Name, "NTDLL.dll");
190 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
191
192 RtlInitAnsiString(&Expression, "nt??krnl.???");
193 RtlInitAnsiString(&Name, "ntoskrnl.exe");
194 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
195
196 RtlInitAnsiString(&Expression, "he*o");
197 RtlInitAnsiString(&Name, "hello");
198 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
199 RtlInitAnsiString(&Name, "helo");
200 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
201 RtlInitAnsiString(&Name, "hella");
202 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
203
204 RtlInitAnsiString(&Expression, "he*");
205 RtlInitAnsiString(&Name, "hello");
206 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
207 RtlInitAnsiString(&Name, "helo");
208 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
209 RtlInitAnsiString(&Name, "hella");
210 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
211
212 RtlInitAnsiString(&Expression, "*.cpl");
213 RtlInitAnsiString(&Name, "kdcom.dll");
214 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
215 RtlInitAnsiString(&Name, "bootvid.dll");
216 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
217 RtlInitAnsiString(&Name, "ntoskrnl.exe");
218 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
219
220 RtlInitAnsiString(&Expression, ".");
221 RtlInitAnsiString(&Name, "NTDLL.DLL");
222 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
223
224 RtlInitAnsiString(&Expression, "F0_*.*");
225 RtlInitAnsiString(&Name, ".");
226 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
227 RtlInitAnsiString(&Name, "..");
228 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
229 RtlInitAnsiString(&Name, "SETUP.EXE");
230 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
231 RtlInitAnsiString(&Name, "F0_001");
232 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
233
234 RtlInitAnsiString(&Expression, "*.TTF");
235 RtlInitAnsiString(&Name, ".");
236 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
237 RtlInitAnsiString(&Name, "..");
238 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
239 RtlInitAnsiString(&Name, "SETUP.INI");
240 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
241
242 RtlInitAnsiString(&Expression, "*");
243 RtlInitAnsiString(&Name, ".");
244 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
245 RtlInitAnsiString(&Name, "..");
246 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
247 RtlInitAnsiString(&Name, "SETUP.INI");
248 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
249
250 RtlInitAnsiString(&Expression, "\"ntoskrnl.exe");
251 RtlInitAnsiString(&Name, "ntoskrnl.exe");
252 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
253 RtlInitAnsiString(&Expression, "ntoskrnl\"exe");
254 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
255 RtlInitAnsiString(&Expression, "ntoskrn\".exe");
256 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
257 RtlInitAnsiString(&Expression, "ntoskrn\"\"exe");
258 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
259 RtlInitAnsiString(&Expression, "ntoskrnl.\"exe");
260 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
261 RtlInitAnsiString(&Expression, "ntoskrnl.exe\"");
262 RtlInitAnsiString(&Name, "ntoskrnl.exe");
263 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
264 RtlInitAnsiString(&Name, "ntoskrnl.exe.");
265 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
266
267 RtlInitAnsiString(&Expression, "*.c.d");
268 RtlInitAnsiString(&Name, "a.b.c.d");
269 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
270 RtlInitAnsiString(&Expression, "*?");
271 RtlInitAnsiString(&Name, "");
272 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
273 RtlInitAnsiString(&Name, "a");
274 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
275 RtlInitAnsiString(&Name, "aa");
276 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
277 RtlInitAnsiString(&Expression, "?*?");
278 RtlInitAnsiString(&Name, "");
279 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
280 RtlInitAnsiString(&Name, "a");
281 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
282 RtlInitAnsiString(&Name, "aa");
283 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
284 RtlInitAnsiString(&Name, "aaa");
285 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
286 }
287
288 /* PUBLIC FUNCTIONS ***********************************************************/
289
290 VOID
291 NtoskrnlFsRtlTest(HANDLE KeyHandle)
292 {
293 FsRtlIsNameInExpressionTest();
294 FsRtlIsDbcsInExpressionTest();
295
296 FinishTest(KeyHandle, L"FsRtlTest");
297 }