www.pudn.com > antinimda.zip > memoryscanDlg.cpp
// memoryscanDlg.cpp : implementation file
//
#include "stdafx.h"
#include "memoryscan.h"
#include "memoryscanDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMemoryscanDlg dialog
CMemoryscanDlg::CMemoryscanDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMemoryscanDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMemoryscanDlg)
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMemoryscanDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMemoryscanDlg)
DDX_Control(pDX, IDOK, btnOk);
DDX_Control(pDX, IDC_MEMSCANPERCENT, memscanpercent);
DDX_Control(pDX, IDC_SCANPROGRESS, scanprogress);
DDX_Control(pDX, IDC_SCANNED, scanned);
DDX_Control(pDX, IDC_PROCESSPROGRESS, processprogress);
DDX_Control(pDX, IDC_PROCESSNAME, processname);
DDX_Control(pDX, IDC_MEMSCANNED, memscanned);
DDX_Control(pDX, IDC_INFECTIONS, infections);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMemoryscanDlg, CDialog)
//{{AFX_MSG_MAP(CMemoryscanDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMemoryscanDlg message handlers
BOOL CMemoryscanDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
processprogress.SetRange(0,100);
Start();
SetTimer(1,200,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMemoryscanDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CMemoryscanDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMemoryscanDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent==1) {
CString s;
int brk;
/* process name */
s=CurrentProcessName();
if((brk=s.ReverseFind('\\'))!=-1) s=s.Mid(brk+1);
s.MakeLower();
processname.SetWindowText(" "+s);
/* scanned */
s.Format("%d of %d ", Scanned(), processes.size());
scanned.SetWindowText(s);
/* infections */
s.Format("%d ", Infections());
infections.SetWindowText(s);
/* memory scanned */
s.Format("%d MB ", CurrentProcessPosition()/1024/1024 );
memscanned.SetWindowText(s);
if (CurrentProcessSize()) {
/* process memory scan progress */
s.Format("%6.1f%% ", (double)CurrentProcessPosition()*100/CurrentProcessSize() );
memscanpercent.SetWindowText(s);
/* update progress ctrl */
processprogress.SetPos( CurrentProcessPosition()*100/CurrentProcessSize() );
}
/* global scan progress */
scanprogress.SetRange(0,processes.size());
scanprogress.SetPos( Scanned() );
if (!Running()) {
KillTimer(1);
processname.SetWindowText(" Scan complete!");
btnOk.SetWindowText("Close");
memscanned.SetWindowText("");
memscanpercent.SetWindowText("");
processprogress.SetPos( 0 );
scanprogress.SetPos( 100 );
}
}
CDialog::OnTimer(nIDEvent);
}
void CMemoryscanDlg::OnOK()
{
/* stop scanning memory */
if (Running()) Stop();
CDialog::OnOK();
}