25{
27 USHORT BackTrackingBuffer[16], OldBackTrackingBuffer[16] = {0};
28 PUSHORT BackTrackingSwap, BackTracking = BackTrackingBuffer, OldBackTracking = OldBackTrackingBuffer;
32 USHORT ExpressionPosition, NamePosition = 0, MatchingChars = 1;
38
39
41 {
42
45 else
47 }
48
49
51 {
54 }
55
57
58
60 {
61
63
64
67
68
69
71 {
72
75
76
78
79
81 {
82
84 Name->Buffer + NamePosition,
86 }
87 else
88 {
89
90 for (ExpressionPosition = 0; ExpressionPosition < (IntExpression.
Length /
sizeof(
WCHAR)); ExpressionPosition++)
91 {
92
94
95
97 IntExpression.
Buffer[ExpressionPosition])
98 {
100 }
101 }
102
103
105 }
106 }
107 }
108
109
110 for (; !EndOfName; MatchingChars = BackTrackingPosition, NamePosition++)
111 {
112
113 OldBackTrackingPosition = BackTrackingPosition = 0;
114
115 if (NamePosition >=
Name->Length /
sizeof(
WCHAR))
116 {
118 if (MatchingChars && (OldBackTracking[MatchingChars - 1] ==
Expression->Length * 2))
119 break;
120 }
121
122 while (MatchingChars > OldBackTrackingPosition)
123 {
124 ExpressionPosition = (OldBackTracking[OldBackTrackingPosition++] + 1) / 2;
125
126
128 {
129 ExpressionPosition +=
Offset;
130
132 {
133 BackTracking[BackTrackingPosition++] =
Expression->Length * 2;
134 break;
135 }
136
137
138 if (BackTrackingPosition > BackTrackingBufferSize - 3)
139 {
140
142 ASSERT((BackTracking == BackTrackingBuffer) || (BackTracking == OldBackTrackingBuffer));
143 ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking == OldBackTrackingBuffer));
144
145
147
148
150 2 * BackTrackingBufferSize *
sizeof(
USHORT),
151 'nrSF');
152 if (AllocatedBuffer ==
NULL)
153 {
154 DPRINT1(
"Failed to allocate BackTracking buffer. BackTrackingBufferSize = =x%lx\n",
155 BackTrackingBufferSize);
158 }
159
160
162 BackTracking,
164
165
166 BackTracking = AllocatedBuffer;
167
168
170 OldBackTracking,
172
173
174 OldBackTracking = &BackTracking[BackTrackingBufferSize];
175 }
176
177
179 Name->Buffer[NamePosition]);
180 if (
Expression->Buffer[ExpressionPosition /
sizeof(
WCHAR)] == CompareChar && !EndOfName)
181 {
182 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
sizeof(
WCHAR)) * 2;
183 }
184
185 else if (
Expression->Buffer[ExpressionPosition /
sizeof(
WCHAR)] ==
L'?' && !EndOfName)
186 {
187 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
sizeof(
WCHAR)) * 2;
188 }
189
191 {
192 BackTracking[BackTrackingPosition++] = ExpressionPosition * 2;
193 BackTracking[BackTrackingPosition++] = (ExpressionPosition * 2) + 3;
194 continue;
195 }
196
198 {
199
201 if (!EndOfName &&
Name->Buffer[NamePosition] ==
'.')
202 {
204 {
206 {
208 break;
209 }
210 }
211 }
212
213 if (EndOfName ||
Name->Buffer[NamePosition] !=
L'.' || !DontSkipDot)
214 BackTracking[BackTrackingPosition++] = ExpressionPosition * 2;
215
216 BackTracking[BackTrackingPosition++] = (ExpressionPosition * 2) + 3;
217 continue;
218 }
219
221 {
222 if (EndOfName) continue;
223
224 if (
Name->Buffer[NamePosition] ==
L'.')
225 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
sizeof(
WCHAR)) * 2;
226 }
227
229 {
230 if (EndOfName ||
Name->Buffer[NamePosition] ==
L'.')
continue;
231
232 BackTracking[BackTrackingPosition++] = (ExpressionPosition +
sizeof(
WCHAR)) * 2;
233 }
234
235
236 break;
237 }
238
240 {
241 while (MatchingChars > OldBackTrackingPosition &&
242 BackTracking[
Position] > OldBackTracking[OldBackTrackingPosition])
243 {
244 ++OldBackTrackingPosition;
245 }
246 }
247 }
248
249
250 BackTrackingSwap = BackTracking;
251 BackTracking = OldBackTracking;
252 OldBackTracking = BackTrackingSwap;
253 }
254
255
256 Result = MatchingChars > 0 && (OldBackTracking[MatchingChars - 1] == (
Expression->Length * 2));
257
259
260
261 if (AllocatedBuffer !=
NULL)
262 {
264 }
265
267}
#define ExAllocatePoolWithTag(hernya, size, tag)
#define ExFreePoolWithTag(_P, _T)
_In_ ULONG _In_ ULONG Offset
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
#define RtlCopyMemory(Destination, Source, Length)
#define POOL_RAISE_IF_ALLOCATION_FAILURE