Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        /// <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);

                if (result)
                {
                    // Verify dump output and save it
                    result = _env.VerifyAndSaveDumpOutput(progress,
                                                          (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;
            }

            if (EjectWhenDoneCheckBox.IsChecked == true)
            {
                ViewModels.LoggerViewModel.VerboseLogLn($"Ejecting disc in drive {_env.Drive.Letter}");
                _env.EjectDisc();
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }