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

// https://learn.microsoft.com/en-us/windows/win32/imapi/imapi-interfaces
meta("library", "IMAPI2");

function detect() {
    var sDataPreparer = ISO9660.getDataPreparerIdentifier();

    if (sDataPreparer.indexOf("IMAPI2") !== -1) {
        bDetected = true;

        // Try to extract version if present
        // Format: "IMAPI2 (1.0) ISO9660 FORMATTER COPYRIGHT (C) 2004-2007 MICROSOFT"
        var nVerPos = sDataPreparer.indexOf("IMAPI2");
        if (nVerPos !== -1) {
            var sVersionPart = sDataPreparer.substring(nVerPos + 6).trim();
            if (sVersionPart.charAt(0) === '(') {
                var nClosePos = sVersionPart.indexOf(")");

                if (nClosePos !== -1) {
                    sVersion = sVersionPart.substring(1, nClosePos);
                }
            }
        }
    }

    return result();
}
