// Detect It Easy: detection rule file

// Author: DosX
// E-Mail: collab@kay-software.ru
// GitHub: https://github.com/DosX-dev
// Telegram: @DosX_dev

// https://freebasic.net/
meta("compiler", "FreeBASIC");

function detect() {
    if (PE.isNet()) return; // Doesn't support .NET

    if (PE.isSectionNamePresent(".CRT") && PE.isLibraryPresent("msvcrt.dll")) {
        sVersion = "MinGW";

        // fb_StrAllocTempDescZEx
        if (PE.is64()) {
            bDetected = PE.compareEP("48") && PE.isSignatureInSectionPresent(0, "564889CE534889D34883EC28E8........4885C074..48893048895808488958104883C4285B5EC3");
        } else {
            bDetected = PE.compareEP("83") && PE.isSignatureInSectionPresent(0, "5383EC088B5C2414E8........85C074..8B542410895804895808891083C4085BC20800");
        }
    }

    if (!bDetected && PE.compareEP("E8....0000E801000000C35589E5")) {
        sVersion = "0.11+";
    }

    sLang = "FreeBASIC";

    return result();
}