private async void ApplyChanges_Click(object sender, RoutedEventArgs e) { var tb = (Button)e.OriginalSource; var vm = (MainViewModel)tb.DataContext; await Task.Run(() => { try { vm.IsRestarting = true; vm.SelectedDevice.ApplyChanges(); } catch { Dispatcher.Invoke(() => MessageBox.Show( "Failed to restart device. The settings have been saved, but couldn't be applied. " + "Please manually reconnect the device for the changes to become active.", "Device restart failed", MessageBoxButton.OK, MessageBoxImage.Exclamation )); } finally { vm.IsRestarting = false; } }); }
private void SaveToFile(bool saveAs = false) { var unixTimestamp = Convert.ToString(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMinutes, CultureInfo.InvariantCulture); var filename = $@"{string.Join("_", Title.Split())}_{unixTimestamp}.txt"; if (saveAs) { var saveFileDialog = new SaveFileDialog { Filter = "text files (*.txt)|*.txt|All files (*.*)|*.*", FilterIndex = 1, DefaultExt = "txt", FileName = filename, RestoreDirectory = true }; if (saveFileDialog.ShowDialog() == false) { return; } filename = saveFileDialog.FileName; } File.WriteAllText(filename, textBoxDebugOutput.Text); MessageBox.Show($"Debug report saved as {filename}", saveAs ? "Save As" : "Save"); }
private void InitializeApp(object sender, StartupEventArgs args) { Settings = Configuration.Load(); if (!Utilities.IsRunningAsAdministrator()) { AdonisMessageBox.Show("You need to run this program as administrator to use it!", "WxInjector"); Current.Shutdown(); } MainWindow = new WnMain(); MainWindow.Show(); }
private void MenuItemDeleteStoragePlace_OnClick(object sender, RoutedEventArgs e) { var storagePlace = (StoragePlace)StoragePlaceComboBox.SelectedItem; try { ApplicationDbContext.Instance.StoragePlaces.Remove(storagePlace); ApplicationDbContext.Instance.SaveChanges(); StoragePlaces.Remove(storagePlace); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { MessageBox.Show("To miejsce przechowywania jest przypisane do jakiejś książki, nie można go usunąć.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void MenuItemDeletePublisher_OnClick(object sender, RoutedEventArgs e) { var publisher = (PublishingHouse)PublisherComboBox.SelectedItem; try { ApplicationDbContext.Instance.PublishingHouses.Remove(publisher); ApplicationDbContext.Instance.SaveChanges(); PublishingHouses.Remove(publisher); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { MessageBox.Show("Ten wydawca jest przypisany do jakiejś książki, nie można go usunąć.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void MenuItemDeleteSeries_Click(object sender, RoutedEventArgs e) { var series = (Series)SeriesCombobox.SelectedItem; try { ApplicationDbContext.Instance.Series.Remove(series); ApplicationDbContext.Instance.SaveChanges(); SeriesList.Remove(series); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { MessageBox.Show("Istnieją książki należące do tej serii, nie można jej usunąć.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void Continue(object sender, RoutedEventArgs args) { var item = (ProcessItemBinding)ProcessList.SelectedItem; if (item == null) { AdonisMessageBox.Show("Select a process before continuing!", "WxInjector"); return; } SelectedProcessId = item.Id; SelectedProcessName = item.Name; DialogResult = true; Close(); }
private void ConfirmButton_Click(object sender, RoutedEventArgs e) { bool isIncorrect = false; if (!AuthorCombobox.Text.IsNullOrEmpty() && AuthorCombobox.Items.Cast <Author>().All(a => a.ToString() != AuthorCombobox.Text)) { AuthorCombobox.Text = string.Empty; MessageBox.Show("Wprowadzony autor nie istnieje. Użyj opcji dodaj autora.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); isIncorrect = true; } if (!SeriesCombobox.Text.IsNullOrEmpty() && SeriesCombobox.Items.Cast <Series>().All(a => a.ToString() != SeriesCombobox.Text)) { SeriesCombobox.Text = string.Empty; MessageBox.Show("Wprowadzona seria nie istnieje. Użyj opcji dodaj serię.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); isIncorrect = true; } if (!PublisherComboBox.Text.IsNullOrEmpty() && PublisherComboBox.Items.Cast <PublishingHouse>() .All(a => a.ToString() != PublisherComboBox.Text)) { PublisherComboBox.Text = string.Empty; MessageBox.Show("Wprowadzone wydawnictwo nie istnieje. Użyj opcji dodaj wydawnictwo.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); isIncorrect = true; } if (!StoragePlaceComboBox.Text.IsNullOrEmpty() && StoragePlaceComboBox.Items.Cast <StoragePlace>() .All(a => a.ToString() != StoragePlaceComboBox.Text)) { StoragePlaceComboBox.Text = string.Empty; MessageBox.Show( "Wprowadzone miejsce przechowywania nie istnieje. Użyj opcji dodaj miejsce przechowywania.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); isIncorrect = true; } if (!isIncorrect) { var myWindow = Window.GetWindow(this); myWindow.Close(); } }
private void InjectToProcess(object sender, RoutedEventArgs args) { if (!InjectButton.IsEnabled) { return; } if (DllFileList.SelectedItem == null || _targetProcessId <= 0) { AdonisMessageBox.Show("Select a DLL and a target process before injecting.", "WxInjector"); return; } try { var binding = (DllFileBinding)DllFileList.SelectedItem; var method = MethodBox.SelectedIndex switch { 1 => InjectionMethod.HijackThread, 2 => InjectionMethod.ManualMap, _ => InjectionMethod.CreateThread }; var flag = FlagBox.SelectedIndex switch { 1 => InjectionFlags.HideDllFromPeb, 2 => InjectionFlags.RandomiseDllHeaders, 3 => InjectionFlags.RandomiseDllName, _ => InjectionFlags.None }; _currentInjector = new Injector(_targetProcessId, binding.Path, method, flag); _currentInjector.InjectDll(); var message = "DLL has been injected into process!"; if (flag != InjectionFlags.HideDllFromPeb) { Dispatcher.Invoke(() => { InjectButton.IsEnabled = false; EjectButton.IsEnabled = true; }); message += " You can also eject the DLL from the process at will."; } AdonisMessageBox.Show($"Injection successful!\n\n{message}", "WxInjector"); } catch { AdonisMessageBox.Show("Injection unsuccessful!\n\nDLL has been injected into process! The DLL's architecture might not be the same as the target process's architecture. Restart and reselect the target process and try again.", "WxInjector"); } }
private async void UpdateCheck(bool auto) { //s.Execute("ShowWindow"); var github = new GitHubClient(new ProductHeaderValue("FLauncher")); github.Credentials = creds; Release release = new Release(); try { release = await github.Repository.Release.GetLatest("OliveOil1", "Flauncher"); } catch (Exception ex) { if (!auto) { MessageBox.Show(ex.Message, "Error"); } return; } if (release.TagName != File.ReadAllText(Directory.GetCurrentDirectory() + @"\version.txt")) { if (auto) { NotifyIcon1.ShowCustomBalloon(new UpdateBalloon(true, release.TagName), System.Windows.Controls.Primitives.PopupAnimation.Fade, 10000); } else { NotifyIcon1.ShowCustomBalloon(new UpdateBalloon(true, release.TagName), System.Windows.Controls.Primitives.PopupAnimation.Fade, 10000); } } else { if (!auto) { NotifyIcon1.ShowCustomBalloon(new UpdateBalloon(false), System.Windows.Controls.Primitives.PopupAnimation.Fade, 10000); } } }
private void EjectFromProcess(object sender, RoutedEventArgs args) { if (!EjectButton.IsEnabled) { return; } try { _currentInjector.EjectDll(); _currentInjector.Dispose(); AdonisMessageBox.Show("DLL has been ejected from process!", "WxInjector"); } catch { AdonisMessageBox.Show("Unable to eject from process! Restart the target process as an alternative.", "WxInjector"); } Dispatcher.Invoke(() => { InjectButton.IsEnabled = true; EjectButton.IsEnabled = false; }); }
private void ImportDll(object sender, RoutedEventArgs args) { var dialog = new OpenFileDialog { Filter = "Dynamic Link Library|*.dll", Multiselect = true }; if (dialog.ShowDialog() != true) { return; } var items = DllFileList.Items.OfType <DllFileBinding>().ToArray(); try { foreach (var path in dialog.FileNames) { var alreadyExisted = false; foreach (var item in items) { if (item.Path == path) { alreadyExisted = true; } } if (alreadyExisted) { continue; } var binding = DllFileBinding.Create(path); DllFileList.Items.Add(binding); App.Settings.DllFiles = DllFileList.Items.OfType <DllFileBinding>().ToArray(); } UpdateDllSelection(null, null); } catch { AdonisMessageBox.Show("Import unsuccessful! The file might be invalid or unreadable.", "WxInjector"); } }
private void Input_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { ParamsPopup.IsOpen = !ParamsPopup.IsOpen; ParamsPopup.Width = Width; ParamsBox.Text = ""; if (ParamsPopup.IsOpen == true) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { ParamsBox.Focus(); // Set Logical Focus Keyboard.Focus(ParamsBox); // Set Keyboard Focus })); } else { Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { Input.Focus(); // Set Logical Focus Keyboard.Focus(Input); // Set Keyboard Focus })); } } if (e.Key == Key.Enter) { textEntered = Input.Text.ToLower(); args = ParamsBox.Text; bool inputHandled = false; foreach (IPlugin plugin in plugins) { try { inputHandled = plugin.CommandEntered(textEntered, ParamsBox.Text); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } if (inputHandled == true) { return; } Process process = new Process(); ProcessStartInfo processStartInfo = new ProcessStartInfo(); foreach (Alias _alias in aliases) { //MessageBox.Show(_alias.alias + " " +_alias.full_path); if (textEntered == _alias.alias.ToLower()) { textEntered = _alias.full_path; if (args == "") { args = _alias.parameters; } break; } else if (textEntered.StartsWith(_alias.alias.ToLower() + "/")) { string sub = textEntered.Substring(textEntered.IndexOf('/')); textEntered = _alias.full_path + sub.Trim('/'); break; } } processStartInfo.FileName = textEntered; processStartInfo.UseShellExecute = true; processStartInfo.Arguments = args; processStartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { processStartInfo.Verb = "runas"; } //processStartInfo.Arguments = "/c " + textEntered; process.StartInfo = processStartInfo; Visibility = Visibility.Hidden; try { process.Start(); ParamsPopup.IsOpen = false; ParamsBox.Text = ""; } catch (Exception ex) { //MessageBox.Show(textEntered); MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Visibility = Visibility.Visible; Activate(); Input.Focus(); } } if (e.Key == Key.F5) { Reload(); MessageBox.Show("Refreshed Application List", "Refreshed", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void RefreshAliases_Click(object sender, RoutedEventArgs e) { Reload(); MessageBox.Show("Refreshed Application List", "Refreshed", MessageBoxButton.OK, MessageBoxImage.Information); }
private void Reload() { try { Input.Items.Clear(); aliases = new List <Alias>(); var FODLERID_AppsFolder = new Guid("{1e87508d-89c2-42f0-8a7e-645a0f50ca58}"); ShellObject appsFolder = (ShellObject)KnownFolderHelper.FromKnownFolderId(FODLERID_AppsFolder); foreach (var app in (IKnownFolder)appsFolder) { // The friendly app name string name = app.Name; // The ParsingName property is the AppUserModelID string appUserModelID = app.ParsingName; // or app.Properties.System.AppUserModel.ID // You can even get the Jumbo icon in one shot //ImageSource icon = app.Thumbnail.ExtraLargeBitmapSource; var new_alias = new Alias { alias = name, full_path = "explorer.exe", parameters = @"shell:appsFolder\" + appUserModelID }; aliases.Add(new_alias); } List <String> searchDirs = new List <string>() { Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) }; List <String> shortcuts = new List <string>(); foreach (String dir in searchDirs) { shortcuts.AddRange(Directory.GetFiles(dir, "*", SearchOption.AllDirectories)); } foreach (String shortcut in shortcuts) { var new_alias = new Alias { alias = Path.GetFileNameWithoutExtension(shortcut), full_path = shortcut }; //MessageBox.Show("|" + new_alias.alias + "|" + " " + new_alias.full_path); bool exists = false; foreach (var _alias in aliases) { if (_alias.alias == new_alias.alias) { exists = true; _alias.alias = new_alias.alias; _alias.full_path = new_alias.full_path; _alias.parameters = ""; //MessageBox.Show(_alias.alias); } } if (exists == false) { aliases.Add(new_alias); } } aliases.Sort((x, y) => string.Compare(y.alias, x.alias)); var reader = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/FLauncher" + "/Aliases.csv"); var csv = new CsvReader(reader, CultureInfo.InvariantCulture); var records = csv.GetRecords <Alias>(); var recordlist = records.ToList(); aliases.AddRange(recordlist); aliases.Reverse(); foreach (Alias _alias in aliases) { if (_alias.alias != "" && !_alias.alias.ToLower().StartsWith("uninstall")) { ComboBoxItem comboBoxItem = new ComboBoxItem(); if (_alias.alias.Length > 21) { comboBoxItem.Content = _alias.alias; //.Substring(0, 18) + "..."; } else { comboBoxItem.Content = _alias.alias; } comboBoxItem.ToolTip = _alias.alias; Input.Items.Add(comboBoxItem); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }