mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-20 15:55:15 +00:00
Implement AACS version detection (#25)
* Implement AACS version detection * Address comments * Address more comments * Address comment
This commit is contained in:
@@ -12,23 +12,55 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
if (isDirectory)
|
||||
{
|
||||
if (files.Any(f => f.Contains(Path.Combine("aacs", "VTKF000.AACS")))
|
||||
&& files.Any(f => f.Contains(Path.Combine("AACS", "CPSUnit00001.cci"))))
|
||||
if (files.Any(f => f.Contains(Path.Combine("AACS", "MKBROM.AACS"))))
|
||||
{
|
||||
return "AACS";
|
||||
string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase));
|
||||
int? version = GetVersion(file);
|
||||
return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}");
|
||||
}
|
||||
if (files.Any(f => f.Contains(Path.Combine("AACS", "MKB_RO.inf"))))
|
||||
{
|
||||
string file = files.FirstOrDefault(f => Path.GetFileName(f).Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase));
|
||||
int? version = GetVersion(file);
|
||||
return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string filename = Path.GetFileName(path);
|
||||
if (filename.Equals("VTKF000.AACS", StringComparison.OrdinalIgnoreCase)
|
||||
|| filename.Equals("CPSUnit00001.cci", StringComparison.OrdinalIgnoreCase))
|
||||
if (filename.Equals("MKBROM.AACS", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "AACS";
|
||||
string file = path;
|
||||
int? version = GetVersion(file);
|
||||
return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}");
|
||||
}
|
||||
if (filename.Equals("MKB_RO.inf", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string file = path;
|
||||
int? version = GetVersion(file);
|
||||
return (version == null ? "AACS (Unknown Version)" : $"AACS Version {version}");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetVersion(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
return null;
|
||||
try
|
||||
{
|
||||
using (var fs = File.OpenRead(path))
|
||||
{
|
||||
fs.Seek(0xB, SeekOrigin.Begin);
|
||||
int version = fs.ReadByte();
|
||||
return version;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user