Skip to content

Commit

Permalink
fix startup bug
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyRabbit committed Dec 4, 2017
1 parent 3d946a0 commit 0f12ac1
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 21 deletions.
30 changes: 25 additions & 5 deletions AntiRecall/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
WindowStartupLocation="CenterScreen"
Title="AntiRecall"
Height="370"
Width="182.153"
Width="182"
ResizeMode="CanMinimize">

<Window.Resources>
Expand All @@ -19,8 +19,8 @@
</Window.Resources>


<Grid Margin="0,0,-6,0"
Background="Transparent">
<Grid Margin="0,0,0,0"
Background="White">


<Grid.RowDefinitions>
Expand Down Expand Up @@ -60,9 +60,29 @@
Margin="21,76,10,213"
FontSize="13" BorderBrush="#1E4E7099"/>

<StackPanel Margin="21,130,10,120">
<StackPanel Orientation="Vertical" Margin="0,18,0,0">
<RadioButton Content="内存补丁 " x:Name="Memory_patch_button" Command="{StaticResource patch_memory}"/>
<RadioButton Content="代理服务器 " x:Name="Proxy_button" Command="{StaticResource proxy}"/>
</StackPanel>
</StackPanel>

<TextBox Height="58"
Width="135"
x:Name="Descript_text"
IsEnabled="False"
HorizontalAlignment="Left"
TextWrapping="Wrap"
VerticalAlignment="Top"
VerticalContentAlignment="Bottom"
HorizontalContentAlignment="Center"
Text="AntiRecall v2.0"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Margin="21,223,0,0"/>

<telerik:RadToggleButton VerticalAlignment="Center"
HorizontalAlignment="Center"
MinWidth="35" Margin="54,280,59,42"
MinWidth="35" Margin="57,300,57,24"
IsChecked="False"
Click="StartButton_Click"
x:Name="Start"
Expand All @@ -75,7 +95,7 @@
PopupHorizontalOffset="-400"
PopupVerticalOffset="-25"
HorizontalAlignment="Center"
IsOpen="True"
IsOpen="False"
SelectionChanged="RadRadialMenu_SelectionChanged">
<telerik:RadRadialMenu.Resources>
<Style BasedOn="{StaticResource RadialMenuButtonStyle}"
Expand Down
12 changes: 10 additions & 2 deletions AntiRecall/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using AntiRecall.deploy;
using AntiRecall.network;
using System.Threading;
using System.Windows.Media;
using System.IO;
using AntiRecall.patch;

namespace AntiRecall
Expand Down Expand Up @@ -69,11 +69,14 @@ private void init_socks5()

public void ModeCheck()
{
if (Xml.antiRElement["Mode"] == "proxy")
if (Xml.antiRElement["Mode"] == "proxy")
{
this.PortItem.Foreground = System.Windows.Media.Brushes.Black;
this.PortText.Foreground = System.Windows.Media.Brushes.Black;
this.PortText.IsReadOnly = false;
this.Proxy_button.IsChecked = true;
this.Memory_patch_button.IsChecked = false;
this.Descript_text.Text = "请手动为QQ设置代理";
this.Explorer.Foreground = System.Windows.Media.Brushes.Black;
this.Explorer.IsEnabled = true;
}
Expand All @@ -82,6 +85,10 @@ public void ModeCheck()
{
this.PortItem.Foreground = System.Windows.Media.Brushes.Gray;
this.PortText.Foreground = System.Windows.Media.Brushes.Gray;
this.PortText.IsReadOnly = true;
this.Proxy_button.IsChecked = false;
this.Memory_patch_button.IsChecked = true;
this.Descript_text.Text = "请保证在开启后30秒内登录QQ";
this.Explorer.Foreground = System.Windows.Media.Brushes.Black;
this.Explorer.IsEnabled = true;
}
Expand Down Expand Up @@ -128,6 +135,7 @@ public MainWindow()
Xml.CreateXml(Xml.antiRElement);
}
ModeCheck();
this.Descript_text.Text = Xml.antiRElement["Descript"];
}


Expand Down
12 changes: 7 additions & 5 deletions AntiRecall/deploy/ReplaceQQStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace AntiRecall.deploy
public class ReplaceQQStartup : ICommand
{
private static RegistryKey startupKey;
private static string QQ_ori_path;

public bool CanExecute(object parameter)
{
Expand All @@ -19,12 +18,16 @@ public void Execute(object parameter)
startupKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
string QQName = "QQ2009";
string MyName = "AntiRecall";
string MyValue = ShortCut.currentDirectory + @"\AntiRecall.exe";
string MyValue = "\"" + ShortCut.currentDirectory + @"\AntiRecall.exe" + "\"";
if (IsInStartup(QQName))
{
DeleteStartup(QQName);
DeleteStartup(QQName);
}
CreateStartup(MyName, MyValue);
if (!IsInStartup(MyName))
{
CreateStartup(MyName, MyValue);
}
System.Windows.Forms.MessageBox.Show("已将QQ自启动替换为AntiRecall");
}

public event EventHandler CanExecuteChanged;
Expand All @@ -36,7 +39,6 @@ private static bool IsInStartup(string KeyName)
Object o = startupKey.GetValue(KeyName);
if (o != null)
{
QQ_ori_path = (string)o;
return true;
}

Expand Down
10 changes: 7 additions & 3 deletions AntiRecall/deploy/ResumeQQStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace AntiRecall.deploy
public class ResumeQQStartup : ICommand
{
private static RegistryKey startupKey;
private static string QQ_ori_path;

public bool CanExecute(object parameter)
{
Expand All @@ -19,11 +18,17 @@ public void Execute(object parameter)
startupKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
string QQName = "QQ2009";
string MyName = "AntiRecall";
if (-1 == Xml.antiRElement["QQPath"].IndexOf("QQ.exe"))
{
System.Windows.Forms.MessageBox.Show("未设置QQ安装目录");
return;
}
if (IsInStartup(MyName))
{
DeleteStartup(MyName);
CreateStartup(QQName, "\"" + Xml.antiRElement["QQPath"] + "\" /background");
}
CreateStartup(QQName, Xml.antiRElement["QQPath"]);
System.Windows.Forms.MessageBox.Show("已恢复QQ自启动,AntiRecall不再自启动");
}

public event EventHandler CanExecuteChanged;
Expand All @@ -35,7 +40,6 @@ private static bool IsInStartup(string KeyName)
Object o = startupKey.GetValue(KeyName);
if (o != null)
{
QQ_ori_path = (string)o;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion AntiRecall/deploy/ShortCut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void init_shortcut(string filename)
{
if (currentDirectory == null)
currentDirectory = System.IO.Directory.GetCurrentDirectory();
myVersion = "1.2.0";
myVersion = "2.0.1";

if (!CheckShortCut(filename))
{
Expand Down
1 change: 1 addition & 0 deletions AntiRecall/deploy/Xml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void init_xml()
antiRElement.Add("PortText", "");
antiRElement.Add("QQPath", "");
antiRElement.Add("Mode", "");
antiRElement.Add("Descript", "AntiRecall v2.0");
}

public static bool CheckXml()
Expand Down
22 changes: 19 additions & 3 deletions AntiRecall/network/CheckUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private static bool CheckNewVersion()
XmlDocument doc = new XmlDocument();
try
{

doc.Load("https://etenal.me/wp-content/uploads/AntiRecall/newversion.xml");
}
catch
Expand All @@ -65,8 +64,25 @@ private static bool CheckNewVersion()
}
newVersion = doc.DocumentElement.GetAttribute("Version");
url = doc.DocumentElement.GetAttribute("Url");

return (!newVersion.Equals(ShortCut.myVersion));

if (newVersion.Equals(ShortCut.myVersion))
return false;

var t1 = newVersion.Split('.');
var t2 = ShortCut.myVersion.Split('.');

if (Convert.ToInt32(t1[0]) > Convert.ToInt32(t2[0]))
return true;
else if (Convert.ToInt32(t1[1]) > Convert.ToInt32(t2[1]) &&
Convert.ToInt32(t1[0]) == Convert.ToInt32(t2[0]))
return true;
else if (Convert.ToInt32(t1[2]) > Convert.ToInt32(t2[2]) &&
Convert.ToInt32(t1[0]) == Convert.ToInt32(t2[0]) &&
Convert.ToInt32(t1[1]) == Convert.ToInt32(t2[1]))
return true;


return false;
}

private static bool ShowUpdate()
Expand Down
2 changes: 1 addition & 1 deletion AntiRecall/patch/patch_memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void StartPatch()
int is_running = 0;
int result = -1;

System.Threading.Thread.Sleep(20000);
System.Threading.Thread.Sleep(30000);
is_running = FindProcess();
if ((is_running & 1) == 1) //QQ.exe
{
Expand Down
2 changes: 1 addition & 1 deletion AntiRecall/patch/proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public bool CanExecute(object parameter)

public void Execute(object parameter)
{
AntiRecall.deploy.Xml.antiRElement["QQPath"] = "proxy";
AntiRecall.deploy.Xml.antiRElement["Mode"] = "proxy";
((MainWindow)System.Windows.Application.Current.MainWindow).ModeCheck();
}

Expand Down

0 comments on commit 0f12ac1

Please sign in to comment.