Add BD protection info, fix Cover ID setting (fixes #970)

This commit is contained in:
Matt Nadareski
2026-04-30 09:46:45 -04:00
parent 4e2620a1c0
commit f95d6095d1
3 changed files with 58 additions and 10 deletions

View File

@@ -12,6 +12,7 @@
- Update RedumpLib to 1.10.2
- Fix name conflict
- Sync with Redump wiki
- Add BD protection info, fix Cover ID setting
### 3.7.1 (2026-03-30)

View File

@@ -6,6 +6,7 @@ using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SabreTools.Hashing;
using SabreTools.IO;
using SabreTools.RedumpLib.Data;
@@ -106,6 +107,47 @@ namespace MPF.Frontend.Tools
#region BD-Video
/// <summary>
/// Get Blu-ray protection information
/// </summary>
/// <param name="drive">Drive to extract information from</param>
/// <returns>Formatted string representing the protection on success, null otherwise</returns>
public static string? GetBluRayProtection(Drive? drive)
{
// If there's no drive path, we can't get information
if (string.IsNullOrEmpty(drive?.Name))
return null;
// If the folder no longer exists, we can't get information
if (!Directory.Exists(drive!.Name))
return null;
// Generate unit key file hash
string? unitKeyFileHash = null;
#if NET20 || NET35
string unitKeyPath = Path.Combine(Path.Combine(drive.Name, "AACS"), "Unit_Key_RO.inf ");
#else
string unitKeyPath = Path.Combine(drive.Name, "AACS", "Unit_Key_RO.inf ");
#endif
if (File.Exists(unitKeyPath))
unitKeyFileHash = HashTool.GetFileHash(unitKeyPath, HashType.SHA1)?.ToUpperInvariant();
// Determine if BEE is set
bool busEncryptionEnabled = GetBusEncryptionEnabled(drive);
// Generate the output strings
var sb = new StringBuilder();
sb.AppendLine($"Media Key: (OPTIONAL)");
sb.AppendLine($"Volume ID: (OPTIONAL)");
sb.AppendLine($"Volume Unique Key: (OPTIONAL)");
sb.AppendLine($"Unit Key File Hash (DiscID): {unitKeyFileHash ?? "(OPTIONAL)"}");
if (busEncryptionEnabled)
sb.AppendLine("Bus encryption enabled flag set");
return sb.ToString();
}
/// <summary>
/// Get if the Bus Encryption Enabled (BEE) flag is set in a path
/// </summary>
@@ -117,7 +159,7 @@ namespace MPF.Frontend.Tools
if (string.IsNullOrEmpty(drive?.Name))
return false;
// If the folder no longer exists, we can't get exe name
// If the folder no longer exists, we can't get BEE flag
if (!Directory.Exists(drive!.Name))
return false;

View File

@@ -834,11 +834,11 @@ namespace MPF.Frontend.Tools
case RedumpSystem.BDVideo:
info.CommonDiscInfo.Category ??= DiscCategory.Video;
bool bee = PhysicalTool.GetBusEncryptionEnabled(drive);
if (bee && string.IsNullOrEmpty(info.CopyProtection.Protection))
info.CopyProtection.Protection = "Bus encryption enabled flag set";
else if (bee)
info.CopyProtection.Protection += "\nBus encryption enabled flag set";
string? bdProtection = PhysicalTool.GetBluRayProtection(drive);
if (bdProtection is not null && string.IsNullOrEmpty(info.CopyProtection.Protection))
info.CopyProtection.Protection = bdProtection;
else if (bdProtection is not null)
info.CopyProtection.Protection += $"\n{bdProtection}";
else
info.CopyProtection.Protection ??= addPlaceholders ? RequiredIfExistsValue : string.Empty;
@@ -942,17 +942,20 @@ namespace MPF.Frontend.Tools
case RedumpSystem.MicrosoftXbox:
case RedumpSystem.MicrosoftXbox360:
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DiscHologramID] ??= addPlaceholders ? RequiredIfExistsValue : string.Empty;
if (!info.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.DiscHologramID))
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DiscHologramID] = addPlaceholders ? RequiredIfExistsValue : string.Empty;
break;
case RedumpSystem.MicrosoftXboxOne:
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DiscHologramID] ??= addPlaceholders ? RequiredIfExistsValue : string.Empty;
if (!info.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.DiscHologramID))
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DiscHologramID] = addPlaceholders ? RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.Filename] = PhysicalTool.GetXboxFilenames(drive) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.TitleID] = PhysicalTool.GetXboxTitleID(drive) ?? string.Empty;
break;
case RedumpSystem.MicrosoftXboxSeriesXS:
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DiscHologramID] ??= addPlaceholders ? RequiredIfExistsValue : string.Empty;
if (!info.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.DiscHologramID))
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DiscHologramID] = addPlaceholders ? RequiredIfExistsValue : string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.Filename] = PhysicalTool.GetXboxFilenames(drive) ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.TitleID] = PhysicalTool.GetXboxTitleID(drive) ?? string.Empty;
break;
@@ -981,7 +984,9 @@ namespace MPF.Frontend.Tools
case RedumpSystem.NintendoGameCube:
case RedumpSystem.NintendoWii:
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.CoverID] ??= addPlaceholders ? RequiredValue : string.Empty;
if (!info.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.CoverID))
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.CoverID] = addPlaceholders ? RequiredIfExistsValue : string.Empty;
break;
case RedumpSystem.SegaChihiro: