VirusCleaner.h
资源名称:antinimda.zip [点击查看]
上传用户:leon2013
上传日期:2007-01-10
资源大小:186k
文件大小:4k
源码类别:
杀毒
开发平台:
Visual C++
- // VirusCleaner.h: interface for the CVirusCleaner class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_VIRUSCLEANER_H__0C2F5D44_E182_44B9_B6EC_99169BDEE15B__INCLUDED_)
- #define AFX_VIRUSCLEANER_H__0C2F5D44_E182_44B9_B6EC_99169BDEE15B__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #pragma warning(disable : 4786)
- #include "ServiceThread.h"
- #include "../src/VirusKiller.h"
- #include <set>
- #include <map>
- class CVirusCleaner : public CServiceThread
- {
- public:
- /* scan starts immediately */
- CVirusCleaner(LPCTSTR root=NULL);
- /* stops scan (if in progress) and destroys object */
- virtual ~CVirusCleaner();
- /* overload of service thread */
- virtual bool Start();
- /* control of scanning thread */
- inline bool IsPaused() const { return m_paused; }
- void Pause() { m_paused=true; }
- void Continue() { m_paused=false; }
- /* get or set the root directory the scan begins at */
- inline const CString& Root() const { return m_root; }
- void Root(LPCTSTR root);
- /* number of files scanned */
- inline int Scanned() const { return m_scanned; }
- /* number of files skipped in scan */
- inline int Skipped() const { return m_skipped; }
- /* number of errors encountered scanning files */
- inline int Errors() const { return m_errors; }
- /* number of directories scanned */
- inline int Directories() const { return m_directories; }
- /* velocity of scanning in files / second */
- double Velocity() const;
- /* number of files cleaned */
- inline int Cleaned() const { return m_cleaned; }
- /* number of files deleted */
- inline int Deleted() const { return m_deleted; }
- /* number of files infected */
- inline int Infected() const { return m_infected; }
- /* start of scanning */
- inline CTime StartTime() const { m_starttime; }
- /* duration of scanning */
- inline CTimeSpan Duration() const { if (Running()) return CTime::GetCurrentTime()-m_starttime; else return m_stoptime-m_starttime; }
- /* last file scanned */
- inline const CString& LastFileScanned() const { return m_lastfile; }
- /* amount of data scanned in bytes */
- inline DWORD BytesScanned() const { return m_bytesscanned; }
- /* true if cleaner is to scan all files */
- inline bool ScanAll() const { return false; }
- /* notification method that a file has been scanned as infected */
- virtual void OnInfected(LPCTSTR filename, VirusKiller::SCANRESULT result) {}
- protected:
- /* starting directory of scan */
- CString m_root;
- /* pauses scanning thread */
- bool m_paused;
- /* scan statistics */
- int m_scanned,
- m_skipped,
- m_errors,
- m_infected,
- m_deleted,
- m_cleaned,
- m_directories;
- double m_velocity;
- DWORD m_bytesscanned;
- CTime m_starttime,
- m_stoptime;
- CString m_lastfile;
- /* log file */
- CFile m_logfile;
- /* scan algorithm configuration */
- DWORD m_read_block_size; /* size of each file read operation */
- /* collection of virus scanners & killers */
- VirusKiller::Set m_killers;
- /* start of worker thread : starts scanning from root */
- virtual void run();
- /* definition of a collection of virus keyed by extension */
- typedef map<CString , VirusKiller::Set > VirusGraph;
- /* collection of virus signatures when scan is active */
- VirusGraph m_killergraph;
- /* builds a graph of file extensions and associated virus killers given a list of virus killers */
- VirusGraph BuildVirusGraph(const VirusKiller::Set& kset);
- /* scans a single directory for infected files : uses recursion */
- bool scandirectory(LPCTSTR root);
- /* scans a file for a virus signature */
- bool scanfile(LPCTSTR file);
- /* cleans a specified file by a specified number of virus killers */
- VirusKiller::SCANRESULT cleanfile(LPCTSTR file, VirusKiller::Set& infections);
- };
- #endif // !defined(AFX_VIRUSCLEANER_H__0C2F5D44_E182_44B9_B6EC_99169BDEE15B__INCLUDED_)