www.pudn.com > BAV.v2.rar > BAV.cpp, change:2005-07-09,size:1955b
// 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:]path\n");
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.\n\n", 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;
}