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


C# Channel.BeginWriteGroup方法代码示例

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


在下文中一共展示了Channel.BeginWriteGroup方法的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>
 /// 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

示例3: EncodeData

 /// <summary>
 /// Encode the struct of SMB_COM_IOCTL_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();
             if (this.smbData.Pad1 != null)
             {
                 channel.WriteBytes(this.smbData.Pad1);
             }
             if (this.smbData.Parameters != null)
             {
                 channel.WriteBytes(this.smbData.Parameters);
             }
             if (this.smbData.Pad2 != null)
             {
                 channel.WriteBytes(this.smbData.Pad2);
             }
             if (this.smbData.Data != null)
             {
                 channel.WriteBytes(this.smbData.Data);
             }
             channel.EndWriteGroup();
         }
     }
 }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:32,代码来源:SmbIoctlRequestPacket.cs

示例4: EncodeData

 /// <summary>
 /// Encode the struct of SMB_COM_NEGOTIATE_NtLanManagerResponse_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();
             if (this.smbData.Challenge != null)
             {
                 channel.WriteBytes(this.smbData.Challenge);
             }
             if (this.smbData.DomainName != null)
             {
                 channel.WriteBytes(this.smbData.DomainName);
             }
             channel.EndWriteGroup();
         }
     }
 }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:24,代码来源:SmbNegotiateResponsePacket.cs

示例5: EncodeNtTransData

 /// <summary>
 /// Encode the struct of NtTransData into the byte array in SmbData.NT_Trans_Data
 /// </summary>
 protected override void EncodeNtTransData()
 {
     if (this.ntTransData.Data != null)
     {
         this.smbData.NT_Trans_Data = new byte[this.ntTransData.Data.Length];
         using (MemoryStream memoryStream = new MemoryStream(this.smbData.NT_Trans_Data))
         {
             using (Channel channel = new Channel(null, memoryStream))
             {
                 channel.BeginWriteGroup();
                 channel.WriteBytes(this.ntTransData.Data);
                 channel.EndWriteGroup();
             }
         }
     }
     else
     {
         this.smbData.NT_Trans_Data = new byte[0];
     }
 }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:23,代码来源:SmbNtTransactIoctlRequestPacket.cs

示例6: EncodeTrans2Data

        /// <summary>
        /// Encode the struct of Trans2Data into the byte array in SmbData.Trans2_Data
        /// </summary>
        protected override void EncodeTrans2Data()
        {
            int totalSize = referralHeaderSize;
            DFS_REFERRAL_V1[] referral1List = this.trans2Data.ReferralResponse.ReferralEntries as DFS_REFERRAL_V1[];
            DFS_REFERRAL_V2[] referral2List = this.trans2Data.ReferralResponse.ReferralEntries as DFS_REFERRAL_V2[];

            if (referral1List != null)
            {
                for (int i = 0; i < referral1List.Length; i++)
                {
                    totalSize += referralV1FixedSize + referral1List[i].ShareName.Length;
                }
            }
            else if (referral2List != null)
            {
                ushort wordLength = 2;
                ushort nullLength = 3;

                for (int i = 0; i < referral2List.Length; i++)
                {
                    totalSize += referralV2FixedSize + wordLength * (referral2List[i].DFSPath.Length
                         + referral2List[i].DFSAlternatePath.Length + referral2List[i].DFSTargetPath.Length + nullLength);
                }
            }
            else
            {
                // Branch for negative testing.
            }

            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();
                    channel.Write<ushort>(this.trans2Data.ReferralResponse.PathConsumed);
                    channel.Write<ushort>(this.trans2Data.ReferralResponse.NumberOfReferrals);
                    channel.Write<ReferralHeaderFlags>(this.trans2Data.ReferralResponse.ReferralHeaderFlags);

                    if (referral1List != null)
                    {
                        for (int i = 0; i < referral1List.Length; i++)
                        {
                            channel.Write<DFS_REFERRAL_V1>(referral1List[i]);
                        }
                    }
                    else if (referral2List != null)
                    {
                        for (int i = 0; i < referral2List.Length; i++)
                        {
                            channel.Write<ushort>(referral2List[i].VersionNumber);
                            channel.Write<ushort>(referral2List[i].Size);
                            channel.Write<ushort>(referral2List[i].ServerType);
                            channel.Write<ushort>(referral2List[i].ReferralEntryFlags);
                            channel.Write<uint>(referral2List[i].Proximity);
                            channel.Write<uint>(referral2List[i].TimeToLive);
                            channel.Write<ushort>(referral2List[i].DFSPathOffset);
                            channel.Write<ushort>(referral2List[i].DFSAlternatePathOffset);
                            channel.Write<ushort>(referral2List[i].NetworkAddressOffset);
                        }
                        for (int i = 0; i < referral2List.Length; i++)
                        {
                            channel.WriteBytes(Encoding.Unicode.GetBytes(referral2List[i].DFSPath + "\0"));
                            channel.WriteBytes(Encoding.Unicode.GetBytes(referral2List[i].DFSAlternatePath + "\0"));
                            channel.WriteBytes(Encoding.Unicode.GetBytes(referral2List[i].DFSTargetPath + "\0"));
                        }
                    }
                    else
                    {
                        // Branch for negative testing.
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:78,代码来源:SmbTrans2GetDfsReferalFinalResponsePacket.cs

示例7: 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

示例8: GetBytesWithoutHeader

        /// <summary>
        /// to encode the SmbParameters and SmbDada into bytes.
        /// </summary>
        /// <returns>the bytes array of SmbParameters, SmbDada, and AndX if existed.</returns>
        protected byte[] GetBytesWithoutHeader(bool isHeaderRequest, ushort andXOffset)
        {
            this.AndXOffset = (ushort)(this.ParametersSize + this.DataSize + andXOffset);

            if (isHeaderRequest)
            {
                this.AndXOffset += (ushort)(this.HeaderSize);
            }

            // get bytes of andx:
            byte[] andxBytes = new byte[0];

            if (this.andxPacket != null)
            {
                if (andxPacket as SmbBatchedRequestPacket != null)
                {
                    andxBytes = ((SmbBatchedRequestPacket)this.andxPacket).GetBytesWithoutHeader(false, this.AndXOffset);
                }
                else
                {
                    andxBytes = this.andxPacket.GetBytesWithoutHeader();
                }
            }

            // get the total CIFS packet size:
            int size = this.ParametersSize + this.DataSize + andxBytes.Length;

            // 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.WriteBytes(andxBytes);
                    channel.EndWriteGroup();
                }
            }
            return packetBytes;
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:46,代码来源:SmbBatchedRequestPacket.cs

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: EncodeData

        /// <summary>
        /// Encode the struct of SMB_COM_SESSION_SETUP_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];
            using (MemoryStream memoryStream = new MemoryStream(this.smbDataBlock.Bytes))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {

                    channel.BeginWriteGroup();
                    if (this.SmbData.OEMPassword != null)
                    {
                        channel.WriteBytes(this.SmbData.OEMPassword);
                    }
                    if (this.SmbData.UnicodePassword != null)
                    {
                        channel.WriteBytes(this.SmbData.UnicodePassword);
                    }
                    if (this.SmbData.Pad != null)
                    {
                        channel.WriteBytes(this.SmbData.Pad);
                    }
                    if (this.SmbData.AccountName != null)
                    {
                        channel.WriteBytes(this.SmbData.AccountName);
                    }
                    if (this.SmbData.PrimaryDomain != null)
                    {
                        channel.WriteBytes(this.SmbData.PrimaryDomain);
                    }
                    if (this.SmbData.NativeOS != null)
                    {
                        channel.WriteBytes(this.SmbData.NativeOS);
                    }
                    if (this.SmbData.NativeLanMan != null)
                    {
                        channel.WriteBytes(this.SmbData.NativeLanMan);
                    }
                    channel.EndWriteGroup();
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:45,代码来源:SmbSessionSetupAndxRequestPacket.cs

示例14: 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

示例15: 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


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