mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-22 23:05:03 +00:00
Macrovision cleanup
This commit is contained in:
@@ -33,8 +33,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
/// </summary>
|
||||
public partial class Macrovision
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public string CDillaCheckNewExecutable(string file, NewExecutable nex, bool includeDebug)
|
||||
/// <inheritdoc cref="Interfaces.INewExecutableCheck.CheckNewExecutable(string, NewExecutable, bool)"/>
|
||||
internal string CDillaCheckNewExecutable(string file, NewExecutable nex, bool includeDebug)
|
||||
{
|
||||
// Check we have a valid executable
|
||||
if (nex == null)
|
||||
@@ -63,6 +63,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IPortableExecutableCheck.CheckPortableExecutable(string, PortableExecutable, bool)"/>
|
||||
internal string CDillaCheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
||||
{
|
||||
// Get the sections from the executable, if possible
|
||||
@@ -149,7 +150,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="Interfaces.IPathCheck.CheckDirectoryPath(string, IEnumerable{string})"/>
|
||||
internal ConcurrentQueue<string> CDillaCheckDirectoryPath(string path, IEnumerable<string> files)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
@@ -192,7 +193,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return MatchUtil.GetAllMatches(files, matchers, any: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>
|
||||
internal string CDillaCheckFilePath(string path)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
/// </summary>
|
||||
public partial class Macrovision
|
||||
{
|
||||
/// <inheritdoc cref="Interfaces.IPortableExecutableCheck.CheckPortableExecutable(string, PortableExecutable, bool)"/>
|
||||
internal string FLEXnetCheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
||||
{
|
||||
// Get the sections from the executable, if possible
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
/// </summary>
|
||||
public partial class Macrovision
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public string SafeCastCheckNewExecutable(string file, NewExecutable nex, bool includeDebug)
|
||||
/// <inheritdoc cref="Interfaces.INewExecutableCheck.CheckNewExecutable(string, NewExecutable, bool)"/>
|
||||
internal string SafeCastCheckNewExecutable(string file, NewExecutable nex, bool includeDebug)
|
||||
{
|
||||
// Check we have a valid executable
|
||||
if (nex == null)
|
||||
@@ -48,6 +48,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Interfaces.IPortableExecutableCheck.CheckPortableExecutable(string, PortableExecutable, bool)"/>
|
||||
internal string SafeCastCheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
||||
{
|
||||
// Get the sections from the executable, if possible
|
||||
@@ -88,7 +89,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="Interfaces.IPathCheck.CheckDirectoryPath(string, IEnumerable{string})"/>
|
||||
internal ConcurrentQueue<string> SafeCastCheckDirectoryPath(string path, IEnumerable<string> files)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
@@ -110,7 +111,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return MatchUtil.GetAllMatches(files, matchers, any: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>
|
||||
internal string SafeCastCheckFilePath(string path)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
/// </summary>
|
||||
public partial class Macrovision
|
||||
{
|
||||
/// <inheritdoc cref="Interfaces.IPortableExecutableCheck.CheckPortableExecutable(string, PortableExecutable, bool)"/>
|
||||
internal string SafeDiscCheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
||||
{
|
||||
// Get the sections from the executable, if possible
|
||||
@@ -70,7 +71,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="Interfaces.IPathCheck.CheckDirectoryPath(string, IEnumerable{string})"/>
|
||||
internal ConcurrentQueue<string> SafeDiscCheckDirectoryPath(string path, IEnumerable<string> files)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
@@ -113,7 +114,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
// TODO: Research "splash16.bmp" and "splash256.bmp".
|
||||
|
||||
// Found to be present in every version of SafeDisc, possibly every single release.
|
||||
new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), GetSafeDisc00000001TMPVersion, "SafeDisc"),
|
||||
//new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), GetSafeDisc00000001TMPVersion, "SafeDisc"),
|
||||
|
||||
// Found in many versions of SafeDisc, beginning in 2.05.030 and being used all the way until the final version 4.90.010. It is not always present, even in versions it has been used in. Found in Redump entries 56319 and 72195.
|
||||
new PathMatchSet(new PathMatch("00000002.TMP", useEndsWith: true), "SafeDisc 2+"),
|
||||
@@ -179,7 +180,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
return MatchUtil.GetAllMatches(files, matchers, any: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="Interfaces.IPathCheck.CheckFilePath(string)"/>
|
||||
internal string SafeDiscCheckFilePath(string path)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
@@ -188,7 +189,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
new PathMatchSet(new PathMatch("CLCD32.DLL", useEndsWith: true), GetSafeDiscCLCD32Version, "SafeDisc"),
|
||||
new PathMatchSet(new PathMatch("CLOKSPL.EXE", useEndsWith: true), GetSafeDiscCLOKSPLVersion, "SafeDisc"),
|
||||
|
||||
new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), GetSafeDisc00000001TMPVersion, "SafeDisc"),
|
||||
//new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), GetSafeDisc00000001TMPVersion, "SafeDisc"),
|
||||
new PathMatchSet(new PathMatch("00000002.TMP", useEndsWith: true), "SafeDisc 2+"),
|
||||
|
||||
// TODO: Research "splash16.bmp" and "splash256.bmp".
|
||||
@@ -350,27 +351,6 @@ namespace BurnOutSharp.ProtectionType
|
||||
return $"{version}.{subVersion:00}.{subsubVersion:000}";
|
||||
}
|
||||
|
||||
internal static string GetSafeDisc00000001TMPVersion(string firstMatchedString, IEnumerable<string> files)
|
||||
{
|
||||
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
|
||||
return string.Empty;
|
||||
|
||||
// This file is present in most, if not all, SafeDisc protected discs. It seems to have very consistent file sizes, only being found to use three different file sizes in it's entire run.
|
||||
FileInfo fi = new FileInfo(firstMatchedString);
|
||||
switch (fi.Length)
|
||||
{
|
||||
// Found in Redump entries 37832 and 66005.
|
||||
case 20:
|
||||
return "1.00.025-1.41.001";
|
||||
// Found in Redump entries 11347 and 64255.
|
||||
case 20_482_048:
|
||||
return "3+ (DVD)";
|
||||
// An unknown filesize may indicate a protection other than SafeDisc, due to Macrovision using this file throughout multiple protections.
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetSafeDiscCLCD16Version(string firstMatchedString, IEnumerable<string> files)
|
||||
{
|
||||
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
|
||||
|
||||
@@ -145,16 +145,13 @@ namespace BurnOutSharp.ProtectionType
|
||||
/// <inheritdoc/>
|
||||
public string CheckFilePath(string path)
|
||||
{
|
||||
// TODO: Add all common Macrovision file path checks here
|
||||
|
||||
var matchers = new List<PathMatchSet>
|
||||
{
|
||||
// Present in SafeDisc and CDS-300.
|
||||
new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), Get00000001TMPVersion, "Macrovision Protection File"),
|
||||
};
|
||||
|
||||
List<string> resultsList = new List<string>();
|
||||
|
||||
// Run Macrovision file checks
|
||||
string macrovision = MacrovisionCheckFilePath(path);
|
||||
if (!string.IsNullOrWhiteSpace(macrovision))
|
||||
resultsList.Add(macrovision);
|
||||
|
||||
// Run C-Dilla file checks
|
||||
string cDilla = CDillaCheckFilePath(path);
|
||||
if (!string.IsNullOrWhiteSpace(cDilla))
|
||||
@@ -173,28 +170,46 @@ namespace BurnOutSharp.ProtectionType
|
||||
if (resultsList != null && resultsList.Count > 0)
|
||||
return string.Join(", ", resultsList);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
internal string MacrovisionCheckFilePath(string path)
|
||||
{
|
||||
var matchers = new List<PathMatchSet>
|
||||
{
|
||||
new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), Get00000001TMPVersion, string.Empty),
|
||||
};
|
||||
|
||||
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
||||
}
|
||||
|
||||
static string Get00000001TMPVersion(string firstMatchedString, IEnumerable<string> files)
|
||||
internal static string Get00000001TMPVersion(string firstMatchedString, IEnumerable<string> files)
|
||||
{
|
||||
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
|
||||
return string.Empty;
|
||||
|
||||
// This file is present in most, if not all, SafeDisc protected discs. It seems to have very consistent file sizes, only being found to use three different file sizes in it's entire run.
|
||||
// A rough estimate of the product and version can be gotten by checking the file size.
|
||||
// One filesize is known to overlap with both SafeDisc and CDS-300, and so is detected separately here.
|
||||
FileInfo fi = new FileInfo(firstMatchedString);
|
||||
switch (fi.Length)
|
||||
{
|
||||
// Found in Redump entries 37832 and 66005.
|
||||
case 20:
|
||||
return "SafeDisc 1.00.025-1.41.001";
|
||||
// Found in Redump entries 30555 and 58573.
|
||||
case 2_048:
|
||||
return "[Likely indicates either SafeDisc 1.45.011+ (CD) or CDS-300]";
|
||||
return "Macrovision Protection File [Likely indicates either SafeDisc 1.45.011+ (CD) or CDS-300]";
|
||||
// Found in Redump entries 11347 and 64255.
|
||||
case 20_482_048:
|
||||
return "SafeDisc 3+ (DVD)";
|
||||
default:
|
||||
return "(Unknown Version - Report this to us on GitHub)";
|
||||
}
|
||||
}
|
||||
|
||||
static string GetMacrovisionVersion(string file, byte[] fileContent, List<int> positions)
|
||||
internal static string GetMacrovisionVersion(string file, byte[] fileContent, List<int> positions)
|
||||
{
|
||||
int index = positions[0] + 20; // Begin reading after "BoG_ *90.0&!! Yy>" for old SafeDisc
|
||||
int version = fileContent.ReadInt32(ref index);
|
||||
|
||||
Reference in New Issue
Block a user