From 3e10199cb00e001b4b557eb06cfa644cbb36db7d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 7 Aug 2020 21:15:36 -0700 Subject: [PATCH] Add path and scan to Check --- DICUI.Check/DICUI.Check.csproj | 4 ++ DICUI.Check/Program.cs | 89 ++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 36 deletions(-) diff --git a/DICUI.Check/DICUI.Check.csproj b/DICUI.Check/DICUI.Check.csproj index eee6486e..d0ac0d09 100644 --- a/DICUI.Check/DICUI.Check.csproj +++ b/DICUI.Check/DICUI.Check.csproj @@ -11,6 +11,10 @@ + + + + {51ab0928-13f9-44bf-a407-b6957a43a056} diff --git a/DICUI.Check/Program.cs b/DICUI.Check/Program.cs index d87ff7ae..b0db43f5 100644 --- a/DICUI.Check/Program.cs +++ b/DICUI.Check/Program.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using BurnOutSharp; using DICUI.Data; using DICUI.Utilities; using DICUI.Web; @@ -60,9 +61,13 @@ namespace DICUI.Check return; } - // Check for additional flags + // 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++) { @@ -91,6 +96,23 @@ namespace DICUI.Check 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 { @@ -98,9 +120,11 @@ namespace DICUI.Check } } - // Make a new Progress object - var progress = new Progress(); - progress.ProgressChanged += ProgressUpdated; + // Make new Progress objects + var resultProgress = new Progress(); + resultProgress.ProgressChanged += ProgressUpdated; + var protectionProgress = new Progress(); + protectionProgress.ProgressChanged += ProgressUpdated; // If credentials are invalid, alert the user if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) @@ -132,18 +156,22 @@ namespace DICUI.Check var options = new Options { InternalProgram = internalProgram, - ScanForProtection = false, + ScanForProtection = scan && !string.IsNullOrWhiteSpace(path), PromptForDiscInformation = false, Username = username, Password = password, }; - var env = new DumpEnvironment(options, "", filepath, null, knownSystem, mediaType, null); + 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(progress).ConfigureAwait(false).GetAwaiter().GetResult(); + var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(result.Message); } } @@ -160,36 +188,17 @@ namespace DICUI.Check Console.WriteLine("Usage:"); Console.WriteLine("DICUI.Check.exe [options] ..."); Console.WriteLine(); - Console.WriteLine(@"Common Media Types: -bd / bluray - BD-ROM -cd / cdrom - CD-ROM -dvd - DVD-ROM -fd / floppy - Floppy Disk -gd / gdrom - GD-ROM -umd - UMD"); - Console.WriteLine("Run 'DICUI.Check.exe [-lm|--listmedia' for more options"); + Console.WriteLine("Standalone Options:"); + Console.WriteLine("-h, -? Show this help text"); + Console.WriteLine("-lm, --listmedia List supported media types"); + Console.WriteLine("-ls, --listsystems List supported system types"); + Console.WriteLine("-lp, --listprograms List supported dumping program outputs"); Console.WriteLine(); - Console.WriteLine(@"Common Systems: -apple / mac - Apple Macintosh -cdi - Philips CD-i -ibm / ibmpc - IBM PC Compatible -psx / ps1 - Sony PlayStation -ps2 - Sony PlayStation 2 -psp - Sony PlayStation Portable -saturn - Sega Saturn -xbox - Microsoft XBOX -x360 - Microsoft XBOX 360"); - Console.WriteLine("Run 'DICUI.Check.exe [-ls|--listsystems' for more options"); - Console.WriteLine(); - Console.WriteLine(@"Common Options: --c username password - Redump credentials --u - Set dumping program"); - Console.WriteLine(); - Console.WriteLine(@"Common Dumping Programs: -aaru / chef - Aaru -cr / cleanrip - CleanRip -dic - DiscImageCreator"); - Console.WriteLine("Run 'DICUI.Check.exe [-lp|--listprograms' for more options"); + Console.WriteLine("Check Options:"); + Console.WriteLine("-c, --credentials Redump username and password"); + Console.WriteLine("-u, --use Dumping program output type"); + Console.WriteLine("-p, --path Physical drive path for additional checks"); + Console.WriteLine("-s, --scan Enable copy protection scan (requires --path)"); Console.WriteLine(); } @@ -245,5 +254,13 @@ dic - DiscImageCreator"); { Console.WriteLine(value.Message); } + + /// + /// Simple process counter to write to console + /// + private static void ProgressUpdated(object sender, FileProtection value) + { + Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}"); + } } }