mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-18 04:02:46 +00:00
Added BD+ version detection (#26)
* Added BD+ version detection * Address Comments * Address comment * Remove unnecessary assignment
This commit is contained in:
@@ -30,14 +30,12 @@ namespace BurnOutSharp.ProtectionType
|
||||
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}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -17,11 +16,52 @@ namespace BurnOutSharp.ProtectionType
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user