/// <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); }
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 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); }
/// <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 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") { ListKnownSystems(); Console.ReadLine(); return; } // Normal operation check if (args.Length < 3) { DisplayHelp("Invalid number of arguments"); return; } // Check the MediaType var mediaType = Converters.ToMediaType(args[0].Trim('"')); if (mediaType == MediaType.NONE) { DisplayHelp($"{args[0]} is not a recognized media type"); return; } // Check the KnownSystem var knownSystem = Converters.ToKnownSystem(args[1].Trim('"')); if (knownSystem == KnownSystem.NONE) { 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; // 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; } // Default, we fall out else { break; } } // Make new Progress objects var resultProgress = new Progress<Result>(); resultProgress.ProgressChanged += ProgressUpdated; var protectionProgress = new Progress<FileProtection>(); protectionProgress.ProgressChanged += ProgressUpdated; // If credentials are invalid, alert the user if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) { using (RedumpWebClient wc = new RedumpWebClient()) { if (wc.Login(username, password)) Console.WriteLine("Redump username and password accepted!"); else Console.WriteLine("Redump username and password denied!"); } } // 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 // TODO: Replace this with Dictionary constructor var options = new Options { InternalProgram = internalProgram, ScanForProtection = scan && !string.IsNullOrWhiteSpace(path), PromptForDiscInformation = false, Username = username, Password = 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); env.FixOutputPaths(); // Finally, attempt to do the output dance var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(result.Message); } }