// DIE's signature file

init("sfx", "WinZip");

function detect(bShowType, bShowVersion, bShowOptions) {
    if (PE.compareEP("ff15........b1..380874..b1..4080....74..380874..4080....75..80....74..4033")) {
        sVersion = "6.x";
        bDetected = true;
    } else if (PE.compareEP("53ff15........b3..38..74..80c3..4033d28a083aca74..3acb74..408a083aca75")) {
        if (PE.findSignature(PE.getOverlayOffset(), Math.min(255, PE.getOverlaySize()), "504b0304") != -1) {
            sVersion = "2.2";
        } else if (PE.compareEP("8A48014033D23ACA740A3ACB74068A4801", 16)) {
            sVersion = "8.x";
        }
        bDetected = true;
    } else if (PE.compareEP("53ff15........b3..38..74..80c3..8a48..4033d23aca74..3acb74..8a48..40")) {
        sVersion = "8.x";
        bDetected = true;
    } else if (PE.compareEP("e8$$$$$$$$558bec83ec..a1........8365....8365....5357bf........3bc7bb........74..85c374..f7d0")) {
        for (var i = 0; i < PE.resource.length; i++) {
            if (PE.resource[i].Type != "RT_DIALOG") {
                var nSize = Math.min(PE.resource[i].Size, 0x1100);
                var ArcOffset = PE.findSignature(PE.resource[i].Offset, nSize, "'PK'0304");
                if (ArcOffset != -1) {
                    bDetected = true;
                    break;
                }
            }
        }
        if (PE.isSectionNamePresent("_winzip_")) {
            bDetected = true;
        }
    }
    if (PE.isSectionNamePresent("_winzip_")) {
        var nOffset = PE.getSectionFileOffset(PE.getSectionNumber("_winzip_"));
        var ArcOffset = PE.findSignature(nOffset, 0x1000, "'PK'0304");
        if (ArcOffset != -1) {
            sVersion = "3.1";
            bDetected = true;
        }
    }

    return result(bShowType, bShowVersion, bShowOptions);
}