2022-07-05 22:03:27 -06:00
using System.Collections.Concurrent ;
using System.Collections.Generic ;
2022-05-01 17:41:50 -07:00
using BurnOutSharp.Interfaces ;
2022-07-05 22:03:27 -06:00
using BurnOutSharp.Matching ;
2022-12-03 22:17:48 -08:00
using BurnOutSharp.Wrappers ;
2021-03-21 14:30:37 -07:00
namespace BurnOutSharp.ProtectionType
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.
/// Games using this protection aren't able to be run from an ISO file, and presumably use DMI as a protection feature.
/// </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-07-05 22:03:27 -06:00
// Get the .cenega section, if it exists. Seems to be found in the protected game executable (Redump entry 31422).
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-07-05 22:03:27 -06:00
// Get the .cenega0 through .cenega2 sections, if they exists. Found in cenega.dll (Redump entry 31422).
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.
// References the existence of a "ProtectDVD.dll", which has not yet been located (Redump entry 31422).
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.
// References the existence of a "ProtectDVD.dll", which has not yet been located (Redump entry 31422).
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
}
}