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

meta("packer", "PKLITE");

function detect() {
    if (MSDOS.compare("'PKLITE'", 0x1E) || MSDOS.compare("'PKlite'", 0x1E)) {
        var bBit = MSDOS.readByte(0x1D);
        sVersion = (bBit & 0x7) + "." + ("0" + MSDOS.readByte(0x1C)).slice(-2);

        if (bBit & 0x8) {
            sOptions = "Extra compression";
        }
        if (bBit & 0x10) {
            sOptions = sOptions.append("Multi-segment file");
        }

        bDetected = true;
    } else if (MSDOS.compareEP("1FB409BA....CD21B8....CD21")) {
        sVersion = "1.50";
        sOptions = "CRC check";
        bDetected = true;
    } else if (MSDOS.compareEP("50B8....BA....05....3B060200")) {
        sVersion = "1.50";
        bDetected = true;
    } else if (MSDOS.compareEP("B8....BA....05....3B060200")) {
        sVersion = "1.12-1.13";
        bDetected = true;
    } else if (MSDOS.compareEP("b8....ba....05....2d....fa8ed0fb2d....8ec050b9....33ff57be....fc565706518cc88ec0")) {
        sVersion = "1.12";
        sOptions = "extra compression";
        bDetected = true;
    } else if (MSDOS.compareEP("ba....b8....05....3B06....73..2d....fa8ed0fb2d....8ec050b9....33ff57be....fcf3a5cb")) {
        sVersion = "1.1X";
        bDetected = true;
    } else if (MSDOS.compareEP("b8....05....3B06....72..cd20b9....2d....8ed02d....8ec006ba....be....33ff571e571feb")) {
        sVersion = "1.1X";
        bDetected = true;
    } else if (MSDOS.compareEP("B8....BA....3bc473..8bc42d....25....8bf8b9....be....fcf3a58bd8b1..d3eb8cd903d95333db53cb")) {
        sVersion = "1.12, 1.20";
        bDetected = true;
    } else if (MSDOS.compareEP("50532b06....0a06....8b1e....5b58b8....ba....8cdb03d83b1e....73..83eb..fa8ed3bc....fb")) {
        sVersion = "1.05";
        bDetected = true;
    } else if (MSDOS.compareEP("8cd805....ba....903b06....72..b409ba....cd21cd20")) {
        sVersion = "1.15";
        bDetected = true;
    } else if (MSDOS.compareEP("B8....BA....8cdb03d83b1e....73..83eb..fa8ed3bc....fb83eb..8ec353b9....33ff57be....fcf3a5cb")) {
        sVersion = "1.03-1.05";
        bDetected = true;
    } else if (MSDOS.compareEP("B8....BA....8cdb03d83b1e....73..83eb..fa8ed3bc....fb83eb..908ec353b9....33ff57be....90fcf3a5cb")) {
        sVersion = "1.03";
        sOptions = "type 2";
        bDetected = true;
    } else if (MSDOS.compareEP("2e8c1e....8b1e....8cda81c2....3bda72..81eb....83eb..fa8ed3bc....fbfdbe....8bfe8ccab9....03d1")) {
        sVersion = "1.00c";
        bDetected = true;
    } else if (MSDOS.compareEP("b8....ba....3b06....73..2d....8ed02d....518ec050b9....33ff57be....fcf3a5")) {
        sName += " [hacked] by Shay Lev Ary";
        bDetected = true;
    }

    return result();
}