// DIE's signature file
// Author: Levis <levintaeyeon@live.com>
// History:
// Update sign to detect version of Python from 1.0 to 3.4

init("format","Python Compiled Module");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(Binary.getSize()>=8)
    {
        bDetected=1;
        switch(Binary.readDword(0))
        {
        // Full info: https://github.com/python/cpython/blob/master/Lib/importlib/_bootstrap_external.py#L147
        case 0x00999902: sVersion="1.0";     break;
        case 0x00999903: sVersion="1.1-1.2"; break;
        case 0x0A0D2E89: sVersion="1.3";     break;
        case 0x0A0D1704: sVersion="1.4";     break;
        case 0x0A0D4E99: sVersion="1.5";     break;
        case 0x0A0DC4FC: sVersion="1.6";     break;
        case 0x0A0DC687: sVersion="2.0";     break;
        case 0x0A0DEB2A: sVersion="2.1";     break;
        case 0x0A0DED2D: sVersion="2.2";     break;
        case 0x0A0DF23B: sVersion="2.3";     break;
        case 0x0A0DF259: sVersion="2.4a0";   break;
        case 0x0A0DF263: sVersion="2.4a3";   break;
        case 0x0A0DF26D: sVersion="2.4b1";   break;
        case 0x0A0DF277: sVersion="2.5a0";   break;
        case 0x0A0DF281: sVersion="2.5a0";   break;
        case 0x0A0DF28B: sVersion="2.5a0";   break;
        case 0x0A0DF28C: sVersion="2.5a0";   break;
        case 0x0A0DF295: sVersion="2.5b3";   break;
        case 0x0A0DF29F: sVersion="2.5b3";   break;
        case 0x0A0DF2A9: sVersion="2.5c1";   break;
        case 0x0A0DF2B3: sVersion="2.5c2";   break;
        case 0x0A0DF2C7: sVersion="2.6a0";   break;
        case 0x0A0DF2D1: sVersion="2.6a1";   break;
        case 0x0A0DF2DB: sVersion="2.7a0";   break;
        case 0x0A0DF2E5: sVersion="2.7a0";   break;
        case 0x0A0DF2EF: sVersion="2.7a0";   break;
        case 0x0A0DF2F9: sVersion="2.7a0";   break;
        case 0x0A0DF303: sVersion="2.7a0";   break;
        case 0x0A0D0C27: sVersion="3.0a4";   break;
        case 0x0A0D0C3B: sVersion="3.0b1";   break;
        case 0x0A0D0C45: sVersion="3.1a1";   break;
        case 0x0A0D0C4F: sVersion="3.1a1";   break;
        case 0x0A0D0C58: sVersion="3.2a1";   break;
        case 0x0A0D0C62: sVersion="3.2a2";   break;
        case 0x0A0D0C6C: sVersion="3.2a3";   break;
        case 0x0A0D0C76: sVersion="3.3a1";   break;
        case 0x0A0D0C80: sVersion="3.3a1";   break;
        case 0x0A0D0C8A: sVersion="3.3a1";   break;
        case 0x0A0D0C94: sVersion="3.3a2";   break;
        case 0x0A0D0C9E: sVersion="3.3a4";   break;
        case 0x0A0D0CB2: sVersion="3.4a1";   break;
        case 0x0A0D0CBC: sVersion="3.4a1";   break;
        case 0x0A0D0CC6: sVersion="3.4a1";   break;
        case 0x0A0D0CD0: sVersion="3.4a1";   break;
        case 0x0A0D0CDA: sVersion="3.4a4";   break;
        case 0x0A0D0CE4: sVersion="3.4a4";   break;
        case 0x0A0D0CEE: sVersion="3.4rc2";  break;
        case 0x0A0D0CF8: sVersion="3.5a1";   break;
        case 0x0A0D0D02: sVersion="3.5b1";   break;
        case 0x0A0D0D0C: sVersion="3.5b2";   break;
        case 0x0A0D0D16: sVersion="3.5b3";   break; 
        case 0x0A0D0D17: sVersion="3.5.2";   break;
        case 0x0A0D0D20: sVersion="3.6a0";   break; 
        case 0x0A0D0D21: sVersion="3.6a1";   break;
        case 0x0A0D0D2A: sVersion="3.6a2";   break;
        case 0x0A0D0D2B: sVersion="3.6a2";   break;
        case 0x0A0D0D2C: sVersion="3.6a2";   break;
        case 0x0A0D0D2D: sVersion="3.6b1";   break;
        case 0x0A0D0D2F: sVersion="3.6b1";   break;
        case 0x0A0D0D30: sVersion="3.6b1";   break;
        case 0x0A0D0D31: sVersion="3.6b1";   break;
        case 0x0A0D0D32: sVersion="3.6b2";   break;
        case 0x0A0D0D33: sVersion="3.6rc1";  break;
        case 0x0A0D0D3E: sVersion="3.7a1";   break;
        case 0x0A0D0D3F: sVersion="3.7a2";   break;
        case 0x0A0D0D40: sVersion="3.7a4";   break;
        case 0x0A0D0D41: sVersion="3.7b1";   break;
        case 0x0A0D0D42: sVersion="3.7b5";   break;
        case 0x0A0D0D48: sVersion="3.8a1";   break;
        case 0x0A0D0D49: sVersion="3.8a1";   break;
        case 0x0A0D0D52: sVersion="3.8a1";   break;
        
        default:
            bDetected=0;
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
