// Detect It Easy: detection rule file format

init("protector", "Smart Assembly");

function detect(bShowType, bShowVersion, bShowOptions) {
    if (PE.isNET()) {
        if (PE.isSignatureInSectionPresent(0, "20ffffff005f175920ffff0000")) {
            sVersion = "3.X";
            bDetected = true;
        } else if (PE.isNetObjectPresent("Powered by {smartassembly}")) {
            sVersion = "1.X-4.X";
            bDetected = true;
        } else if (PE.isNetObjectPresent("Powered by SmartAssembly")) {
            sVersion = "5.X";
            bDetected = true;
        } else if (PE.isNetObjectPresent("SmartAssembly.Attributes")) {
            bDetected = true;
        } else if ((nOffset = PE.findString(PE.section[0].FileOffset,
                PE.section[0].FileSize,
                "Powered by SmartAssembly ")) != -1) {
            sVersion = PE.getString(nOffset + 25);
            bDetected = true;
        } else {
            var nEPSection = PE.getEntryPointSection();
            if (nEPSection != -1) {
                if ((nOffset = PE.findString(PE.section[nEPSection].FileOffset,
                        PE.section[nEPSection].FileSize,
                        "Powered by {smartassembly}")) != -1) {
                    bDetected = true;
                }
            }
        }
    }

    return result(bShowType, bShowVersion, bShowOptions);
}