Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Swotch9399 authored Nov 27, 2024
1 parent 76aea91 commit b09cbdb
Showing 1 changed file with 58 additions and 33 deletions.
91 changes: 58 additions & 33 deletions dnschanger/dnschanger/dnschanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public dnschanger()
InitializeComponent();
InitializeTrayMenu();
LoadAutoStartSetting();
Application.ApplicationExit += OnApplicationExit;
}

private void InitializeTrayMenu()
Expand All @@ -56,6 +57,11 @@ private void InitializeTrayMenu()
trayIcon.ContextMenuStrip = trayMenu;
}

private void OnApplicationExit(object sender, EventArgs e)
{
StopGoodbyeDPI();
}

protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
Expand Down Expand Up @@ -266,43 +272,15 @@ private void btnCheckForUpdates_Click(object sender, EventArgs e)

private void btnDeleteGoodbyeDPI_Click(object sender, EventArgs e)
{
try
if (IsProcessRunning("goodbyedpi") || IsProcessRunning("WinDivert"))
{
string downloadPath = Path.Combine(Path.GetTempPath(), "goodbyedpi-0.2.3rc3-2.zip");
string extractPath = Path.Combine(Path.GetTempPath(), "goodbyedpi-0.2.3rc3-2");

if (File.Exists(downloadPath))
{
try
{
File.Delete(downloadPath);
}

catch (Exception ex)
{
MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

if (Directory.Exists(extractPath))
{
try
{
Directory.Delete(extractPath, true);
}

catch (Exception ex)
{
MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

MessageBox.Show("GoodbyeDPI has been removed successfully.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
StopGoodbyeDPI();
DeleteGoodbyeDPI();
}

catch (Exception ex)
else
{
MessageBox.Show($"An error occurred: {ex.Message}", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
DeleteGoodbyeDPI();
}
}

Expand Down Expand Up @@ -402,6 +380,53 @@ private void StopGoodbyeDPI()
ExecuteCommand($"sc stop WinDivert");
}

private void DeleteGoodbyeDPI()
{
try
{
string downloadPath = Path.Combine(Path.GetTempPath(), "goodbyedpi-0.2.3rc3-2.zip");
string extractPath = Path.Combine(Path.GetTempPath(), "goodbyedpi-0.2.3rc3-2");

if (File.Exists(downloadPath))
{
try
{
File.Delete(downloadPath);
}

catch (Exception ex)
{
MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

if (Directory.Exists(extractPath))
{
try
{
Directory.Delete(extractPath, true);
}

catch (Exception ex)
{
MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

MessageBox.Show("GoodbyeDPI has been removed successfully.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

catch (Exception ex)
{
MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private bool IsProcessRunning(string processName)
{
return Process.GetProcessesByName(processName).Any();
}

private async void CheckForUpdates(object sender, EventArgs e)
{
try
Expand Down

0 comments on commit b09cbdb

Please sign in to comment.