From 9d3fad0712953816f280a857239992ee90af5f58 Mon Sep 17 00:00:00 2001 From: Soul Dark <1012179378@qq.com> Date: Sat, 21 Jul 2018 18:33:58 +0800 Subject: [PATCH] update to 5.0.1 --- .../Controller/UpdateChecker.cs | 2 +- shadowsocks-csharp/Program.cs | 13 ++++--- shadowsocks-csharp/Util/Util.cs | 24 ++++++++++++- shadowsocks-csharp/View/MenuViewController.cs | 36 +++++++++++++++---- shadowsocks-csharp/ssr-win-4.0.xml | 2 +- 5 files changed, 62 insertions(+), 15 deletions(-) diff --git a/shadowsocks-csharp/Controller/UpdateChecker.cs b/shadowsocks-csharp/Controller/UpdateChecker.cs index 8be0d97f..a8fa8d9a 100755 --- a/shadowsocks-csharp/Controller/UpdateChecker.cs +++ b/shadowsocks-csharp/Controller/UpdateChecker.cs @@ -21,7 +21,7 @@ public class UpdateChecker public const string Name = "ShadowsocksR"; public const string Copyright = "Copyright © BreakWa11 2017. Fork from Shadowsocks by clowwindy"; - public const string Version = "4.0.0"; + public const string Version = "5.0.2"; #if !_DOTNET_4_0 public const string NetVer = "2.0"; #elif !_CONSOLE diff --git a/shadowsocks-csharp/Program.cs b/shadowsocks-csharp/Program.cs index ac991cc0..e4fc0e6a 100755 --- a/shadowsocks-csharp/Program.cs +++ b/shadowsocks-csharp/Program.cs @@ -1,10 +1,9 @@ using Shadowsocks.Controller; -using Shadowsocks.Properties; +using Shadowsocks.Util; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Net; using System.Threading; using System.Windows.Forms; using Microsoft.Win32; @@ -17,9 +16,9 @@ namespace Shadowsocks { static class Program { - static ShadowsocksController _controller; + private static ShadowsocksController _controller; #if !_CONSOLE - static MenuViewController _viewController; + public static MenuViewController _viewController { get; set; } #endif /// @@ -40,6 +39,11 @@ static void Main(string[] args) return; } } + + if (Utils.is360Exist()){ + return; + } + using (Mutex mutex = new Mutex(false, "Global\\ShadowsocksR_" + Application.StartupPath.GetHashCode())) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; @@ -47,7 +51,6 @@ static void Main(string[] args) Application.ApplicationExit += Application_ApplicationExit; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; Application.SetCompatibleTextRenderingDefault(false); - if (!mutex.WaitOne(0, false)) { MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" + diff --git a/shadowsocks-csharp/Util/Util.cs b/shadowsocks-csharp/Util/Util.cs index 22c32406..04d06ecb 100755 --- a/shadowsocks-csharp/Util/Util.cs +++ b/shadowsocks-csharp/Util/Util.cs @@ -11,9 +11,10 @@ using System.Security.Cryptography; using System.Text; using System.Windows.Forms; +using Microsoft.Win32; using OpenDNS; using Shadowsocks.Controller; -using Shadowsocks.Encryption; +using Shadowsocks; using Shadowsocks.Model; namespace Shadowsocks.Util @@ -490,6 +491,27 @@ public static int GetDpiMul() return (dpi * 4 + 48) / 96; } + public static bool is360Exist() + { + List process = new List(Process.GetProcessesByName("ZhuDongFangYu")); + process.AddRange(Process.GetProcessesByName("360Safe")); + string registry_path_360Safe = (IntPtr.Size == 4 ? @"Software\Microsoft\Windows\CurrentVersion\App Paths\360safe.exe" : @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\360safe.exe"); + string registry_path_360Se6 = (IntPtr.Size == 4 ? @"Software\Microsoft\Windows\CurrentVersion\App Paths\360se6.exe" : @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\360se6.exe"); + RegistryKey registry_360Safe = Registry.LocalMachine.OpenSubKey(registry_path_360Safe); + RegistryKey registry_360Se6 = Registry.LocalMachine.OpenSubKey(registry_path_360Se6); + if ( + process.Count != 0 || + registry_360Safe != null|| + registry_360Se6 != null + ) + { + //因为只有国行小白才会看到本消息,所以用中文 + MessageBox.Show(I18N.GetString("SSRR无法运行于安装有360的电脑,告辞!")); + return true; + } + return false; + } + #if !_CONSOLE public enum DeviceCap { diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index d1aaaadd..a7af8e6e 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -2,11 +2,9 @@ using Shadowsocks.Model; using Shadowsocks.Properties; using System; -using System.IO; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; -using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; @@ -15,6 +13,7 @@ using ZXing.QrCode; using System.Threading; using System.Text.RegularExpressions; +using Shadowsocks.Util; namespace Shadowsocks.View { @@ -68,6 +67,7 @@ public class MenuViewController private SubscribeForm subScribeForm; private LogForm logForm; private string _urlToOpen; + private System.Timers.Timer timerDetect360; private System.Timers.Timer timerDelayCheckUpdate; private bool configfrom_open = false; @@ -105,13 +105,24 @@ public MenuViewController(ShadowsocksController controller) updateSubscribeManager = new UpdateSubscribeManager(); LoadCurrentConfiguration(); + timerDetect360 = new System.Timers.Timer(1000.0*30); + timerDetect360.Elapsed += timerDetect360_Elapsed; + timerDetect360.Start(); timerDelayCheckUpdate = new System.Timers.Timer(1000.0 * 10); - timerDelayCheckUpdate.Elapsed += timer_Elapsed; + timerDelayCheckUpdate.Elapsed += timerDelayCheckUpdate_Elapsed; timerDelayCheckUpdate.Start(); } - private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + private void timerDetect360_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + if (Utils.is360Exist()) + { + Quit(); + } + } + + private void timerDelayCheckUpdate_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (timerDelayCheckUpdate != null) { @@ -638,7 +649,7 @@ void updateChecker_NewVersionFound(object sender, EventArgs e) I18N.GetString("Click menu to download"), ToolTipIcon.Info, 10000); _notifyIcon.BalloonTipClicked += notifyIcon1_BalloonTipClicked; - timerDelayCheckUpdate.Elapsed -= timer_Elapsed; + timerDelayCheckUpdate.Elapsed -= timerDelayCheckUpdate_Elapsed; timerDelayCheckUpdate.Stop(); timerDelayCheckUpdate = null; } @@ -970,7 +981,7 @@ private void Setting_Click(object sender, EventArgs e) ShowSettingForm(); } - private void Quit_Click(object sender, EventArgs e) + private void Quit() { controller.Stop(); if (configForm != null) @@ -983,9 +994,15 @@ private void Quit_Click(object sender, EventArgs e) serverLogForm.Close(); serverLogForm = null; } + if (timerDetect360 != null) + { + timerDetect360.Elapsed -= timerDetect360_Elapsed; + timerDetect360.Stop(); + timerDetect360 = null; + } if (timerDelayCheckUpdate != null) { - timerDelayCheckUpdate.Elapsed -= timer_Elapsed; + timerDelayCheckUpdate.Elapsed -= timerDelayCheckUpdate_Elapsed; timerDelayCheckUpdate.Stop(); timerDelayCheckUpdate = null; } @@ -993,6 +1010,11 @@ private void Quit_Click(object sender, EventArgs e) Application.Exit(); } + private void Quit_Click(object sender, EventArgs e) + { + Quit(); + } + private void OpenWiki_Click(object sender, EventArgs e) { Process.Start("https://github.com/shadowsocksrr/shadowsocks-rss/wiki"); diff --git a/shadowsocks-csharp/ssr-win-4.0.xml b/shadowsocks-csharp/ssr-win-4.0.xml index 590d6237..4e604d10 100644 --- a/shadowsocks-csharp/ssr-win-4.0.xml +++ b/shadowsocks-csharp/ssr-win-4.0.xml @@ -2,7 +2,7 @@ - +