MCPcopy Create free account
hub / github.com/D4stiny/PeaceMaker / MatchesFilter

Method MatchesFilter

PeaceMaker Kernel/StringFilters.cpp:254–315  ·  view source on GitHub ↗

Check if a string contains any filtered phrases. @param StrToCmp - The string to search. @param OperationFlag - Specify FILTER_FLAG_X's to match certain filters for a variety of operations. @return Whether or not there was a filter that matched. */

Source from the content-addressed store, hash-verified

252 @return Whether or not there was a filter that matched.
253*/
254BOOLEAN
255StringFilters::MatchesFilter (
256 _In_ WCHAR* StrToCmp,
257 _In_ ULONG OperationFlag
258 )
259{
260 BOOLEAN filterMatched;
261 PFILTER_INFO_LINKED currentFilter;
262 WCHAR tempStrToCmp[MAX_PATH];
263 INT i;
264
265 if (this == NULL || this->destroying)
266 {
267 return FALSE;
268 }
269
270 filterMatched = FALSE;
271
272 //
273 // Copy the string to compare so we don't modify the original string.
274 //
275 wcsncpy_s(tempStrToCmp, StrToCmp, MAX_PATH);
276
277 //
278 // Make the input string lowercase.
279 //
280 i = 0;
281 while (tempStrToCmp[i])
282 {
283 tempStrToCmp[i] = towlower(tempStrToCmp[i]);
284 i++;
285 }
286
287 //
288 // Acquire a shared lock to iterate filters.
289 //
290 FltAcquirePushLockShared(&this->filtersLock);
291
292 //
293 // Iterate filters for a match.
294 //
295 if (this->filtersHead)
296 {
297 currentFilter = RCAST<PFILTER_INFO_LINKED>(this->filtersHead->ListEntry.Flink);
298 while (currentFilter && currentFilter != this->filtersHead)
299 {
300 //
301 // Check if the string to compare contains the filter.
302 //
303 if ((currentFilter->Filter.Flags & OperationFlag) &&
304 (wcsstr(RCAST<CONST WCHAR*>(&tempStrToCmp), RCAST<CONST WCHAR*>(&currentFilter->Filter.MatchString)) != NULL))
305 {
306 filterMatched = TRUE;
307 goto Exit;
308 }
309 currentFilter = RCAST<PFILTER_INFO_LINKED>(currentFilter->ListEntry.Flink);
310 }
311 }

Callers 4

Calls

no outgoing calls

Tested by

no test coverage detected