Remove a filter from the linked list of filters. @param FilterId - The unique filter ID of the filter to delete. @return Whether or not deletion was successful. */
| 181 | @return Whether or not deletion was successful. |
| 182 | */ |
| 183 | BOOLEAN |
| 184 | StringFilters::RemoveFilter ( |
| 185 | _In_ ULONG FilterId |
| 186 | ) |
| 187 | { |
| 188 | BOOLEAN filterDeleted; |
| 189 | PFILTER_INFO_LINKED currentFilter; |
| 190 | |
| 191 | currentFilter = NULL; |
| 192 | filterDeleted = FALSE; |
| 193 | |
| 194 | if (this == NULL || this->destroying) |
| 195 | { |
| 196 | return FALSE; |
| 197 | } |
| 198 | |
| 199 | // |
| 200 | // Get an exclusive lock because we're modifying the filters linked list. |
| 201 | // |
| 202 | FltAcquirePushLockExclusive(&this->filtersLock); |
| 203 | |
| 204 | // |
| 205 | // Check if we have a single filter already. |
| 206 | // |
| 207 | if (this->filtersHead) |
| 208 | { |
| 209 | currentFilter = RCAST<PFILTER_INFO_LINKED>(this->filtersHead->ListEntry.Flink); |
| 210 | |
| 211 | while (currentFilter && currentFilter != this->filtersHead) |
| 212 | { |
| 213 | if (currentFilter->Filter.Id == FilterId) |
| 214 | { |
| 215 | break; |
| 216 | } |
| 217 | currentFilter = RCAST<PFILTER_INFO_LINKED>(currentFilter->ListEntry.Flink); |
| 218 | } |
| 219 | |
| 220 | // |
| 221 | // Remove the entry from the list. |
| 222 | // |
| 223 | if (currentFilter && currentFilter != this->filtersHead) |
| 224 | { |
| 225 | RemoveEntryList(RCAST<PLIST_ENTRY>(currentFilter)); |
| 226 | filterDeleted = TRUE; |
| 227 | this->filtersCount--; |
| 228 | // |
| 229 | // Free the filter. |
| 230 | // |
| 231 | ExFreePoolWithTag(SCAST<PVOID>(currentFilter), FILTER_INFO_TAG); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // |
| 236 | // Release the lock. |
| 237 | // |
| 238 | FltReleasePushLock(&this->filtersLock); |
| 239 | |
| 240 | if (filterDeleted) |
no test coverage detected