| 312 | } |
| 313 | |
| 314 | std::shared_ptr<ProcessInfo> ProcessManager::Impl::BuildProcessInfo( |
| 315 | const SYSTEM_PROCESS_INFORMATION* info, bool includeThreads, ThreadMap& threadsByKey, int64_t delta, |
| 316 | std::shared_ptr<ProcessInfo> pi, bool extended) { |
| 317 | if (pi == nullptr) { |
| 318 | pi = std::make_shared<ProcessInfo>(); |
| 319 | pi->Id = HandleToULong(info->UniqueProcessId); |
| 320 | pi->SessionId = info->SessionId; |
| 321 | pi->CreateTime = info->CreateTime.QuadPart; |
| 322 | pi->Key.Created = pi->CreateTime; |
| 323 | pi->Key.Id = pi->Id; |
| 324 | pi->ParentId = HandleToULong(info->InheritedFromUniqueProcessId); |
| 325 | pi->ClearThreads(); |
| 326 | auto name = info->UniqueProcessId == 0 ? L"(Idle)" : std::wstring(info->ImageName.Buffer, info->ImageName.Length / sizeof(WCHAR)); |
| 327 | if (extended && info->UniqueProcessId > 0) { |
| 328 | auto ext = (SYSTEM_PROCESS_INFORMATION_EXTENSION*)((BYTE*)info + |
| 329 | FIELD_OFFSET(SYSTEM_PROCESS_INFORMATION, Threads) + sizeof(SYSTEM_EXTENDED_THREAD_INFORMATION) * info->NumberOfThreads); |
| 330 | pi->JobObjectId = ext->JobObjectId; |
| 331 | auto index = name.rfind(L'\\'); |
| 332 | ::memcpy(pi->UserSid, (BYTE*)info + ext->UserSidOffset, sizeof(pi->UserSid)); |
| 333 | pi->_processName = index == std::wstring::npos ? name : name.substr(index + 1); |
| 334 | pi->_nativeImagePath = name; |
| 335 | if (ext->PackageFullNameOffset > 0) { |
| 336 | pi->_packageFullName = (const wchar_t*)((BYTE*)ext + ext->PackageFullNameOffset); |
| 337 | } |
| 338 | } |
| 339 | else { |
| 340 | pi->_processName = name; |
| 341 | pi->JobObjectId = 0; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | pi->ThreadCount = info->NumberOfThreads; |
| 346 | pi->BasePriority = info->BasePriority; |
| 347 | pi->UserTime = info->UserTime.QuadPart; |
| 348 | pi->KernelTime = info->KernelTime.QuadPart; |
| 349 | pi->HandleCount = info->HandleCount; |
| 350 | pi->PageFaultCount = info->PageFaultCount; |
| 351 | pi->PeakThreads = info->NumberOfThreadsHighWatermark; |
| 352 | pi->PeakVirtualSize = info->PeakVirtualSize; |
| 353 | pi->VirtualSize = info->VirtualSize; |
| 354 | pi->WorkingSetSize = info->WorkingSetSize; |
| 355 | pi->PeakWorkingSetSize = info->PeakWorkingSetSize; |
| 356 | pi->PagefileUsage = info->PagefileUsage; |
| 357 | pi->OtherOperationCount = info->OtherOperationCount.QuadPart; |
| 358 | pi->ReadOperationCount = info->ReadOperationCount.QuadPart; |
| 359 | pi->WriteOperationCount = info->WriteOperationCount.QuadPart; |
| 360 | pi->HardFaultCount = info->HardFaultCount; |
| 361 | pi->OtherTransferCount = info->OtherTransferCount.QuadPart; |
| 362 | pi->ReadTransferCount = info->ReadTransferCount.QuadPart; |
| 363 | pi->WriteTransferCount = info->WriteTransferCount.QuadPart; |
| 364 | pi->PeakPagefileUsage = info->PeakPagefileUsage; |
| 365 | pi->CycleTime = info->CycleTime; |
| 366 | pi->NonPagedPoolUsage = info->QuotaNonPagedPoolUsage; |
| 367 | pi->PagedPoolUsage = info->QuotaPagedPoolUsage; |
| 368 | pi->PeakNonPagedPoolUsage = info->QuotaPeakNonPagedPoolUsage; |
| 369 | pi->PeakPagedPoolUsage = info->QuotaPeakPagedPoolUsage; |
| 370 | pi->PrivatePageCount = info->PrivatePageCount; |
| 371 |
nothing calls this directly
no test coverage detected