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


C# Channel.ReadBytes方法代码示例

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


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

示例1: DecodeNtTransParameters

 /// <summary>
 /// to decode the NtTrans parameters: from the general NtTransParameters to the concrete NtTrans Parameters.
 /// </summary>
 protected override void DecodeNtTransParameters()
 {
     if (this.smbData.NT_Trans_Parameters != null)
     {
         if ((this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
         {
             using (MemoryStream memoryStream = new MemoryStream(this.smbData.NT_Trans_Parameters))
             {
                 using (Channel channel = new Channel(null, memoryStream))
                 {
                     this.ntTransParameters.Flags = channel.Read<NtTransactFlags>();
                     this.ntTransParameters.RootDirectoryFID = channel.Read<uint>();
                     this.ntTransParameters.DesiredAccess = channel.Read<NtTransactDesiredAccess>();
                     this.ntTransParameters.AllocationSize = channel.Read<ulong>();
                     this.ntTransParameters.ExtFileAttributes = channel.Read<SMB_EXT_FILE_ATTR>();
                     this.ntTransParameters.ShareAccess = channel.Read<NtTransactShareAccess>();
                     this.ntTransParameters.CreateDisposition = channel.Read<NtTransactCreateDisposition>();
                     this.ntTransParameters.CreateOptions = channel.Read<NtTransactCreateOptions>();
                     this.ntTransParameters.SecurityDescriptorLength = channel.Read<uint>();
                     this.ntTransParameters.EALength = channel.Read<uint>();
                     this.ntTransParameters.NameLength = channel.Read<uint>();
                     this.ntTransParameters.ImpersonationLevel = channel.Read<NtTransactImpersonationLevel>();
                     this.ntTransParameters.SecurityFlags = channel.Read<NtTransactSecurityFlags>();
                     // Padding data
                     channel.ReadBytes(PaddingSize);
                     this.ntTransParameters.Name = channel.ReadBytes((int)this.ntTransParameters.NameLength);
                 }
             }
         }
         else
         {
             this.ntTransParameters = TypeMarshal.ToStruct<NT_TRANSACT_CREATE_Request_NT_Trans_Parameters>(
                 this.smbData.NT_Trans_Parameters);
         }
     }
 }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:39,代码来源:SmbNtTransactCreateRequestPacket.cs

示例2: DecodeTransData

        /// <summary>
        /// to decode the Trans data: from the general TransDada to the concrete Trans Data.
        /// </summary>
        protected override void DecodeTransData()
        {
            if (this.smbData.Trans_Data != null && this.smbData.Trans_Data.Length > 0)
            {
                using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans_Data))
                {
                    using (Channel channel = new Channel(null, memoryStream))
                    {
                        this.transData.OutputBufferSize = channel.Read<ushort>();
                        this.transData.InputBufferSize = channel.Read<ushort>();
                        this.transData.MaximumInstances = channel.Read<byte>();
                        this.transData.CurrentInstances = channel.Read<byte>();
                        this.transData.PipeNameLength = channel.Read<byte>();

                        if ((this.smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
                        {
                            this.transData.Pad = new byte[1]{ channel.Read<byte>()};
                        }
                        this.transData.PipeName = channel.ReadBytes(this.transData.PipeNameLength);
                    }
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:26,代码来源:SmbTransQueryNmpipeInfoSuccessResponsePacket.cs

示例3: DecodeTrans2Data

        /// <summary>
        /// to decode the Trans2 data: from the general Trans2Dada to the concrete Trans2 Data.
        /// </summary>
        protected override void DecodeTrans2Data()
        {
            if (this.smbData.Trans2_Data != null && this.smbData.Trans2_Data.Length > 0)
            {
                using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                {
                    using (Channel channel = new Channel(null, memoryStream))
                    {
                        this.trans2Data.ReferralResponse.PathConsumed = channel.Read<ushort>();
                        this.trans2Data.ReferralResponse.NumberOfReferrals = channel.Read<ushort>();
                        this.trans2Data.ReferralResponse.ReferralHeaderFlags = channel.Read<ReferralHeaderFlags>();

                        if (this.trans2Data.ReferralResponse.NumberOfReferrals == 0)
                        {
                            return;
                        }

                        ushort versionNumber = channel.Peek<ushort>(0);

                        switch (versionNumber)
                        {
                            case 0x0001:
                                List<DFS_REFERRAL_V1> referral1List = new List<DFS_REFERRAL_V1>();

                                for (int i = 0; i < this.trans2Data.ReferralResponse.NumberOfReferrals; i++)
                                {
                                    referral1List.Add(channel.Read<DFS_REFERRAL_V1>());
                                }
                                this.trans2Data.ReferralResponse.ReferralEntries = referral1List.ToArray();
                                break;

                            case 0x0002:
                                List<DFS_REFERRAL_V2> referral2List = new List<DFS_REFERRAL_V2>();

                                for (int i = 0; i < this.trans2Data.ReferralResponse.NumberOfReferrals; i++)
                                {
                                    DFS_REFERRAL_V2 referral2 = new DFS_REFERRAL_V2();
                                    referral2.VersionNumber = channel.Read<ushort>();
                                    referral2.Size = channel.Read<ushort>();
                                    referral2.ServerType = channel.Read<ushort>();
                                    referral2.ReferralEntryFlags = channel.Read<ushort>();
                                    referral2.Proximity = channel.Read<uint>();
                                    referral2.TimeToLive = channel.Read<uint>();
                                    referral2.DFSPathOffset = channel.Read<ushort>();
                                    referral2.DFSAlternatePathOffset = channel.Read<ushort>();
                                    referral2.NetworkAddressOffset = channel.Read<ushort>();
                                    referral2List.Add(referral2);
                                }
                                int fixedListSize = this.trans2Data.ReferralResponse.NumberOfReferrals * referralV2FixedSize;
                                byte[] pathData = channel.ReadBytes(this.smbData.Trans2_Data.Length - fixedListSize
                                    - referralHeaderSize);

                                for (int i = 0; i < referral2List.Count; i++)
                                {
                                    int leftCount = referral2List.Count - i;
                                    DFS_REFERRAL_V2 referral2 = referral2List[i];
                                    int dfsPathOffset = referral2.DFSPathOffset - leftCount * referralV2FixedSize;
                                    int dfsAlternatePathOffset = referral2.DFSAlternatePathOffset -
                                        leftCount * referralV2FixedSize;
                                    int targetPathOffset = referral2.NetworkAddressOffset - leftCount * referralV2FixedSize;
                                    int pathLength = 0;
                                    byte wordLength = 2;

                                    for (int j = dfsPathOffset; ; j += wordLength)
                                    {
                                        if (pathData[j] == 0 && pathData[j + 1] == 0)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            pathLength += wordLength;
                                        }
                                    }
                                    referral2.DFSPath = Encoding.Unicode.GetString(pathData, dfsPathOffset, pathLength);
                                    pathLength = 0;

                                    for (int j = dfsAlternatePathOffset; ; j += wordLength)
                                    {
                                        if (pathData[j] == 0 && pathData[j + 1] == 0)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            pathLength += wordLength;
                                        }
                                    }
                                    referral2.DFSAlternatePath = Encoding.Unicode.GetString(pathData, dfsAlternatePathOffset,
                                        pathLength);
                                    pathLength = 0;

                                    for (int j = targetPathOffset; ; j += wordLength)
                                    {
                                        if (pathData[j] == 0 && pathData[j + 1] == 0)
                                        {
                                            break;
//.........这里部分代码省略.........
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:101,代码来源:SmbTrans2GetDfsReferalFinalResponsePacket.cs

示例4: FromBytes

        /// <summary>
        /// Decode the payload data from byte array to RESP_GET_DFS_REFERRAL structure.
        /// And assign the result to referralResponse field.
        /// </summary>
        /// <param name="payloadData">RESP_GET_DFS_REFERRAL in byte array</param>
        /// <exception cref=" System.InvalidOperationException">
        /// Fail to decode payload data to RESP_GET_DFS_REFERRAL structure
        /// </exception>
        /// <exception cref=" System.FormatException">payloadData is null or empty</exception>
        private void FromBytes(byte[] payloadData)
        {
            if (payloadData != null && payloadData.Length > 0)
            {
                using (MemoryStream memoryStream = new MemoryStream(payloadData))
                {
                    Channel channel = new Channel(null, memoryStream);

                    // Read the referral header
                    this.referralResponse.PathConsumed = channel.Read<ushort>();
                    this.referralResponse.NumberOfReferrals = channel.Read<ushort>();
                    this.referralResponse.ReferralHeaderFlags = channel.Read<ReferralHeaderFlags>();

                    // Read Referral Entries
                    if (this.referralResponse.NumberOfReferrals > 0)
                    {
                        this.versionNumber = channel.Peek<ushort>(0);

                        switch (this.versionNumber)
                        {
                            case 0x0001:
                                List<DFS_REFERRAL_V1> referral1List = new List<DFS_REFERRAL_V1>();
                                // The total size of VersionNumber, Size, ServerType and ReferralEntryFlags in DFS_REFERRAL_V1
                                const ushort referralV1fixedSize = 8;

                                for (int i = 0; i < this.referralResponse.NumberOfReferrals; i++)
                                {
                                    DFS_REFERRAL_V1 referral1 = new DFS_REFERRAL_V1();
                                    referral1.VersionNumber = channel.Read<ushort>();
                                    referral1.Size = channel.Read<ushort>();
                                    referral1.ServerType = channel.Read<ushort>();
                                    referral1.ReferralEntryFlags = channel.Read<ushort>();
                                    referral1.ShareName = Encoding.Unicode.GetString(channel.ReadBytes(referral1.Size
                                        - referralV1fixedSize - sizeofWord));
                                    channel.ReadBytes(sizeofWord);
                                    referral1List.Add(referral1);
                                }
                                this.referralResponse.ReferralEntries = referral1List.ToArray();
                                break;

                            case 0x0002:
                                DecodeReferralV2(channel);
                                break;

                            case 0x0003:
                            case 0x0004:
                                // The offset from beginning of DFS_REFERRAL_V3V4 to ReferralEntryFlags field
                                ushort flagOffset = 6;
                                ReferralEntryFlags_Values referralEntryFlags = channel.Peek<ReferralEntryFlags_Values>(flagOffset);

                                if ((referralEntryFlags & ReferralEntryFlags_Values.NameListReferral)
                                    == ReferralEntryFlags_Values.NameListReferral)
                                {
                                    this.isNameListReferral = true;
                                    DecodeReferralV3V4_NameListReferral(channel);
                                }
                                else
                                {
                                    this.isNameListReferral = false;
                                    DecodeReferralV3V4_NonNameListReferral(channel);
                                }
                                break;

                            default:
                                throw new InvalidOperationException("The version number of Referral Entry is not correct.");
                        }
                    }
                }
            }
            else
            {
                throw new FormatException("payload byte array is null or empty for decoding.");
            }
        }
开发者ID:XiaotianLiuMS,项目名称:WindowsProtocolTestSuites,代码行数:83,代码来源:DfscReferralResponsePacket.cs

示例5: ReadPadding

 /// <summary>
 /// Read the pad data from channel.
 /// </summary>
 /// <param name="channel">channel with payload data</param>
 /// <param name="padLength">the length of pad</param>
 /// <exception cref=" System.InvalidOperationException">pad length is negative</exception>
 private void ReadPadding(Channel channel, int padLength)
 {
     if (padLength < 0)
     {
         throw new InvalidOperationException("The length of pad data is negative.");
     }
     channel.ReadBytes(padLength);
 }
开发者ID:XiaotianLiuMS,项目名称:WindowsProtocolTestSuites,代码行数:14,代码来源:DfscReferralResponsePacket.cs

示例6: DecodeTransData

 /// <summary>
 /// to decode the Trans data: from the general TransDada to the concrete Trans Data.
 /// </summary>
 protected override void DecodeTransData()
 {
     if (this.smbData.Trans_Data != null)
     {
         using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans_Data))
         {
             using (Channel channel = new Channel(null, memoryStream))
             {
                 this.transData.WriteData = channel.ReadBytes(this.SmbParameters.DataCount);
             }
         }
     }
     else
     {
         this.transData.WriteData = new byte[0];
     }
 }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:20,代码来源:SmbTransRawWriteNmpipeRequestPacket.cs

示例7: DecodeReferralV3V4_NameListReferral

        /// <summary>
        /// Decode the payload for type of Referral Entry V3V4_NameListReferral
        /// </summary>
        /// <param name="channel">channel with payload data</param>
        /// <exception cref=" System.InvalidOperationException">
        /// Fail to decode payload data to ReferralV3V4_NameListReferral structure
        /// </exception>
        private void DecodeReferralV3V4_NameListReferral(Channel channel)
        {
            bool isDfsPathFollowed = false;
            List<DFS_REFERRAL_V3V4_NameListReferral> tempList = new List<DFS_REFERRAL_V3V4_NameListReferral>();
            // The total size of all fields in front of Padding field in DFS_REFERRAL_V3V4_NameListReferral
            const ushort referral3FixedSize = 18;

            for (int i = 0; i < this.referralResponse.NumberOfReferrals; i++)
            {
                DFS_REFERRAL_V3V4_NameListReferral referral3 = new DFS_REFERRAL_V3V4_NameListReferral();

                // Read the fixed portion of DFS_REFERRAL_V3V4_NameListReferral
                referral3.VersionNumber = channel.Read<ushort>();
                referral3.Size = channel.Read<ushort>();
                referral3.ServerType = channel.Read<ushort>();
                referral3.ReferralEntryFlags = channel.Read<ReferralEntryFlags_Values>();
                referral3.TimeToLive = channel.Read<uint>();
                referral3.SpecialNameOffset = channel.Read<ushort>();
                referral3.NumberOfExpandedNames = channel.Read<ushort>();
                referral3.ExpandedNameOffset = channel.Read<ushort>();
                referral3.Padding = channel.ReadBytes(referral3.Size - referral3FixedSize);

                if (i == 0 && referral3.SpecialNameOffset == referral3.Size)
                {
                    isDfsPathFollowed = true;
                }

                // The Dfs paths of immediately follows each referral entry. Read the paths orderly.
                if (isDfsPathFollowed)
                {
                    // Get the Dfs paths from channel
                    // TD does not mention whether padding data exists between Dfs paths.
                    // Drop the possibly exists padding data
                    referral3.SpecialName = ReadDfsPath(channel);
                    ReadPadding(channel, referral3.ExpandedNameOffset - referral3.SpecialNameOffset
                        - (referral3.SpecialName.Length + 1) * sizeofWord);
                    referral3.DCNameArray = new string[referral3.NumberOfExpandedNames];

                    for (int j = 0; j < referral3.NumberOfExpandedNames; j++)
                    {
                        referral3.DCNameArray[j] = ReadDfsPath(channel);
                    }
                }
                tempList.Add(referral3);
            }

            // All Dfs paths follow the last referral entry.Read the paths after all entries have been read.
            if (!isDfsPathFollowed)
            {
                ushort referralFixedSize = tempList[0].Size;
                byte[] pathData = channel.ReadBytes((int)(channel.Stream.Length - channel.Stream.Position));

                for (int i = 0; i < tempList.Count; i++)
                {
                    // Calculate the offsets of Dfs paths
                    int leftCount = tempList.Count - i;
                    DFS_REFERRAL_V3V4_NameListReferral referral3 = tempList[i];
                    int specialNameOffset = referral3.SpecialNameOffset - leftCount * referralFixedSize;
                    int dcNameOffset = referral3.ExpandedNameOffset - leftCount * referralFixedSize;

                    // Get the Dfs paths
                    referral3.SpecialName = ReadDfsPath(pathData, specialNameOffset);
                    referral3.DCNameArray = new string[referral3.NumberOfExpandedNames];

                    for (int j = 0; j < referral3.NumberOfExpandedNames; j++)
                    {
                        referral3.DCNameArray[j] = ReadDfsPath(pathData, dcNameOffset);
                        dcNameOffset += referral3.DCNameArray[j].Length * sizeofWord;
                    }
                    tempList[i] = referral3;
                }
            }
            this.referralResponse.ReferralEntries = tempList.ToArray();
        }
开发者ID:XiaotianLiuMS,项目名称:WindowsProtocolTestSuites,代码行数:81,代码来源:DfscReferralResponsePacket.cs

示例8: DecodeTrans2Parameters

 /// <summary>
 /// to decode the Trans2 parameters: from the general Trans2Parameters to the concrete Trans2 Parameters.
 /// </summary>
 protected override void DecodeTrans2Parameters()
 {
     if (this.smbData.Trans2_Parameters != null)
     {
         using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Parameters))
         {
             using (Channel channel = new Channel(null, memoryStream))
             {
                 this.trans2Parameters.Reserved = channel.Read<uint>();
                 this.trans2Parameters.DirectoryName = channel.ReadBytes(this.smbParameters.ParameterCount
                     - reservedLength);
             }
         }
     }
 }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:18,代码来源:SmbTrans2CreateDirectoryRequestPacket.cs

示例9: DecodeData

        /// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes<SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount = channel.Read<ushort>();
                    int pad1Len = this.SmbParameters.ParameterOffset - Marshal.SizeOf(this.SmbHeader)
                        - Marshal.SizeOf(this.smbData.ByteCount) - Marshal.SizeOf(this.SmbParameters);

                    if (pad1Len > 0)
                    {
                        this.smbData.Pad1 = channel.ReadBytes(pad1Len);
                    }
                    else
                    {
                        this.smbData.Pad1 = new byte[0];
                    }

                    this.smbData.Parameters = channel.ReadBytes(this.SmbParameters.ParameterCount);
                    int pad2Len = this.SmbParameters.DataOffset - this.SmbParameters.ParameterOffset
                        - this.SmbParameters.ParameterCount;

                    if (pad2Len > 0)
                    {
                        this.smbData.Pad2 = channel.ReadBytes(pad2Len);
                    }
                    this.smbData.Data = channel.ReadBytes(this.SmbParameters.DataCount);
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:34,代码来源:SmbIoctlRequestPacket.cs

示例10: DecodeTrans2Parameters

 /// <summary>
 /// to decode the Trans2 parameters: from the general Trans2Parameters to the concrete Trans2 Parameters.
 /// </summary>
 protected override void DecodeTrans2Parameters()
 {
     using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Parameters))
     {
         using (Channel channel = new Channel(null, memoryStream))
         {
             this.trans2Parameters.SearchAttributes = channel.Read<SmbFileAttributes>();
             this.trans2Parameters.SearchCount = channel.Read<ushort>();
             this.trans2Parameters.Flags = channel.Read<Trans2FindFlags>();
             this.trans2Parameters.InformationLevel = channel.Read<FindInformationLevel>();
             this.trans2Parameters.SearchStorageType = channel.Read<Trans2FindFirst2SearchStorageType>();
             this.trans2Parameters.FileName = channel.ReadBytes(this.SmbParameters.ParameterCount
                 - trans2ParametersLength);
         }
     }
 }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:19,代码来源:SmbTrans2FindFirst2RequestPacket.cs

示例11: DecodeNtTransData

        /// <summary>
        /// to decode the NtTrans data: from the general NtTransDada to the concrete NtTrans Data. 
        /// </summary>
        protected override void DecodeNtTransData()
        {
            NT_TRANSACT_ENUMERATE_SNAPSHOTS_Response_NT_Trans_Data data
                = new NT_TRANSACT_ENUMERATE_SNAPSHOTS_Response_NT_Trans_Data();

            using (MemoryStream stream = new MemoryStream(this.smbData.Data))
            {
                using (Channel channel = new Channel(null, stream))
                {
                    data.NumberOfSnapShots = channel.Read<uint>();
                    data.NumberOfSnapShotsReturned = channel.Read<uint>();
                    data.SnapShotArraySize = channel.Read<uint>();
                    if (data.NumberOfSnapShotsReturned > 0)
                    {
                        data.snapShotMultiSZ = channel.ReadBytes((int)data.SnapShotArraySize);
                    }
                }
            }

            this.NtTransData = data;

            if (this.ntTransData.snapShotMultiSZ == null || this.ntTransData.SnapShotArraySize <= 2)
            {
                return;
            }

            string snapshot = Encoding.Unicode.GetString(this.ntTransData.snapShotMultiSZ);
            this.SnapShots = new Collection<string>(snapshot.Trim('\0').Split('\0'));
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:32,代码来源:SmbNtTransFsctlSrvEnumerateSnapshotsResponsePacket.cs

示例12: DecodeData

        /// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes<SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount = channel.Read<ushort>();
                    int pad1Length = this.smbParameters.ParameterOffset > 0 ?
                        (int)(this.smbParameters.ParameterOffset - this.HeaderSize
                        - SmbComTransactionPacket.SmbParametersWordCountLength - this.smbParameters.WordCount * 2
                        - SmbComTransactionPacket.SmbDataByteCountLength) : 0;

                    this.smbData.Pad1 = channel.ReadBytes(pad1Length);
                    this.smbData.Parameters = channel.ReadBytes((int)this.smbParameters.ParameterCount);
                    this.smbData.Pad2 = channel.ReadBytes((int)(this.smbParameters.DataOffset - this.smbParameters.ParameterOffset
                        - this.smbParameters.ParameterCount));
                    this.smbData.Data = channel.ReadBytes((int)this.smbParameters.DataCount);
                }
                this.DecodeNtTransParameters();
                this.DecodeNtTransData();
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:25,代码来源:SmbNtTransactSuccessResponsePacket.cs

示例13: DecodeTrans2Parameters

 /// <summary>
 /// to decode the Trans2 parameters: from the general Trans2Parameters to the concrete Trans2 Parameters.
 /// </summary>
 protected override void DecodeTrans2Parameters()
 {
     using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Parameters))
     {
         using (Channel channel = new Channel(null, memoryStream))
         {
             this.trans2Parameters.InformationLevel = channel.Read<SetInformationLevel>();
             this.trans2Parameters.Reserved = channel.Read<uint>();
             this.trans2Parameters.FileName = channel.ReadBytes(this.smbParameters.ParameterCount - infoLevelLength
                 - reservedLength);
         }
     }
 }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:16,代码来源:SmbTrans2SetPathInformationRequestPacket.cs

示例14: DecodeData

        /// <summary>
        /// to decode the smb data: from the general SmbDada to the concrete Smb Data.
        /// </summary>
        protected override void DecodeData()
        {
            using (MemoryStream memoryStream = new MemoryStream(CifsMessageUtils.ToBytes<SmbData>(this.smbDataBlock)))
            {
                using (Channel channel = new Channel(null, memoryStream))
                {
                    this.smbData.ByteCount = channel.Read<ushort>();
                    byte wordCountLength = 1;
                    byte byteCountLength = 2;
                    int smbParameterslength = this.smbParameters.WordCount * 2 + wordCountLength;
                    int pad1Len = this.SmbParameters.ParameterOffset - this.HeaderSize - byteCountLength
                        - smbParameterslength;

                    if (pad1Len > 0)
                    {
                        this.smbData.Pad1 = channel.ReadBytes(pad1Len);
                    }
                    else
                    {
                        this.smbData.Pad1 = new byte[0];
                    }
                    this.smbData.Parameters = channel.ReadBytes(this.SmbParameters.ParameterCount);
                    int pad2Len = this.SmbParameters.DataOffset - this.SmbParameters.ParameterOffset
                        - this.SmbParameters.ParameterCount;

                    if (pad1Len > 0)
                    {
                        this.smbData.Pad2 = channel.ReadBytes(pad2Len);
                    }
                    this.smbData.Data = channel.ReadBytes(this.SmbParameters.DataCount);
                }
            }
        }
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:36,代码来源:SmbIoctlSecondaryRequestPacket.cs

示例15: DecodeNtTransParameters

        /// <summary>
        /// to decode the NtTrans parameters: from the general NtTransParameters to the concrete NtTrans Parameters.
        /// </summary>
        protected override void DecodeNtTransParameters()
        {
            if (this.smbParameters.ParameterCount > 0)
            {
                List<FILE_NOTIFY_INFORMATION> list = new List<FILE_NOTIFY_INFORMATION>();
                using (MemoryStream memoryStream = new MemoryStream(this.smbData.Parameters))
                {
                    using (Channel channel = new Channel(null, memoryStream))
                    {
                        FILE_NOTIFY_INFORMATION firstNotifyInformation = channel.Read<FILE_NOTIFY_INFORMATION>();
                        list.Add(firstNotifyInformation);
                        ushort notifyInfoFixedLength = 12;
                        uint nextEntryOffset = firstNotifyInformation.NextEntryOffset;
                        uint nameLength = firstNotifyInformation.FileNameLength;

                        while (nextEntryOffset != 0)
                        {
                            channel.ReadBytes((int)(nextEntryOffset - notifyInfoFixedLength - nameLength));
                            FILE_NOTIFY_INFORMATION nextNotifyInformation = channel.Read<FILE_NOTIFY_INFORMATION>();
                            nextEntryOffset = nextNotifyInformation.NextEntryOffset;
                            nameLength = nextNotifyInformation.FileNameLength;
                            list.Add(nextNotifyInformation);
                        }
                        this.ntTransParameters.FileNotifyInformation = list.ToArray();
                    }
                }
            }
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:31,代码来源:SmbNtTransactNotifyChangeResponsePacket.cs


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