Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions BurnOutSharp/ProtectionType/AACS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ public string CheckPath(string path, bool isDirectory, IEnumerable<string> files
string filename = Path.GetFileName(path);
if (filename.Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase))
{
string file = path;
int? version = GetVersion(file);
int? version = GetVersion(path);
return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}");
}
if (filename.Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase))
{
string file = path;
int? version = GetVersion(file);
int? version = GetVersion(path);
return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}");
}
}
Expand Down
44 changes: 42 additions & 2 deletions BurnOutSharp/ProtectionType/BD+.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace BurnOutSharp.ProtectionType
{
public class BDPlus : IPathCheck
{
// TODO: Figure out how to detect version
/// <inheritdoc/>
public string CheckPath(string path, bool isDirectory, IEnumerable<string> files)
{
Expand All @@ -17,11 +16,52 @@ public string CheckPath(string path, bool isDirectory, IEnumerable<string> files
if (files.Any(f => f.Contains(Path.Combine("BDSVM", "00000.svm")))
&& files.Any(f => f.Contains(Path.Combine("BDSVM", "BACKUP", "00000.svm"))))
{
return "BD+";
string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("00000.svm", StringComparison.OrdinalIgnoreCase));
string version = GetVersion(file);
return (version == null ? "BD+ (Unknown Version)" : $"BD+ Version {version}");
}
}
else
{
string filename = Path.GetFileName(path);
if (filename.Equals("00000.svm", StringComparison.OrdinalIgnoreCase))
{
string version = GetVersion(path);
return (version == null ? "BD+ (Unknown Version)" : $"BD+ Version {version}");
}
}
return null;
}

// Version detection logic from libbdplus was used to implement this
private static string GetVersion(string path)
{
try
{
using (var fs = File.OpenRead(path))
{
fs.Seek(0x0d, SeekOrigin.Begin);
int year1 = fs.ReadByte();
int year2 = fs.ReadByte();
int month = fs.ReadByte();
int day = fs.ReadByte();

int year = (year1 << 8) | year2;

// If the result isn't a valid date, report it as an unknown version
if (year < 2006 || year > 2100 || month < 1 || month > 12 || day < 1 || day > 31)
{
return null;
}

return $"{year}/{month}/{day}";
}
}
catch
{
return null;
}
}
}
}