Пример #1
0
        /// <summary>
        /// Encode the struct of Trans2Data into the byte array in SmbData.Trans2_Data
        /// </summary>
        protected override void EncodeTrans2Data()
        {
            this.smbData.Trans2_Data = new byte[sizeOfListInBytesLength + CifsMessageUtils.GetSmbEAListSize(
                                                    this.trans2Data.ExtendedAttributeList.FEAList)];
            using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    channel.Write <uint>(this.trans2Data.ExtendedAttributeList.SizeOfListInBytes);

                    if (this.trans2Data.ExtendedAttributeList.FEAList != null)
                    {
                        foreach (SMB_FEA smbEa in this.trans2Data.ExtendedAttributeList.FEAList)
                        {
                            channel.Write <byte>(smbEa.ExtendedAttributeFlag);
                            channel.Write <byte>(smbEa.AttributeNameLengthInBytes);
                            channel.Write <ushort>(smbEa.ValueNameLengthInBytes);

                            if (smbEa.AttributeName != null)
                            {
                                channel.WriteBytes(smbEa.AttributeName);
                            }
                            if (smbEa.ValueName != null)
                            {
                                channel.WriteBytes(smbEa.ValueName);
                            }
                        }
                    }
                    channel.EndWriteGroup();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Encode the struct of Trans2Data into the byte array in SmbData.Trans2_Data
        /// </summary>
        protected override void EncodeTrans2Data()
        {
            if (this.trans2Data.Data != null)
            {
                Type type = this.trans2Data.Data.GetType();

                if (type == typeof(SMB_INFO_STANDARD_OF_TRANS2_SET_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes
                                               <SMB_INFO_STANDARD_OF_TRANS2_SET_PATH_INFORMATION>(
                        (SMB_INFO_STANDARD_OF_TRANS2_SET_PATH_INFORMATION)this.trans2Data.Data);
                }
                else if (type == typeof(SMB_INFO_SET_EAS))
                {
                    SMB_INFO_SET_EAS data = (SMB_INFO_SET_EAS)this.trans2Data.Data;
                    this.smbData.Trans2_Data = new byte[sizeOfListInBytesLength + CifsMessageUtils.GetSmbEAListSize(
                                                            data.ExtendedAttributeList)];
                    using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                    {
                        using (Channel channel = new Channel(null, memoryStream))
                        {
                            channel.BeginWriteGroup();
                            channel.Write <uint>(data.SizeOfListInBytes);

                            if (data.ExtendedAttributeList != null)
                            {
                                foreach (SMB_FEA smbEa in data.ExtendedAttributeList)
                                {
                                    channel.Write <byte>(smbEa.ExtendedAttributeFlag);
                                    channel.Write <byte>(smbEa.AttributeNameLengthInBytes);
                                    channel.Write <ushort>(smbEa.ValueNameLengthInBytes);

                                    if (smbEa.AttributeName != null)
                                    {
                                        channel.WriteBytes(smbEa.AttributeName);
                                    }
                                    if (smbEa.ValueName != null)
                                    {
                                        channel.WriteBytes(smbEa.ValueName);
                                    }
                                }
                            }
                            channel.EndWriteGroup();
                        }
                    }
                }
                else
                {
                    // Branch for negative testing.
                }
            }
            else
            {
                this.smbData.Trans2_Data = new byte[0];
            }
        }