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

Method AddFilter

PeaceMaker Kernel/StringFilters.cpp:103–176  ·  view source on GitHub ↗

Add a filter to the linked list of filters. @param MatchString - The string to filter with. @param OperationFlag - Specifies what operations this filter should be used for. @param SaveFilters - Whether or not to save filters. @return A random identifier required for future operations with the new filter. */

Source from the content-addressed store, hash-verified

101 @return A random identifier required for future operations with the new filter.
102*/
103ULONG
104StringFilters::AddFilter (
105 _In_ WCHAR* MatchString,
106 _In_ ULONG OperationFlag,
107 _In_ BOOLEAN SaveFilters
108 )
109{
110 PFILTER_INFO_LINKED newFilter;
111 LARGE_INTEGER currentTime;
112 ULONG epochSeconds;
113
114 if (this == NULL || this->destroying)
115 {
116 return NULL;
117 }
118
119 //
120 // Get an exclusive lock because we're modifying the filters linked list.
121 //
122 FltAcquirePushLockExclusive(&this->filtersLock);
123
124 //
125 // Allocate space for the new filter.
126 //
127 newFilter = RCAST<PFILTER_INFO_LINKED>(ExAllocatePoolWithTag(NonPagedPool, sizeof(FILTER_INFO_LINKED), FILTER_INFO_TAG));
128 if (newFilter == NULL)
129 {
130 DBGPRINT("Failed to allocate space for filter info.");
131 goto Exit;
132 }
133
134 memset(RCAST<PVOID>(newFilter), 0, sizeof(FILTER_INFO_LINKED));
135
136 InsertTailList(RCAST<PLIST_ENTRY>(this->filtersHead), RCAST<PLIST_ENTRY>(newFilter));
137
138 this->filtersCount++;
139
140 //
141 // Generate a pseudo-random ID for the filter using the system time.
142 //
143 KeQuerySystemTime(&currentTime);
144 RtlTimeToSecondsSince1970(&currentTime, &epochSeconds);
145 newFilter->Filter.Id = RtlRandomEx(&epochSeconds);
146 newFilter->Filter.Type = this->filterType;
147
148 //
149 // Copy the filter string to the new filter.
150 //
151 wcsncpy_s(newFilter->Filter.MatchString, MatchString, MAX_PATH);
152
153 //
154 // Set the operation flags for this filter.
155 //
156 newFilter->Filter.Flags = OperationFlag;
157Exit:
158 //
159 // New filter has been initialized, release the lock.
160 //

Callers 4

RestoreFiltersMethod · 0.95
on_pushButton_clickedMethod · 0.45
ImportConfigFiltersMethod · 0.45
IOCTLDeviceControlMethod · 0.45

Calls 1

SaveFiltersMethod · 0.95

Tested by

no test coverage detected