当前位置: 首页>>代码示例>>C#>>正文


C# Channel.Write方法代码示例

本文整理汇总了C#中Channel.Write方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.Write方法的具体用法?C# Channel.Write怎么用?C# Channel.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Channel的用法示例。


在下文中一共展示了Channel.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBytesWithoutHeader

        /// <summary>
        /// to encode the SmbParameters and SmbDada into bytes.
        /// </summary>
        /// <returns>the bytes array of SmbParameters, SmbDada.</returns>
        protected internal override byte[] GetBytesWithoutHeader()
        {
            if (this.smbHeader.Status == 0)
            {
                // get the total CIFS packet size:
                int size = this.ParametersSize + this.DataSize;

                // init packet bytes:
                byte[] packetBytes = new byte[size];
                using (MemoryStream memoryStream = new MemoryStream(packetBytes))
                {
                    using (Channel channel = new Channel(null, memoryStream))
                    {
                        channel.BeginWriteGroup();
                        channel.Write<SmbParameters>(this.smbParametersBlock);
                        channel.Write<SmbData>(this.smbDataBlock);
                        channel.EndWriteGroup();
                    }
                }
                return packetBytes;
            }
            else
            {
                return new byte[3];
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:30,代码来源:SmbSingleResponsePacket.cs

示例2: EncodeData

        /// <summary>
        /// Encode the struct of SMB_COM_TRANSACTION_Request_SMB_Data into the struct of SmbData
        /// Update Smb Data
        /// </summary>
        protected override void EncodeData()
        {
            if (!isDivided)
            {
                this.EncodeTransParameters();
                this.EncodeTransData();
            }
            int byteCount = 0;

            if (this.smbData.Name != null)
            {
                byteCount = (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE ?
                    this.smbData.Name.Length + padLength : this.smbData.Name.Length;
            }
            if (this.smbData.Pad1 != null)
            {
                byteCount += this.smbData.Pad1.Length;
            }
            if (this.smbData.Trans_Parameters != null)
            {
                byteCount += this.smbData.Trans_Parameters.Length;
            }
            if (this.smbData.Pad2 != null)
            {
                byteCount += this.smbData.Pad2.Length;
            }
            if (this.smbData.Trans_Data != null)
            {
                byteCount += this.smbData.Trans_Data.Length;
            }

            this.smbDataBlock.ByteCount = this.SmbData.ByteCount;
            this.smbDataBlock.Bytes = new byte[byteCount];
            using (MemoryStream memoryStream = new MemoryStream(this.smbDataBlock.Bytes))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    if ((this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
                    {
                        byte padding = 0;
                        channel.Write<byte>(padding);
                    }
                    if (this.SmbData.Name != null)
                    {
                        channel.WriteBytes(this.SmbData.Name);
                    }
                    if (this.SmbData.Pad1 != null)
                    {
                        channel.WriteBytes(this.SmbData.Pad1);
                    }
                    if (this.SmbData.Trans_Parameters != null)
                    {
                        channel.WriteBytes(this.SmbData.Trans_Parameters);
                    }
                    if (this.SmbData.Pad2 != null)
                    {
                        channel.WriteBytes(this.SmbData.Pad2);
                    }
                    if (this.SmbData.Trans_Data != null)
                    {
                        channel.WriteBytes(this.SmbData.Trans_Data);
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:71,代码来源:SmbTransactionRequestPacket.cs

示例3: EncodeData

 /// <summary>
 /// decode the SmbData
 /// </summary>
 protected override void EncodeData()
 {
     this.smbDataBlock.ByteCount = this.SmbData.ByteCount;
     this.smbDataBlock.Bytes = new byte[this.smbDataBlock.ByteCount];
     using (MemoryStream memoryStream = new MemoryStream(this.smbDataBlock.Bytes))
     {
         using (Channel channel = new Channel(null, memoryStream))
         {
             channel.BeginWriteGroup();
             channel.Write<byte>(this.SmbData.BufferFormat1);
             if (this.SmbData.OldFileName != null)
             {
                 channel.WriteBytes(this.SmbData.OldFileName);
             }
             channel.Write<byte>(this.SmbData.BufferFormat2);
             if (this.SmbData.NewFileName != null)
             {
                 channel.WriteBytes(this.SmbData.NewFileName);
             }
             channel.EndWriteGroup();
         }
     }
 }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:26,代码来源:SmbNtRenameRequestPacket.cs

示例4: WriteSmbParameter

 /// <summary>
 /// write the smbparameter to channel.
 /// </summary>
 /// <param name="channel">
 /// a Channel to write data to.
 /// </param>
 protected virtual void WriteSmbParameter(Channel channel)
 {
     channel.Write<SmbParameters>(this.smbParametersBlock);
 }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:10,代码来源:SmbBatchedResponsePacket.cs

示例5: EncodeTrans2Parameters

        /// <summary>
        /// Encode the struct of Trans2Parameters into the byte array in SmbData.Trans2_Parameters
        /// </summary>
        protected override void EncodeTrans2Parameters()
        {
            int trans2ParametersCount = reservedLength;

            if (this.trans2Parameters.DirectoryName != null)
            {
                trans2ParametersCount += this.trans2Parameters.DirectoryName.Length;
            }
            this.smbData.Trans2_Parameters = new byte[trans2ParametersCount];
            using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Parameters))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    channel.Write<uint>(this.trans2Parameters.Reserved);

                    if (this.trans2Parameters.DirectoryName != null)
                    {
                        channel.WriteBytes(this.trans2Parameters.DirectoryName);
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:27,代码来源:SmbTrans2CreateDirectoryRequestPacket.cs

示例6: EncodeTrans2Parameters

        /// <summary>
        /// Encode the struct of Trans2Parameters into the byte array in SmbData.Trans2_Parameters
        /// </summary>
        protected override void EncodeTrans2Parameters()
        {
            int trans2ParametersSize = trans2ParametersLength;

            if (this.trans2Parameters.FileName != null)
            {
                trans2ParametersSize += this.trans2Parameters.FileName.Length;
            }
            this.smbData.Trans2_Parameters = new byte[trans2ParametersSize];
            using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Parameters))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    channel.Write<ushort>(this.trans2Parameters.Flags);
                    channel.Write<ushort>(this.trans2Parameters.AccessMode);
                    channel.Write<ushort>(this.trans2Parameters.Reserved1);
                    channel.Write<SmbFileAttributes>(this.trans2Parameters.FileAttributes);
                    channel.Write<uint>(this.trans2Parameters.CreationTime);
                    channel.Write<ushort>(this.trans2Parameters.OpenMode);
                    channel.Write<uint>(this.trans2Parameters.AllocationSize);
                    byte[] reserved = CifsMessageUtils.ToBytesArray(this.trans2Parameters.Reserved);
                    channel.WriteBytes(reserved);

                    if (this.trans2Parameters.FileName != null)
                    {
                        channel.WriteBytes(this.trans2Parameters.FileName);
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:35,代码来源:SmbTrans2Open2RequestPacket.cs

示例7: EncodeData

        /// <summary>
        /// Encode the struct of SMB_COM_SEARCH_Request_SMB_Data into the struct of SmbData
        /// </summary>
        protected override void EncodeData()
        {
            this.smbDataBlock.ByteCount = this.SmbData.ByteCount;
            this.smbDataBlock.Bytes = new byte[this.smbDataBlock.ByteCount];
            using (MemoryStream memoryStream = new MemoryStream(this.smbDataBlock.Bytes))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    channel.Write<byte>(this.smbData.BufferFormat1);

                    if (this.smbData.FileName != null)
                    {
                        channel.WriteBytes(this.smbData.FileName);
                    }
                    channel.Write<byte>(this.smbData.BufferFormat2);
                    channel.Write<ushort>(this.smbData.ResumeKeyLength);

                    if (this.smbData.ResumeKey != null)
                    {
                        foreach (SMB_Resume_Key resumeKey in this.smbData.ResumeKey)
                        {
                            channel.Write<SMB_Resume_Key>(resumeKey);
                        }
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:32,代码来源:SmbSearchRequestPacket.cs

示例8: EncodeTrans2Data

        protected override void EncodeTrans2Data()
        {
            int totalSize = 0;
            int fixedSize = 0; // The fixed size of each structure

            if (this.trans2Data.Data != null)
            {
                Type type = this.trans2Data.Data.GetType();

                if (type == typeof(SMB_INFO_STANDARD_OF_TRANS2_FIND_FIRST2[]))
                {
                    SMB_INFO_STANDARD_OF_TRANS2_FIND_FIRST2[] standardArray = (
                        SMB_INFO_STANDARD_OF_TRANS2_FIND_FIRST2[])this.trans2Data.Data;

                    fixedSize = (this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) ==
                        SmbFlags2.SMB_FLAGS2_UNICODE ? 26 : 24;
                    ushort resumeKeyLength = 4;

                    if (isResumeKeyExisted)
                    {
                        totalSize = (resumeKeyLength + fixedSize) * standardArray.Length;
                    }
                    else
                    {
                        totalSize = fixedSize * standardArray.Length;
                    }

                    for (int i = 0; i < standardArray.Length; i++)
                    {
                        totalSize += standardArray[i].FileNameLength;
                    }
                    this.smbData.Trans2_Data = new byte[totalSize];
                    using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                    {
                        using (Channel channel = new Channel(null, memoryStream))
                        {
                            channel.BeginWriteGroup();
                            for (int i = 0; i < standardArray.Length; i++)
                            {
                                if (isResumeKeyExisted)
                                {
                                    channel.Write<uint>(standardArray[i].ResumeKey);
                                }
                                channel.Write<SmbDate>(standardArray[i].CreationDate);
                                channel.Write<SmbTime>(standardArray[i].CreationTime);
                                channel.Write<SmbDate>(standardArray[i].LastAccessDate);
                                channel.Write<SmbTime>(standardArray[i].LastAccessTime);
                                channel.Write<SmbDate>(standardArray[i].LastWriteDate);
                                channel.Write<SmbTime>(standardArray[i].LastWriteTime);
                                channel.Write<uint>(standardArray[i].DataSize);
                                channel.Write<uint>(standardArray[i].AllocationSize);
                                channel.Write<SmbFileAttributes>(standardArray[i].Attributes);
                                channel.Write<byte>(standardArray[i].FileNameLength);

                                if ((this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
                                {
                                    channel.Write<byte>(new byte());
                                }
                                channel.WriteBytes(standardArray[i].FileName);

                                if ((this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
                                {
                                    channel.Write<ushort>(new ushort());
                                }
                                else
                                {
                                    channel.Write<byte>(new byte());
                                }
                            }
                            channel.EndWriteGroup();
                        }
                    }
                }

                else if (type == typeof(SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_FIND_FIRST2[]))
                {
                    SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_FIND_FIRST2[] queryEaArray = (
                        SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_FIND_FIRST2[])this.trans2Data.Data;
                    fixedSize = 28;
                    ushort resumeKeyLength = 4;

                    if (isResumeKeyExisted)
                    {
                        totalSize = (resumeKeyLength + fixedSize) * queryEaArray.Length;
                    }
                    else
                    {
                        totalSize = fixedSize * queryEaArray.Length;
                    }

                    for (int i = 0; i < queryEaArray.Length; i++)
                    {
                        totalSize += queryEaArray[i].FileNameLength;
                    }
                    this.smbData.Trans2_Data = new byte[totalSize];
                    using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                    {
                        using (Channel channel = new Channel(null, memoryStream))
                        {
                            channel.BeginWriteGroup();
//.........这里部分代码省略.........
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:101,代码来源:SmbTrans2FindFirst2FinalResponsePacket.cs

示例9: EncodeTrans2Data

        /// <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];
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:59,代码来源:SmbTrans2SetPathInformationRequestPacket.cs

示例10: EncodeData

        /// <summary>
        /// Encode the struct of SMB_COM_LOCKING_ANDX_Request_SMB_Data into the struct of SmbData
        /// </summary>
        protected override void EncodeData()
        {
            this.smbDataBlock.ByteCount = this.SmbData.ByteCount;
            this.smbDataBlock.Bytes = new byte[this.smbDataBlock.ByteCount];

            bool largeFiles = (this.smbParameters.TypeOfLock & LockingAndxTypeOfLock.LARGE_FILES)
                == LockingAndxTypeOfLock.LARGE_FILES;

            using (MemoryStream memoryStream = new MemoryStream(this.smbDataBlock.Bytes))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    if (this.smbData.Unlocks != null)
                    {
                        foreach (object unlocking in this.smbData.Unlocks)
                        {
                            if (largeFiles)
                            {
                                channel.Write((LOCKING_ANDX_RANGE64)unlocking);
                            }
                            else
                            {
                                channel.Write((LOCKING_ANDX_RANGE32)unlocking);
                            }
                        }
                    }
                    if (this.smbData.Locks != null)
                    {
                        foreach (object locking in this.smbData.Locks)
                        {
                            if (largeFiles)
                            {
                                channel.Write((LOCKING_ANDX_RANGE64)locking);
                            }
                            else
                            {
                                channel.Write((LOCKING_ANDX_RANGE32)locking);
                            }
                        }
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:48,代码来源:SmbLockingAndxRequestPacket.cs

示例11: EncodeNtTransParameters

        /// <summary>
        /// Encode the struct of NtTransParameters into the byte array in SmbData.NT_Trans_Parameters
        /// </summary>
        protected override void EncodeNtTransParameters()
        {
            if ((this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
            {
                int ntTransParameterSize = CifsMessageUtils.GetSize<NT_TRANSACT_CREATE_Request_NT_Trans_Parameters>(
                    this.ntTransParameters) + PaddingSize;
                this.smbData.NT_Trans_Parameters = new byte[ntTransParameterSize];

                using (MemoryStream memoryStream = new MemoryStream(this.smbData.NT_Trans_Parameters))
                {
                    using (Channel channel = new Channel(null, memoryStream))
                    {
                        channel.BeginWriteGroup();
                        channel.Write<NtTransactFlags>(this.ntTransParameters.Flags);
                        channel.Write<uint>(this.ntTransParameters.RootDirectoryFID);
                        channel.Write<NtTransactDesiredAccess>(this.ntTransParameters.DesiredAccess);
                        channel.Write<ulong>(this.ntTransParameters.AllocationSize);
                        channel.Write<SMB_EXT_FILE_ATTR>(this.ntTransParameters.ExtFileAttributes);
                        channel.Write<NtTransactShareAccess>(this.ntTransParameters.ShareAccess);
                        channel.Write<NtTransactCreateDisposition>(this.ntTransParameters.CreateDisposition);
                        channel.Write<NtTransactCreateOptions>(this.ntTransParameters.CreateOptions);
                        channel.Write<uint>(this.ntTransParameters.SecurityDescriptorLength);
                        channel.Write<uint>(this.ntTransParameters.EALength);
                        channel.Write<uint>(this.ntTransParameters.NameLength);
                        channel.Write<NtTransactImpersonationLevel>(this.ntTransParameters.ImpersonationLevel);
                        channel.Write<NtTransactSecurityFlags>(this.ntTransParameters.SecurityFlags);
                        // Padding data
                        channel.WriteBytes(new byte[PaddingSize]);
                        channel.WriteBytes(this.ntTransParameters.Name);
                        channel.EndWriteGroup();
                    }
                }
            }
            else
            {
                this.smbData.NT_Trans_Parameters =
                    CifsMessageUtils.ToBytes<NT_TRANSACT_CREATE_Request_NT_Trans_Parameters>(this.ntTransParameters);
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:42,代码来源:SmbNtTransactCreateRequestPacket.cs

示例12: EncodeNtTransData

        /// <summary>
        /// Encode the struct of NtTransData into the byte array in SmbData.NT_Trans_Data
        /// </summary>
        protected override void EncodeNtTransData()
        {
            byte[] securicyInformation = null;

            if (this.ntTransData.SecurityDescriptor != null)
            {
                securicyInformation = new byte[this.ntTransData.SecurityDescriptor.BinaryLength];
                this.ntTransData.SecurityDescriptor.GetBinaryForm(securicyInformation, 0);
                this.smbData.NT_Trans_Data = securicyInformation;
            }
            else
            {
                securicyInformation = new byte[0];
            }
            this.smbData.NT_Trans_Data = new byte[this.ntTransParameters.SecurityDescriptorLength +
                this.ntTransParameters.EALength];
            using (MemoryStream memoryStream = new MemoryStream(this.smbData.NT_Trans_Data))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    channel.BeginWriteGroup();
                    channel.WriteBytes(securicyInformation);

                    if (this.ntTransData.ExtendedAttributes != null)
                    {
                        for (int i = 0; i < this.ntTransData.ExtendedAttributes.Length; i++)
                        {
                            channel.Write<uint>(this.ntTransData.ExtendedAttributes[i].NextEntryOffset);
                            channel.Write<FULL_EA_FLAGS>(this.ntTransData.ExtendedAttributes[i].Flags);
                            channel.Write<byte>(this.ntTransData.ExtendedAttributes[i].EaNameLength);
                            channel.Write<ushort>(this.ntTransData.ExtendedAttributes[i].EaValueLength);
                            int size = 0;

                            if (this.ntTransData.ExtendedAttributes[i].EaName != null)
                            {
                                channel.WriteBytes(this.ntTransData.ExtendedAttributes[i].EaName);
                                size += this.ntTransData.ExtendedAttributes[i].EaName.Length;
                            }
                            if (this.ntTransData.ExtendedAttributes[i].EaValue != null)
                            {
                                channel.WriteBytes(this.ntTransData.ExtendedAttributes[i].EaValue);
                                size += this.ntTransData.ExtendedAttributes[i].EaValue.Length;
                            }
                            int pad = (int)(this.ntTransData.ExtendedAttributes[i].NextEntryOffset - EA.FULL_EA_FIXED_SIZE - size);

                            if (pad > 0)
                            {
                                channel.WriteBytes(new byte[pad]);
                            }
                        }
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:58,代码来源:SmbNtTransactCreateRequestPacket.cs

示例13: EncodeTrans2Data

        /// <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_QUERY_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes<
                        SMB_INFO_STANDARD_OF_TRANS2_QUERY_PATH_INFORMATION>(
                (SMB_INFO_STANDARD_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data);
                }

                else if (type == typeof(SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes<
                        SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_QUERY_PATH_INFORMATION>(
                        (SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data);
                }

                else if (type == typeof(SMB_INFO_QUERY_EAS_FROM_LIST_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    SMB_INFO_QUERY_EAS_FROM_LIST_OF_TRANS2_QUERY_PATH_INFORMATION data =
                        (SMB_INFO_QUERY_EAS_FROM_LIST_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data;

                    if (data.ExtendedAttributeList != null)
                    {
                        this.smbData.Trans2_Data = new byte[data.SizeOfListInBytes];
                        using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                        {
                            using (Channel channel = new Channel(null, memoryStream))
                            {
                                channel.BeginWriteGroup();
                                channel.Write<uint>(data.SizeOfListInBytes);

                                foreach (SMB_FEA smbEa in data.ExtendedAttributeList)
                                {
                                    channel.Write<SMB_FEA>(smbEa);
                                }
                                channel.EndWriteGroup();
                            }
                        }
                    }
                }

                else if (type == typeof(SMB_INFO_QUERY_ALL_EAS_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    SMB_INFO_QUERY_ALL_EAS_OF_TRANS2_QUERY_PATH_INFORMATION easData =
                        (SMB_INFO_QUERY_ALL_EAS_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data;

                    if (easData.ExtendedAttributeList != null)
                    {
                        this.smbData.Trans2_Data = new byte[easData.SizeOfListInBytes];
                        using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                        {
                            using (Channel channel = new Channel(null, memoryStream))
                            {
                                channel.BeginWriteGroup();
                                channel.Write<uint>(easData.SizeOfListInBytes);

                                foreach (SMB_FEA smbEa in easData.ExtendedAttributeList)
                                {
                                    channel.Write<SMB_FEA>(smbEa);
                                }
                                channel.EndWriteGroup();
                            }
                        }
                    }
                }

                else if (type == typeof(SMB_QUERY_FILE_BASIC_INFO_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes<
                        SMB_QUERY_FILE_BASIC_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(
                        (SMB_QUERY_FILE_BASIC_INFO_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data);
                }

                else if (type == typeof(SMB_QUERY_FILE_STANDARD_INFO_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes<
                        SMB_QUERY_FILE_STANDARD_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(
                        (SMB_QUERY_FILE_STANDARD_INFO_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data);
                }

                else if (type == typeof(SMB_QUERY_FILE_EA_INFO_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes<
                        SMB_QUERY_FILE_EA_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(
                        (SMB_QUERY_FILE_EA_INFO_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data);
                }

                else if (type == typeof(SMB_QUERY_FILE_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION))
                {
                    this.smbData.Trans2_Data = CifsMessageUtils.ToBytes<
                        SMB_QUERY_FILE_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(
                        (SMB_QUERY_FILE_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION)this.trans2Data.Data);
                }
//.........这里部分代码省略.........
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:101,代码来源:SmbTrans2QueryFileInformationFinalResponsePacket.cs

示例14: WriteSmbParameter

 /// <summary>
 /// override the marshal method of smb parameter.<para/>
 /// in the create response, the WordCount is not equal to Words.Count.
 /// </summary>
 /// <param name="channel">
 /// a Channel to write data to.
 /// </param>
 protected override void WriteSmbParameter(Channel channel)
 {
     channel.Write<byte>((byte)CREATE_EXTENDED_INFORMATION_RESPONSE_LENGTH);
     channel.WriteBytes(Cifs.CifsMessageUtils.ToBytesArray<ushort>(this.smbParametersBlock.Words));
 }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:12,代码来源:SmbNtCreateAndxResponsePacket.cs

示例15: EncodeNtTransParameters

        /// <summary>
        /// Encode the struct of NtTransParameters into the byte array in SmbData.NT_Trans_Parameters
        /// </summary>
        protected override void EncodeNtTransParameters()
        {
            if (this.ntTransParameters.FileNotifyInformation != null &&
                this.ntTransParameters.FileNotifyInformation.Length > 0)
            {
                uint size = 0;
                ushort notifyInfoFixedLength = 12;

                foreach (FILE_NOTIFY_INFORMATION fileNotifyInformation in this.ntTransParameters.FileNotifyInformation)
                {
                    if (fileNotifyInformation.NextEntryOffset != 0)
                    {
                        size += fileNotifyInformation.NextEntryOffset;
                    }
                    else
                    {
                        size += notifyInfoFixedLength + fileNotifyInformation.FileNameLength;
                    }
                }
                this.smbData.Parameters = new byte[size];
                using (MemoryStream memoryStream = new MemoryStream(this.smbData.Parameters))
                {
                    using (Channel channel = new Channel(null, memoryStream))
                    {
                        channel.BeginWriteGroup();
                        foreach (FILE_NOTIFY_INFORMATION fileNotifyInformation in this.ntTransParameters.FileNotifyInformation)
                        {
                            channel.Write<FILE_NOTIFY_INFORMATION>(fileNotifyInformation);
                            int padLength = (int)(fileNotifyInformation.NextEntryOffset - notifyInfoFixedLength
                                - fileNotifyInformation.FileNameLength);

                            if (padLength > 0)
                            {
                                channel.WriteBytes(new byte[padLength]);
                            }
                        }
                        channel.EndWriteGroup();
                    }
                }
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:44,代码来源:SmbNtTransactNotifyChangeResponsePacket.cs


注:本文中的Channel.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。