// Detect It Easy: detection rule file format

init("compiler", "Zig");

function detect(bShowType, bShowVersion, bShowOptions) {
    if (PE.compare("'MZ'78000100000004000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000780000000E1FBA0E00B409CD21B8014CCD21'This program cannot be run in DOS mode.$'0000'PE'0000")) {
        if ((PE.section[".rdata"]) && (PE.isDeepScan())) {
            var nOffset = PE.section[".rdata"].FileOffset;
            var nSize = PE.section[".rdata"].FileSize;
            var nVersionOffset = PE.findSignature(nOffset, nSize, "5A00490047005F00440045004200550047005F0043004F004C004F005200"); // Unicode ZIG_DEBUG_COLOR

            if (nVersionOffset != -1) {
                bDetected = true;
            }
        }
    }

    _setLang("Zig", bDetected);
    return result(bShowType, bShowVersion, bShowOptions);
}
