| 60 | END_MESSAGE_MAP( ) |
| 61 | |
| 62 | void CDialogProcSelect::ListRunningProcs( ) |
| 63 | { |
| 64 | if (m_bLoadingProcesses) |
| 65 | return; |
| 66 | |
| 67 | m_ProcessIcons.DeleteImageList( ); |
| 68 | m_ProcessIcons.Create( 15, 15, ILC_COLOR32, 1, 1 ); |
| 69 | m_ProcessIcons.SetBkColor( RGB( 255, 255, 255 ) ); |
| 70 | m_ProcessList.SetImageList( &m_ProcessIcons, LVSIL_SMALL ); |
| 71 | m_ProcessList.DeleteAllItems( ); |
| 72 | m_ProcessInfos.clear( ); |
| 73 | |
| 74 | PSYSTEM_PROCESS_INFORMATION ProcessInfo = NULL; |
| 75 | std::unique_ptr<uint8_t[]> BufferArray; |
| 76 | ULONG BufferSize = 0; |
| 77 | NTSTATUS status; |
| 78 | |
| 79 | status = ntdll::NtQuerySystemInformation( SystemProcessInformation, NULL, NULL, &BufferSize ); |
| 80 | if (status != STATUS_SUCCESS && status != STATUS_INFO_LENGTH_MISMATCH) |
| 81 | { |
| 82 | #ifdef _DEBUG |
| 83 | PrintOut( _T( "[CDialogProcSelect::RefreshRunningProcesses] Failed to get size for system process list from ProcessBasicInformation" ) ); |
| 84 | #endif |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | BufferArray = std::make_unique<uint8_t[]>( BufferSize + 1 ); |
| 89 | |
| 90 | if (NT_SUCCESS( ntdll::NtQuerySystemInformation( SystemProcessInformation, (PVOID)BufferArray.get( ), BufferSize, &BufferSize ) )) |
| 91 | { |
| 92 | int CurrentProcessIndex = 0; |
| 93 | |
| 94 | m_bLoadingProcesses = TRUE; |
| 95 | |
| 96 | ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)BufferArray.get( ); |
| 97 | while (ProcessInfo) |
| 98 | { |
| 99 | if (ProcessInfo->ImageName.Buffer && ProcessInfo->ImageName.Length > 0) |
| 100 | { |
| 101 | if (m_FilterCheck.GetCheck( ) != BST_CHECKED || |
| 102 | CommonProcesses.end( ) == std::find_if( CommonProcesses.begin( ), CommonProcesses.end( ), |
| 103 | [ProcessInfo] ( const wchar_t* proc ) { return _wcsnicmp( proc, ProcessInfo->ImageName.Buffer, ProcessInfo->ImageName.MaximumLength / sizeof(wchar_t) ) == 0; } ) |
| 104 | ) |
| 105 | { |
| 106 | HANDLE hProcess = ReClassOpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, (DWORD)ProcessInfo->UniqueProcessId ); |
| 107 | #ifdef _WIN64 |
| 108 | if (hProcess && Utils::GetProcessPlatform( hProcess ) == Utils::ProcessPlatformX64) |
| 109 | #else |
| 110 | if (hProcess && Utils::GetProcessPlatform( hProcess ) == Utils::ProcessPlatformX86) |
| 111 | #endif |
| 112 | { |
| 113 | ProcessInfoStack Info = { 0 }; |
| 114 | TCHAR tcsProcessId[16] = { 0 }; |
| 115 | TCHAR tcsProcessPath[MAX_PATH] = { 0 }; |
| 116 | SHFILEINFO FileInfo = { 0 }; |
| 117 | LVITEM lvi = { 0 }; |
| 118 | int pos; |
| 119 |
nothing calls this directly
no test coverage detected