// Detect It Easy: detection rule file
// Author: hypn0 <hypn0@mail.ru>, LinXP

meta("format");

includeScript("zlib");

function detect() {
    var TrueTypeTags = [];
    TrueTypeTags['BASE'] =
        TrueTypeTags['cmap'] =
        TrueTypeTags['DSIG'] =
        TrueTypeTags['EBDT'] =
        TrueTypeTags['Feat'] =
        TrueTypeTags['FFTM'] =
        TrueTypeTags['GDEF'] =
        TrueTypeTags['GPOS'] =
        TrueTypeTags['GSUB'] =
        TrueTypeTags['LTSH'] =
        TrueTypeTags['OS/2'] = 1;

    if (Binary.compare("950412de00000000") || Binary.compare("de12049500000000")) {
        sName = "GNU Gettext Machine Object (.MO)";
    } else if (TrueTypeTags[Binary.getString(0xC, 4)]) {
        sName = "TrueType font (.TTF)";
    } else if (Binary.compare("f702018392c01c3b")) {
        sName = "Device Independent Document (.DVI)";
    } else if (Binary.compare("31be000000ab0000") || Binary.compare("32be000000ab0000")) {
        sName = "Windows Write document (.WRI)";
    } else if (Binary.compare("'MICROSOFT PIFEX'0087010000", 0x171)) {
        sName = "Microsoft Program Information (.PIF)";
    } else if (Binary.compare("4c0000000114020000000000c000000000000046")) {
        sName = "Windows Shortcut (.LNK)";
    } else if (Binary.compare("'Zinc Data File Version'")) {
        sName = "Zinc Data (.DAT)";
    } else if (Binary.compare("00010000'Jet System DB  '00")) {
        sName = "Microsoft Access Workgroup Information (.MDW)";
    } else if (Binary.compare("dca5..00..................00000000") || Binary.compare("eca5c100..................00000000")) {
        sName = "Microsoft Word 2 document";
    } else if (Binary.compare("'OTTO'................'CFF '")) {
        sName = "OpenType - CFF compact font (.OTF)";
    } else if (Binary.compare("3cb86418caef9c95")) {
        sName = "Qt Message (.QM)";
    } else if (Binary.compare("'SIB file: TsiLang binary translation data'")) {
        sName = "TsiLang binary translation data (.SIB)";
    } else if (Binary.compare("......00..........000200") && Binary.compare("00'LP'", 0x21)) {
        sName = "Embedded OpenType font (.EOT)";
    } else if (Binary.compare("d4c3b2a1020004")) {
        sName = "TCPDUMP's style capture (.ACP/PCAP)";
    } else if (Binary.compare("'HSP'")) {
        sName = "OS/2 help file";
    } else if (Binary.compare("'LN'0200")) {
        sName = "Quick Help";
    } else if (Binary.compare("'MZIP'")) {
        sName = "MZIP archive";
    } else if (Binary.compare("'Kaydara FBX Binary  '00")) {
        sName = "Kaydara FBX Binary (.FBX)";
        sVersion = Binary.read_uint16(0x17);
    } else if (Binary.compare("89'FCP'0D0A1A0A")) {
        sName = "High-Logic FontCreator Project (.FCP)";
        sVersion = Binary.read_uint16(0x08) + "." + Binary.read_uint16(0x0A);
        detect_zlib(Binary, 0x14 + Binary.read_uint32(0x10) * 0x11 + 0x0C);
    } else if (Binary.compare("'XALZ'")) {
        sName = "Xamarin Compressed DLL";
        sOptions = sOptions.append("LZ4 compression", "Index:" + Binary.read_uint32(0x4), "Original size:" + Binary.read_uint32(0x8))
    }

    bDetected = bDetected || Boolean(sName);

    return result();
}