ModulePage.cpp
上传用户:shouhua
上传日期:2014-12-06
资源大小:5685k
文件大小:4k
- // ModulePage.cpp : implementation file
- //
- #include "stdafx.h"
- #include "AntiEvilTools.h"
- #include "ModulePage.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CModulePage property page
- IMPLEMENT_DYNCREATE(CModulePage, CPropertyPage)
- CModulePage::CModulePage() : CPropertyPage(CModulePage::IDD)
- {
- //{{AFX_DATA_INIT(CModulePage)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- CModulePage::~CModulePage()
- {
- }
- void CModulePage::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CModulePage)
- DDX_Control(pDX, IDC_LIST_MODULE, m_ctrlModule);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CModulePage, CPropertyPage)
- //{{AFX_MSG_MAP(CModulePage)
- ON_NOTIFY(NM_RCLICK, IDC_LIST_MODULE, OnRclickProcessList)
- ON_COMMAND(ID_MENUITEM_MODULE_REFRESH,OnMenuitemModuleRefresh)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CModulePage message handlers
- BOOL CModulePage::OnInitDialog()
- {
- CDialog::OnInitDialog();
- int ret=m_ctrlModule.InsertColumn(0,"文件名",LVCFMT_RIGHT,100,0);
- m_ctrlModule.InsertColumn(1,"基址",LVCFMT_LEFT,100,1);
- m_ctrlModule.InsertColumn(2,"映像大小",LVCFMT_LEFT,100,2);
- m_ctrlModule.InsertColumn(3,"标志",LVCFMT_LEFT,100,3);
- m_ctrlModule.InsertColumn(4,"加载顺序",LVCFMT_LEFT,60,4);
- m_ctrlModule.InsertColumn(5,"文件名称",LVCFMT_LEFT,250,5);
- m_ctrlModule.SetTextBkColor(RGB(171,174,235));
- m_ctrlModule.SetExtendedStyle(LVS_EX_FULLROWSELECT);
- ListModule();
- return true;
- }
- void CModulePage::ListModule()
- {
- NTSTATUS status;
- CString str;
- PSYSTEM_MODULE_INFORMATION module = NULL;
- ULONG n = 0;
- ULONG i = 0;
- void *buf = NULL;
- m_ctrlModule.DeleteAllItems();
- if ( !( ZwQuerySystemInformation = ( ZWQUERYSYSTEMINFORMATION )GetProcAddress(GetModuleHandle("ntdll.dll"),
- "ZwQuerySystemInformation" ) ) )
- {
- return;
- }
- ZwQuerySystemInformation( SystemModuleInformation, &n, 0, &n );
- if ( NULL == ( buf = calloc( ( size_t )n, 1 ) ) )
- {
- return;
- }
- status = ZwQuerySystemInformation( SystemModuleInformation, buf, n, NULL );
- if ( !NT_SUCCESS( status ) )
- {
- return;
- }
- module = ( PSYSTEM_MODULE_INFORMATION )( ( PULONG )buf + 1 );
- n = *( ( PULONG )buf );
- for ( i = 0; i < n; i++ )
- {
- m_ctrlModule.InsertItem(i,(LPCTSTR)(module[i].ImageName + module[i].ModuleNameOffset));
- str.Format("0x%08x",module[i].Base);
- m_ctrlModule.SetItemText(i,1,str);
- str.Format("0x%08x",module[i].Size);
- m_ctrlModule.SetItemText(i,2,str);
- str.Format("0x%08x",module[i].Flags);
- m_ctrlModule.SetItemText(i,3,str);
- str.Format("%d",module[i].Index);
- m_ctrlModule.SetItemText(i,4,str);
- m_ctrlModule.SetItemText(i,5,(LPCTSTR)(module[i].ImageName));
- }
- if ( buf != NULL )
- {
- free( buf );
- buf = NULL;
- }
- return;
- }
- void CModulePage::OnMenuitemModuleRefresh()
- {
- // TODO: Add your command handler code here
- ListModule();
- }
- void CModulePage::OnRclickProcessList(NMHDR* pNMHDR, LRESULT* pResult)
- {
- POINT point;
- ::GetCursorPos(&point);
- CMenu menu;
- menu.LoadMenu(IDR_MENU_MODULE);
- menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
- *pResult = 0;
- }