2021-07-18 09:44:23 -07:00
using System.Collections.Concurrent ;
2021-07-17 23:40:16 -07:00
using System.Collections.Generic ;
2023-03-09 11:52:28 -05:00
using BinaryObjectScanner.Interfaces ;
2023-03-07 16:59:14 -05:00
using BinaryObjectScanner.Matching ;
2019-09-27 23:52:24 -07:00
2023-03-09 23:19:27 -05:00
namespace BinaryObjectScanner.Protection
2019-09-27 23:52:24 -07:00
{
2021-07-02 11:16:06 -06:00
/// <summary>
2022-06-30 17:14:09 -06:00
/// Bitpool is a copy protection found most commonly in German releases.
2022-12-27 12:00:00 -07:00
/// It always has errors present on the disc (either between 1-4, or between 1,000-10,000+ depending on generation), and makes use of padded dummy files to prevent copying.
2023-02-09 07:05:13 -07:00
/// <see href="https://github.com/TheRogueArchivist/DRML/blob/main/entries/Bitpool/Bitpool.md"/>
2021-07-02 11:16:06 -06:00
/// </summary>
2021-09-12 13:43:08 -07:00
public class Bitpool : IPathCheck
2019-09-27 23:52:24 -07:00
{
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
2021-07-18 09:44:23 -07:00
public ConcurrentQueue < string > CheckDirectoryPath ( string path , IEnumerable < string > files )
2019-09-27 23:52:24 -07:00
{
2021-03-22 22:23:55 -07:00
var matchers = new List < PathMatchSet >
{
new PathMatchSet ( new PathMatch ( "bitpool.rsc" , useEndsWith : true ) , "Bitpool" ) ,
2023-08-26 22:51:55 -04:00
new PathMatchSet ( new FilePathMatch ( "CD.IDX" ) , "Bitpool" ) ,
2022-06-30 17:14:09 -06:00
2022-12-27 12:00:00 -07:00
// Completely empty file present on multiple discs with Bitpool (Redump entries 52626 and 50229).
2022-06-30 17:14:09 -06:00
new PathMatchSet ( new PathMatch ( "LEADOUT.OFS" , useEndsWith : true ) , "Bitpool" ) ,
2022-12-27 12:00:00 -07:00
// A set of 4 identically sized (within the same game, not between games), corrupted/padded files present in several games (Redump entries 31782 and 35476).
2022-06-30 17:14:09 -06:00
// Both examples with only having the first letter uppercase and as the whole file name being uppercase have been seen.
new PathMatchSet ( new List < PathMatch >
{
2023-08-26 22:51:55 -04:00
new FilePathMatch ( "Crc_a" ) ,
new FilePathMatch ( "Crc_b" ) ,
new FilePathMatch ( "Crc_c" ) ,
new FilePathMatch ( "Crc_d" ) ,
2022-06-30 17:14:09 -06:00
} , "Bitpool" ) ,
2021-03-22 22:23:55 -07:00
} ;
2019-09-27 23:52:24 -07:00
2021-03-23 13:35:12 -07:00
return MatchUtil . GetAllMatches ( files , matchers , any : true ) ;
2019-09-27 23:52:24 -07:00
}
2021-03-19 15:41:49 -07:00
/// <inheritdoc/>
public string CheckFilePath ( string path )
{
2021-03-22 22:23:55 -07:00
var matchers = new List < PathMatchSet >
{
new PathMatchSet ( new PathMatch ( "bitpool.rsc" , useEndsWith : true ) , "Bitpool" ) ,
2023-08-26 22:51:55 -04:00
new PathMatchSet ( new FilePathMatch ( "CD.IDX" ) , "Bitpool" ) ,
2022-06-30 17:14:09 -06:00
2022-12-27 12:00:00 -07:00
// Completely empty file present on multiple discs with Bitpool (Redump entries 52626 and 50229).
2022-06-30 17:14:09 -06:00
new PathMatchSet ( new PathMatch ( "LEADOUT.OFS" , useEndsWith : true ) , "Bitpool" ) ,
2021-03-22 22:23:55 -07:00
} ;
return MatchUtil . GetFirstMatch ( path , matchers , any : true ) ;
2021-03-19 15:41:49 -07:00
}
2019-09-27 23:52:24 -07:00
}
}