// Detect It Easy: detection rule file format

init("compiler", "Free Basic");

function detect(bShowType, bShowVersion, bShowOptions) {
    if (PE.compareEP("5589E583EC08C70424..000000FF15........E8..FFFFFF89EC31C05DC389F65589E583EC08")) {
        // Free Basic is really MinGW, so make an extra check.
        // Well, it works for the one file I have on hand...
        if (PE.section[".rdata"]) {
            var nOffset = PE.section[".rdata"].FileOffset;
            var nSize = PE.section[".rdata"].FileSize;
            if (nSize > 0x800 && PE.isSignaturePresent(nOffset + nSize - 0x800, 0x800, "'FreeBASIC'")) {
                sVersion = "0.14+";
                bDetected = true;
            }
        }
    } else if (PE.compareEP("E8....0000E801000000C35589E5")) {
        sVersion = "0.11";
        bDetected = true;
    }

    _setLang("Basic", bDetected);
    return result(bShowType, bShowVersion, bShowOptions);
}
