// Detect It Easy: detection rule file
// Author: horsicq <horsicq@gmail.com>
// coauthor: sendersu

meta("library", "Qt");

includeScript("QtFramework");

function detect() {
    if (aQt) {
        sVersion = PE.getPEFileVersion(PE.getFileDirectory() + "/" + aQt[0]);
        if (!sVersion) {
            if (PE.getVersionStringInfo("ProductName") == "The Qt Company Ltd" ||
                PE.getVersionStringInfo("ProductName") == "Qt5") {
                sVersion = PE.getPEFileVersion(PE.getFileDirectory() + "/" + ownName); // Check Linux !!!
            }
            if (!sVersion)
                sVersion = (aQt[3] ? aQt[3] : aQt[1]) + ".X";
        }
        if (aQt[2]) {
            sOptions = "debug";
        }
        bDetected = true;
    }

    if (!aQt && PE.section[".rdata"]) {
        if (PE.findString(PE.section[".rdata"].FileOffset, PE.section[".rdata"].FileSize, "QWidget") != -1) {
            sOptions = "static";
            bDetected = true;
        }
    }

    return result();
}
