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. */
| 252 | @return Whether or not there was a filter that matched. |
| 253 | */ |
| 254 | BOOLEAN |
| 255 | StringFilters::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*>(¤tFilter->Filter.MatchString)) != NULL)) |
| 305 | { |
| 306 | filterMatched = TRUE; |
| 307 | goto Exit; |
| 308 | } |
| 309 | currentFilter = RCAST<PFILTER_INFO_LINKED>(currentFilter->ListEntry.Flink); |
| 310 | } |
| 311 | } |
no outgoing calls
no test coverage detected