Skip to content

Commit

Permalink
release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Himmelt committed Mar 5, 2018
1 parent 58fb713 commit dd8f006
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
11 changes: 7 additions & 4 deletions FoshanVirusKiller/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
Title="FoshanVirusKiller" Width="600" Height="400" MinWidth="600" MinHeight="400" FontFamily="Microsoft YaHei" FontSize="14">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="251*"/>
<RowDefinition Height="110*" MinHeight="110" MaxHeight="110"/>
<RowDefinition Height="256*"/>
<RowDefinition Height="115*" MinHeight="110" MaxHeight="110"/>
</Grid.RowDefinitions>
<TextBox x:Name="console" Margin="30,20,30.333,9.667" AcceptsReturn="True" TextOptions.TextFormattingMode="Display" ClipToBounds="True" Padding="5" Foreground="#FFB85300" FontFamily="Microsoft YaHei" FontSize="14" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/>
<Button x:Name="killer" Content="快 速 查 杀" HorizontalAlignment="Center" Height="50" Margin="0,0,0,32" VerticalAlignment="Bottom" Width="140" Click="OneKeyKill" Grid.Row="1" FontFamily="Microsoft YaHei" FontSize="16" Foreground="#FF0080FF"/>
<TextBox x:Name="console" Margin="30,20,30,5" AcceptsReturn="True" TextOptions.TextFormattingMode="Display" ClipToBounds="True" Padding="5" Foreground="#FFB85300" FontFamily="Microsoft YaHei" FontSize="14" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Text="佛山现场病毒专杀程序&#xD;&#xA;&#xD;&#xA;当前版本:1.2.0&#xD;&#xA;发布时间:2018-03-05"/>
<Button x:Name="killer" Content="快 速 查 杀" HorizontalAlignment="Center" Height="40" Margin="0,0,0,15" VerticalAlignment="Bottom" Width="140" Click="OneKeyKill" Grid.Row="1" FontFamily="Microsoft YaHei" FontSize="14" Foreground="#FF0080FF"/>
<TextBlock HorizontalAlignment="Right" Height="20" Margin="0,0,10.333,9.667" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Bottom" TextAlignment="Center" Width="{Binding ActualWidth, ElementName=killer, Mode=OneWay}">
<Hyperlink Click="OpenHyperlink" NavigateUri="https://github.com/Himmelt/FoshanVirusKiller" ToolTip="前往项目主页">查看项目主页及更新</Hyperlink>
</TextBlock>
<TextBlock x:Name="status" Height="40" Margin="30,0" Grid.Row="1" VerticalAlignment="Top" FontSize="10" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Animated" Padding="1" TextWrapping="Wrap"/>
<RadioButton x:Name="checkEntire" Content="全盘扫描" HorizontalAlignment="Left" Margin="109,62.333,0,0" Grid.Row="1" VerticalAlignment="Top" FontSize="12" Checked="OnEntireChecked"/>
<RadioButton x:Name="checkQuick" Content="快速扫描" HorizontalAlignment="Left" Margin="30,62.333,0,0" Grid.Row="1" VerticalAlignment="Top" FontSize="12" Checked="OnQuickChecked" IsChecked="True"/>
</Grid>
</Window>
63 changes: 50 additions & 13 deletions FoshanVirusKiller/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace FoshanVirusKiller
/// </summary>
public partial class MainWindow : Window
{
private static long count = 0;
private static bool entire = false;

private static string KEYFOLDER = @"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced";
private static List<long> SIZES = new List<long> {
Expand All @@ -25,6 +27,7 @@ public partial class MainWindow : Window
//347, // disk.lnk
480768, // svhost.exe
376832, // fold.exe
680511, //rundll32.exe
32768
};
private static List<string> VHASH = new List<string>{
Expand All @@ -51,7 +54,15 @@ public partial class MainWindow : Window
textBox.AppendText(text + "\n");
textBox.ScrollToEnd();
});
private static Action<Button, bool> EnableButton = new Action<Button, bool>((button, enable) => button.IsEnabled = enable);
private static Action<TextBlock, string> ShowStatus = new Action<TextBlock, string>((status, text) =>
{
status.Text = "正在检查:" + text;
});
private static Action<TextBlock> ClearStatus = new Action<TextBlock>((status) =>
{
status.Text = "";
});
private static Action<Control, bool> EnableControl = new Action<Control, bool>((control, enable) => control.IsEnabled = enable);

private void DeleteFile(FileInfo target, bool top)
{
Expand Down Expand Up @@ -85,8 +96,11 @@ private void OneKeyKill(object sender, RoutedEventArgs e)
private void KillTask()
{
// 初始化启动
count = 0;
TASKS.Clear();
Dispatcher.BeginInvoke(EnableButton, killer, false);
Dispatcher.BeginInvoke(EnableControl, killer, false);
Dispatcher.BeginInvoke(EnableControl, checkQuick, false);
Dispatcher.BeginInvoke(EnableControl, checkEntire, false);
Dispatcher.BeginInvoke(ClearText, console);

// 检查系统进程
Expand All @@ -99,8 +113,11 @@ private void KillTask()
Task.WaitAll(TASKS.ToArray());

// 查杀完毕
Dispatcher.BeginInvoke(ClearStatus, status);
Dispatcher.BeginInvoke(Println, console, "查杀完毕!");
Dispatcher.BeginInvoke(EnableButton, killer, true);
Dispatcher.BeginInvoke(EnableControl, killer, true);
Dispatcher.BeginInvoke(EnableControl, checkQuick, true);
Dispatcher.BeginInvoke(EnableControl, checkEntire, true);
}

private void KillProcess()
Expand All @@ -111,7 +128,7 @@ private void KillProcess()
try
{
FileInfo info = new FileInfo(process.MainModule.FileName);
//Dispatcher.BeginInvoke(Println, console, "正在检查进程:" + info.Name);
Dispatcher.BeginInvoke(ShowStatus, status, info.FullName);
if (info.Exists && SIZES.Contains(info.Length))
{
FileStream file = info.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Expand Down Expand Up @@ -143,26 +160,30 @@ private void KillProcess()

private void KillDisks()
{
if (entire) Dispatcher.BeginInvoke(Println, console, "正在全盘检查,文件数量巨大,请耐心等待!");
foreach (DriveInfo info in DriveInfo.GetDrives())
{
if (info.DriveType == DriveType.Removable)
if (entire || info.DriveType == DriveType.Removable)
{
Dispatcher.BeginInvoke(Println, console, "正在检查可移动磁盘:" + info.VolumeLabel);
KillDirectory(info.RootDirectory, true);
Dispatcher.BeginInvoke(Println, console, "正在检查磁盘:" + info.VolumeLabel);
CheckDirectory(info.RootDirectory, info.DriveType == DriveType.Removable);
}
}
Dispatcher.BeginInvoke(Println, console, "正在检查用户文件夹,文件数量巨大,请耐心等待!");
KillDirectory(new DirectoryInfo(@"C:\Users\"), false);
if (!entire)
{
Dispatcher.BeginInvoke(Println, console, "正在检查用户文件夹,文件数量较大,请耐心等待!");
CheckDirectory(new DirectoryInfo(@"C:\Users\"), false);
}
}

private void KillDirectory(DirectoryInfo directory, bool usb)
private void CheckDirectory(DirectoryInfo directory, bool usb)
{
foreach (var dir in directory.GetDirectories())
{
try
{
dir.Attributes = FileAttributes.Normal;
KillDirectory(dir, usb);
if (usb) dir.Attributes = FileAttributes.Normal;
CheckDirectory(dir, usb);
}
catch (Exception)
{
Expand All @@ -172,9 +193,14 @@ private void KillDirectory(DirectoryInfo directory, bool usb)
}
foreach (var file in directory.GetFiles())
{
if (count++ > 100)
{
Dispatcher.BeginInvoke(ShowStatus, status, file.FullName);
count = 0;
}
try
{
file.Attributes = FileAttributes.Normal;
if (usb) file.Attributes = FileAttributes.Normal;
if (usb && file.Extension.Contains("lnk"))
DeleteFile(file, true);
else
Expand Down Expand Up @@ -241,5 +267,16 @@ private void OpenHyperlink(object sender, RoutedEventArgs e)
Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
}

private void OnQuickChecked(object sender, RoutedEventArgs e)
{
entire = false;
killer.Content = "快 速 查 杀";
}

private void OnEntireChecked(object sender, RoutedEventArgs e)
{
entire = true;
killer.Content = "全 盘 查 杀";
}
}
}
6 changes: 3 additions & 3 deletions FoshanVirusKiller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyTitle("FoshanVirusKiller")]
[assembly: AssemblyDescription("FoshanVirusKiller")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Hanm")]
[assembly: AssemblyCompany("SoraWorld")]
[assembly: AssemblyProduct("FoshanVirusKiller")]
[assembly: AssemblyCopyright("Copyright © 2017-2018 Himmelt")]
[assembly: AssemblyTrademark("Himmelt")]
Expand Down Expand Up @@ -51,7 +51,7 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: Guid("BF12D8E8-9EDD-4299-BF8A-6F7A49499A2D")]

0 comments on commit dd8f006

Please sign in to comment.