diff --git a/.vs/Ad_Catch_v1.8/v14/.suo b/.vs/Ad_Catch_v1.8/v14/.suo index fc8e944..2099304 100644 Binary files a/.vs/Ad_Catch_v1.8/v14/.suo and b/.vs/Ad_Catch_v1.8/v14/.suo differ diff --git a/Ad_Catch_v1.0/Ad_Catch.csproj b/Ad_Catch_v1.0/Ad_Catch.csproj index 173455c..7289f3a 100644 --- a/Ad_Catch_v1.0/Ad_Catch.csproj +++ b/Ad_Catch_v1.0/Ad_Catch.csproj @@ -109,6 +109,8 @@ + + diff --git a/Ad_Catch_v1.0/Form1.Designer.cs b/Ad_Catch_v1.0/Form1.Designer.cs index 55ee9b5..4793295 100644 --- a/Ad_Catch_v1.0/Form1.Designer.cs +++ b/Ad_Catch_v1.0/Form1.Designer.cs @@ -33,12 +33,11 @@ private void InitializeComponent() this.label3 = new System.Windows.Forms.Label(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.startToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startAdCatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stopAdCatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.programUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.hostUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.panel1 = new System.Windows.Forms.Panel(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -66,7 +65,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.BackColor = System.Drawing.Color.Transparent; this.label3.ForeColor = System.Drawing.Color.Gray; - this.label3.Location = new System.Drawing.Point(176, 239); + this.label3.Location = new System.Drawing.Point(333, 252); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(93, 13); this.label3.TabIndex = 6; @@ -89,26 +88,10 @@ private void InitializeComponent() // // startToolStripMenuItem // - this.startToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.startAdCatchToolStripMenuItem, - this.stopAdCatchToolStripMenuItem}); this.startToolStripMenuItem.Name = "startToolStripMenuItem"; - this.startToolStripMenuItem.Size = new System.Drawing.Size(59, 20); - this.startToolStripMenuItem.Text = "Actions"; - // - // startAdCatchToolStripMenuItem - // - this.startAdCatchToolStripMenuItem.Name = "startAdCatchToolStripMenuItem"; - this.startAdCatchToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.startAdCatchToolStripMenuItem.Text = "Start Ad_Catch"; - this.startAdCatchToolStripMenuItem.Click += new System.EventHandler(this.startAdCatchToolStripMenuItem_Click); - // - // stopAdCatchToolStripMenuItem - // - this.stopAdCatchToolStripMenuItem.Name = "stopAdCatchToolStripMenuItem"; - this.stopAdCatchToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.stopAdCatchToolStripMenuItem.Text = "Stop Ad_Catch"; - this.stopAdCatchToolStripMenuItem.Click += new System.EventHandler(this.stopAdCatchToolStripMenuItem_Click); + this.startToolStripMenuItem.Size = new System.Drawing.Size(43, 20); + this.startToolStripMenuItem.Text = "Start"; + this.startToolStripMenuItem.Click += new System.EventHandler(this.OnOffButtonClick); // // aboutToolStripMenuItem // @@ -140,18 +123,28 @@ private void InitializeComponent() this.hostUpdatesToolStripMenuItem.Text = "Host Updates"; this.hostUpdatesToolStripMenuItem.Click += new System.EventHandler(this.hostUpdatesToolStripMenuItem_Click); // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.Transparent; + this.panel1.Location = new System.Drawing.Point(78, 25); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(282, 248); + this.panel1.TabIndex = 8; + this.panel1.Click += new System.EventHandler(this.OnOffButtonClick); + // // Form1 // this.AccessibleName = "Ad_Catch"; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.SystemColors.ActiveCaption; - this.BackgroundImage = global::Ad_Catch_v1._0.Properties.Resources.ico; + this.BackColor = System.Drawing.SystemColors.ActiveBorder; + this.BackgroundImage = global::Ad_Catch_v1._0.Properties.Resources.ico_stopped; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.ClientSize = new System.Drawing.Size(438, 274); this.Controls.Add(this.label3); this.Controls.Add(this.label1); this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.panel1); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -180,8 +173,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem programUpdatesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem hostUpdatesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startAdCatchToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem stopAdCatchToolStripMenuItem; + private System.Windows.Forms.Panel panel1; } } diff --git a/Ad_Catch_v1.0/Form1.cs b/Ad_Catch_v1.0/Form1.cs index 463ffa6..93f10ae 100644 --- a/Ad_Catch_v1.0/Form1.cs +++ b/Ad_Catch_v1.0/Form1.cs @@ -31,6 +31,7 @@ public partial class Form1 : Form private System.Windows.Forms.ContextMenu contextMenu1= new System.Windows.Forms.ContextMenu(); private System.Windows.Forms.MenuItem menuItem1; public int status = 0; + public bool elevated; //cambiare host/hostparental/hostnospotify per generare versioni diverse public byte[] host= Properties.Resources.host; // @@ -41,6 +42,15 @@ public Form1() private void Form1_Load(object sender, EventArgs e) { + //check if is running + + if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1) + { + MessageBox.Show("Another instance of this application is running."); + Close(); + return; + } + // check admin or root bool isElevated; WindowsIdentity identity = WindowsIdentity.GetCurrent(); @@ -64,15 +74,26 @@ private void Form1_Load(object sender, EventArgs e) this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(new System.ComponentModel.Container()); //notifyIcon1.Icon = new Icon(Directory.GetCurrentDirectory() + "\\files\\ico_small.ico"); OLD METHOD + + // + System.IntPtr icH = Properties.Resources.ico_stopped_small.GetHicon(); + Icon icoStopped = Icon.FromHandle(icH); + icH = Properties.Resources.ico_small.GetHicon(); + Icon icoStarted = Icon.FromHandle(icH); + + if (status == 0) notifyIcon1.Icon = icoStopped; + else notifyIcon1.Icon = icoStarted; - notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - notifyIcon1.Text = "Ad_Catch_v1.8"; + //notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + notifyIcon1.Text = "Ad_Catch"; notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); notifyIcon1.ContextMenu = this.contextMenu1; #endregion this.FormClosed += FormClosed; - + + if (status == 0) this.BackgroundImage = Properties.Resources.ico_stopped; + else this.BackgroundImage = Properties.Resources.ico; if (!isElevated) { @@ -81,7 +102,7 @@ private void Form1_Load(object sender, EventArgs e) //hostUpdatesToolStripMenuItem.Enabled = false; } - + elevated = isElevated; } @@ -153,7 +174,14 @@ private void button3_Click(object sender, EventArgs e) if(this.WindowState == FormWindowState.Minimized) { this.Hide(); - notifyIcon1.Visible = true; + System.IntPtr icH = Properties.Resources.ico_stopped_small.GetHicon(); + Icon icoStopped = Icon.FromHandle(icH); + icH = Properties.Resources.ico_small.GetHicon(); + Icon icoStarted = Icon.FromHandle(icH); + + if (status == 0) notifyIcon1.Icon = icoStopped; + else notifyIcon1.Icon = icoStarted; + notifyIcon1.Visible = true; } } @@ -194,8 +222,14 @@ private void start() { string location = "C:\\Windows\\System32\\drivers\\etc\\hosts"; string backup = "C:\\Windows\\System32\\drivers\\etc\\hosts.backupAdCatch"; - + if (File.Exists(backup) && this.status == 0) + { + File.Delete(location); + System.IO.File.Copy(backup, location); + File.Delete(backup); + this.status = 0; + } if (this.status == 1) MessageBox.Show("Service already started!"); if (this.status == 0) { @@ -213,8 +247,9 @@ private void start() File.WriteAllBytes(location, host); System.IO.File.AppendAllText(location, targ); System.IO.File.AppendAllText(location, oldhostcontent); //mette cio che c' era prima nell host - - MessageBox.Show("Service successfully started!"); + this.BackgroundImage = Properties.Resources.ico; + this.BackColor= System.Drawing.SystemColors.ActiveCaption; + //MessageBox.Show("Service successfully started!"); this.status = 1; } } @@ -226,7 +261,13 @@ private void stop() { string location = "C:\\Windows\\System32\\drivers\\etc\\hosts"; string backup = "C:\\Windows\\System32\\drivers\\etc\\hosts.backupAdCatch"; - + if (File.Exists(backup) && this.status==0) + { + File.Delete(location); + System.IO.File.Copy(backup, location); + File.Delete(backup); + this.status = 1; + } if (this.status == 0) MessageBox.Show("Service already stopped!"); if (this.status == 1) { @@ -234,24 +275,31 @@ private void stop() if (!File.Exists(backup)) { MessageBox.Show("Backup file not found"); } else if (File.Exists(location) && File.Exists(backup)) { - File.Delete(location); // + try { File.Delete(location); } + catch (Exception egeneric) + { + MessageBox.Show("Something went wrong. Try to manually restore backup"); + System.Diagnostics.Process.Start("C:\\Windows\\System32\\drivers\\etc\\"); + }// System.IO.File.Copy(backup, location); //ripristina backup File.Delete(backup); // - MessageBox.Show("Service successfully stopped!"); + this.BackgroundImage = Properties.Resources.ico_stopped; + this.BackColor = System.Drawing.SystemColors.ActiveBorder; + // MessageBox.Show("Service successfully stopped!"); this.status = 0; } } } - private void startAdCatchToolStripMenuItem_Click(object sender, EventArgs e) - { - start(); - } + //private void startAdCatchToolStripMenuItem_Click(object sender, EventArgs e) + //{ + // start(); + //} - private void stopAdCatchToolStripMenuItem_Click(object sender, EventArgs e) - { - stop(); - } + //private void stopAdCatchToolStripMenuItem_Click(object sender, EventArgs e) + //{ + // stop(); + //} private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { @@ -267,5 +315,24 @@ private void hostUpdatesToolStripMenuItem_Click(object sender, EventArgs e) { updatehost(); } + + private void OnOffButtonClick(object sender, EventArgs e) + { + if (!elevated) return; + else + { + if (startToolStripMenuItem.Text == "Start") + { + start(); + startToolStripMenuItem.Text = "Stop"; + } + else if (startToolStripMenuItem.Text == "Stop") + { + stop(); + startToolStripMenuItem.Text = "Start"; + } + } + + } } } diff --git a/Ad_Catch_v1.0/Properties/AssemblyInfo.cs b/Ad_Catch_v1.0/Properties/AssemblyInfo.cs index 19e2586..bef5be1 100644 --- a/Ad_Catch_v1.0/Properties/AssemblyInfo.cs +++ b/Ad_Catch_v1.0/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ // Le informazioni generali relative a un assembly sono controllate dal seguente // set di attributi. Modificare i valori di questi attributi per modificare le informazioni // associate a un assembly. -[assembly: AssemblyTitle("Ad_Catch_v1.881")] +[assembly: AssemblyTitle("Ad_Catch")] [assembly: AssemblyDescription("A simple undetectable Ad-Block")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("BurningHAM18")] -[assembly: AssemblyProduct("Ad_Catch_v1.881")] +[assembly: AssemblyProduct("Ad_Catch")] [assembly: AssemblyCopyright("Copyright © 2016 BurningHAM18")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // usando l'asterisco '*' come illustrato di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.0.0")] -[assembly: AssemblyFileVersion("1.8.0.0")] +[assembly: AssemblyVersion("1.8.0.1")] +[assembly: AssemblyFileVersion("1.8.0.1")] diff --git a/Ad_Catch_v1.0/Properties/Resources.Designer.cs b/Ad_Catch_v1.0/Properties/Resources.Designer.cs index 40db69d..ed6feb2 100644 --- a/Ad_Catch_v1.0/Properties/Resources.Designer.cs +++ b/Ad_Catch_v1.0/Properties/Resources.Designer.cs @@ -99,5 +99,25 @@ internal static System.Drawing.Bitmap ico_small { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ico_stopped { + get { + object obj = ResourceManager.GetObject("ico_stopped", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ico_stopped_small { + get { + object obj = ResourceManager.GetObject("ico_stopped_small", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Ad_Catch_v1.0/Properties/Resources.resx b/Ad_Catch_v1.0/Properties/Resources.resx index 2759fcd..b2accc8 100644 --- a/Ad_Catch_v1.0/Properties/Resources.resx +++ b/Ad_Catch_v1.0/Properties/Resources.resx @@ -130,4 +130,10 @@ ..\Resources\ico_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ico_stopped.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ico_stopped_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Ad_Catch_v1.0/Resources/ico_stopped.png b/Ad_Catch_v1.0/Resources/ico_stopped.png new file mode 100644 index 0000000..93f17c1 Binary files /dev/null and b/Ad_Catch_v1.0/Resources/ico_stopped.png differ diff --git a/Ad_Catch_v1.0/Resources/ico_stopped_small.png b/Ad_Catch_v1.0/Resources/ico_stopped_small.png new file mode 100644 index 0000000..d05e037 Binary files /dev/null and b/Ad_Catch_v1.0/Resources/ico_stopped_small.png differ diff --git a/Ad_Catch_v1.0/bin/Debug/Ad_Catch.exe b/Ad_Catch_v1.0/bin/Debug/Ad_Catch.exe index 230e2dc..cd0eee2 100644 Binary files a/Ad_Catch_v1.0/bin/Debug/Ad_Catch.exe and b/Ad_Catch_v1.0/bin/Debug/Ad_Catch.exe differ diff --git a/Ad_Catch_v1.0/bin/Debug/Ad_Catch.pdb b/Ad_Catch_v1.0/bin/Debug/Ad_Catch.pdb index b94acd1..f9d267f 100644 Binary files a/Ad_Catch_v1.0/bin/Debug/Ad_Catch.pdb and b/Ad_Catch_v1.0/bin/Debug/Ad_Catch.pdb differ diff --git a/Ad_Catch_v1.0/bin/Debug/Ad_Catch.vshost.exe.manifest b/Ad_Catch_v1.0/bin/Debug/Ad_Catch.vshost.exe.manifest new file mode 100644 index 0000000..3896b78 --- /dev/null +++ b/Ad_Catch_v1.0/bin/Debug/Ad_Catch.vshost.exe.manifest @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.FileListAbsolute.txt b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.FileListAbsolute.txt index 70b7c98..524c294 100644 --- a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.FileListAbsolute.txt +++ b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.FileListAbsolute.txt @@ -8,3 +8,4 @@ E:\GitHub\adcatch\Ad_Catch_v1.0\obj\Debug\Ad_Catch_v1._0.Properties.Resources.re E:\GitHub\adcatch\Ad_Catch_v1.0\obj\Debug\Ad_Catch.csproj.GenerateResource.Cache E:\GitHub\adcatch\Ad_Catch_v1.0\obj\Debug\Ad_Catch.exe E:\GitHub\adcatch\Ad_Catch_v1.0\obj\Debug\Ad_Catch.pdb +E:\GitHub\adcatch\Ad_Catch_v1.0\obj\Debug\Ad_Catch.csprojResolveAssemblyReference.cache diff --git a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.GenerateResource.Cache b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.GenerateResource.Cache index c41cfff..8f64376 100644 Binary files a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.GenerateResource.Cache and b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csproj.GenerateResource.Cache differ diff --git a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csprojResolveAssemblyReference.cache b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..8e190ae Binary files /dev/null and b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.csprojResolveAssemblyReference.cache differ diff --git a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.exe b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.exe index 230e2dc..cd0eee2 100644 Binary files a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.exe and b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.exe differ diff --git a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.pdb b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.pdb index b94acd1..f9d267f 100644 Binary files a/Ad_Catch_v1.0/obj/Debug/Ad_Catch.pdb and b/Ad_Catch_v1.0/obj/Debug/Ad_Catch.pdb differ diff --git a/Ad_Catch_v1.0/obj/Debug/Ad_Catch_v1._0.Properties.Resources.resources b/Ad_Catch_v1.0/obj/Debug/Ad_Catch_v1._0.Properties.Resources.resources index 3045d26..ce4b291 100644 Binary files a/Ad_Catch_v1.0/obj/Debug/Ad_Catch_v1._0.Properties.Resources.resources and b/Ad_Catch_v1.0/obj/Debug/Ad_Catch_v1._0.Properties.Resources.resources differ diff --git a/Ad_Catch_v1.0/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Ad_Catch_v1.0/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 417225b..9b0ab16 100644 Binary files a/Ad_Catch_v1.0/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Ad_Catch_v1.0/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Ad_Catch_v1.0/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll b/Ad_Catch_v1.0/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll index 18d2143..b55dcdd 100644 Binary files a/Ad_Catch_v1.0/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll and b/Ad_Catch_v1.0/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll differ diff --git a/Program/Ad_Catch.exe b/Program/Ad_Catch.exe index 230e2dc..cd0eee2 100644 Binary files a/Program/Ad_Catch.exe and b/Program/Ad_Catch.exe differ