ClamWin是一套功能非常优秀的免费防毒软件,它的体积非常的小,不会占用太多计算机资源,不像其它防毒软件安装之后会拖累整台计算机的速度。而且除了强大的文件与电子邮件防护能力以外,它还拥有排程扫描、在线更新病毒码、及时侦测等功能,和市面上知名防毒软件比起来一点也不逊色!杀毒软件是电脑的必备软件,否则总是要徘徊在被毒感染和消灭病毒的生活边缘。那么今天就要大家推荐一款袖珍型免费杀毒软件而且功能强悍的杀毒软件——ClamWin,有了它你就不用为反复重新格式化重装系统而犯愁了。
项目如图:
程序效果如图:
profiler测试代码:
int wmain(int argc, wchar_t *argv[]) { //模拟参数 argc = 2; argv[0] = L"clamwind"; argv[1] = L"18"; if (argc > 3) { wprintf(L"Usage %s: [cycles]\n", argv[0]); return -1; } if (argc == 2) { cycles = _wtoi(argv[1]); if ((cycles < 2) || (cycles > 20)) { wprintf(L"Invalid number of cycles\n"); return -1; } } SetConsoleCtrlHandler((PHANDLER_ROUTINE) console_ctrl_handler, TRUE); atexit(stop_console_handler); #if !defined(PROFILE_ADLER32) && !defined(PROFILE_PANAMA) int ret = -1; unsigned int no = 0; wprintf(L"Loading Clamav DB...\n"); #ifndef DAILY_ONLY ret = cl_loaddb("main.cvd", &m_root, &no); if (ret || !m_root || !no) { wprintf(L"Error loading main db...\n"); return 1; } #endif if ((ret = cl_loaddb("daily.cvd", &m_root, &no))) { wprintf(L"Error loading daily.cvd...\n"); return -1; } wprintf(L"Known viruses: %d\n", no); /* build engine */ if((ret = cl_build(m_root))) { wprintf(L"Error initializing database: %s\n", cl_strerror(ret)); cl_free(m_root); return 1; } /* Specify no callback */ m_root->callback = NULL; /* set up archive limits */ memset(&limits, 0, sizeof(struct cl_limits)); limits.maxscansize = 150 * (1 << 20); /* 150 mb : during the scanning of archives this size will never be exceeded */ limits.maxfilesize = 100 * (1 << 20); /* 100 mb : compressed files will only be decompressed and scanned up to this size */ limits.maxreclevel = 15; /* maximum recursion level for archives */ limits.maxfiles = 10000; /* maximum number of files to be scanned within a single archive */ limits.archivememlim = 0; /* limit memory usage for some unpackers */ #endif if (cycles) { wprintf(L"Warm up cycle\n"); benchmark(); wprintf(L"Warm up done... starting..." PADDING_48); for (runs = 1; runs <= cycles; runs++) speed += benchmark(); } else { cycles = 1; speed = benchmark(); } #if !defined(PROFILE_ADLER32) && !defined(PROFILE_PANAMA) cl_free(m_root); #endif wprintf(L"Average speed: %4.3f mb/s" PADDING_50, (speed * BMTOMS / cycles)); return 0; }
clamwind测试代码:
int wmain(int argc, wchar_t *argv[]) { // read loglevel from registry DWORD logLevel = LOG_ALWAYS; svc.GetConfigValue(L"LogLevel", &logLevel); if ((argc > 1) && wcsstr(argv[1], L"/t")) log.InitStdOut(logLevel); else { wchar_t szPath[MAX_PATH]; GetOurDir(szPath, sizeof(szPath)); wcsncat(szPath, L"\\ClamWind.log", MAX_PATH); log.InitFile(logLevel, szPath); } if(!InitNtFunctions()) dbgprint(LOG_ALWAYS, L"ERROR Loading NTDll Functions...\n"); svc.Run(argv[1]); UnintNtFunctions(); return 0; }
pipeclient测试代码:
int main(int argc, char *argv[]) { HANDLE hFile; BOOL flg; DWORD dwWrite, cbBytesRead; int i; char reply[BUFSIZE]; char *buffer = NULL; FILE *fd = NULL; size_t flen = 0; if (argc < 2) { printf("Usage: %s file1 [file2] [file3] [...]\n", argv[0]); return -1; } log.InitStdOut(LOG_TRACE); hFile = CreateFile(CLAMWIND_PIPE, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hFile == INVALID_HANDLE_VALUE) { printf("CreateFile failed for Named Pipe client %d\n", ::GetLastError()); return -1; } for (i = 1; i < argc; i ++) { if (!(fd = fopen(argv[i], "rb"))) { printf("Invalid file %s - skipping\n", argv[i]); continue; } fseek(fd, 0L, SEEK_END); flen = ftell(fd); fseek(fd, 0L, SEEK_SET); buffer = new char[flen]; if (fread(buffer, 1, flen, fd) != flen) { perror("fread()"); delete buffer; fclose(fd); continue; } fclose(fd); printf("-------------------------------------\n"); printf("Sending %s to the server\n", argv[i]); flg = WriteFile(hFile, buffer, (DWORD) flen, &dwWrite, NULL); FlushFileBuffers(hFile); if (FALSE == flg) printf("WriteFile failed for Named Pipe client: %d\n", ::GetLastError()); else printf("WriteFile succeeded for Named Pipe client\n"); delete buffer; cbBytesRead = 0; if (ReadFile(hFile, reply, BUFSIZE, &cbBytesRead, NULL)) { reply[cbBytesRead] = 0; printf("Server reply: %s\n", reply); CwXmlMessage *msg = new CwXmlMessage(reply, (int) cbBytesRead, TAG_CLAMWINREPLY); delete msg; } else printf("Error reading from server %d\n", ::GetLastError()); FlushFileBuffers(hFile); } CloseHandle(hFile); return 0; }
源码包下载