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

Method SaveFilters

PeaceMaker Kernel/StringFilters.cpp:371–456  ·  view source on GitHub ↗

Save the current filters to the registry for persistence. @return Whether or not the save was successful. */

Source from the content-addressed store, hash-verified

369 @return Whether or not the save was successful.
370*/
371BOOLEAN
372StringFilters::SaveFilters (
373 VOID
374 )
375{
376 PFILTER_STORE filterStore;
377 PFILTER_INFO_LINKED currentFilter;
378 ULONG i;
379 OBJECT_ATTRIBUTES driverRegistryAttributes;
380 NTSTATUS status;
381 HANDLE driverRegistryKey;
382 BOOLEAN result;
383
384 result = FALSE;
385 driverRegistryKey = NULL;
386 i = 0;
387
388 //
389 // Allocate space for the filter store.
390 //
391 filterStore = RCAST<PFILTER_STORE>(ExAllocatePoolWithTag(NonPagedPool, FILTER_STORE_SIZE(this->filtersCount), FILTER_INFO_TAG));
392 if (filterStore == NULL)
393 {
394 DBGPRINT("StringFilters!SaveFilters: Failed to allocate space for the filter store with size %i.", this->filtersCount);
395 goto Exit;
396 }
397 memset(filterStore, 0, sizeof(filterStore));
398
399 //
400 // Initialize basic members.
401 //
402 filterStore->FilterCount = this->filtersCount;
403
404 //
405 // Acquire a shared lock to iterate filters.
406 //
407 FltAcquirePushLockShared(&this->filtersLock);
408
409 //
410 // Iterate filters for a match.
411 //
412 if (this->filtersHead)
413 {
414 currentFilter = RCAST<PFILTER_INFO_LINKED>(this->filtersHead->ListEntry.Flink);
415 while (currentFilter && currentFilter != this->filtersHead)
416 {
417 memcpy_s(&filterStore->Filters[i], sizeof(FILTER_INFO), &currentFilter->Filter, sizeof(FILTER_INFO));
418 i++;
419 currentFilter = RCAST<PFILTER_INFO_LINKED>(currentFilter->ListEntry.Flink);
420 }
421 }
422
423 FltReleasePushLock(&this->filtersLock);
424
425 //
426 // Open the driver's registry key.
427 //
428 InitializeObjectAttributes(&driverRegistryAttributes, &this->driverRegistryPath, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);

Callers 2

AddFilterMethod · 0.95
RemoveFilterMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected