Split SafeDisc and CDS-300 checks (#236)

* Split SafeDisc/CDS-300 checks.
* Add new DrvMgt.dll hash check.
This commit is contained in:
TheRogueArchivist
2023-03-05 15:33:39 -07:00
committed by GitHub
parent 370cc68fa4
commit 3cfb60430a
3 changed files with 42 additions and 27 deletions

View File

@@ -102,8 +102,8 @@ namespace BurnOutSharp.ProtectionType
new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), GetVersion, "Cactus Data Shield"),
new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), GetVersion, "Cactus Data Shield"),
// Present on CDS-300, as well as SafeDisc. This is likely due to both protections being created by Macrovision.
new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), Get00000001TMPVersion, "Cactus Data Shield 300 (Confirm presence of other CDS-300 files)"),
// The file "00000001.TMP" (with a filesize of 2,048 bytes) can be found in CDS-300, as well as SafeDisc.
// Due to this file being used in both protections, this file is detected within the general Macrovision checks.
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
@@ -128,30 +128,13 @@ namespace BurnOutSharp.ProtectionType
new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), "Cactus Data Shield 200"),
new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), "Cactus Data Shield 200"),
// Present on CDS-300, as well as SafeDisc. This is likely due to both protections being created by Macrovision.
new PathMatchSet(new PathMatch("00000001.TMP", useEndsWith: true), Get00000001TMPVersion, "Cactus Data Shield 300"),
// The file "00000001.TMP" (with a filesize of 2,048 bytes) can be found in CDS-300, as well as SafeDisc.
// Due to this file being used in both protections, this file is detected within the general Macrovision checks.
};
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
public static string Get00000001TMPVersion(string firstMatchedString, IEnumerable<string> files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
// This file is present on both CDS-300 and SafeDisc.
// Only one specific file size appears to be associated with CDS-300, so any files with a differing file size are discarded. If it is the correct file size, return it as valid.
FileInfo fi = new FileInfo(firstMatchedString);
switch (fi.Length)
{
case 2_048:
return "(Confirm presence of other CDS-300 files)";
default:
return null;
}
}
// TODO: Simplify version checking.
public static string GetVersion(string firstMatchedString, IEnumerable<string> files)
{

View File

@@ -362,14 +362,12 @@ namespace BurnOutSharp.ProtectionType
// Found in Redump entries 37832 and 66005.
case 20:
return "1.00.025-1.41.001";
// Found in Redump entries 30555 and 58573.
case 2_048:
return "1.45.011+ (CD) (Confirm presence of other SafeDisc files)";
// 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 "Unknown Version (Report this to us on GitHub)";
return null;
}
}
@@ -752,6 +750,9 @@ namespace BurnOutSharp.ProtectionType
// TODO: Further investigate versions 3.20.020-3.20.024, and verify that 3.20.024 doesn't use drvmgt.dll at all.
case "ECB341AB36C5B3B912F568D347368A6A2DEF8D5F":
return "3.20.020-3.20.022";
// Found in Redump entries 53666, 76775, and 102301.
case "69C776F67EBD53CB5FD760B498B4A491BF22F293":
return "3.20.022";
// Found in Redump entries 15614, 79729, 83408, and 86196.
// The presence of any drvmgt.dll file at all is notably missing in several games with SafeDisc versions 4.00.001-4.00.003, including Redump entries 33326, 51597, and 67927.
case "E21FF43C2E663264D6CB11FBBC31EB1DCEE42B1A":

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BurnOutSharp.Interfaces;
using BurnOutSharp.Matching;
@@ -112,6 +113,12 @@ namespace BurnOutSharp.ProtectionType
{
// TODO: Add all common Macrovision directory 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"),
};
ConcurrentQueue<string> results = new ConcurrentQueue<string>();
// Run C-Dilla directory checks
@@ -132,7 +139,7 @@ namespace BurnOutSharp.ProtectionType
if (results != null && results.Count > 0)
return results;
return MatchUtil.GetAllMatches(files, null, any: false);
return MatchUtil.GetAllMatches(files, matchers, any: false);
}
/// <inheritdoc/>
@@ -140,6 +147,12 @@ namespace BurnOutSharp.ProtectionType
{
// 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 C-Dilla file checks
@@ -160,7 +173,25 @@ namespace BurnOutSharp.ProtectionType
if (resultsList != null && resultsList.Count > 0)
return string.Join(", ", resultsList);
return MatchUtil.GetFirstMatch(path, null, any: true);
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
static string Get00000001TMPVersion(string firstMatchedString, IEnumerable<string> files)
{
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
// 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 30555 and 58573.
case 2_048:
return "[Likely indicates either SafeDisc 1.45.011+ (CD) or CDS-300]";
default:
return "(Unknown Version - Report this to us on GitHub)";
}
}
static string GetMacrovisionVersion(string file, byte[] fileContent, List<int> positions)