// Detect It Easy: detection rule file format
// coauthor: sendersu

init("library", "Qt");

includeScript("QtFramework");

function detect(bShowType, bShowVersion, bShowOptions) {
    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"]) {
        var nVersionOffset = PE.findString(PE.section[".rdata"].FileOffset, PE.section[".rdata"].FileSize, "QWidget");
        if (nVersionOffset != -1) {
            sVersion = "x.xx";
            sOptions = "static linked";
            bDetected = true;
        }
    }

    return result(bShowType, bShowVersion, bShowOptions);
}
