diff --git a/CHANGELIST.md b/CHANGELIST.md index 904592e7..1a4b312f 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -62,6 +62,7 @@ - Semi-unify drive finding - Introduce cross-platform MMI - Remove System.Management +- Add Redumper Universal Hash support ### 2.4 (2022-10-26) diff --git a/MPF.Library/InfoTool.cs b/MPF.Library/InfoTool.cs index 69c415a9..2654cef2 100644 --- a/MPF.Library/InfoTool.cs +++ b/MPF.Library/InfoTool.cs @@ -2562,6 +2562,8 @@ namespace MPF.Library sorted.Add(new KeyValuePair(SiteCode.VolumeLabel, tags[SiteCode.VolumeLabel])); if (tags.ContainsKey(SiteCode.Multisession)) sorted.Add(new KeyValuePair(SiteCode.Multisession, tags[SiteCode.Multisession])); + if (tags.ContainsKey(SiteCode.UniversalHash)) + sorted.Add(new KeyValuePair(SiteCode.UniversalHash, tags[SiteCode.UniversalHash])); if (tags.ContainsKey(SiteCode.XMID)) sorted.Add(new KeyValuePair(SiteCode.XMID, tags[SiteCode.XMID])); diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs index f7a3acd3..198b76d6 100644 --- a/MPF.Modules/Redumper/Parameters.cs +++ b/MPF.Modules/Redumper/Parameters.cs @@ -212,6 +212,9 @@ namespace MPF.Modules.Redumper long errorCount = GetErrorCount($"{basePath}.log"); info.CommonDiscInfo.ErrorsCount = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString()); + + string universalHash = GetUniversalHash($"{basePath}.log") ?? ""; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash] = universalHash; break; } @@ -988,6 +991,41 @@ namespace MPF.Modules.Redumper } } + /// + /// Get the universal hash from the input file, if possible + /// + /// Log file location + /// Universal hash if possible, null on error + private static string GetUniversalHash(string log) + { + // If the file doesn't exist, we can't get info from it + if (!File.Exists(log)) + return null; + + using (StreamReader sr = File.OpenText(log)) + { + try + { + // We skip during detection and get the write offset + string line; + while (!sr.EndOfStream) + { + line = sr.ReadLine().TrimStart(); + if (line.StartsWith("Universal Hash")) + return line.Substring("Universal Hash (SHA-1): ".Length).Trim(); + } + + // We couldn't detect it then + return null; + } + catch + { + // We don't care what the exception is right now + return null; + } + } + } + /// /// Get the write offset from the input file, if possible /// diff --git a/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs b/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs index 5f89cc2c..a66558ed 100644 --- a/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs +++ b/MPF.UI.Core/ViewModels/DiscInformationViewModel.cs @@ -330,6 +330,8 @@ namespace MPF.UI.Core.ViewModels Parent.SecuritySectorRanges.Visibility = Visibility.Collapsed; if (SubmissionInfo?.CommonDiscInfo?.CommentsSpecialFields.Keys.Contains(SiteCode.SSVersion) != true) Parent.SSVersion.Visibility = Visibility.Collapsed; + if (SubmissionInfo?.CommonDiscInfo?.CommentsSpecialFields.Keys.Contains(SiteCode.UniversalHash) != true) + Parent.UniversalHash.Visibility = Visibility.Collapsed; if (SubmissionInfo?.CommonDiscInfo?.CommentsSpecialFields.Keys.Contains(SiteCode.VolumeLabel) != true) Parent.VolumeLabel.Visibility = Visibility.Collapsed; if (SubmissionInfo?.CommonDiscInfo?.CommentsSpecialFields.Keys.Contains(SiteCode.XeMID) != true) @@ -469,6 +471,8 @@ namespace MPF.UI.Core.ViewModels Parent.SSHash.Text = SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash]; if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.SSVersion)) Parent.SSVersion.Text = SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion]; + if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.UniversalHash)) + Parent.UniversalHash.Text = SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash]; if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.VolumeLabel)) Parent.VolumeLabel.Text = SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.VolumeLabel]; if (SubmissionInfo.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.XeMID)) @@ -583,6 +587,7 @@ namespace MPF.UI.Core.ViewModels SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.PFIHash] = Parent.PFIHash.Text; SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = Parent.SSHash.Text; SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = Parent.SSVersion.Text; + SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash] = Parent.UniversalHash.Text; SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.VolumeLabel] = Parent.VolumeLabel.Text; SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.XeMID] = Parent.XeMID.Text; SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[SiteCode.XMID] = Parent.XMID.Text; diff --git a/MPF.UI.Core/Windows/DiscInformationWindow.xaml b/MPF.UI.Core/Windows/DiscInformationWindow.xaml index 95370b1b..908f8250 100644 --- a/MPF.UI.Core/Windows/DiscInformationWindow.xaml +++ b/MPF.UI.Core/Windows/DiscInformationWindow.xaml @@ -377,6 +377,7 @@ Text="{Binding SubmissionInfo.Extras.SecuritySectorRanges, Mode=TwoWay}" TextHeight="75" TextWrapping="NoWrap" VerticalContentAlignmentValue="Top" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/> + diff --git a/RedumpLib/Data/Enumerations.cs b/RedumpLib/Data/Enumerations.cs index 4fd1d95d..5d452334 100644 --- a/RedumpLib/Data/Enumerations.cs +++ b/RedumpLib/Data/Enumerations.cs @@ -3666,6 +3666,10 @@ namespace RedumpLib.Data [HumanReadable(ShortName = "[T:UID]", LongName = "Ubisoft ID:")] UbisoftID, + // TODO: This doesn't have a site tag yet + [HumanReadable(ShortName = "Universal Hash (SHA-1):", LongName = "Universal Hash (SHA-1):")] + UniversalHash, + [HumanReadable(ShortName = "[T:VID]", LongName = "Valve ID:")] ValveID,