BOOL CMemoryHackerDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here DWORD dwStyle = m_cListCtrl.GetExtendedStyle(); dwStyle |= LVS_EX_FULLROWSELECT; // Setup the list control m_cListCtrl.SetExtendedStyle(dwStyle); // Create the columns CRect rect; m_cListCtrl.GetClientRect(&rect); int size = rect.Width()/3-16; m_cListCtrl.InsertColumn(0, _T("ProcessName"), LVCFMT_LEFT, size*2); m_cListCtrl.InsertColumn(1, _T("pid"), LVCFMT_LEFT, size); RefreshProcessList(); return TRUE; // return TRUE unless you set the focus to a control }
LRESULT CSelProcDlg::OnInitDialog( UINT, WPARAM, LPARAM, BOOL& ) { m_hProc = NULL; DlgResize_Init( false ); m_lst.SubclassWindow( GetDlgItem( IDC_PROCESS_LIST ) ); DWORD dwStyle = LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES; dwStyle |= LVS_EX_HEADERDRAGDROP; m_lst.SetExtendedListViewStyle( dwStyle ); TCHAR szHeaders[128]; AtlLoadString( IDS_PROCESS_LIST_HEADER, szHeaders, _countof(szHeaders) ); RECT rect; m_lst.GetWindowRect( &rect ); int nWidth = rect.right - rect.left; int nIndex = 0; LPCTSTR sz = _tcstok( szHeaders, _T("\n") ); while( sz != NULL ) { int w = _ttoi(_tcstok( NULL, _T("\n") )) * nWidth / 100; m_lst.InsertColumn( nIndex++, sz, LVCFMT_LEFT, w, 0 ); sz = _tcstok( NULL, _T("\n") ); } m_lst.SetColumnSortType( 0, LVCOLSORT_TEXTNOCASE ); m_lst.SetColumnSortType( 1, LVCOLSORT_LONG ); m_lst.SetColumnSortType( 2, LVCOLSORT_TEXTNOCASE ); m_lst.SetSortColumn( 0 ); RefreshProcessList(); return TRUE; }
BOOL ProcessMonitor::GetProcessList(list<ProcessEntry> &pRetList) { pRetList.clear(); RefreshProcessList(); WAIT_AND_SIGNAL(hProcessMutex); pRetList = pList; UNLOCK(hProcessMutex); return TRUE; }
BOOL SkimbadPList::OnInitDialog() { CDialog::OnInitDialog(); szPName.clear(); //initialize the list control m_SkimbadPList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE); m_SkimbadPList.InsertColumn(0, L"PID", LVCFMT_LEFT, 90); m_SkimbadPList.InsertColumn(1, L"Name", LVCFMT_LEFT, 180); RefreshProcessList(); return TRUE; }
BOOL CMemoryHackerDlg::OnCommand(WPARAM wParam, LPARAM lParam) { // TODO: Add your specialized code here and/or call the base class if (HIWORD(wParam) == BN_CLICKED) // if button clicked { switch(LOWORD(wParam)) // Retrieves the low-order word from the specified value. { case ID_PROCESS_MEMORYHACK: { if (!IsWindow(memoryhackdlg.m_hWnd)||!memoryhackdlg.IsWindowVisible()) { MemoryHack m_pmhdialog = new MemoryHack(this); memoryhackdlg = m_pmhdialog; POSITION pos = m_cListCtrl.GetFirstSelectedItemPosition(); int position = m_cListCtrl.GetNextSelectedItem(pos); memoryhackdlg.processname = m_cListCtrl.GetItemText(position, 0); // item number, subitem number CString pid_str = m_cListCtrl.GetItemText(position, 1); // 1 since we need process id memoryhackdlg.processid = GenericPurposeMethods::StringToNumber(pid_str.GetBuffer(pid_str.GetLength())); //testdlg.DoModal(); // not modal one! BOOL ret = memoryhackdlg.Create(IDD_MEMORYHACK_DIALOG,this); if (ret) // If create not failed. memoryhackdlg.ShowWindow(SW_SHOWNORMAL); } break; } case ID_PROCESS_REFRESH: RefreshProcessList(); break; } } return CDialog::OnCommand(wParam, lParam); }
UINT ProcessMonitor::GetPidW(const WCHAR *pProcName) { list<ProcessEntry>::iterator iter; if (RefreshProcessList() == FALSE) return FALSE; WAIT_AND_SIGNAL(hProcessMutex); if (pList.size() == 0 || pProcName == NULL || wcslen(pProcName) == 0) { UNLOCK(hProcessMutex); return 0; } for (iter = pList.begin(); iter != pList.end(); ++iter) { if (CmpWildW(pProcName, (*iter).pe.szExeFile) != 0) { UNLOCK(hProcessMutex); return (*iter).pe.th32ProcessID; } } UNLOCK(hProcessMutex); return 0; }
// Returns a string list of all processes since the last refresh CInjector::ProcessList_t CInjector::GetProcessList() { RefreshProcessList(); return processNames; }
LRESULT CSelProcDlg::OnRefresh( WORD, WORD, HWND, BOOL& ) { RefreshProcessList(); return 0; }