BAV.cpp
上传用户:chaoyu
上传日期:2013-04-28
资源大小:18k
文件大小:2k
- // BAV.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "VirusDB.h"
- #include "ScanObject.h"
- #include "VirusInfo.h"
- #include "Engine.h"
- int _tmain(int argc, _TCHAR* argv[])
- {
- //////////////////////////////////////////////////////////////////////////
- //
- // 参数检查
- //
- if(argc<2)
- {
- printf("Not enough parameter!nBAV [drive:]pathn");
- return -1;
- }
- //////////////////////////////////////////////////////////////////////////
- //
- // 病毒库装载,先不从文件装载,后面版本增加。
- //
- CVirusDB cVDB;
- if( !cVDB.Load(NULL) )
- return -2;
- //////////////////////////////////////////////////////////////////////////
- //
- // 扫描
- //
- CEngine cBavEngine;
- PSCAN_RESULTS pScanResults = NULL;
- if( cBavEngine.Load(&cVDB) )
- {
- SCAN_PARAM stScanParam;
- stScanParam.nSize = sizeof(SCAN_PARAM);
- stScanParam.strPathName = argv[1]; // TODO: Add path verify here
- stScanParam.eAction = BA_SCAN;
- pScanResults = cBavEngine.Scan(&stScanParam);
- }
- //////////////////////////////////////////////////////////////////////////
- //
- // show results
- //
- if(pScanResults)
- {
- CVirusInfo cVInfo;
- printf("n---------------------- Done ----------------------n");
- printf("Total %d file(s), %d virus(es) detected.nn", pScanResults->dwObjCount, pScanResults->dwRecCount);
- printf("Total %d milliseconds, %d ms/file.n", pScanResults->dwTime, pScanResults->dwTime/pScanResults->dwObjCount);
- PSCAN_RECORD pScanRecord = pScanResults->pScanRecords;
- while( pScanRecord )
- {
- printf(""%s" infected by "%s" virus.n", pScanRecord->pScanObject->GetObjectName(), cVInfo.GetNameByID(pScanRecord->dwVirusID));
- pScanRecord = pScanRecord->pNext;
- }
- }
- //////////////////////////////////////////////////////////////////////////
- //
- // clean up
- //
- cBavEngine.Release();
- cVDB.Unload();
- return 0;
- }