766149c5875e80335cdd5480daecfbf4103a450b
[reactos.git] / rostests / kmtests / ntos_fsrtl / FsRtlExpression.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite FsRtl Test
5 * PROGRAMMER: Pierre Schweitzer <pierre.schweitzer@reactos.org>
6 */
7
8 /* TODO: most of these calls fail the Windows checked build's !islower assertion and others */
9
10 #include <kmt_test.h>
11
12 #define NDEBUG
13 #include <debug.h>
14
15 static VOID FsRtlIsNameInExpressionTest()
16 {
17 UNICODE_STRING Expression, Name;
18
19 /* !Name->Length || !Expression->Length asserts */
20 if (!KmtIsCheckedBuild)
21 {
22 RtlInitUnicodeString(&Expression, L"*");
23 RtlInitUnicodeString(&Name, L"");
24 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
25 RtlInitUnicodeString(&Expression, L"");
26 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
27 }
28
29 RtlInitUnicodeString(&Expression, L"**");
30 if (!KmtIsCheckedBuild)
31 {
32 RtlInitUnicodeString(&Name, L"");
33 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
34 }
35 RtlInitUnicodeString(&Name, L"a");
36 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
37
38 RtlInitUnicodeString(&Expression, L"ntdll.dll");
39 RtlInitUnicodeString(&Name, L".");
40 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
41 RtlInitUnicodeString(&Name, L"~1");
42 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
43 RtlInitUnicodeString(&Name, L"..");
44 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
45 RtlInitUnicodeString(&Name, L"ntdll.dll");
46 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
47
48 RtlInitUnicodeString(&Expression, L"smss.exe");
49 RtlInitUnicodeString(&Name, L".");
50 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
51 RtlInitUnicodeString(&Name, L"~1");
52 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
53 RtlInitUnicodeString(&Name, L"..");
54 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
55 RtlInitUnicodeString(&Name, L"ntdll.dll");
56 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
57 RtlInitUnicodeString(&Name, L"NTDLL.dll");
58 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
59
60 RtlInitUnicodeString(&Expression, L"nt??krnl.???");
61 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
62 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
63
64 RtlInitUnicodeString(&Expression, L"he*o");
65 RtlInitUnicodeString(&Name, L"hello");
66 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
67 RtlInitUnicodeString(&Name, L"helo");
68 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
69 RtlInitUnicodeString(&Name, L"hella");
70 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
71
72 RtlInitUnicodeString(&Expression, L"he*");
73 RtlInitUnicodeString(&Name, L"hello");
74 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
75 RtlInitUnicodeString(&Name, L"helo");
76 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
77 RtlInitUnicodeString(&Name, L"hella");
78 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
79
80 RtlInitUnicodeString(&Expression, L"*.cpl");
81 RtlInitUnicodeString(&Name, L"kdcom.dll");
82 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
83 RtlInitUnicodeString(&Name, L"bootvid.dll");
84 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
85 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
86 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
87
88 RtlInitUnicodeString(&Expression, L".");
89 RtlInitUnicodeString(&Name, L"NTDLL.DLL");
90 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
91
92 RtlInitUnicodeString(&Expression, L"F0_*.*");
93 RtlInitUnicodeString(&Name, L".");
94 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
95 RtlInitUnicodeString(&Name, L"..");
96 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
97 RtlInitUnicodeString(&Name, L"SETUP.EXE");
98 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
99 RtlInitUnicodeString(&Name, L"F0_001");
100 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
101
102 RtlInitUnicodeString(&Expression, L"*.TTF");
103 RtlInitUnicodeString(&Name, L".");
104 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
105 RtlInitUnicodeString(&Name, L"..");
106 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
107 RtlInitUnicodeString(&Name, L"SETUP.INI");
108 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
109
110 RtlInitUnicodeString(&Expression, L"*");
111 RtlInitUnicodeString(&Name, L".");
112 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
113 RtlInitUnicodeString(&Name, L"..");
114 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
115 RtlInitUnicodeString(&Name, L"SETUP.INI");
116 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
117
118 RtlInitUnicodeString(&Expression, L"\"ntoskrnl.exe");
119 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
120 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
121 RtlInitUnicodeString(&Expression, L"ntoskrnl\"exe");
122 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
123 RtlInitUnicodeString(&Expression, L"ntoskrn\".exe");
124 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
125 RtlInitUnicodeString(&Expression, L"ntoskrn\"\"exe");
126 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
127 RtlInitUnicodeString(&Expression, L"ntoskrnl.\"exe");
128 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
129 RtlInitUnicodeString(&Expression, L"ntoskrnl.exe\"");
130 RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
131 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
132 RtlInitUnicodeString(&Name, L"ntoskrnl.exe.");
133 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
134
135 RtlInitUnicodeString(&Expression, L"*.c.d");
136 RtlInitUnicodeString(&Name, L"a.b.c.d");
137 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
138 RtlInitUnicodeString(&Expression, L"*.?.c.d");
139 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
140 RtlInitUnicodeString(&Expression, L"*?");
141 if (!KmtIsCheckedBuild)
142 {
143 RtlInitUnicodeString(&Name, L"");
144 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
145 }
146 RtlInitUnicodeString(&Name, L"a");
147 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
148 RtlInitUnicodeString(&Name, L"aa");
149 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
150 RtlInitUnicodeString(&Name, L"aaa");
151 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
152 RtlInitUnicodeString(&Expression, L"?*?");
153 if (!KmtIsCheckedBuild)
154 {
155 RtlInitUnicodeString(&Name, L"");
156 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
157 }
158 RtlInitUnicodeString(&Name, L"a");
159 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
160 RtlInitUnicodeString(&Name, L"aa");
161 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
162 RtlInitUnicodeString(&Name, L"aaa");
163 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
164 RtlInitUnicodeString(&Name, L"aaaa");
165 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
166
167 /* Tests from #5923 */
168 RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\**");
169 RtlInitUnicodeString(&Name, L"C:\\ReactOS\\dings.bmp");
170 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
171 RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\***");
172 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
173 RtlInitUnicodeString(&Expression, L"C:\\Windows\\*a*");
174 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
175
176 RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\*.bmp");
177 RtlInitUnicodeString(&Name, L"C:\\Windows\\explorer.exe");
178 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
179 RtlInitUnicodeString(&Expression, L"*.bmp;*.dib");
180 RtlInitUnicodeString(&Name, L"winhlp32.exe");
181 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
182
183 /* Backtracking tests */
184 RtlInitUnicodeString(&Expression, L"*.*.*.*");
185 RtlInitUnicodeString(&Name, L"127.0.0.1");
186 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
187
188 RtlInitUnicodeString(&Expression, L"*?*?*?*");
189 RtlInitUnicodeString(&Name, L"1.0.0.1");
190 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
191 RtlInitUnicodeString(&Expression, L"?*?*?*?");
192 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
193 RtlInitUnicodeString(&Expression, L"?.?.?.?");
194 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
195
196 RtlInitUnicodeString(&Expression, L"*a*ab*abc");
197 RtlInitUnicodeString(&Name, L"aabaabcdadabdabc");
198 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
199
200 /* Tests for extra wildcards */
201 RtlInitUnicodeString(&Expression, L"ab<exe");
202 RtlInitUnicodeString(&Name, L"abcd.exe");
203 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
204 RtlInitUnicodeString(&Name, L"ab.exe");
205 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
206 RtlInitUnicodeString(&Name, L"abcdexe");
207 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
208 RtlInitUnicodeString(&Name, L"acd.exe");
209 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
210 RtlInitUnicodeString(&Expression, L"a.b<exe");
211 RtlInitUnicodeString(&Name, L"a.bcd.exe");
212 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
213 RtlInitUnicodeString(&Expression, L"a<b.exe");
214 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
215 RtlInitUnicodeString(&Name, L"a.b.exe");
216 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
217
218 RtlInitUnicodeString(&Expression, L"abc.exe\"");
219 RtlInitUnicodeString(&Name, L"abc.exe");
220 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
221 RtlInitUnicodeString(&Name, L"abc.exe.");
222 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
223 RtlInitUnicodeString(&Name, L"abc.exe.back");
224 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
225 RtlInitUnicodeString(&Name, L"abc.exes");
226 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
227
228 RtlInitUnicodeString(&Expression, L"a>c.exe");
229 RtlInitUnicodeString(&Name, L"abc.exe");
230 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE\n");
231 RtlInitUnicodeString(&Name, L"ac.exe");
232 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
233 RtlInitUnicodeString(&Expression, L"a>>>exe");
234 RtlInitUnicodeString(&Name, L"abc.exe");
235 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
236 RtlInitUnicodeString(&Name, L"ac.exe");
237 ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE\n");
238 }
239
240 static VOID FsRtlIsDbcsInExpressionTest()
241 {
242 ANSI_STRING Expression, Name;
243
244 if (!KmtIsCheckedBuild)
245 {
246 RtlInitAnsiString(&Expression, "*");
247 RtlInitAnsiString(&Name, "");
248 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
249 RtlInitAnsiString(&Expression, "");
250 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
251 }
252
253 RtlInitAnsiString(&Expression, "**");
254 if (!KmtIsCheckedBuild)
255 {
256 RtlInitAnsiString(&Name, "");
257 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
258 }
259 RtlInitAnsiString(&Name, "a");
260 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
261
262 RtlInitAnsiString(&Expression, "ntdll.dll");
263 RtlInitAnsiString(&Name, ".");
264 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
265 RtlInitAnsiString(&Name, "~1");
266 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
267 RtlInitAnsiString(&Name, "..");
268 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
269 RtlInitAnsiString(&Name, "ntdll.dll");
270 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
271
272 RtlInitAnsiString(&Expression, "smss.exe");
273 RtlInitAnsiString(&Name, ".");
274 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
275 RtlInitAnsiString(&Name, "~1");
276 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
277 RtlInitAnsiString(&Name, "..");
278 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
279 RtlInitAnsiString(&Name, "ntdll.dll");
280 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
281 RtlInitAnsiString(&Name, "NTDLL.dll");
282 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
283
284 RtlInitAnsiString(&Expression, "nt??krnl.???");
285 RtlInitAnsiString(&Name, "ntoskrnl.exe");
286 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
287
288 RtlInitAnsiString(&Expression, "he*o");
289 RtlInitAnsiString(&Name, "hello");
290 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
291 RtlInitAnsiString(&Name, "helo");
292 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
293 RtlInitAnsiString(&Name, "hella");
294 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
295
296 RtlInitAnsiString(&Expression, "he*");
297 RtlInitAnsiString(&Name, "hello");
298 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
299 RtlInitAnsiString(&Name, "helo");
300 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
301 RtlInitAnsiString(&Name, "hella");
302 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
303
304 RtlInitAnsiString(&Expression, "*.cpl");
305 RtlInitAnsiString(&Name, "kdcom.dll");
306 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
307 RtlInitAnsiString(&Name, "bootvid.dll");
308 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
309 RtlInitAnsiString(&Name, "ntoskrnl.exe");
310 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
311
312 RtlInitAnsiString(&Expression, ".");
313 RtlInitAnsiString(&Name, "NTDLL.DLL");
314 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
315
316 RtlInitAnsiString(&Expression, "F0_*.*");
317 RtlInitAnsiString(&Name, ".");
318 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
319 RtlInitAnsiString(&Name, "..");
320 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
321 RtlInitAnsiString(&Name, "SETUP.EXE");
322 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
323 RtlInitAnsiString(&Name, "F0_001");
324 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
325
326 RtlInitAnsiString(&Expression, "*.TTF");
327 RtlInitAnsiString(&Name, ".");
328 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
329 RtlInitAnsiString(&Name, "..");
330 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
331 RtlInitAnsiString(&Name, "SETUP.INI");
332 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
333
334 RtlInitAnsiString(&Expression, "*");
335 RtlInitAnsiString(&Name, ".");
336 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
337 RtlInitAnsiString(&Name, "..");
338 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
339 RtlInitAnsiString(&Name, "SETUP.INI");
340 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
341
342 RtlInitAnsiString(&Expression, "\"ntoskrnl.exe");
343 RtlInitAnsiString(&Name, "ntoskrnl.exe");
344 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
345 RtlInitAnsiString(&Expression, "ntoskrnl\"exe");
346 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
347 RtlInitAnsiString(&Expression, "ntoskrn\".exe");
348 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
349 RtlInitAnsiString(&Expression, "ntoskrn\"\"exe");
350 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
351 RtlInitAnsiString(&Expression, "ntoskrnl.\"exe");
352 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
353 RtlInitAnsiString(&Expression, "ntoskrnl.exe\"");
354 RtlInitAnsiString(&Name, "ntoskrnl.exe");
355 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
356 RtlInitAnsiString(&Name, "ntoskrnl.exe.");
357 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
358
359 RtlInitAnsiString(&Expression, "*.c.d");
360 RtlInitAnsiString(&Name, "a.b.c.d");
361 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
362 RtlInitAnsiString(&Expression, "*.?.c.d");
363 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
364 RtlInitAnsiString(&Expression, "*?");
365 if (!KmtIsCheckedBuild)
366 {
367 RtlInitAnsiString(&Name, "");
368 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
369 }
370 RtlInitAnsiString(&Name, "a");
371 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
372 RtlInitAnsiString(&Name, "aa");
373 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
374 RtlInitAnsiString(&Name, "aaa");
375 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
376 RtlInitAnsiString(&Expression, "?*?");
377 if (!KmtIsCheckedBuild)
378 {
379 RtlInitAnsiString(&Name, "");
380 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
381 }
382 RtlInitAnsiString(&Name, "a");
383 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
384 RtlInitAnsiString(&Name, "aa");
385 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
386 RtlInitAnsiString(&Name, "aaa");
387 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
388 RtlInitAnsiString(&Name, "aaaa");
389 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
390
391 /* Tests from #5923 */
392 RtlInitAnsiString(&Expression, "C:\\ReactOS\\**");
393 RtlInitAnsiString(&Name, "C:\\ReactOS\\dings.bmp");
394 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
395 RtlInitAnsiString(&Expression, "C:\\ReactOS\\***");
396 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
397 RtlInitAnsiString(&Expression, "C:\\Windows\\*a*");
398 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
399
400 RtlInitAnsiString(&Expression, "C:\\ReactOS\\*.bmp");
401 RtlInitAnsiString(&Name, "C:\\Windows\\explorer.exe");
402 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
403 RtlInitAnsiString(&Expression, "*.bmp;*.dib");
404 RtlInitAnsiString(&Name, "winhlp32.exe");
405 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
406
407 /* Backtracking tests */
408 RtlInitAnsiString(&Expression, "*.*.*.*");
409 RtlInitAnsiString(&Name, "127.0.0.1");
410 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
411
412 RtlInitAnsiString(&Expression, "*?*?*?*");
413 RtlInitAnsiString(&Name, "1.0.0.1");
414 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
415 RtlInitAnsiString(&Expression, "?*?*?*?");
416 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
417 RtlInitAnsiString(&Expression, "?.?.?.?");
418 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
419
420 RtlInitAnsiString(&Expression, "*a*ab*abc");
421 RtlInitAnsiString(&Name, "aabaabcdadabdabc");
422 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
423
424 /* Tests for extra wildcards */
425 RtlInitAnsiString(&Expression, "ab<exe");
426 RtlInitAnsiString(&Name, "abcd.exe");
427 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
428 RtlInitAnsiString(&Name, "ab.exe");
429 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
430 RtlInitAnsiString(&Name, "abcdexe");
431 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
432 RtlInitAnsiString(&Name, "acd.exe");
433 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
434 RtlInitAnsiString(&Expression, "a.b<exe");
435 RtlInitAnsiString(&Name, "a.bcd.exe");
436 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
437 RtlInitAnsiString(&Expression, "a<b.exe");
438 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
439 RtlInitAnsiString(&Name, "a.b.exe");
440 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
441
442 RtlInitAnsiString(&Expression, "abc.exe\"");
443 RtlInitAnsiString(&Name, "abc.exe");
444 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
445 RtlInitAnsiString(&Name, "abc.exe.");
446 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
447 RtlInitAnsiString(&Name, "abc.exe.back");
448 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
449 RtlInitAnsiString(&Name, "abc.exes");
450 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
451
452 RtlInitAnsiString(&Expression, "a>c.exe");
453 RtlInitAnsiString(&Name, "abc.exe");
454 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE\n");
455 RtlInitAnsiString(&Name, "ac.exe");
456 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
457 RtlInitAnsiString(&Expression, "a>>>exe");
458 RtlInitAnsiString(&Name, "abc.exe");
459 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
460 RtlInitAnsiString(&Name, "ac.exe");
461 ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE\n");
462 }
463
464 START_TEST(FsRtlExpression)
465 {
466 FsRtlIsNameInExpressionTest();
467 FsRtlIsDbcsInExpressionTest();
468 }