2022-06-29 15:28:46 -06:00
using System ;
using System.Collections.Concurrent ;
2021-07-18 09:44:23 -07:00
using System.Collections.Generic ;
2022-12-03 22:17:48 -08:00
using System.Linq ;
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 ;
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
{
2022-07-07 16:24:41 -06:00
/// <summary>
/// MediaMax CD-3 is a copy protection for audio CDs created by SunnComm, which once installed, restricted users by only allowing a limited number of copies to be made, and only using Windows Media Player.
/// It appears to accomplish this using the official Windows Media Data Session Toolkit.
/// List of discs known to contain MediaMax CD-3: https://en.wikipedia.org/wiki/List_of_compact_discs_sold_with_MediaMax_CD-3
/// TODO: Add support for detecting the Mac version, which is present on "All That I Am" by Santana (Barcode 8 2876-59773-2 6)
/// </summary>
2022-05-01 17:23:00 -07:00
public class MediaMaxCD3 : IPathCheck , IPortableExecutableCheck
2019-09-27 23:52:24 -07:00
{
2021-09-01 14:06:19 -07:00
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable ( string file , PortableExecutable pex , bool includeDebug )
2021-03-23 09:52:09 -07:00
{
2021-09-01 14:06:19 -07:00
// Get the sections from the executable, if possible
var sections = pex ? . SectionTable ;
if ( sections = = null )
return null ;
2022-06-29 15:28:46 -06:00
// Used to detect "LicGen.exe", found on "All That I Am" by Santana (Barcode 8 2876-59773-2 6)
string name = pex . FileDescription ;
2022-08-21 20:34:59 -07:00
if ( name ? . StartsWith ( "LicGen Module" , StringComparison . OrdinalIgnoreCase ) = = true )
2022-06-29 15:28:46 -06:00
return $"MediaMax CD-3" ;
name = pex . ProductName ;
2022-08-21 20:34:59 -07:00
if ( name ? . StartsWith ( "LicGen Module" , StringComparison . OrdinalIgnoreCase ) = = true )
2022-06-29 15:28:46 -06:00
return $"MediaMax CD-3" ;
2022-12-03 22:17:48 -08:00
var cd3CtrlResources = pex . FindGenericResource ( "Cd3Ctl" ) ;
if ( cd3CtrlResources . Any ( ) )
return $"MediaMax CD-3" ;
var limitedProductionResources = pex . FindDialogBoxByItemTitle ( "This limited production advanced CD is not playable on your computer. It is solely intended for playback on standard CD players." ) ;
if ( limitedProductionResources . Any ( ) )
2021-09-10 22:02:57 -07:00
return $"MediaMax CD-3" ;
2022-12-08 16:01:30 -08:00
// TODO: Investigate the following dialog item title resource
// "This limited production advanced CD is not playable on your computer. It is solely intended for playback on standard CD players."
2022-12-09 15:10:23 -08:00
// Get the .data/DATA section strings, if they exist
List < string > strs = pex . GetFirstSectionStrings ( ".data" ) ? ? pex . GetFirstSectionStrings ( "DATA" ) ;
if ( strs ! = null )
2021-07-17 23:40:16 -07:00
{
2022-12-09 15:10:23 -08:00
if ( strs . Any ( s = > s . Contains ( "CD3 Launch Error" ) ) )
return "MediaMax CD-3" ;
2021-09-01 14:06:19 -07:00
}
2022-12-08 16:01:30 -08:00
// Get the export name table
if ( pex . ExportNameTable ! = null )
2021-09-01 14:06:19 -07:00
{
2022-12-08 16:01:30 -08:00
if ( pex . ExportNameTable . Any ( s = > s = = "DllInstallSbcp" ) )
return "MediaMax CD-3" ;
2021-09-01 14:06:19 -07:00
}
return null ;
}
2020-11-03 14:41:05 -08: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-23 09:52:09 -07:00
var matchers = new List < PathMatchSet >
{
2022-06-29 15:28:46 -06:00
// Found on "All That I Am" by Santana (Barcode 8 2876-59773-2 6)
new PathMatchSet ( new List < PathMatch >
{
// TODO: Verify if these are OR or AND
2022-07-24 00:55:04 -06:00
// TODO: Verify that this is directly related to MediaMax CD-3.
2022-06-29 15:28:46 -06:00
new PathMatch ( "PlayDisc.exe" , useEndsWith : true ) ,
new PathMatch ( "PlayDisc.xml" , useEndsWith : true ) ,
} , "MediaMax CD-3" ) ,
// Found on "Contraband" by Velvet Revolver (Barcode 8 28766 05242 8)
// "SCCD3X01.dll" should already be detected by the content checks, but not "SCCD3X02.dll".
new PathMatchSet ( new List < PathMatch >
{
// TODO: Verify if these are OR or AND
new PathMatch ( "SCCD3X01.dll" , useEndsWith : true ) ,
new PathMatch ( "SCCD3X02.dll" , useEndsWith : true ) ,
} , "MediaMax CD-3" ) ,
2021-03-23 09:52:09 -07:00
} ;
2022-07-07 16:24:41 -06:00
return MatchUtil . GetAllMatches ( files , matchers , any : false ) ;
2021-03-19 15:41:49 -07:00
}
/// <inheritdoc/>
public string CheckFilePath ( string path )
{
2021-03-23 09:52:09 -07:00
var matchers = new List < PathMatchSet >
{
2022-06-29 15:28:46 -06:00
// Found on "Contraband" by Velvet Revolver (Barcode 8 28766 05242 8)
new PathMatchSet ( new PathMatch ( "SCCD3X01.dll" , useEndsWith : true ) , "MediaMax CD-3" ) ,
new PathMatchSet ( new PathMatch ( "SCCD3X02.dll" , useEndsWith : true ) , "MediaMax CD-3" ) ,
2021-03-23 09:52:09 -07:00
} ;
2019-09-27 23:52:24 -07:00
2021-03-23 09:52:09 -07:00
return MatchUtil . GetFirstMatch ( path , matchers , any : true ) ;
2019-09-27 23:52:24 -07:00
}
}
}