// Author: DosX
// E-Mail: collab@kay-software.ru
// GitHub: https://github.com/DosX-dev
// Telegram: @DosX_dev

init("compiler", "Rust");

function detect(bShowType, bShowVersion, bShowOptions) {
    /*
    if (PE.isTLSPresent()) {
        if (!PE.is64()) {
            if (PE.compareEP("E8........E9........CCCCCCCCCC")) {
                sVersion = "i686-pc-windows-msvc";
                bDetected = true;
            }
        } else if (PE.compareEP("4883EC28E8........4883C428E9........CCCCCCCC")) {
            sVersion = "x86_64-pc-windows-msvc";
            bDetected = true;
        }
    }
    */

    var rdataSection = PE.section[".rdata"];

    if (PE.isTLSPresent() && rdataSection && PE.section["_RDATA"] &&
        PE.findSignature(rdataSection.FileOffset, rdataSection.FileSize, "4C6F63616C5C527573744261636B74726163654D75746578") != -1 &&
        PE.findSignature(rdataSection.FileOffset, rdataSection.FileSize, "'/rust'") != -1) {
        bDetected = true;
    }

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