/*public*/bool vrParser::CompileFile( LPSTR strFileName, CODE* code ) { if ( ( !strFileName ) || ( !code ) ) return false; this->code = code; return CleanFile( strFileName ); }
/** @internalComponent */ void CTestVirusHook::VsFileClose(TFsPluginRequest& aRequest) { TFileName fileName; TInt err = GetName(&aRequest, fileName); if(err == KErrNone) { err = ScanFile(fileName); if (err != KErrNone) { // Clean the infected file CleanFile(fileName, EFileClose); } } }
/** @internalComponent */ TInt CTestVirusHook::VsFileOpen(TFsPluginRequest& aRequest) { TFileName fileName; TInt err = ValidateRequest(aRequest, fileName); if (err == KErrNone) { err = ScanFile(fileName); if (err != KErrNone) { // Clean the infected file CleanFile(fileName, EFileOpen); } } return err; }
BOOL __stdcall _ScanFileCallBack(void* pMain,int iType,LPCTSTR lpcszFileFullPath,DWORD dwFileLowPart,LONG dwFileHighPart) { g_fnOutScanFile(pMain,iType,lpcszFileFullPath,dwFileLowPart,dwFileHighPart); if (lpcszFileFullPath==NULL||wcscmp(lpcszFileFullPath,_T(""))==0) { return TRUE; } if (TRUE == g_bIsClean) { CString strFileFullPath = lpcszFileFullPath; if (FALSE==CleanFile(iType,strFileFullPath)) { MoveFileEx (strFileFullPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT); WIN32_FIND_DATA fd; HANDLE hFindFile = FindFirstFile(strFileFullPath.GetBuffer(), &fd); strFileFullPath.ReleaseBuffer(); if(hFindFile == INVALID_HANDLE_VALUE) { OutputDebugString(_T("\n文件不存在\n")); ::FindClose(hFindFile); return TRUE; } ::FindClose(hFindFile); g_fnScanFileError(g_pMainError, iType, lpcszFileFullPath, fd.nFileSizeLow,fd.nFileSizeHigh ); } } else { } return TRUE; }
/** @internalComponent */ TInt CTestVirusHook::VsFileRename(TFsPluginRequest& aRequest) { TInt err = VsDirRename(aRequest); if(err != KErrAccessDenied) { TFileName fileName; err = ValidateRequest(aRequest, fileName); if (err == KErrNone) { err = ScanFile(fileName); if (err != KErrNone) { // Clean the infected file CleanFile(fileName, EFileRename); } } } return err; }
unsigned int __stdcall CleanFileThread(void* parm) { VEC_FILEINFO vec_fileInfo = *((VEC_FILEINFO*)parm); if(vec_fileInfo.GetSize()<=0) return 0; g_fnScanFileError(g_pMainError,BEGINPROC(vec_fileInfo[0].iType),NULL,NULL,NULL); int iType = vec_fileInfo[0].iType; int i; for (i=0; i<vec_fileInfo.GetSize(); i++) { if (iType != vec_fileInfo[i].iType) { //如果与上次类型不同则结束上次类型,开启新类型 g_fnScanFileError(g_pMainError,ENDPROC(iType),NULL,NULL,NULL); g_fnScanFileError(g_pMainError,BEGINPROC(vec_fileInfo[i].iType),NULL,NULL,NULL); iType = vec_fileInfo[i].iType; } if(FALSE==CleanFile(vec_fileInfo[i].iType,vec_fileInfo[i].strFileFullPath)) { KCLEAR_LOG(LOG_LEVEL_TRACKCLEAN) << "Clean Failed :" << UnicodeToAnsi(vec_fileInfo[i].strFileFullPath.GetBuffer()); MoveFileEx (vec_fileInfo[i].strFileFullPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT); WIN32_FIND_DATA fd; HANDLE hFindFile = FindFirstFile(vec_fileInfo[i].strFileFullPath.GetBuffer(), &fd); vec_fileInfo[i].strFileFullPath.ReleaseBuffer(); if(hFindFile == INVALID_HANDLE_VALUE) { OutputDebugString(_T("文件不存在")); ::FindClose(hFindFile); continue; } ::FindClose(hFindFile); g_fnScanFileError(g_pMainError, vec_fileInfo[i].iType, vec_fileInfo[i].strFileFullPath, fd.nFileSizeLow,fd.nFileSizeHigh ); } else { KCLEAR_LOG(LOG_LEVEL_TRACKCLEAN) << "Clean Successed:" << UnicodeToAnsi(vec_fileInfo[i].strFileFullPath.GetBuffer()); } } g_fnScanFileError(g_pMainError,ENDPROC(vec_fileInfo[i-1].iType),NULL,NULL,NULL); //删除空文件夹 //WCHAR* pEnv; //pEnv = _wgetenv(_T("USERPROFILE")); //if (pEnv !=NULL) //{ // g_fileOpt.DeleteEmptyDirectories(pEnv); //} g_fnScanFileError(g_pMainError,0,_T(""),0,0); OutputDebugString(_T("File清理完成")); _endthreadex(0); return 0; }