Skip to content

Commit 94c4bf4

Browse files
unknounkno
unkno
authored and
unkno
committed
Classes
1 parent b63d2e5 commit 94c4bf4

26 files changed

+19933
-160
lines changed

VysorProAuto.sln

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27428.1
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.28729.10
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VysorProAuto", "VysorProAuto\VysorProAuto.csproj", "{C7B530F0-D805-4478-ADE9-EADB13BF6542}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyVysorPro", "VysorProAuto\EasyVysorPro.csproj", "{C7B530F0-D805-4478-ADE9-EADB13BF6542}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A6BEB297-C82E-400C-B114-4CEA8C376956}"
9+
ProjectSection(SolutionItems) = preProject
10+
..\EnglishWords\EnglishWords\inifiles.cs = ..\EnglishWords\EnglishWords\inifiles.cs
11+
EndProjectSection
712
EndProject
813
Global
914
GlobalSection(SolutionConfigurationPlatforms) = preSolution

VysorProAuto/App.config

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
55
</startup>
6-
</configuration>
6+
</configuration>

VysorProAuto/Classes/CheckUpdates.cs

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
using MetroFramework;
2+
using System;
3+
using System.ComponentModel;
4+
using System.Diagnostics;
5+
using System.IO;
6+
using System.Net;
7+
using System.Threading;
8+
using System.Windows.Forms;
9+
using System.Xml;
10+
using VysorProAuto;
11+
12+
namespace EzShell
13+
{
14+
public delegate DialogResult ShowMessageDownloade(string message, string header, MessageBoxButtons buttons, MessageBoxIcon icon);
15+
public delegate DialogResult SwMsgDwnldUpt(string message, string header, MessageBoxButtons buttons, MessageBoxIcon icon);
16+
public class CheckUpdates
17+
{
18+
private static string GetRemoteVerLinq = Constants.link + @"/Files/version.xml";
19+
private static string GetReleaseNotesLinq = Constants.link + @"/Files/news.xml";
20+
public static string AppName { get; set; }
21+
private static string RemoteVersion { get { return RemoteVer(); } }
22+
private static string ThisVersion { get; set; }
23+
private static double RemoteVerDouble { get { return Convert.ToDouble(RemoteVer().Replace(".", "")); } }
24+
private static double ThisVerDouble { get { return Convert.ToDouble(ThisVersion.Replace(".", "")); } }
25+
private static SwMsgDwnldUpt swMsg { get; set; }
26+
public static MetroFramework.Controls.MetroProgressBar progressBar;
27+
public static Panel panelProgress;
28+
public static Label labelProgress;
29+
private static NotifyIcon notifyIcon;
30+
public static string UrlLinq { get; set; }
31+
public CheckUpdates(string _AppName, string _ThisVers, string _UrlLinq, SwMsgDwnldUpt _sw, MetroFramework.Controls.MetroProgressBar _progressBar, NotifyIcon notify, Panel panel, Label labelU)
32+
{
33+
progressBar = _progressBar;
34+
AppName = _AppName;
35+
ThisVersion = _ThisVers;
36+
UrlLinq = _UrlLinq;
37+
swMsg = _sw;
38+
notifyIcon = notify;
39+
panelProgress = panel;
40+
labelProgress = labelU;
41+
}
42+
43+
// tag
44+
45+
public void UpdaterProg(SwMsgDwnldUpt swMs)
46+
{
47+
try
48+
{
49+
if (ThisVerDouble < RemoteVerDouble)
50+
{
51+
if (DialogResult.Yes == swMs("New version detected (" + RemoteVersion + ")\nThe application will be automatically updated and restarted\nWhat new:\n" +
52+
WhatNewVer(swMs), AppName + " v" + ThisVersion, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
53+
{
54+
panelProgress.Invoke(new Action(()=> panelProgress.Visible = true));
55+
var ClientDownloader = new WebClient();
56+
ClientDownloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(download_ProgressChanged);
57+
ClientDownloader.DownloadFileCompleted += new AsyncCompletedEventHandler(download_Completed);
58+
ClientDownloader.DownloadFileAsync(new Uri(@UrlLinq), AppName + ".zip");
59+
}
60+
}
61+
else if (ThisVerDouble == RemoteVerDouble || ThisVerDouble > RemoteVerDouble)
62+
swMs("You using the lastest version!\nCurrent version: " + ThisVersion, "No updates available!", MessageBoxButtons.OK, MessageBoxIcon.Information);
63+
}
64+
catch (Exception exception)
65+
{
66+
swMs(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
67+
}
68+
}
69+
private static string WhatNewVer(SwMsgDwnldUpt swMsgDwnld)
70+
{
71+
try
72+
{
73+
XmlDocument docUpdates = new XmlDocument();
74+
docUpdates.Load(GetReleaseNotesLinq);
75+
return docUpdates.GetElementsByTagName(AppName)[0].InnerText;
76+
}
77+
catch (Exception ex)
78+
{
79+
//swMsgDwnld(ex.Message, "Can't get release notes", MessageBoxButtons.OK, MessageBoxIcon.Error);
80+
return "\nError.\nCan't load update notes";
81+
}
82+
}
83+
private static string RemoteVer()
84+
{
85+
XmlDocument docVersion = new XmlDocument();
86+
try
87+
{
88+
docVersion.Load(GetRemoteVerLinq);
89+
var RemoteVers = docVersion.GetElementsByTagName(AppName)[0].InnerText;
90+
return RemoteVers;
91+
}
92+
catch (Exception)
93+
{
94+
return "0";
95+
}
96+
}
97+
public string MsgUpdateAvailable()
98+
{
99+
Thread.Sleep(1500);
100+
if (ThisVerDouble < RemoteVerDouble)
101+
{
102+
return RemoteVersion;
103+
}
104+
return null;
105+
}
106+
private void Notify_BalloonTipClicked(object sender, EventArgs e)
107+
{
108+
UpdaterProg(swMsg);
109+
}
110+
private static void download_ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
111+
{
112+
progressBar.Invoke(new Action(() => progressBar.Value = e.ProgressPercentage));
113+
labelProgress.Invoke(new Action(() =>labelProgress.Text = Installer.SizeSuffix(e.BytesReceived) + " / " + Installer.SizeSuffix(e.TotalBytesToReceive)));
114+
}
115+
private static void download_Completed(object sender, AsyncCompletedEventArgs e)
116+
{
117+
panelProgress.Invoke(new Action(() => panelProgress.Visible = false));
118+
try
119+
{
120+
if (File.Exists("updater.exe"))
121+
{
122+
Process.Start("updater.exe", AppName);
123+
Thread.Sleep(500);
124+
Process.GetCurrentProcess().Kill();
125+
}
126+
else
127+
{
128+
if (DialogResult.Yes== swMsg("Updater.exe not founded! Download the updater?","Attention",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation))
129+
{
130+
var ClientDownloader = new WebClient();
131+
ClientDownloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(download_ProgressChanged);
132+
ClientDownloader.DownloadFileCompleted += new AsyncCompletedEventHandler(download_Completed);
133+
ClientDownloader.DownloadFileAsync(new Uri(Constants.updaterexelink),"updater.exe");
134+
}
135+
}
136+
137+
}
138+
catch (Win32Exception ex)
139+
{
140+
swMsg("Updater.exe not founded! " +
141+
"Please download the lastest version of this patcher from my website\n"+ex.Message, "Error",
142+
MessageBoxButtons.OK, MessageBoxIcon.Error);
143+
}
144+
}
145+
}
146+
}

VysorProAuto/Classes/Constants.cs

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Net;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace VysorProAuto
10+
{
11+
public class Constants
12+
{
13+
public static readonly string dirVysor = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Vysor\";
14+
public static readonly string dirVysorRoam = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Vysor\";
15+
public static readonly string defaultPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
16+
public static readonly string chromeVysorDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\Extensions\gidgenkbbabolejbgbpnhbimgjbffefm\";
17+
public static readonly string vLocalAdditionUgli = @"\resources\app\unpacked-crx\uglify.js";
18+
public static readonly string vysorDirRoam = dirVysorRoam + @"crx\gidgenkbbabolejbgbpnhbimgjbffefm\";
19+
public static readonly string vysorFile217v = vysorDirRoam + @"app-2.1.7.crx-unpacked\uglify.js";
20+
public static readonly string vysorFile225v = vysorDirRoam + @"app-2.2.5.crx-unpacked\uglify.js";
21+
public static readonly string vysorFile226v = vysorDirRoam + @"app-2.2.6.crx-unpacked\uglify.js";
22+
public static readonly string vysorFile229v = vysorDirRoam + @"app-2.2.9.crx-unpacked\uglify.js";
23+
public static readonly string vysorFile222v = dirVysor + @"app-2.2.2\resources\app\unpacked-crx\uglify.js";
24+
public static readonly string vysorFile212v = dirVysor + @"app-2.1.2\resources\app\unpacked-crx\uglify.js";
25+
public static readonly string chromeDefaultLinq = @"C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe";
26+
public static readonly string chromeInitialDir = @"C:\Program Files (x86)\Google\Chrome\Application";
27+
public static readonly string uglifyName = "uglify.js";
28+
public static readonly string uglifyFilter = "uglify.js(*.js)|*.js";
29+
public static readonly string fileExeInstaller = "Vysor-222inst.exe";
30+
public static readonly string chromeDirFilter = "chrome_proxy.exe(*.exe)|*.exe";
31+
public static readonly string chromeVsrUglify = chromeVysorDir + @"2.1.7_1\uglify.js";
32+
public static readonly string chromeStartVysorParams = "--profile-directory=Default --app-id=gidgenkbbabolejbgbpnhbimgjbffefm";
33+
public static readonly string[] PathFind = new string[] { "Googl=p,g=!1,b=!1,k=", "var t=!1;return e.subscriptions" };
34+
public static readonly string[] PathReplace = new string[] { "Googl=p,g=!0,b=!0,k=", "var t=!0;return e.subscriptions" };
35+
36+
public static readonly string vysorPackageLinq = link + @"/Files/Vysor-222inst.exe";
37+
public static readonly string wifiADBHelperLinq = link + "/wifi-adb-helper/";
38+
public static readonly string vysorServerDownload = link + @"/Files/EasyVysorPro.zip";
39+
public static readonly string updaterexelink = link + @"/Files/updater.exe";
40+
public static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
41+
public static string link { get => LinkGenerator(); }
42+
43+
public static string LinkGenerator()
44+
{
45+
string linkmaincheck = @"https://fordroid.3dn.ru/pictures/domaincheck.txt";
46+
string finaldomain = @"";
47+
string filename = "linkdomain.txt";
48+
// Объект запроса
49+
HttpWebRequest rew = (HttpWebRequest)WebRequest.Create(linkmaincheck);
50+
// Отправить запрос и получить ответ
51+
HttpWebResponse resp = (HttpWebResponse)rew.GetResponse();
52+
// Получить поток
53+
Stream str = resp.GetResponseStream();
54+
// Выводим в TextBox
55+
int ch;
56+
for (int i = 1; ; i++)
57+
{
58+
ch = str.ReadByte();
59+
if (ch == -1) break;
60+
finaldomain += (char)ch;
61+
}
62+
// Закрыть поток
63+
str.Close();
64+
return finaldomain;
65+
}
66+
}
67+
}

VysorProAuto/Classes/FireWaller.cs

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using NetFwTypeLib;
7+
8+
namespace EasyVysorPro
9+
{
10+
public class FireWaller
11+
{
12+
public void firewalldown()
13+
{
14+
15+
var apps = new List<string> {
16+
VysorProAuto.Constants.dirVysor + "Vysor.exe",
17+
VysorProAuto.Constants.dirVysor + "Update.exe",
18+
VysorProAuto.Constants.dirVysor + @"app-2.2.2\Vysor.exe",
19+
VysorProAuto.Constants.dirVysor + @"app-2.2.2\squirrel.exe"
20+
};
21+
var name = new List<string>
22+
{
23+
"VysorMain","VysorUpdater","VysorSec","VysorSquirrel"
24+
};
25+
foreach (string nam in name)
26+
{
27+
removerules(nam);
28+
}
29+
30+
int i = 0;
31+
foreach (string App in apps)
32+
{
33+
netDisabler(App, name[i]);
34+
i++;
35+
}
36+
}
37+
public void netDisabler(string path, string name )
38+
{
39+
List<NET_FW_RULE_DIRECTION_> directions = new List<NET_FW_RULE_DIRECTION_> {
40+
NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN,
41+
NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_OUT };
42+
foreach (NET_FW_RULE_DIRECTION_ rule in directions)
43+
{
44+
Type tNetFwPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
45+
INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(tNetFwPolicy2);
46+
var currentProfiles = fwPolicy2.CurrentProfileTypes;
47+
48+
INetFwRule2 inboundRule1 = (INetFwRule2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));
49+
inboundRule1.Enabled = true;
50+
inboundRule1.ApplicationName = path;
51+
inboundRule1.Profiles = currentProfiles;
52+
inboundRule1.Description = "testtest";
53+
inboundRule1.Name = name;
54+
inboundRule1.InterfaceTypes = "All";
55+
inboundRule1.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;
56+
inboundRule1.Direction = rule;
57+
try
58+
{
59+
INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));
60+
firewallPolicy.Rules.Add(inboundRule1);
61+
}
62+
catch (Exception ex) {
63+
VysorProAuto.Form1 _fo1m = new VysorProAuto.Form1();
64+
_fo1m.messageBoxCaller(ex.Message, "Firewall rule adding error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
65+
}
66+
67+
68+
}
69+
}
70+
void removerules(string name)
71+
{
72+
Type tNetFwPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
73+
INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(tNetFwPolicy2);
74+
var currentProfiles = fwPolicy2.CurrentProfileTypes;
75+
foreach (INetFwRule rule in fwPolicy2.Rules)
76+
{
77+
if (rule.Name.IndexOf(name) != -1)
78+
{
79+
INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));
80+
firewallPolicy.Rules.Remove(rule.Name);
81+
Console.WriteLine(rule.Name + " has been deleted from the Firewall Policy");
82+
}
83+
}
84+
}
85+
86+
}
87+
}

0 commit comments

Comments
 (0)