diff --git a/Constants.cs b/Constants.cs index 79611c79..cb4dec62 100644 --- a/Constants.cs +++ b/Constants.cs @@ -104,10 +104,10 @@ public const string PlayStationLibCryptField = "LibCrypt"; // TODO: Not automatic yet public const string SaturnHeaderField = "Header"; public const string SaturnBuildDateField = "Build Date"; - public const string XBOXDMICRC = "DMI.bin CRC32"; // TODO: Not automatic yet - public const string XBOXPFICRC = "PFI.bin CRC32"; // TODO: Not automatic yet - public const string XBOXSSCRC = "SS.bin CRC32"; // TODO: Not automatic yet - public const string XBOXSSRanges = "Security Sector Ranges"; // TODO: Not automatic yet + public const string XBOXDMIHash = "DMI.bin Hashes"; + public const string XBOXPFIHash = "PFI.bin Hashes"; + public const string XBOXSSHash = "SS.bin Hashes"; + public const string XBOXSSRanges = "Security Sector Ranges"; // Default values diff --git a/Enumerations.cs b/Enumerations.cs index b866f495..cb699a05 100644 --- a/Enumerations.cs +++ b/Enumerations.cs @@ -40,7 +40,8 @@ CommodoreAmigaCDTV, MattelHyperscan, MicrosoftXBOX, - MicrosoftXBOX360, + MicrosoftXBOX360XDG2, + MicrosoftXBOX360XDG3, MicrosoftXBOXOne, NECPCEngineTurboGrafxCD, NECPCFX, diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 7f0f072b..e29466c8 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -473,6 +473,19 @@ namespace DICUI lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", Converters.DiscTypeToString(tuple.Item3)); btn_StartStop.IsEnabled = false; break; + case DiscType.DVD5: + case DiscType.DVD9: + if (tuple.Item2 == KnownSystem.MicrosoftXBOX360XDG3) + { + lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", Converters.DiscTypeToString(tuple.Item3)); + btn_StartStop.IsEnabled = false; + } + else + { + lbl_Status.Content = string.Format("{0} ready to dump", Converters.DiscTypeToString(tuple.Item3)); + btn_StartStop.IsEnabled = (_drives.Count > 0 ? true : false); + } + break; default: lbl_Status.Content = string.Format("{0} ready to dump", Converters.DiscTypeToString(tuple.Item3)); btn_StartStop.IsEnabled = (_drives.Count > 0 ? true : false); @@ -488,7 +501,16 @@ namespace DICUI cmb_DriveSpeed.IsEnabled = false; break; default: - cmb_DriveSpeed.IsEnabled = true; + if (tuple.Item2 == KnownSystem.MicrosoftXBOX + || tuple.Item2 == KnownSystem.MicrosoftXBOX360XDG2 + || tuple.Item2 == KnownSystem.MicrosoftXBOX360XDG3) + { + cmb_DriveSpeed.IsEnabled = false; + } + else + { + cmb_DriveSpeed.IsEnabled = true; + } break; } @@ -511,7 +533,6 @@ namespace DICUI txt_OutputDirectory.IsEnabled = true; btn_OutputDirectoryBrowse.IsEnabled = true; cmb_DriveLetter.IsEnabled = true; - cmb_DriveSpeed.IsEnabled = true; // Populate with the correct params for inputs (if we're not on the default option) if (cmb_DiscType.SelectedIndex > 0) @@ -525,7 +546,7 @@ namespace DICUI return; } - string discType = Converters.DiscTypeToBaseCommand(selected.Item3); + string discType = Converters.KnownSystemAndDiscTypeToBaseCommand(selected.Item2, selected.Item3); List defaultParams = Converters.KnownSystemAndDiscTypeToParameters(selected.Item2, selected.Item3); txt_Parameters.Text = discType + " " + driveletter.Item1 @@ -534,7 +555,8 @@ namespace DICUI && selected.Item3 != DiscType.BD25 && selected.Item3 != DiscType.BD50 && selected.Item2 != KnownSystem.MicrosoftXBOX - && selected.Item2 != KnownSystem.MicrosoftXBOX360 + && selected.Item2 != KnownSystem.MicrosoftXBOX360XDG2 + && selected.Item2 != KnownSystem.MicrosoftXBOX360XDG3 ? (int)cmb_DriveSpeed.SelectedItem + " " : "") + string.Join(" ", defaultParams); } diff --git a/Utilities/Converters.cs b/Utilities/Converters.cs index d9c5c38e..977dfdb9 100644 --- a/Utilities/Converters.cs +++ b/Utilities/Converters.cs @@ -59,47 +59,6 @@ namespace DICUI.Utilities } } - /// - /// Get the DIC command to be used for a given DiscType - /// - /// DiscType value to check - /// String containing the command, null on error - public static string DiscTypeToBaseCommand(DiscType? type) - { - switch (type) - { - case DiscType.CD: - return DICCommands.CompactDisc; - case DiscType.DVD5: - case DiscType.DVD9: - return DICCommands.DigitalVideoDisc; - case DiscType.GDROM: - return DICCommands.GDROM; - case DiscType.HDDVD: - return null; - case DiscType.BD25: - case DiscType.BD50: - return DICCommands.BluRay; - - // Special Formats - case DiscType.GameCubeGameDisc: - return DICCommands.DigitalVideoDisc; - case DiscType.WiiOpticalDisc: - return null; - case DiscType.WiiUOpticalDisc: - return null; - case DiscType.UMD: - return null; - - // Non-optical - case DiscType.Floppy: - return DICCommands.Floppy; - - default: - return null; - } - } - /// /// Get the default extension for a given disc type /// @@ -174,6 +133,64 @@ namespace DICUI.Utilities } } + /// + /// Get the DIC command to be used for a given DiscType + /// + /// DiscType value to check + /// String containing the command, null on error + public static string KnownSystemAndDiscTypeToBaseCommand(KnownSystem? sys, DiscType? type) + { + switch (type) + { + case DiscType.CD: + if (sys == KnownSystem.MicrosoftXBOX) + { + return DICCommands.XBOX; + } + return DICCommands.CompactDisc; + case DiscType.DVD5: + if (sys == KnownSystem.MicrosoftXBOX + || sys == KnownSystem.MicrosoftXBOX360XDG2 + || sys == KnownSystem.MicrosoftXBOX360XDG3) + { + return DICCommands.XBOX; + } + return DICCommands.DigitalVideoDisc; + case DiscType.DVD9: + if (sys == KnownSystem.MicrosoftXBOX + || sys == KnownSystem.MicrosoftXBOX360XDG2 + || sys == KnownSystem.MicrosoftXBOX360XDG3) + { + return DICCommands.XBOX; + } + return DICCommands.DigitalVideoDisc; + case DiscType.GDROM: + return DICCommands.GDROM; + case DiscType.HDDVD: + return null; + case DiscType.BD25: + case DiscType.BD50: + return DICCommands.BluRay; + + // Special Formats + case DiscType.GameCubeGameDisc: + return DICCommands.DigitalVideoDisc; + case DiscType.WiiOpticalDisc: + return null; + case DiscType.WiiUOpticalDisc: + return null; + case DiscType.UMD: + return null; + + // Non-optical + case DiscType.Floppy: + return DICCommands.Floppy; + + default: + return null; + } + } + /// /// Get list of default parameters for a given system and disc type /// @@ -275,8 +292,10 @@ namespace DICUI.Utilities return "Mattel HyperScan"; case KnownSystem.MicrosoftXBOX: return "Microsoft XBOX"; - case KnownSystem.MicrosoftXBOX360: - return "Microsoft XBOX 360"; + case KnownSystem.MicrosoftXBOX360XDG2: + return "Microsoft XBOX 360 (XDG2)"; + case KnownSystem.MicrosoftXBOX360XDG3: + return "Microsoft XBOX 360 (XDG3)"; case KnownSystem.MicrosoftXBOXOne: return "Microsoft XBOX One"; case KnownSystem.NECPCEngineTurboGrafxCD: diff --git a/Utilities/DumpInformation.cs b/Utilities/DumpInformation.cs index 8be1db25..0caaa5b1 100644 --- a/Utilities/DumpInformation.cs +++ b/Utilities/DumpInformation.cs @@ -206,7 +206,7 @@ namespace DICUI.Utilities } break; - case DiscType.DVD5: // TODO: Add XBOX360-specific outputs to this + case DiscType.DVD5: case DiscType.HDDVD: case DiscType.BD25: mappings[Template.MasteringRingField] = Template.RequiredIfExistsValue; @@ -232,12 +232,6 @@ namespace DICUI.Utilities } } break; - case KnownSystem.MicrosoftXBOX: - mappings[Template.XBOXDMICRC] = Template.RequiredValue; - mappings[Template.XBOXPFICRC] = Template.RequiredValue; - mappings[Template.XBOXSSCRC] = Template.RequiredValue; - mappings[Template.XBOXSSRanges] = Template.RequiredValue; - break; case KnownSystem.SonyPlayStation2: mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(driveLetter); mappings[Template.VersionField] = GetPlayStation2Version(driveLetter); @@ -245,7 +239,7 @@ namespace DICUI.Utilities } break; - case DiscType.DVD9: // TODO: Add XBOX360-specific outputs to this + case DiscType.DVD9: case DiscType.BD50: mappings["Outer " + Template.MasteringRingField] = Template.RequiredIfExistsValue; mappings["Inner " + Template.MasteringRingField] = Template.RequiredIfExistsValue; @@ -275,10 +269,15 @@ namespace DICUI.Utilities } break; case KnownSystem.MicrosoftXBOX: - mappings[Template.XBOXDMICRC] = Template.RequiredValue; - mappings[Template.XBOXPFICRC] = Template.RequiredValue; - mappings[Template.XBOXSSCRC] = Template.RequiredValue; - mappings[Template.XBOXSSRanges] = Template.RequiredValue; + case KnownSystem.MicrosoftXBOX360XDG2: + case KnownSystem.MicrosoftXBOX360XDG3: + if (GetXBOXAuxInfo(combinedBase + "_disc.txt", out string dmihash, out string pfihash, out string sshash, out string ss)) + { + mappings[Template.XBOXDMIHash] = dmihash; + mappings[Template.XBOXPFIHash] = pfihash; + mappings[Template.XBOXSSHash] = sshash; + mappings[Template.XBOXSSRanges] = ss; + } break; case KnownSystem.SonyPlayStation2: mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(driveLetter); @@ -669,6 +668,64 @@ namespace DICUI.Utilities } } + /// + /// Get the XBOX/360 auxiliary info from the outputted files, if possible + /// + /// _disc.txt file location + /// True on successful extraction of info, false otherwise + private static bool GetXBOXAuxInfo(string disc, out string dmihash, out string pfihash, out string sshash, out string ss) + { + dmihash = null; pfihash = null; sshash = null; ss = null; + + // If the file doesn't exist, we can't get info from it + if (!File.Exists(disc)) + { + return false; + } + + using (StreamReader sr = File.OpenText(disc)) + { + try + { + // Make sure this file is a _disc.txt for XBOX + if (sr.ReadLine() != "========== Lock state ==========") + { + return false; + } + + // Fast forward to the Security Sector Ranges + while (!sr.ReadLine().Trim().StartsWith("Number of security sector ranges:")) ; + + // Now that we're at the ranges, read each line in and concatenate + // TODO: Make this output like the old method (startlba-endlba) + string line = sr.ReadLine(); + while (!line.Trim().StartsWith("========== Unlock 2 state(wxripper) ==========")) + { + ss += line + "\n"; + line = sr.ReadLine(); + } + + // Fast forward to the aux hashes + while (!line.Trim().StartsWith(" /// Get the write offset from the input file, if possible /// @@ -825,9 +882,11 @@ namespace DICUI.Utilities } break; case KnownSystem.MicrosoftXBOX: - output.Add(Template.XBOXDMICRC + ": " + info[Template.XBOXDMICRC]); - output.Add(Template.XBOXPFICRC + ": " + info[Template.XBOXPFICRC]); - output.Add(Template.XBOXSSCRC + ": " + info[Template.XBOXSSCRC]); output.Add(""); + case KnownSystem.MicrosoftXBOX360XDG2: + case KnownSystem.MicrosoftXBOX360XDG3: + output.Add(Template.XBOXDMIHash + ": " + info[Template.XBOXDMIHash]); + output.Add(Template.XBOXPFIHash + ": " + info[Template.XBOXPFIHash]); + output.Add(Template.XBOXSSHash + ": " + info[Template.XBOXSSHash]); output.Add(""); output.Add(Template.XBOXSSRanges + ":"); output.Add(""); output.AddRange(info[Template.XBOXSSRanges].Split('\n')); break; diff --git a/Utilities/Validation.cs b/Utilities/Validation.cs index 490bcb4f..0665e0e5 100644 --- a/Utilities/Validation.cs +++ b/Utilities/Validation.cs @@ -39,9 +39,14 @@ namespace DICUI.Utilities break; case KnownSystem.MicrosoftXBOX: types.Add(DiscType.CD); - types.Add(DiscType.DVD5); + types.Add(DiscType.DVD9); break; - case KnownSystem.MicrosoftXBOX360: + case KnownSystem.MicrosoftXBOX360XDG2: + types.Add(DiscType.CD); + types.Add(DiscType.DVD9); + types.Add(DiscType.HDDVD); + break; + case KnownSystem.MicrosoftXBOX360XDG3: types.Add(DiscType.CD); types.Add(DiscType.DVD9); types.Add(DiscType.HDDVD); @@ -479,7 +484,8 @@ namespace DICUI.Utilities new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_LogicalDisk"); - foreach (ManagementObject queryObj in searcher.Get()) + var collection = searcher.Get(); + foreach (ManagementObject queryObj in collection) { uint? mediaType = (uint?)queryObj["MediaType"]; if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22)))