2022-12-30 10:54:44 -07:00
using System ;
using System.Collections.Concurrent ;
2022-07-05 22:03:27 -06: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 ;
using BinaryObjectScanner.Wrappers ;
2021-03-21 14:30:37 -07:00
2023-03-09 23:19:27 -05:00
namespace BinaryObjectScanner.Protection
2019-09-27 23:52:24 -07:00
{
2022-07-05 22:03:27 -06:00
/// <summary>
/// Cenega ProtectDVD is a protection seemingly created by the publisher Cenega for use with their games.
2023-02-09 07:05:13 -07:00
/// Games using this protection aren't able to be run from an ISO file, and presumably use DPM as a protection feature.
/// <see href="https://github.com/TheRogueArchivist/DRML/blob/main/entries/Cenega_ProtectDVD/Cenega_ProtectDVD.md"/>
2022-07-05 22:03:27 -06:00
/// </summary>
public class CengaProtectDVD : IPathCheck , IPortableExecutableCheck
2019-09-27 23:52:24 -07:00
{
2021-02-26 01:26:49 -08:00
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable ( string file , PortableExecutable pex , bool includeDebug )
2021-08-29 21:51:43 -07:00
{
// Get the sections from the executable, if possible
var sections = pex ? . SectionTable ;
if ( sections = = null )
return null ;
2022-12-30 10:54:44 -07:00
// Get the export directory table
if ( pex . ExportTable ? . ExportDirectoryTable ! = null )
{
// Found in "cenega.dll" in IA item "speed-pack".
bool match = pex . ExportTable . ExportDirectoryTable . Name ? . Equals ( "ProtectDVD.dll" , StringComparison . OrdinalIgnoreCase ) = = true ;
if ( match )
return "Cenega ProtectDVD" ;
}
// Get the .cenega section, if it exists. Seems to be found in the protected game executable ("game.exe" in Redump entry 31422 and "Classic Car Racing.exe" in IA item "speed-pack").
2021-09-11 21:03:36 -07:00
bool cenegaSection = pex . ContainsSection ( ".cenega" , exact : true ) ;
if ( cenegaSection )
2021-08-29 21:51:43 -07:00
return "Cenega ProtectDVD" ;
2022-12-30 10:54:44 -07:00
// Get the .cenega0 through .cenega2 sections, if they exists. Found in "cenega.dll" in Redump entry 31422 and IA item "speed-pack".
2022-07-05 22:03:27 -06:00
cenegaSection = pex . ContainsSection ( ".cenega0" , exact : true ) ;
if ( cenegaSection )
return "Cenega ProtectDVD" ;
cenegaSection = pex . ContainsSection ( ".cenega1" , exact : true ) ;
if ( cenegaSection )
return "Cenega ProtectDVD" ;
cenegaSection = pex . ContainsSection ( ".cenega2" , exact : true ) ;
if ( cenegaSection )
return "Cenega ProtectDVD" ;
2021-08-29 21:51:43 -07:00
return null ;
}
2022-07-05 22:03:27 -06:00
/// <inheritdoc/>
public ConcurrentQueue < string > CheckDirectoryPath ( string path , IEnumerable < string > files )
{
var matchers = new List < PathMatchSet >
{
// Seems likely to be present in most, if not all discs protected with Cenega ProtectDVD, but unable to confirm due to only having a small sample size.
2022-12-30 10:54:44 -07:00
// Found in Redump entry 31422 and IA item "speed-pack".
2022-07-05 22:03:27 -06:00
new PathMatchSet ( new PathMatch ( "cenega.dll" , useEndsWith : true ) , "Cenega ProtectDVD" ) ,
} ;
return MatchUtil . GetAllMatches ( files , matchers , any : true ) ;
}
/// <inheritdoc/>
public string CheckFilePath ( string path )
{
var matchers = new List < PathMatchSet >
{
// Seems likely to be present in most, if not all discs protected with Cenega ProtectDVD, but unable to confirm due to only having a small sample size.
2022-12-30 10:54:44 -07:00
// Found in Redump entry 31422 and IA item "speed-pack".
2022-07-05 22:03:27 -06:00
new PathMatchSet ( new PathMatch ( "cenega.dll" , useEndsWith : true ) , "Cenega ProtectDVD" ) ,
} ;
return MatchUtil . GetFirstMatch ( path , matchers , any : true ) ;
}
2019-09-27 23:52:24 -07:00
}
}