Beispiel #1
0
 private void CheckFiles()
 {
     for (int i = 0; i < FilesArray.Length; i++)
     {
         if (FilesArray[i].Path != null)
         {
             if (cancellationTokenSource.Token.IsCancellationRequested)
             {
                 break;
             }
             if (!FileValidater.VerifyAuthenticodeSignature(FilesArray[i].Path))
             {
                 bool findSignature = false;
                 if (File.Exists(FilesArray[i].Path))
                 {
                     if (signatureM)
                     {
                         if (SignatureString.Contains(FilesArray[i].Signature))
                         {
                             if (autoDeleteVirus)
                             {
                                 FilesArray[i].DeleteFile();
                             }
                             else
                             {
                                 FindDangerEvent?.Invoke(this, new FindDangerEventArgs(FilesArray[i]));
                             }
                             //VirusList.Add((VirusFile)FilesArray[i]);
                             findSignature = true;
                         }
                     }
                     if (evrizmM)
                     {
                         if (!findSignature)
                         {
                             string fileSignature = File.ReadAllText(FilesArray[i].Path);
                             foreach (var signature in EvrizmSignature.signatures)
                             {
                                 if (fileSignature.Contains(signature))
                                 {
                                     if (autoDeleteVirus)
                                     {
                                         FilesArray[i].DeleteFile();
                                     }
                                     else
                                     {
                                         FindDangerEvent?.Invoke(this, new FindDangerEventArgs(FilesArray[i]));
                                     }
                                     //VirusList.Add((VirusFile)FilesArray[i]);
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         FileCheckedEvent?.Invoke(this, new FileCheckEventArgs(true));
         Thread.Sleep(200);
         FilesArray[i] = null;
     }
     FilesArray      = null;
     SignatureString = null;
     //cancellationTokenSource.Cancel();
 }
 public void AddInDangerFile(object sender, FindDangerEventArgs e)
 {
     DangerFiles.Add(e.DangerFile);
     FileCheckedEvent?.Invoke(this, new FileCheckEventArgs(true));
 }
 public void AddInException(object sender, ExceptionAddEventArgs e)
 {
     //ExceptionFiles.Add((ExceptionFile)e.FileWithException.Clone());
     DangerFiles.RemoveAll(x => x.Path == e.FileWithException.Path);
     FileCheckedEvent?.Invoke(this, new FileCheckEventArgs(false));
 }
 /// <summary>
 /// Отчистка списка вирусов
 /// </summary>
 public void ClearVirusList()
 {
     DangerFiles = new List <FileWithSignature>();
     FileCheckedEvent?.Invoke(this, new FileCheckEventArgs(true));
 }