| 245 | } |
| 246 | |
| 247 | void CDialogProcSelect::OnAttachButton( ) |
| 248 | { |
| 249 | int SelectedIndex = m_ProcessList.GetSelectionMark( ); |
| 250 | if (SelectedIndex != -1) |
| 251 | { |
| 252 | HANDLE ProcessHandle; |
| 253 | DWORD SelectedProcessId; |
| 254 | TCHAR SelectedProcessIdText[64]; |
| 255 | |
| 256 | m_ProcessList.GetItemText( SelectedIndex, COLUMN_PROCESSID, SelectedProcessIdText, sizeof( SelectedProcessIdText ) ); |
| 257 | SelectedProcessId = _tcstoul( SelectedProcessIdText, NULL, 10 ); |
| 258 | |
| 259 | auto FoundProcessInfo = std::find_if( m_ProcessInfos.begin( ), m_ProcessInfos.end( ), |
| 260 | [SelectedProcessId] ( const ProcessInfoStack& proc ) -> bool { return proc.dwProcessId == SelectedProcessId; } ); |
| 261 | |
| 262 | if (FoundProcessInfo != m_ProcessInfos.end( )) |
| 263 | { |
| 264 | ProcessHandle = ReClassOpenProcess( PROCESS_ALL_ACCESS, FALSE, FoundProcessInfo->dwProcessId ); |
| 265 | if (ProcessHandle == NULL || GetLastError( ) != ERROR_SUCCESS) |
| 266 | { |
| 267 | CString MessageText; |
| 268 | MessageText.Format( _T( "Failed to attach to process \"%s\"!" ), FoundProcessInfo->strProcessName.GetString( ) ); |
| 269 | MessageBox( MessageText, g_ReClassApp.m_pszAppName, MB_OK | MB_ICONERROR ); |
| 270 | } |
| 271 | else |
| 272 | { |
| 273 | if (g_hProcess != NULL) // Stop leaking handles! |
| 274 | CloseHandle( g_hProcess ); |
| 275 | |
| 276 | g_hProcess = ProcessHandle; |
| 277 | g_ProcessID = FoundProcessInfo->dwProcessId; |
| 278 | g_ProcessName = FoundProcessInfo->strProcessName; |
| 279 | |
| 280 | UpdateMemoryMap( ); |
| 281 | |
| 282 | if (g_bSymbolResolution && m_LoadAllSymbols.GetCheck( ) == BST_CHECKED) |
| 283 | { |
| 284 | OnClose( ); |
| 285 | |
| 286 | MSG Msg; |
| 287 | CStatusBar* StatusBar = g_ReClassApp.GetStatusBar( ); |
| 288 | |
| 289 | CProgressBar ProgressBar( _T( "Progress" ), 100, 100, TRUE, 0, StatusBar ); |
| 290 | ProgressBar.SetStep( 1 ); |
| 291 | ProgressBar.SetText( _T( "Symbols loading: " ) ); |
| 292 | |
| 293 | for (size_t i = 0; i < g_MemMapModules.size( ); i++) |
| 294 | { |
| 295 | TCHAR ProgressText[256]; |
| 296 | MemMapInfo *CurrentModule = &g_MemMapModules[i]; |
| 297 | |
| 298 | ProgressBar.SetRange32( 0, (int)g_MemMapModules.size( ) ); |
| 299 | |
| 300 | _stprintf_s( ProgressText, _T( "[%d/%d] %s" ), (UINT)i + 1, (UINT)g_MemMapModules.size( ), CurrentModule->Name.GetString( ) ); |
| 301 | StatusBar->SetPaneText( 1, ProgressText ); |
| 302 | |
| 303 | //MemMapInfo* pCurrentModule = new MemMapInfo( CurrentModule ); |
| 304 | //Utils::NtCreateThread( LoadModuleSymbolsThread, pCurrentModule, 0 ); |
nothing calls this directly
no test coverage detected