| 258 | |
| 259 | |
| 260 | void COperationTable::Refresh() { |
| 261 | m_Table.data.n = 0; |
| 262 | m_Table.data.info.clear(); |
| 263 | |
| 264 | ULONG offset = SymbolHelper::GetFltmgrStructMemberOffset("_FLT_FILTER", "Operations"); |
| 265 | |
| 266 | auto len = (ULONG)m_Name.length(); |
| 267 | DWORD size = len * sizeof(WCHAR) + sizeof(MiniFilterData); |
| 268 | |
| 269 | auto pData = std::make_unique<BYTE[]>(size); |
| 270 | if (!pData) |
| 271 | return; |
| 272 | |
| 273 | auto data = reinterpret_cast<MiniFilterData*>(pData.get()); |
| 274 | data->OperationsOffset = offset; |
| 275 | data->Length = len; |
| 276 | ::wcscpy_s(data->Name, len + 1, m_Name.c_str()); |
| 277 | |
| 278 | DWORD dataSize = size; |
| 279 | |
| 280 | int maxCount = IRP_MJ_MAXIMUM_FUNCTION + FLT_INTERNAL_OPERATION_COUNT; |
| 281 | size = maxCount * sizeof(OperationInfo); |
| 282 | wil::unique_virtualalloc_ptr<> buffer(::VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE)); |
| 283 | OperationInfo* p = (OperationInfo*)buffer.get(); |
| 284 | |
| 285 | if (p != nullptr) { |
| 286 | memset(p, 0, size); |
| 287 | DriverHelper::EnumMiniFilterOperations(data, dataSize,p, size); |
| 288 | for (int i = 0; (p->MajorFunction != IRP_MJ_OPERATION_END&& i<maxCount); i++) { |
| 289 | OperationCallbackInfo info; |
| 290 | info.Module = Helpers::GetKernelModuleByAddress((ULONG_PTR)p->PostOperation); |
| 291 | std::wstring path = Helpers::StringToWstring(info.Module); |
| 292 | info.Company = FileVersionInfoHelpers::GetCompanyName(path); |
| 293 | info.Routine = p->PostOperation; |
| 294 | info.FilterHandle = p->FilterHandle; |
| 295 | info.Flags = p->Flags; |
| 296 | info.MajorCode = p->MajorFunction; |
| 297 | info.Type = FilterType::PostOperation; |
| 298 | m_Table.data.info.push_back(info); |
| 299 | |
| 300 | info.Module = Helpers::GetKernelModuleByAddress((ULONG_PTR)p->PreOperation); |
| 301 | path = Helpers::StringToWstring(info.Module); |
| 302 | info.Company = FileVersionInfoHelpers::GetCompanyName(path); |
| 303 | info.Routine = p->PreOperation; |
| 304 | info.FilterHandle = p->FilterHandle; |
| 305 | info.Flags = p->Flags; |
| 306 | info.MajorCode = p->MajorFunction; |
| 307 | info.Type = FilterType::PreOperation; |
| 308 | m_Table.data.info.push_back(info); |
| 309 | p++; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | m_Table.data.n = m_Table.data.info.size(); |
| 315 | } |
| 316 | |
| 317 | std::wstring COperationTable::GetSingleOperationInfo(OperationCallbackInfo& info) { |
nothing calls this directly
no test coverage detected