private void LauncherOpenBtn_Click(object sender, RoutedEventArgs e) { IsEnabled = false; try { var launcherPath = Assembly.GetEntryAssembly().Location; if (!File.Exists(launcherPath)) { GenericMessageDialog.Show(Celeste_Launcher_Gui.Properties.Resources.WindowsFirewallHelperLauncherNotFound, DialogIcon.Error, DialogOptions.Ok); Close(); return; } //outbound_tcp var rule = FirewallHelper.RuleExist("celeste_launcher_outbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_launcher_outbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_launcher_outbound_tcp", launcherPath, FirewallDirection.Outbound, FirewallProtocol.TCP); } catch (Exception ex) { Logger.Error(ex, ex.Message); GenericMessageDialog.Show(Celeste_Launcher_Gui.Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok); } LoadFirewallRules(); IsEnabled = true; }
private void Btn_Fix_LauncherRules(object sender, EventArgs e) { Enabled = false; try { var launcherPath = Assembly.GetEntryAssembly().Location; if (!File.Exists(launcherPath)) { throw new FileNotFoundException("Launcher not found!", launcherPath); } //inbound_tcp var rule = FirewallHelper.RuleExist("celeste_launcher_inbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_launcher_inbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_launcher_inbound_tcp", launcherPath, FirewallDirection.Inbound, FirewallProtocol.TCP); //outbound_tcp rule = FirewallHelper.RuleExist("celeste_launcher_outbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_launcher_outbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_launcher_outbound_tcp", launcherPath, FirewallDirection.Outbound, FirewallProtocol.TCP); } catch (Exception ex) { MsgBox.ShowMessage( $"Error: {ex.Message}", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Error); } RefreshForm(); Enabled = true; }
private void SpartanOpenBtn_Click(object sender, RoutedEventArgs e) { IsEnabled = false; try { var path = !string.IsNullOrWhiteSpace(LegacyBootstrapper.UserConfig?.GameFilesPath) ? LegacyBootstrapper.UserConfig?.GameFilesPath : GameScannerManager.GetGameFilesRootPath(); var spartanPath = Path.Combine(path, "Spartan.exe"); if (!File.Exists(spartanPath)) { GenericMessageDialog.Show(Celeste_Launcher_Gui.Properties.Resources.WindowsFirewallHelperSpartanNotFound, DialogIcon.Error, DialogOptions.Ok); Close(); return; } //inbound_tcp var rule = FirewallHelper.RuleExist("celeste_spartan_inbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_inbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_spartan_inbound_tcp", spartanPath, FirewallDirection.Inbound, FirewallProtocol.TCP); //outbound_tcp rule = FirewallHelper.RuleExist("celeste_spartan_outbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_outbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_spartan_outbound_tcp", spartanPath, FirewallDirection.Outbound, FirewallProtocol.TCP); //inbound_udp rule = FirewallHelper.RuleExist("celeste_spartan_inbound_udp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_inbound_udp"); } FirewallHelper.AddApplicationRule("celeste_spartan_inbound_udp", spartanPath, FirewallDirection.Inbound, FirewallProtocol.UDP); //outbound_udp rule = FirewallHelper.RuleExist("celeste_spartan_outbound_udp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_outbound_udp"); } FirewallHelper.AddApplicationRule("celeste_spartan_outbound_udp", spartanPath, FirewallDirection.Outbound, FirewallProtocol.UDP); } catch (Exception ex) { Logger.Error(ex, ex.Message); GenericMessageDialog.Show(Celeste_Launcher_Gui.Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok); } LoadFirewallRules(); IsEnabled = true; }
private void Btn_Fix_SpartanRules_Click(object sender, EventArgs e) { Enabled = false; try { var path = !string.IsNullOrWhiteSpace(Program.UserConfig?.GameFilesPath) ? Program.UserConfig?.GameFilesPath : GameScannnerApi.GetGameFilesRootPath(); var spartanPath = Path.Combine(path, "Spartan.exe"); if (!File.Exists(spartanPath)) { throw new FileNotFoundException("Spartan.exe not found!", spartanPath); } //inbound_tcp var rule = FirewallHelper.RuleExist("celeste_spartan_inbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_inbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_spartan_inbound_tcp", spartanPath, FirewallDirection.Inbound, FirewallProtocol.TCP); //outbound_tcp rule = FirewallHelper.RuleExist("celeste_spartan_outbound_tcp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_outbound_tcp"); } FirewallHelper.AddApplicationRule("celeste_spartan_outbound_tcp", spartanPath, FirewallDirection.Outbound, FirewallProtocol.TCP); //inbound_udp rule = FirewallHelper.RuleExist("celeste_spartan_inbound_udp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_inbound_udp"); } FirewallHelper.AddApplicationRule("celeste_spartan_inbound_udp", spartanPath, FirewallDirection.Inbound, FirewallProtocol.UDP); //outbound_udp rule = FirewallHelper.RuleExist("celeste_spartan_outbound_udp"); if (rule) { FirewallHelper.RemoveRules("celeste_spartan_outbound_udp"); } FirewallHelper.AddApplicationRule("celeste_spartan_outbound_udp", spartanPath, FirewallDirection.Outbound, FirewallProtocol.UDP); } catch (Exception ex) { MsgBox.ShowMessage( $"Error: {ex.Message}", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Error); } RefreshForm(); Enabled = true; }