2021-03-21 14:30:37 -07:00
using System.Collections.Generic ;
2022-12-09 12:49:22 -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.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-28 22:03:35 -06:00
/// <summary>
/// Alpha-ROM is a form of copy protection created by SETTEC. It is known to make use of twin sectors as well as region locking.
/// Later forms of Alpha-ROM appear to be digital only, and it's currently unsure what forms of protection the digital only version includes, except that it does make use of region locking.
/// It seems that Alpha-ROM was used in Visual Novels using certain game engines, most notably RealLive and Siglus (https://forums.fuwanovel.net/topic/20927-cannot-crack-siglus-engine-with-alpharom/).
/// Not every Siglus engine game uses Alpha-ROM (Source: https://sample9.dmm.co.jp/digital/pcgame/vsat_0263/vsat_0263t.zip {Official trial mirror}).
/// Not every RealLive engine game uses Alpha-ROM (Source: IA item "Kanon_Standard_Edition_Japan").
/// Alpha-ROM also seems to have made use of something called "Alpha-DPS" for non-executable data files (http://www.gonsuke.co.jp/protect.html).
/// Example of Alpha-ROM (official trial download mirrors):
/// (Siglus Engine)
/// http://suezou.dyndns.org/dl2018/key/summer_pokets/Summer_Pockets_trial.zip
/// http://mirror.studio-ramble.com/upload/300/201103/RewriteTE_Ver200.zip
/// http://suezou.dyndns.org/dl2012/tone-works/hatsukoi1-1/hatsukoi_tr_web.zip
/// (RealLive Engine)
/// http://suezou.dyndns.org/dl2020/hadashi/princess_heart_link/phl_trial.exe
/// https://archive.org/details/little-busters-regular-edition-iso-only-2007
/// Games that may have Alpha-ROM:
/// http://cpdb.kemuri-net.com/ (Protection database that includes many different protections, including Alpha-ROM).
2022-08-30 21:10:56 -06:00
/// https://w.atwiki.jp/tirasinoura/pages/3.html (List of games with Alpha-ROM, and explains some version differences).
2022-07-28 22:03:35 -06:00
/// https://vndb.org/r?f=fwSiglusEngine- (VNs made with an engine known to use Alpha-ROM).
/// https://vndb.org/r?f=fwRealLive- (VNs made with an engine known to use Alpha-ROM).
/// References and further information:
2022-08-30 21:10:56 -06:00
/// http://hhg.sakura.ne.jp/cd-dvd/dust/alpha/alpha_index.htm
2022-07-28 22:03:35 -06:00
/// https://www.weblio.jp/content/Alpha-ROM
/// https://ameblo.jp/michael-j-fox/entry-10046574609.html
/// http://s2000.yokinihakarae.com/sub03-10-2(DVD).html
/// https://www.cdmediaworld.com/hardware/cdrom/cd_protections_alpha.shtml
/// Special thanks to Bestest for researching this protection and helping make further improvements possible!
/// </summary>
2021-10-20 21:06:43 -07:00
// TODO: Alternative string possibilities:
// - \AlphaDiscLog.txt
// - \SETTEC
// - AlphaROM
// - SETTEC0000SETTEC1111
// - SOFTWARE\SETTEC
// TODO: Are there version numbers?
2022-05-01 17:17:15 -07:00
public class AlphaROM : 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 )
2019-09-27 23:52:24 -07:00
{
2022-07-28 22:03:35 -06:00
// TODO: Add support for detecting Alpha-ROM found in older games made with the RealLive engine.
// TODO: Add version detection for Alpha-ROM.
2021-10-20 21:06:43 -07:00
// Get the sections from the executable, if possible
var sections = pex ? . SectionTable ;
if ( sections = = null )
return null ;
2022-12-09 12:49:22 -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 12:49:22 -08:00
if ( strs . Any ( s = > s . Contains ( "\\SETTEC" ) ) )
return "Alpha-ROM" ;
2021-10-20 21:06:43 -07:00
2022-12-09 12:49:22 -08:00
if ( strs . Any ( s = > s . Contains ( "SETTEC0000" ) ) )
return "Alpha-ROM" ;
2021-10-20 21:06:43 -07:00
}
2022-12-09 12:49:22 -08:00
// Get the .rdata section strings, if they exist
strs = pex . GetFirstSectionStrings ( ".rdata" ) ;
if ( strs ! = null )
2022-07-28 22:03:35 -06:00
{
2022-12-09 12:49:22 -08:00
if ( strs . Any ( s = > s . Contains ( "This Game is Japan Only" ) ) )
return "Alpha-ROM" ;
2022-07-28 22:03:35 -06:00
}
2022-08-30 21:10:56 -06:00
// Get the overlay data, if it exists
2022-12-10 20:10:25 -08:00
if ( pex . OverlayStrings ! = null )
2022-08-30 21:10:56 -06:00
{
2022-12-10 20:10:25 -08:00
// Found in Redump entry 84122.
if ( pex . OverlayStrings . Any ( s = > s . Contains ( "SETTEC0000" ) ) )
return "Alpha-ROM" ;
2022-08-30 21:10:56 -06:00
}
2021-10-20 21:06:43 -07:00
return null ;
2021-09-10 15:32:37 -07:00
}
2019-09-27 23:52:24 -07:00
}
}