162{
164 USHORT BackTrackingBuffer[16], OldBackTrackingBuffer[16] = {0};
165 PUSHORT BackTrackingSwap, BackTracking = BackTrackingBuffer, OldBackTracking = OldBackTrackingBuffer;
168 USHORT ExpressionPosition, NamePosition = 0, MatchingChars = 1;
169 USHORT NameChar = 0, ExpressionChar;
174
178
179
181 {
182
185 else
187 }
188
189
191 {
194 }
195
196
197
198
200 {
201
203
204
207
208
209
211 {
212
215
216
217 NamePosition = (
Name->Length - IntExpression.
Length) /
sizeof(
CHAR);
218
219
221 {
222 MatchingChars = 0;
223
224 while (MatchingChars < NamePosition)
225 {
226
228 }
229
230
231 if (MatchingChars > NamePosition)
233 }
234
235
237 (
Name->Buffer + NamePosition),
239 }
240 }
241
242
243 for (; !EndOfName; MatchingChars = BackTrackingPosition)
244 {
245
246 OldBackTrackingPosition = BackTrackingPosition = 0;
247
248 if (NamePosition >=
Name->Length)
249 {
251 if (MatchingChars && OldBackTracking[MatchingChars - 1] ==
Expression->Length * 2)
252 break;
253 }
254 else
255 {
256
258 {
259 NameChar =
Name->Buffer[NamePosition] +
260 (0x100 *
Name->Buffer[NamePosition + 1]);
261 NamePosition +=
sizeof(
USHORT);
262 }
263 else
264 {
265 NameChar =
Name->Buffer[NamePosition];
266 NamePosition +=
sizeof(
UCHAR);
267 }
268 }
269
270 while (MatchingChars > OldBackTrackingPosition)
271 {
272 ExpressionPosition = (OldBackTracking[OldBackTrackingPosition++] + 1) / 2;
273
274
276 {
277 ExpressionPosition +=
Offset;
278
280 {
281 BackTracking[BackTrackingPosition++] =
Expression->Length * 2;
282 break;
283 }
284
285
286 if (BackTrackingPosition > BackTrackingBufferSize - 3)
287 {
288
290 ASSERT((BackTracking == BackTrackingBuffer) || (BackTracking == OldBackTrackingBuffer));
291 ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking == OldBackTrackingBuffer));
292
293
294 BackTrackingBufferSize =
Expression->Length * 2 + 1;
295
296
298 2 * BackTrackingBufferSize *
sizeof(
USHORT),
299 'nrSF');
300 if (AllocatedBuffer ==
NULL)
301 {
302 DPRINT1(
"Failed to allocate BackTracking buffer. BackTrackingBufferSize = =x%lx\n",
303 BackTrackingBufferSize);
306 }
307
308
310 BackTracking,
312
313
314 BackTracking = AllocatedBuffer;
315
316
318 OldBackTracking,
320
321
322 OldBackTracking = &BackTracking[BackTrackingBufferSize];
323 }
324
325
327 {
328 ExpressionChar =
Expression->Buffer[ExpressionPosition] +
329 (0x100 *
Expression->Buffer[ExpressionPosition + 1]);
331 }
332 else
333 {
334 ExpressionChar =
Expression->Buffer[ExpressionPosition];
336 }
337
338
339 if (ExpressionChar == NameChar && !EndOfName)
340 {
341 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
Offset) * 2;
342 }
343
344 else if (ExpressionChar == '?' && !EndOfName)
345 {
346 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
Offset) * 2;
347 }
348
349 else if (ExpressionChar == '*')
350 {
351 BackTracking[BackTrackingPosition++] = ExpressionPosition * 2;
352 BackTracking[BackTrackingPosition++] = (ExpressionPosition * 2) + 1;
353 continue;
354 }
355
357 {
358
360 if (!EndOfName && NameChar == '.')
361 {
363 {
364
366 {
368 {
370 break;
371 }
372
374 }
375 else
376 {
378 }
379 }
380 }
381
382 if (EndOfName || NameChar != '.' || !DontSkipDot)
383 BackTracking[BackTrackingPosition++] = ExpressionPosition * 2;
384
385 BackTracking[BackTrackingPosition++] = (ExpressionPosition * 2) + 1;
386 continue;
387 }
388
390 {
391 if (EndOfName) continue;
392
393 if (NameChar == '.')
394 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
Offset) * 2;
395 }
396
398 {
399 if (EndOfName || NameChar == '.') continue;
400
401 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
Offset) * 2;
402 }
403
404
405 break;
406 }
407
409 {
410 while (MatchingChars > OldBackTrackingPosition &&
411 BackTracking[
Position] > OldBackTracking[OldBackTrackingPosition])
412 {
413 ++OldBackTrackingPosition;
414 }
415 }
416 }
417
418
419 BackTrackingSwap = BackTracking;
420 BackTracking = OldBackTracking;
421 OldBackTracking = BackTrackingSwap;
422 }
423
424
425 Result = MatchingChars && (OldBackTracking[MatchingChars - 1] ==
Expression->Length * 2);
426
428
429
430 if (AllocatedBuffer !=
NULL)
431 {
433 }
434
436}
BOOLEAN NTAPI FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define RtlEqualMemory(dst, src, len)
#define ExFreePoolWithTag(_P, _T)
BOOLEAN NlsMbOemCodePageTag
_In_ ULONG _In_ ULONG Offset
#define RtlCopyMemory(Destination, Source, Length)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
#define POOL_RAISE_IF_ALLOCATION_FAILURE