/// <summary> /// Create a DumpEnvironment with all current settings /// </summary> /// <returns>Filled DumpEnvironment instance</returns> private DumpEnvironment DetermineEnvironment() { // Populate the new environment var env = new DumpEnvironment() { // Paths to tools SubdumpPath = _options.SubDumpPath, DICPath = _options.DICPath, OutputDirectory = OutputDirectoryTextBox.Text, OutputFilename = OutputFilenameTextBox.Text, // Get the currently selected options Drive = DriveLetterComboBox.SelectedItem as Drive, DICParameters = new Parameters(ParametersTextBox.Text), QuietMode = _options.QuietMode, ParanoidMode = _options.ParanoidMode, ScanForProtection = _options.ScanForProtection, RereadAmountC2 = _options.RereadAmountForC2, System = SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem, Type = MediaTypeComboBox.SelectedItem as MediaType? }; // Fix and write back the paths env.FixOutputPaths(); OutputDirectoryTextBox.Text = env.OutputDirectory; OutputFilenameTextBox.Text = env.OutputFilename; return(env); }
/// <summary> /// Scan and show copy protection for the current disc /// </summary> private async void ScanAndShowProtection() { if (_env == null) { _env = DetermineEnvironment(); } if (_env.Drive.Letter != default(char)) { ViewModels.LoggerViewModel.VerboseLogLn("Scanning for copy protection in {0}", _env.Drive.Letter); var tempContent = StatusLabel.Content; StatusLabel.Content = "Scanning for copy protection... this might take a while!"; StartStopButton.IsEnabled = false; DiskScanButton.IsEnabled = false; CopyProtectScanButton.IsEnabled = false; string protections = await Validators.RunProtectionScanOnPath(_env.Drive.Letter + ":\\"); if (!ViewModels.LoggerViewModel.WindowVisible) { MessageBox.Show(protections, "Detected Protection", MessageBoxButton.OK, MessageBoxImage.Information); } ViewModels.LoggerViewModel.VerboseLog("Detected the following protections in {0}:\r\n\r\n{1}", _env.Drive.Letter, protections); StatusLabel.Content = tempContent; StartStopButton.IsEnabled = true; DiskScanButton.IsEnabled = true; CopyProtectScanButton.IsEnabled = true; } }
/// <summary> /// Create a DumpEnvironment with all current settings /// </summary> /// <returns>Filled DumpEnvironment instance</returns> private DumpEnvironment DetermineEnvironment() { // Populate the new environment var env = new DumpEnvironment(Options, OutputDirectoryTextBox.Text, OutputFilenameTextBox.Text, DriveLetterComboBox.SelectedItem as Drive, SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem, MediaTypeComboBox.SelectedItem as Element <MediaType>, ParametersTextBox.Text); // Disable automatic reprocessing of the textboxes until we're done RemovePathEventHandlers(); // Save the current cursor positions int outputDirectorySelectionStart = OutputDirectoryTextBox.SelectionStart; int outputFilenameSelectionStart = OutputFilenameTextBox.SelectionStart; // Set the new text OutputDirectoryTextBox.Text = env.OutputDirectory; OutputFilenameTextBox.Text = env.OutputFilename; // Set the cursor position back to where it was OutputDirectoryTextBox.SelectionStart = outputDirectorySelectionStart; OutputDirectoryTextBox.SelectionLength = 0; OutputFilenameTextBox.SelectionStart = outputFilenameSelectionStart; OutputFilenameTextBox.SelectionLength = 0; // Re-enable automatic reprocessing of textboxes AddPathEventHandlers(); return(env); }
/// <summary> /// Ensure information is consistent with the currently selected disc type /// </summary> private void EnsureDiscInformation() { // Get the current environment information _env = DetermineEnvironment(); // Take care of null cases if (_env.System == null) { _env.System = KnownSystem.NONE; } if (_env.Type == null) { _env.Type = MediaType.NONE; } // Get the status to write out Result result = Validators.GetSupportStatus(_env.System, _env.Type); StatusLabel.Content = result.Message; // Set the index for the current disc type SetCurrentDiscType(); StartStopButton.IsEnabled = result && (_drives != null && _drives.Count > 0 ? true : false); // If we're in a type that doesn't support drive speeds DriveSpeedComboBox.IsEnabled = _env.Type.DoesSupportDriveSpeed() && _env.System.DoesSupportDriveSpeed(); // Special case for Custom input if (_env.System == KnownSystem.Custom) { ParametersTextBox.IsEnabled = true; OutputFilenameTextBox.IsEnabled = false; OutputDirectoryTextBox.IsEnabled = false; OutputDirectoryBrowseButton.IsEnabled = false; DriveLetterComboBox.IsEnabled = false; DriveSpeedComboBox.IsEnabled = false; StartStopButton.IsEnabled = (_drives.Count > 0 ? true : false); StatusLabel.Content = "User input mode"; } else { ParametersTextBox.IsEnabled = false; OutputFilenameTextBox.IsEnabled = true; OutputDirectoryTextBox.IsEnabled = true; OutputDirectoryBrowseButton.IsEnabled = true; DriveLetterComboBox.IsEnabled = true; // Generate the full parameters from the environment string generated = _env.GetFullParameters((int?)DriveSpeedComboBox.SelectedItem); if (generated != null) { ParametersTextBox.Text = generated; } } }
public void FixOutputPathsTest(string outputDirectory, string outputFilename, string expectedOutputDirectory, string expectedOutputFilename) { var options = new Options() { InternalProgram = "dic" }; var env = new DumpEnvironment(options, outputDirectory, outputFilename, null, KnownSystem.IBMPCCompatible, MediaType.CDROM, string.Empty); env.FixOutputPaths(); Assert.Equal(expectedOutputDirectory, env.OutputDirectory); Assert.Equal(expectedOutputFilename, env.OutputFilename); }
public void FixOutputPathsTest(string outputDirectory, string outputFilename, string expectedOutputDirectory, string expectedOutputFilename) { var env = new DumpEnvironment { OutputDirectory = outputDirectory, OutputFilename = outputFilename, }; env.FixOutputPaths(); Assert.Equal(expectedOutputDirectory, env.OutputDirectory); Assert.Equal(expectedOutputFilename, env.OutputFilename); }
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType?mediaType, bool expected) { var env = new DumpEnvironment { DICParameters = new Parameters(parameters), Drive = isFloppy ? Drive.Floppy(letter) : Drive.Optical(letter, "", true), Type = mediaType, }; bool actual = env.ParametersValid(); Assert.Equal(expected, actual); }
public static void Main(string[] args) { // Try processing the standalone arguments if (ProcessStandaloneArguments(args)) return; // Try processing the common arguments (bool success, MediaType mediaType, RedumpSystem? knownSystem) = ProcessCommonArguments(args); if (!success) return; // Loop through and process options (Options options, string path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2); // Make new Progress objects var resultProgress = new Progress<Result>(); resultProgress.ProgressChanged += ProgressUpdated; var protectionProgress = new Progress<ProtectionProgress>(); protectionProgress.ProgressChanged += ProgressUpdated; // Validate the supplied credentials (bool? _, string message) = RedumpWebClient.ValidateCredentials(options?.RedumpUsername, options?.RedumpPassword); if (!string.IsNullOrWhiteSpace(message)) Console.WriteLine(message); // Loop through all the rest of the args for (int i = startIndex; i < args.Length; i++) { // Check for a file if (!File.Exists(args[i].Trim('"'))) { DisplayHelp($"{args[i].Trim('"')} does not exist"); return; } // Get the full file path string filepath = Path.GetFullPath(args[i].Trim('"')); // Now populate an environment Drive drive = null; if (!string.IsNullOrWhiteSpace(path)) drive = Drive.Create(null, path); var env = new DumpEnvironment(options, "", filepath, drive, knownSystem, mediaType, null); // Finally, attempt to do the output dance var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(result.Message); } }
public void AdjustForCustomConfigurationTest(string parameters, MediaType?expectedMediaType, KnownSystem?expectedKnownSystem, char expectedDriveLetter, string expectedOutputDirectory, string expectedOutputFilename) { var env = new DumpEnvironment { DICParameters = new Parameters(parameters), System = KnownSystem.Custom, }; env.AdjustForCustomConfiguration(); Assert.Equal(expectedMediaType, env.Type); Assert.Equal(expectedKnownSystem, env.System); Assert.Equal(expectedDriveLetter, env.Drive.Letter); Assert.Equal(expectedOutputDirectory, env.OutputDirectory); Assert.Equal(expectedOutputFilename, env.OutputFilename); }
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType?mediaType, bool expected) { var env = new DumpEnvironment { CreatorParameters = new CreatorParameters(parameters), Drive = isFloppy ? new Drive(InternalDriveType.Floppy, new DriveInfo(letter.ToString())) : new Drive(InternalDriveType.Optical, new DriveInfo(letter.ToString())), Type = mediaType, }; bool actual = env.ParametersValid(); Assert.Equal(expected, actual); }
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType?mediaType, bool expected) { var options = new Options() { InternalProgram = "dic" }; var drive = isFloppy ? new Drive(InternalDriveType.Floppy, new DriveInfo(letter.ToString())) : new Drive(InternalDriveType.Optical, new DriveInfo(letter.ToString())); var env = new DumpEnvironment(options, string.Empty, string.Empty, drive, KnownSystem.IBMPCCompatible, mediaType, parameters); bool actual = env.ParametersValid(); Assert.Equal(expected, actual); }
/// <summary> /// Create a DumpEnvironment with all current settings /// </summary> /// <returns>Filled DumpEnvironment instance</returns> private DumpEnvironment DetermineEnvironment() { // Populate the new environment var env = new DumpEnvironment() { // Paths to tools SubdumpPath = _options.SubDumpPath, DICPath = _options.DICPath, OutputDirectory = OutputDirectoryTextBox.Text, OutputFilename = OutputFilenameTextBox.Text, // Get the currently selected options Drive = DriveLetterComboBox.SelectedItem as Drive, DICParameters = new Parameters(ParametersTextBox.Text), QuietMode = _options.QuietMode, ParanoidMode = _options.ParanoidMode, ScanForProtection = _options.ScanForProtection, RereadAmountC2 = _options.RereadAmountForC2, AddPlaceholders = _options.AddPlaceholders, PromptForDiscInformation = _options.PromptForDiscInformation, Username = _options.Username, Password = _options.Password, System = SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem, Type = MediaTypeComboBox.SelectedItem as MediaType?, }; // Fix the output paths env.FixOutputPaths(); // Disable automatic reprocessing of the textboxes until we're done OutputDirectoryTextBox.TextChanged -= OutputDirectoryTextBoxTextChanged; OutputFilenameTextBox.TextChanged -= OutputFilenameTextBoxTextChanged; OutputDirectoryTextBox.Text = env.OutputDirectory; OutputFilenameTextBox.Text = env.OutputFilename; OutputDirectoryTextBox.TextChanged += OutputDirectoryTextBoxTextChanged; OutputFilenameTextBox.TextChanged += OutputFilenameTextBoxTextChanged; return(env); }
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType?mediaType, bool expected) { var options = new Options() { InternalProgram = InternalProgram.DiscImageCreator }; // TODO: This relies on creating real objects for the drive. Can we mock this out instead? var drive = isFloppy ? Drive.Create(InternalDriveType.Floppy, letter.ToString()) : Drive.Create(InternalDriveType.Optical, letter.ToString()); var env = new DumpEnvironment(options, string.Empty, string.Empty, drive, RedumpSystem.IBMPCcompatible, mediaType, parameters); bool actual = env.ParametersValid(); Assert.Equal(expected, actual); }
/// <summary> /// Begin the dumping process using the given inputs /// </summary> private async void StartDumping() { _env = DetermineEnvironment(); try { // Check for the firmware first // TODO: Remove this (and method) once DIC end-to-end logging becomes a thing if (!await _env.DriveHasLatestFimrware()) { return; } StartStopButton.Content = UIElements.StopDumping; CopyProtectScanButton.IsEnabled = false; StatusLabel.Content = "Beginning dumping process"; ViewModels.LoggerViewModel.VerboseLogLn("Starting dumping process.."); var progress = new Progress <Result>(); progress.ProgressChanged += ProgressUpdated; Result result = await _env.StartDumping(progress); StatusLabel.Content = result ? "Dumping complete!" : result.Message; ViewModels.LoggerViewModel.VerboseLogLn(result ? "Dumping complete!" : result.Message); } catch { // No-op, we don't care what it was } finally { StartStopButton.Content = UIElements.StartDumping; CopyProtectScanButton.IsEnabled = true; } if (EjectWhenDoneCheckBox.IsChecked == true) { _env.EjectDisc(); } }
/// <summary> /// Scan and show copy protection for the current disc /// </summary> private async void ScanAndShowProtection() { if (_env == null) { _env = DetermineEnvironment(); } if (_env.Drive.Letter != default(char)) { ViewModels.LoggerViewModel.VerboseLogLn("Scanning for copy protection in {0}", _env.Drive.Letter); var tempContent = StatusLabel.Content; StatusLabel.Content = "Scanning for copy protection... this might take a while!"; StartStopButton.IsEnabled = false; DiskScanButton.IsEnabled = false; CopyProtectScanButton.IsEnabled = false; string protections = await Validators.RunProtectionScanOnPath(_env.Drive.Letter + ":\\"); // If SmartE is detected on the current disc, remove `/sf` from the flags if (protections.Contains("SmartE")) { _env.CreatorParameters[CreatorFlag.ScanFileProtect] = false; ViewModels.LoggerViewModel.VerboseLogLn($"SmartE detected, removing {CreatorFlagStrings.ScanFileProtect} from parameters"); } if (!ViewModels.LoggerViewModel.WindowVisible) { MessageBox.Show(protections, "Detected Protection", MessageBoxButton.OK, MessageBoxImage.Information); } ViewModels.LoggerViewModel.VerboseLog("Detected the following protections in {0}:\r\n\r\n{1}", _env.Drive.Letter, protections); StatusLabel.Content = tempContent; StartStopButton.IsEnabled = true; DiskScanButton.IsEnabled = true; CopyProtectScanButton.IsEnabled = true; } }
/// <summary> /// Ensure information is consistent with the currently selected disc type /// </summary> private void EnsureDiscInformation() { // Get the current environment information _env = DetermineEnvironment(); // Take care of null cases if (_env.System == null) { _env.System = KnownSystem.NONE; } if (_env.Type == null) { _env.Type = MediaType.NONE; } // Get the status to write out Result result = Validators.GetSupportStatus(_env.System, _env.Type); StatusLabel.Text = result.Message; // Set the index for the current disc type SetCurrentDiscType(); StartStopButton.Enabled = result && (_drives != null && _drives.Count > 0 ? true : false); // If we're in a type that doesn't support drive speeds DriveSpeedComboBox.Enabled = _env.Type.DoesSupportDriveSpeed(); // If input params are not enabled, generate the full parameters from the environment if (!ParametersTextBox.Enabled) { string generated = _env.GetFullParameters((int?)DriveSpeedComboBox.SelectedItem); if (generated != null) { ParametersTextBox.Text = generated; } } }
/// <summary> /// Create a DumpEnvironment with all current settings /// </summary> /// <returns>Filled DumpEnvironment instance</returns> private DumpEnvironment DetermineEnvironment() { // Populate the new environment var env = new DumpEnvironment(UIOptions.Options, this.Find <TextBox>("OutputDirectoryTextBox").Text, this.Find <TextBox>("OutputFilenameTextBox").Text, this.Find <ComboBox>("DriveLetterComboBox").SelectedItem as Drive, this.Find <ComboBox>("SystemTypeComboBox").SelectedItem as KnownSystemComboBoxItem, this.Find <ComboBox>("MediaTypeComboBox").SelectedItem as MediaType?, this.Find <TextBox>("ParametersTextBox").Text); // Disable automatic reprocessing of the textboxes until we're done this.Find <TextBox>("OutputDirectoryTextBox").TextInput -= OutputDirectoryTextBoxTextChanged; this.Find <TextBox>("OutputFilenameTextBox").TextInput -= OutputFilenameTextBoxTextChanged; this.Find <TextBox>("OutputDirectoryTextBox").Text = env.OutputDirectory; this.Find <TextBox>("OutputFilenameTextBox").Text = env.OutputFilename; this.Find <TextBox>("OutputDirectoryTextBox").TextInput += OutputDirectoryTextBoxTextChanged; this.Find <TextBox>("OutputFilenameTextBox").TextInput += OutputFilenameTextBoxTextChanged; return(env); }
/// <summary> /// Create a DumpEnvironment with all current settings /// </summary> /// <returns>Filled DumpEnvironment instance</returns> private DumpEnvironment DetermineEnvironment() { // Populate the new environment var env = new DumpEnvironment(UIOptions.Options, OutputDirectoryTextBox.Text, OutputFilenameTextBox.Text, DriveLetterComboBox.SelectedItem as Drive, SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem, MediaTypeComboBox.SelectedItem as MediaType?, ParametersTextBox.Text); // Disable automatic reprocessing of the textboxes until we're done OutputDirectoryTextBox.TextChanged -= OutputDirectoryTextBoxTextChanged; OutputFilenameTextBox.TextChanged -= OutputFilenameTextBoxTextChanged; OutputDirectoryTextBox.Text = env.OutputDirectory; OutputFilenameTextBox.Text = env.OutputFilename; OutputDirectoryTextBox.TextChanged += OutputDirectoryTextBoxTextChanged; OutputFilenameTextBox.TextChanged += OutputFilenameTextBoxTextChanged; return(env); }
/// <summary> /// Begin the dumping process using the given inputs /// </summary> private async void StartDumping() { if (_env == null) { _env = DetermineEnvironment(); } // If still in custom parameter mode, check that users meant to continue or not if (EnableParametersCheckBox.IsChecked == true) { MessageBoxResult result = MessageBox.Show("It looks like you have custom parameters that have not been saved. Would you like to apply those changes before starting to dump?", "Custom Changes", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { EnableParametersCheckBox.IsChecked = false; ParametersTextBox.IsEnabled = false; ProcessCustomParameters(); } else if (result == MessageBoxResult.Cancel) { return; } // If "No", then we continue with the current known environment } try { // Check for the firmware first // TODO: Remove this (and method) once DIC end-to-end logging becomes a thing if (!await _env.DriveHasLatestFimrware()) { MessageBox.Show($"DiscImageCreator has reported that drive {_env.Drive.Letter} is not updated to the most recent firmware. Please update the firmware for your drive and try again.", "Outdated Firmware", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Validate that the user explicitly wants an inactive drive to be considered for dumping if (!_env.Drive.MarkedActive) { MessageBoxResult mbresult = MessageBox.Show("The currently selected drive does not appear to contain a disc! Are you sure you want to continue?", "Missing Disc", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (mbresult == MessageBoxResult.No || mbresult == MessageBoxResult.Cancel || mbresult == MessageBoxResult.None) { ViewModels.LoggerViewModel.VerboseLogLn("Dumping aborted!"); return; } } // If a complete dump already exists if (_env.FoundAllFiles()) { MessageBoxResult mbresult = MessageBox.Show("A complete dump already exists! Are you sure you want to overwrite?", "Overwrite?", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (mbresult == MessageBoxResult.No || mbresult == MessageBoxResult.Cancel || mbresult == MessageBoxResult.None) { ViewModels.LoggerViewModel.VerboseLogLn("Dumping aborted!"); return; } } StartStopButton.Content = Constants.StopDumping; CopyProtectScanButton.IsEnabled = false; StatusLabel.Content = "Beginning dumping process"; ViewModels.LoggerViewModel.VerboseLogLn("Starting dumping process.."); var progress = new Progress <Result>(); progress.ProgressChanged += ProgressUpdated; Result result = await _env.StartDumping(progress); StatusLabel.Content = result ? "Dumping complete!" : result.Message; ViewModels.LoggerViewModel.VerboseLogLn(result ? "Dumping complete!" : result.Message); } catch { // No-op, we don't care what it was } finally { StartStopButton.Content = Constants.StartDumping; CopyProtectScanButton.IsEnabled = true; } if (EjectWhenDoneCheckBox.IsChecked == true) { ViewModels.LoggerViewModel.VerboseLogLn($"Ejecting disc in drive {_env.Drive.Letter}"); _env.EjectDisc(); } }
public static void Main(string[] args) { // Help options if (args.Length == 0 || args[0] == "/h" || args[0] == "/?" || args[0] == "-h" || args[0] == "-?") { DisplayHelp(); return; } // List options if (args[0] == "/lm" || args[0] == "/listmedia" || args[0] == "-lm" || args[0] == "--listmedia") { ListMediaTypes(); Console.ReadLine(); return; } else if (args[0] == "/ls" || args[0] == "/listsystems" || args[0] == "-ls" || args[0] == "--listsystems") { ListKnownSystems(); Console.ReadLine(); return; } // Normal operation check if (args.Length < 3) { DisplayHelp("Invalid number of arguments"); return; } // Check the MediaType var mediaType = Converters.StringToMediaType(args[0].Trim('"')); if (mediaType == MediaType.NONE) { DisplayHelp($"{args[0]} is not a recognized media type"); return; } // Check the KnownSystem var knownSystem = Converters.StringToKnownSystem(args[1].Trim('"')); if (knownSystem == KnownSystem.NONE) { DisplayHelp($"{args[1]} is not a recognized system"); return; } // Check for Redump login credentials string username = null, password = null; int startIndex = 2; if (args[2] == "-c" || args[2] == "--credentials") { username = args[3]; password = args[4]; startIndex = 5; } // Make a new Progress object var progress = new Progress <Result>(); progress.ProgressChanged += ProgressUpdated; // Loop through all the rest of the args for (int i = startIndex; i < args.Length; i++) { // Check for a file if (!File.Exists(args[i])) { DisplayHelp($"{args[i]} does not exist"); return; } // Get the full file path string filepath = Path.GetFullPath(args[i]); // Now populate an environment var env = new DumpEnvironment { OutputDirectory = "", OutputFilename = filepath, System = knownSystem, Type = mediaType, ScanForProtection = false, PromptForDiscInformation = false, Username = username, Password = password, }; env.FixOutputPaths(); // Finally, attempt to do the output dance var result = env.VerifyAndSaveDumpOutput(progress); Console.WriteLine(result.Message); } }
/// <summary> /// Begin the dumping process using the given inputs /// </summary> private async void StartDumping() { if (_env == null) { _env = DetermineEnvironment(); } // If still in custom parameter mode, check that users meant to continue or not if (EnableParametersCheckBox.IsChecked == true) { MessageBoxResult result = MessageBox.Show("It looks like you have custom parameters that have not been saved. Would you like to apply those changes before starting to dump?", "Custom Changes", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { EnableParametersCheckBox.IsChecked = false; ParametersTextBox.IsEnabled = false; ProcessCustomParameters(); } else if (result == MessageBoxResult.Cancel) { return; } // If "No", then we continue with the current known environment } // Fix the output paths _env.FixOutputPaths(); try { // Check for the firmware first for DiscImageCreator // TODO: Remove this (and method) once DIC end-to-end logging becomes a thing if (!_env.UseChef && !await _env.DriveHasLatestFimrware()) { MessageBox.Show($"DiscImageCreator has reported that drive {_env.Drive.Letter} is not updated to the most recent firmware. Please update the firmware for your drive and try again.", "Outdated Firmware", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Validate that the user explicitly wants an inactive drive to be considered for dumping if (!_env.Drive.MarkedActive) { MessageBoxResult mbresult = MessageBox.Show("The currently selected drive does not appear to contain a disc! Are you sure you want to continue?", "Missing Disc", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (mbresult == MessageBoxResult.No || mbresult == MessageBoxResult.Cancel || mbresult == MessageBoxResult.None) { ViewModels.LoggerViewModel.VerboseLogLn("Dumping aborted!"); return; } } // If a complete dump already exists if (_env.FoundAllFiles()) { MessageBoxResult mbresult = MessageBox.Show("A complete dump already exists! Are you sure you want to overwrite?", "Overwrite?", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (mbresult == MessageBoxResult.No || mbresult == MessageBoxResult.Cancel || mbresult == MessageBoxResult.None) { ViewModels.LoggerViewModel.VerboseLogLn("Dumping aborted!"); return; } } StartStopButton.Content = Constants.StopDumping; CopyProtectScanButton.IsEnabled = false; StatusLabel.Content = "Beginning dumping process"; ViewModels.LoggerViewModel.VerboseLogLn("Starting dumping process.."); var progress = new Progress <Result>(); progress.ProgressChanged += ProgressUpdated; Result result = await _env.Run(progress); // If we didn't execute a dumping command we cannot get submission output bool isDumpingCommand = false; if (_env.UseChef) { isDumpingCommand = _env.ChefParameters.IsDumpingCommand(); } else { isDumpingCommand = _env.CreatorParameters.IsDumpingCommand(); } if (!isDumpingCommand) { ViewModels.LoggerViewModel.VerboseLogLn("No dumping command was run, submission information will not be gathered."); StatusLabel.Content = "Execution complete!"; StartStopButton.Content = Constants.StartDumping; CopyProtectScanButton.IsEnabled = true; return; } if (result) { // TODO: Remove Chef handling when irrelevant if (_env.UseChef) { ViewModels.LoggerViewModel.VerboseLogLn("DiscImageChef does not support split tracks or DiscImageCreator-compatible outputs"); ViewModels.LoggerViewModel.VerboseLogLn("No automatic submission information will be gathered for this disc"); } else { // Verify dump output and save it result = _env.VerifyAndSaveDumpOutput(progress, EjectWhenDoneCheckBox.IsChecked, _options.ResetDriveAfterDump, (si) => { // lazy initialization if (_discInformationWindow == null) { _discInformationWindow = new DiscInformationWindow(this, si); _discInformationWindow.Closed += delegate { _discInformationWindow = null; }; } _discInformationWindow.Owner = this; _discInformationWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; _discInformationWindow.Refresh(); return(_discInformationWindow.ShowDialog()); } ); } } StatusLabel.Content = result ? "Dumping complete!" : result.Message; ViewModels.LoggerViewModel.VerboseLogLn(result ? "Dumping complete!" : result.Message); } catch { // No-op, we don't care what it was } finally { StartStopButton.Content = Constants.StartDumping; CopyProtectScanButton.IsEnabled = true; } }
public static void Main(string[] args) { // Help options if (args.Length == 0 || args[0] == "-h" || args[0] == "-?") { DisplayHelp(); return; } // List options if (args[0] == "-lm" || args[0] == "--listmedia") { ListMediaTypes(); Console.ReadLine(); return; } else if (args[0] == "-lp" || args[0] == "--listprograms") { ListPrograms(); Console.ReadLine(); return; } else if (args[0] == "-ls" || args[0] == "--listsystems") { ListSystems(); Console.ReadLine(); return; } // Normal operation check if (args.Length < 3) { DisplayHelp("Invalid number of arguments"); return; } // Check the MediaType var mediaType = EnumConverter.ToMediaType(args[0].Trim('"')); if (mediaType == MediaType.NONE) { DisplayHelp($"{args[0]} is not a recognized media type"); return; } // Check the RedumpSystem var knownSystem = Extensions.ToRedumpSystem(args[1].Trim('"')); if (knownSystem == null) { DisplayHelp($"{args[1]} is not a recognized system"); return; } // Default values string username = null, password = null; string internalProgram = "DiscImageCreator"; string path = string.Empty; bool scan = false, compress = false; // Loop through and process options int startIndex = 2; for (; startIndex < args.Length; startIndex++) { // Redump login if (args[startIndex].StartsWith("-c=") || args[startIndex].StartsWith("--credentials=")) { string[] credentials = args[startIndex].Split('=')[1].Split(';'); username = credentials[0]; password = credentials[1]; } else if (args[startIndex] == "-c" || args[startIndex] == "--credentials") { username = args[startIndex + 1]; password = args[startIndex + 2]; startIndex += 2; } // Use specific program else if (args[startIndex].StartsWith("-u=") || args[startIndex].StartsWith("--use=")) { internalProgram = args[startIndex].Split('=')[1]; } else if (args[startIndex] == "-u" || args[startIndex] == "--use") { internalProgram = args[startIndex + 1]; startIndex++; } // Use a device path for physical checks else if (args[startIndex].StartsWith("-p=") || args[startIndex].StartsWith("--path=")) { path = args[startIndex].Split('=')[1]; } else if (args[startIndex] == "-p" || args[startIndex] == "--path") { path = args[startIndex + 1]; startIndex++; } // Scan for protection (requires device path) else if (args[startIndex].StartsWith("-s") || args[startIndex].StartsWith("--scan")) { scan = true; } // Compress log and extraneous files else if (args[startIndex].StartsWith("-z") || args[startIndex].StartsWith("--zip")) { compress = true; } // Default, we fall out else { break; } } // Make new Progress objects var resultProgress = new Progress<Result>(); resultProgress.ProgressChanged += ProgressUpdated; var protectionProgress = new Progress<ProtectionProgress>(); protectionProgress.ProgressChanged += ProgressUpdated; // If credentials are invalid, alert the user if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) { using (RedumpWebClient wc = new RedumpWebClient()) { bool? loggedIn = wc.Login(username, password); if (loggedIn == true) Console.WriteLine("Redump username and password accepted!"); else if (loggedIn == false) Console.WriteLine("Redump username and password denied!"); else Console.WriteLine("An error occurred validating your crendentials!"); } } // Loop through all the rest of the args for (int i = startIndex; i < args.Length; i++) { // Check for a file if (!File.Exists(args[i].Trim('"'))) { DisplayHelp($"{args[i].Trim('"')} does not exist"); return; } // Get the full file path string filepath = Path.GetFullPath(args[i].Trim('"')); // Now populate an environment var options = new Options { InternalProgram = EnumConverter.ToInternalProgram(internalProgram), ScanForProtection = scan && !string.IsNullOrWhiteSpace(path), PromptForDiscInformation = false, ShowDiscEjectReminder = false, CompressLogFiles = compress, RedumpUsername = username, RedumpPassword = password, }; Drive drive = null; if (!string.IsNullOrWhiteSpace(path)) drive = new Drive(null, new DriveInfo(path)); var env = new DumpEnvironment(options, "", filepath, drive, knownSystem, mediaType, null); // Finally, attempt to do the output dance var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(result.Message); } }
public void FixOutputPathsTest(string outputDirectory, string outputFilename, string expectedOutputDirectory, string expectedOutputFilename) { (string actualOutputDirectory, string actualOutputFilename) = DumpEnvironment.NormalizeOutputPaths(outputDirectory, outputFilename, false); Assert.Equal(expectedOutputDirectory, actualOutputDirectory); Assert.Equal(expectedOutputFilename, actualOutputFilename); }
/// <summary> /// Process the current custom parameters back into UI values /// </summary> private void ProcessCustomParameters() { Env.SetParameters(ParametersTextBox.Text); if (Env.Parameters == null) { return; } int driveIndex = Drives.Select(d => d.Letter).ToList().IndexOf(Env.Parameters.InputPath[0]); if (driveIndex > -1) { DriveLetterComboBox.SelectedIndex = driveIndex; } int driveSpeed = Env.Parameters.Speed ?? -1; if (driveSpeed > 0) { DriveSpeedComboBox.SelectedValue = driveSpeed; } else { Env.Parameters.Speed = DriveSpeedComboBox.SelectedValue as int?; } // Disable automatic reprocessing of the textboxes until we're done RemovePathEventHandlers(); // Save the current cursor positions int outputDirectorySelectionStart = OutputDirectoryTextBox.SelectionStart; int outputFilenameSelectionStart = OutputFilenameTextBox.SelectionStart; string trimmedPath = Env.Parameters.OutputPath?.Trim('"') ?? string.Empty; string outputDirectory = Path.GetDirectoryName(trimmedPath); string outputFilename = Path.GetFileName(trimmedPath); (outputDirectory, outputFilename) = DumpEnvironment.NormalizeOutputPaths(outputDirectory, outputFilename, Options.InternalProgram == InternalProgram.DiscImageCreator); if (!string.IsNullOrWhiteSpace(outputDirectory)) { OutputDirectoryTextBox.Text = outputDirectory; } else { outputDirectory = OutputDirectoryTextBox.Text; } if (!string.IsNullOrWhiteSpace(outputFilename)) { OutputFilenameTextBox.Text = outputFilename; } else { outputFilename = OutputFilenameTextBox.Text; } // Set the cursor position back to where it was OutputDirectoryTextBox.SelectionStart = outputDirectorySelectionStart; OutputDirectoryTextBox.SelectionLength = 0; OutputFilenameTextBox.SelectionStart = outputFilenameSelectionStart; OutputFilenameTextBox.SelectionLength = 0; // Re-enable automatic reprocessing of textboxes AddPathEventHandlers(); MediaType?mediaType = Env.Parameters.GetMediaType(); int mediaTypeIndex = MediaTypes.FindIndex(m => m == mediaType); if (mediaTypeIndex > -1) { MediaTypeComboBox.SelectedIndex = mediaTypeIndex; } }