// DIE's signature file

init("compiler","Rust");

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

    if(bDetected)
    {
        bDetected=0;
        if(PE.section[".rdata"])
        {
            var nOffset=PE.section[".rdata"].FileOffset;
            var nSize=PE.section[".rdata"].FileSize;
            var nVersionOffset=PE.findSignature(nOffset,nSize,"4C6F63616C5C527573744261636B74726163654D75746578"); // Local\RustBacktraceMutex
            
            if(nVersionOffset!=-1)
            {
                bDetected=1;
            }
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
