private void UnPatchBtn_Click(object sender, RoutedEventArgs e) { PatchBtn.IsEnabled = UnPatchBtn.IsEnabled = false; try { List <InstallationPaths> installPaths = new List <InstallationPaths>(); foreach (CustomCheckBox installBox in InstallationList.Items) { installPaths.Add(new InstallationPaths(installBox.Content.ToString(), installBox.ToolTip.ToString().Split(new string[] { " & " }, StringSplitOptions.None)[1])); // chromeExePath is always in the ToolTip after " & " } PatcherInstaller installer = new PatcherInstaller(installPaths); if (installer.UninstallAll(Log)) { foreach (CustomCheckBox installBox in InstallationList.Items) { if (installBox.IsChecked == true) { installBox.Foreground = installBox.BorderBrush = new SolidColorBrush(Color.FromRgb(72, 207, 133)); } } } } catch (Exception ex) { Log("Error while uninstalling:" + ex.Message); } PatchBtn.IsEnabled = UnPatchBtn.IsEnabled = true; }
private void OnInstall(object sender, RoutedEventArgs e) { this.DisableButtons(true); List <int> disabledGroups = new List <int>(); // Get all disabled patch groups from the UI foreach (SelectionListElement element in this.mainModel.PatchListModel.ElementList) { if (element is PatchGroupElement { IsSelected: false } patchGroup) { disabledGroups.Add(patchGroup.Group); } } new Thread((() => { try { List <InstallationPaths> installPaths = this.GetEnabledInstallationPaths(); PatcherInstaller installer = new PatcherInstaller(installPaths); if (installer.Install(this.Log, disabledGroups)) { foreach (InstallationPaths paths in installPaths) { this.Log($"Successfully installed to {paths.ChromeExePath}", Brushes.Green); } } } catch (Exception exception) { this.Log("Error while installing: " + exception.Message, Brushes.Red); } this.DisableButtons(false); })).Start(); }
private void PatchBtn_Click(object sender, RoutedEventArgs e) { PatchBtn.IsEnabled = UnPatchBtn.IsEnabled = false; Program.bytePatchManager.DisabledGroups.Clear(); foreach (CustomCheckBox patchBox in PatchGroupList.Items) { if (patchBox.IsChecked == false) { Program.bytePatchManager.DisabledGroups.Add(patchBox.Group); } } try { List <InstallationPaths> installPaths = new List <InstallationPaths>(); foreach (CustomCheckBox installBox in InstallationList.Items) { if (installBox.IsChecked == true) { installPaths.Add(new InstallationPaths(installBox.Content.ToString(), installBox.ToolTip.ToString().Split(new string[] { " & " }, StringSplitOptions.None)[1])); } } PatcherInstaller installer = new PatcherInstaller(installPaths); if (installer.Install(Log)) { foreach (CustomCheckBox installBox in InstallationList.Items) { if (installBox.IsChecked == true) { installBox.Foreground = installBox.BorderBrush = new SolidColorBrush(Color.FromRgb(72, 207, 133)); } } } } catch (Exception ex) { Log("Error while installing:" + ex.Message); } PatchBtn.IsEnabled = UnPatchBtn.IsEnabled = true; }
private void OnUninstall(object sender, RoutedEventArgs e) { this.DisableButtons(true); new Thread((() => { try { List <InstallationPaths> installPaths = this.GetEnabledInstallationPaths(); PatcherInstaller installer = new PatcherInstaller(installPaths); if (installer.UninstallAll(this.Log)) { foreach (InstallationPaths paths in installPaths) { this.Log($"Successfully uninstalled from {paths.ChromeExePath}", Brushes.Green); } } } catch (Exception exception) { this.Log("Error while uninstalling: " + exception.Message, Brushes.Red); } this.DisableButtons(false); })).Start(); }
public static void MainCmd(string[] args) { CommandLineOptions clOptions = null; ParserResult <CommandLineOptions> result = Parser.Default.ParseArguments <CommandLineOptions>(args).WithParsed(options => { clOptions = options; }); if (result.Tag == ParserResultType.NotParsed) { HelpText.AutoBuild(result); return; } if (clOptions == null) { return; } bytePatchManager = new BytePatchManager(CustomConsoleWrite); List <InstallationPaths> applicationPaths = new List <InstallationPaths>(); List <int> groups = new List <int>(clOptions.Groups); if (groups.Count == 0) { Console.WriteLine("Groups need to be defined. Use --help for help."); return; } if (clOptions.CustomPath != null && clOptions.CustomPath.Length > 0) { if (!Directory.Exists(clOptions.CustomPath)) { Console.WriteLine("CustomPath not found"); return; } applicationPaths.AddRange(new CustomPath(clOptions.CustomPath).FindInstallationPaths()); } else { applicationPaths.AddRange(new InstallationFinder.InstallationManager().FindAllChromiumInstallations()); } foreach (GuiPatchGroupData patchData in bytePatchManager.PatchGroups) { if (!groups.Contains(patchData.Group)) { bytePatchManager.DisabledGroups.Add(patchData.Group); } } if (applicationPaths.Count == 0) { Console.WriteLine("Error: No patchable browser files found!"); } try { PatcherInstaller installer = new PatcherInstaller(applicationPaths); installer.Install(Console.WriteLine); } catch (Exception ex) { Console.WriteLine("Error while installing patches: " + ex.Message); } if (!clOptions.NoWait) { Thread.Sleep(5000); // Wait a bit to let the user see the result } }
private static void MainCmd(string[] args) { CommandLineOptions?clOptions = null; ParserResult <CommandLineOptions> result = Parser.Default.ParseArguments <CommandLineOptions>(args).WithParsed(options => { clOptions = options; }); if (result.Tag == ParserResultType.NotParsed) // Show help if wrong/no arguments were given { HelpText.AutoBuild(result); return; } if (clOptions == null) { return; } SelectionListModel groupModel = new SelectionListModel(); // Required to store the grouped patches BytePatchManager = new BytePatchManager(CustomConsoleWrite, groupModel); List <InstallationPaths> applicationPaths = new List <InstallationPaths>(); List <int> groups = new List <int>(clOptions.Groups); List <int> disabledGroups = new List <int>(); if (groups.Count == 0) { Console.WriteLine("Groups need to be defined. Use --help for help."); return; } if (!string.IsNullOrEmpty(clOptions.CustomPath)) { if (!Directory.Exists(clOptions.CustomPath)) { Console.WriteLine("CustomPath not found"); return; } applicationPaths.AddRange(new CustomPath(clOptions.CustomPath).FindInstallationPaths()); } else { applicationPaths.AddRange(new InstallationManager().FindAllChromiumInstallations()); } foreach (SelectionListElement element in groupModel.ElementList) { if (element is PatchGroupElement patchGroup && !groups.Contains(patchGroup.Group)) { disabledGroups.Add(patchGroup.Group); } } if (applicationPaths.Count == 0) { Console.WriteLine("Error: No patchable browser files found!"); return; } try { PatcherInstaller installer = new PatcherInstaller(applicationPaths); installer.Install(Console.WriteLine, disabledGroups); } catch (Exception ex) { Console.WriteLine("Error while installing patches: " + ex.Message); } if (!clOptions.NoWait) { Thread.Sleep(5000); // Wait a bit to let the user see the result } }