// DIE's signature file
// Author: deadmau5 <deadmau5@tutanota.de>

init("protector","Denuvo");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if (PE.isSectionNamePresent(".arch") || PE.isSectionNamePresent(".srdata") || PE.isSectionNamePresent(".xpdata") || PE.isSectionNamePresent(".xdata") || PE.isSectionNamePresent(".xtls"))
    {
      if(PE.isPEPlus())
      {
        // Mad Max, Metal Gear Solid: TPP, Rise of the Tomb Raider
        if(PE.compareEP("51 52 41 50 41 51 4C 8D ?? ?? ?? ?? ?? 4C 8D ?? ?? ?? ?? ?? 4D 29 C1"))
        {
            sVersion="v1.0";
            sOptions="x64";
            bDetected=1;
        }
        // Lords of the Fallen, Batman: AK, Just Cause 3, Sherlock Holmes: TdD, Tales of Berseria etc
        else if(PE.compareEP("48 8D 0D ?? ?? ?? ?? E9 ?? ?? ?? ??"))
        {
            sVersion="v2.0a";
            sOptions="x64";
            bDetected=1;
        }
        // Yesterday Origins
        else if(PE.compareEP("48 89 ?? ?? ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 4C 89 ?? ?? ?? ?? ?? 4C 89 ?? ?? ?? ?? ?? 48 83 FA 01"))
        {
            sVersion="v2.0b";
            sOptions="x64";
            bDetected=1;
        }
        // Sniper Ghost Warrior 3 (beta), Dead Rising 4 (SteamStub-free)
        else if(PE.compareEP("?? ?? ?? ?? ?? ?? ?? ?? 4C 89 1C 24 49 89 E3"))
        {
            sVersion="v3.0a";
            sOptions="x64";
            bDetected=1;
        }
        // Train Sim World CSX Heavy Haul
        else if(PE.compareEP("4D 8D ?? ?? ?? ?? ?? ?? ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8D ?? ?? 48 89 ?? 48 89 ?? 48 89"))
        {
            sVersion="v3.0b";
            sOptions="x64";
            bDetected=1;
        }
        else
        {
            sVersion="v?";
            sOptions="x64";
        }
        // Check if steam_api64.dll present
        if(PE.isLibraryPresent("steam_api64.dll"))
        {
            // Override additional info
            sOptions="x64 -> Steam";
            bDetected=1;
        }
        // Check if uplay_r1_loader64.dll present
        if(PE.isLibraryPresent("uplay_r1_loader64.dll"))
        {
            // Override additional info
            sOptions="x64 -> uPlay";
            bDetected=1;
        }
        // Check if Core/Activation64.dll present
        if(PE.isLibraryPresent("Core/Activation64.dll"))
        {
           // Override additional info
           sOptions="x64 -> Origin";
           bDetected=1;
        }
      }
      else
      {
        // Pro Evolution Soccer 2017, Champions of Anteria
        if(PE.compareEP("55 89 E5 8D ?? ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? E8 ?? ?? ?? ??"))
        {
            sVersion="v1.0";
            sOptions="x86";
            bDetected=1;
        }
        // Romance of 13 Kingdoms, 2Dark
        else if(PE.compareEP("8D ?? ?? ?? ?? ?? ?? 89 7C 24 04 89 E7"))
        {
            sVersion="v2.0";
            sOptions="x86";
            bDetected=1;
        }
        else
        {
            sVersion="v?";
            sOptions="x86";
        }
        // Check if steam_api64.dll present
        if(PE.isLibraryPresent("steam_api.dll"))
        {
            // Override additional info
            sOptions="x86 -> Steam";
            bDetected=1;
        }
        // Check if uplay_r1_loader.dll present
        if(PE.isLibraryPresent("uplay_r1_loader.dll"))
        {
            // Override additional info
            sOptions="x86 -> uPlay";
            bDetected=1;
        }
        // Check if Core/Activation.dll present
        if(PE.isLibraryPresent("Core/Activation.dll"))
        {
            // Override additional info
            sOptions="x86 -> Origin";
            bDetected=1;
        }
      }
    }
    return result(bShowType,bShowVersion,bShowOptions);
}
