ProcessModule.cpp
上传用户:shouhua
上传日期:2014-12-06
资源大小:5685k
文件大小:2k
- // ProcessModule.cpp : implementation file
- //
- #include "stdafx.h"
- #include "AntiEvilTools.h"
- #include "ProcessModule.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CProcessModule dialog
- CProcessModule::CProcessModule(CWnd* pParent /*=NULL*/)
- : CDialog(CProcessModule::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CProcessModule)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CProcessModule::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CProcessModule)
- DDX_Control(pDX, IDC_LIST_PROCESS_MODULE, m_listModule);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CProcessModule, CDialog)
- //{{AFX_MSG_MAP(CProcessModule)
- // NOTE: the ClassWizard will add message map macros here
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CProcessModule message handlers
- BOOL CProcessModule::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- pid = -1;
- m_listModule.SetExtendedStyle(LVS_EX_FULLROWSELECT);
- m_listModule.InsertColumn(0, "模块", LVCFMT_LEFT, 80);
- m_listModule.InsertColumn(1, "路径", LVCFMT_LEFT, 320);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CProcessModule::SetPID(DWORD tPid)
- {
- pid = tPid;
- }
- void CProcessModule::Refresh()
- {
- // TODO: Add extra validation here
- DWORD pid = GetPid();
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
- if((int)hSnap == -1)
- {
- MessageBox("Create Failed!");
- return;
- }
- MODULEENTRY32 info;
- info.dwSize = sizeof(info);
- m_listModule.DeleteAllItems();
- if(!Module32First(hSnap, &info))
- {
- MessageBox("Module32First Failed");
- return;
- }
- int index = 0;
- do
- {
- m_listModule.InsertItem(index, info.szModule);
- m_listModule.SetItemText(index, 1, info.szExePath);
- index++;
- }while(Module32Next(hSnap, &info));
- CloseHandle(hSnap);
- }
- DWORD CProcessModule::GetPid()
- {
- return pid;
- }