如何在C#中将结构转换为字节数组?
public struct CIFSPacket{
    public uint protocolIdentifier; //The value must be "0xFF+'SMB'".
    public byte command;
    public byte errorClass;
    public byte reserved;
    public ushort error;
    public byte flags;
    //Here there are 14 bytes of data which is used differently among different dialects.
    //I do want the flags2. However, so I'll try parsing them.
    public ushort flags2;
    public ushort treeId;
    public ushort processId;
    public ushort userId;
    public ushort multiplexId;
    //Trans request
    public byte wordCount;//Count of parameter words defining the data portion of the packet.
    //From here it might be undefined...
    public int parametersStartIndex;
    public ushort byteCount; //Buffer length
    public int bufferStartIndex;
    public string Buffer;}CIFSPacket packet = new CIFSPacket();packet.protocolIdentifier = 0xff;packet.command = (byte)CommandTypes.SMB_COM_NEGOTIATE; packet.errorClass = 0xff;packet.error = 0;packet.flags = 0x00;packet.flags2 = 0x0001;packet.multiplexId = 22;packet.wordCount = 0; packet.byteCount = 119;packet.Buffer = "NT LM 0.12";
代码片段是什么?
精慕HU
临摹微笑
相关分类