Exemplo n.º 1
0
 private void TryKillVirus(FileInfo info)
 {
     if (info.Exists && SIZES.Contains(info.Length))
     {
         FileStream file = info.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         string     hash = BitConverter.ToString(SHA1.ComputeHash(file));
         file.Close();
         if (VHASH.Contains(hash))
         {
             DeleteFile(info);
         }
     }
 }
Exemplo n.º 2
0
 private void KillProcess()
 {
     //遍历电脑中的进程
     foreach (var process in Process.GetProcesses())
     {
         try
         {
             FileInfo info = new FileInfo(process.MainModule.FileName);
             Dispatcher.BeginInvoke(ShowStatus, status, "进程:" + info.Name);
             if (info.Exists && SIZES.Contains(info.Length))
             {
                 FileStream file = info.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                 string     hash = BitConverter.ToString(SHA1.ComputeHash(file));
                 file.Close();
                 if (VHASH.Contains(hash))
                 {
                     try
                     {
                         process.Kill();
                         Dispatcher.BeginInvoke(Println, console, "结束病毒进程:" + info.Name);
                         DeleteFile(info);
                     }
                     catch (Exception e)
                     {
                         Dispatcher.BeginInvoke(Println, console, "病毒进程处理失败:" + info.FullName);
                         Dispatcher.BeginInvoke(Println, console, e.Message);
                     }
                 }
             }
         }
         catch (Exception)
         {
             //Console.WriteLine(e.Message);
             //Dispatcher.BeginInvoke(Println, console, e.Message);
         }
     }
 }