/// <summary>
        /// to decode stack packet from the received message bytes.
        /// </summary>
        /// <param name = "endPointIdentity">the endPointIdentity from which the message bytes are received. </param>
        /// <param name = "messageBytes">the received message bytes to be decoded. </param>
        /// <param name = "consumedLength">the length of message bytes consumed by decoder. </param>
        /// <param name = "expectedLength">the length of message bytes the decoder expects to receive. </param>
        /// <returns>the stack packets decoded from the received message bytes. </returns>
        internal new SmbPacket[] DecodePacket(
            object endPointIdentity, byte[] messageBytes, out int consumedLength, out int expectedLength)
        {
            // initialize the default values
            expectedLength = 0;
            consumedLength = 0;
            SmbPacket[] packets = null;

            switch (this.smbClient.Capability.TransportType)
            {
            case TransportType.TCP:
                // direct tcp transport management instance
                SmbDirectTcpPacket directTcp = new SmbDirectTcpPacket(null);

                // get the endpoint for direct tcp transport
                int endpoint = smbClient.Context.GetConnectionID(endPointIdentity as IPEndPoint);

                // message bytes is invalid
                if (directTcp.IsPacketInvalid(messageBytes))
                {
                    return(null);
                }

                // if the packet has continue packet, do not parse it.
                if (directTcp.HasContinuousPacket(messageBytes))
                {
                    return(null);
                }

                // decode the data of packet
                byte[] packetBytes = directTcp.GetTcpData(messageBytes);
                packets = DecodePacketFromBytesWithoutTransport(endpoint, packetBytes, out consumedLength, out expectedLength);

                // decode the header of packet
                if (packets != null && packets.Length > 0)
                {
                    packets[0].TransportHeader = CifsMessageUtils.ToStuct <TransportHeader>(messageBytes);
                }

                // to consume the additional data
                consumedLength = Math.Max(consumedLength, directTcp.GetTcpPacketLength(messageBytes));

                // update the consumed length with transport
                consumedLength += directTcp.TcpTransportHeaderSize;

                break;

            case TransportType.NetBIOS:
                // decode packet
                packets = DecodePacketFromBytesWithoutTransport(
                    Convert.ToInt32(endPointIdentity), messageBytes, out consumedLength, out expectedLength);

                break;

            default:
                break;
            }

            return(packets);
        }
 /// <summary>
 /// initialize packet from base packet.
 /// </summary>
 /// <param name = "packet">the base packet to initialize this packet. </param>
 public SmbNtTransFsctlSrvCopyChunkResponsePacket(Cifs.SmbNtTransactIoctlResponsePacket packet)
     : base(packet)
 {
     this.ntTransData =
         CifsMessageUtils.ToStuct <NT_TRANSACT_COPY_CHUNK_Response_NT_Trans_Data>(
             packet.NtTransData.Data);
 }
 /// <summary>
 /// initialize packet from base packet.
 /// </summary>
 /// <param name = "packet">the base packet to initialize this packet. </param>
 public SmbNtTransFsctlSrvEnumerateSnapshotsResponsePacket(Cifs.SmbNtTransactIoctlResponsePacket packet)
     : base(packet)
 {
     this.ntTransData =
         CifsMessageUtils.ToStuct <NT_TRANSACT_ENUMERATE_SNAPSHOTS_Response_NT_Trans_Data>(
             packet.NtTransData.Data);
 }
 /// <summary>
 /// initialize packet from base packet.
 /// </summary>
 /// <param name = "packet">the base packet to initialize this packet. </param>
 public SmbNtTransFsctlSrvRequestResumeKeyResponsePacket(Cifs.SmbNtTransactIoctlResponsePacket packet)
     : base(packet)
 {
     this.ntTransData =
         CifsMessageUtils.ToStuct <NT_TRANSACT_RESUME_KEY_Response_NT_Trans_Data>(
             packet.NtTransData.Data);
 }
 /// <summary>
 /// to decode the smb parameters: from the general SmbParameters to the concrete Smb Parameters.
 /// </summary>
 /// <exception cref="NotImplementedException">
 /// TD did not define the SmbParameters for Lan Manager Dialect.
 /// </exception>
 /// <exception cref="NotSupportedException">Unknow SmbParameters structure.</exception>
 protected override void DecodeParameters()
 {
     if (this.SmbParametersBlock.WordCount > 0)
     {
         if (this.smbParametersBlock.WordCount == WordCountOfCoreProtocol)
         {
             this.smbParameters.WordCount    = this.smbParametersBlock.WordCount;
             this.smbParameters.DialectIndex = this.SmbParametersBlock.Words[0];
         }
         else if (this.smbParametersBlock.WordCount == WordCountOfNtLanManager)
         {
             this.smbParameters = CifsMessageUtils.ToStuct <SMB_COM_NEGOTIATE_NtLanManagerResponse_SMB_Parameters>(
                 CifsMessageUtils.ToBytes <SmbParameters>(this.smbParametersBlock));
         }
         else if (this.smbParametersBlock.WordCount == WordCountOfLanManager)
         {
             throw new NotImplementedException("TD did not define the SmbParameters for Lan Manager Dialect.");
         }
         else
         {
             throw new NotSupportedException("Unknow SmbParameters structure.");
         }
     }
     else
     {
         this.smbParameters.WordCount = this.SmbParametersBlock.WordCount;
     }
 }
 /// <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 && this.smbData.Trans2_Parameters.Length > 0)
     {
         this.trans2Parameters = CifsMessageUtils.ToStuct <
             TRANS2_SET_PATH_INFORMATION_Response_Trans2_Parameters>(this.smbData.Trans2_Parameters);
     }
 }
Exemple #7
0
        public SmbPacket[] DecodePacket(
            object endPointIdentity, byte[] messageBytes, out int consumedLength, out int expectedLength)
        {
            // initialize the default values
            expectedLength = 0;
            consumedLength = 0;
            SmbPacket[] packets = null;

            byte[] packetBytes = null;
            // direct tcp transport management instance
            SmbDirectTcpPacket directTcp = new SmbDirectTcpPacket(null);

            // Netbios over Tcp
            if (endPointIdentity is int)
            {
                packetBytes = messageBytes;
            }
            // Direct Tcp
            else
            {
                // message bytes is invalid
                if (directTcp.IsPacketInvalid(messageBytes))
                {
                    return(null);
                }

                // if the packet has continue packet, do not parse it.
                if (directTcp.HasContinuousPacket(messageBytes))
                {
                    return(null);
                }

                // decode the data of packet
                packetBytes = directTcp.GetTcpData(messageBytes);
            }

            packets = DecodePacketFromBytesWithoutTransport(
                this.context.GetConnection(endPointIdentity), packetBytes, out consumedLength, out expectedLength);

            // decode the header of packet
            if (packets != null && packets.Length > 0)
            {
                packets[0].TransportHeader = CifsMessageUtils.ToStuct <TransportHeader>(messageBytes);
            }

            // for Direct Tcp, calculate the cosumedlength and plus the Tcp header length.
            if (!(endPointIdentity is int))
            {
                // to consume the additional data
                consumedLength = Math.Max(consumedLength, directTcp.GetTcpPacketLength(messageBytes));

                // update the consumed length with transport
                consumedLength += directTcp.TcpTransportHeaderSize;
            }

            return(packets);
        }
 /// <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)
     {
         this.trans2Parameters = CifsMessageUtils.ToStuct <
             TRANS2_QUERY_FILE_INFORMATION_Request_Trans2_Parameters>(
             this.smbData.Trans2_Parameters);
     }
 }
Exemple #9
0
 /// <summary>
 /// to decode the Trans2 parameters: from the general Trans2Parameters to the concrete Trans2 Parameters.
 /// </summary>
 protected override void DecodeTrans2Parameters()
 {
     if (this.informationLevel != QueryInformationLevel.SMB_INFO_IS_NAME_VALID &&
         this.smbData.Trans2_Parameters != null && this.smbData.Trans2_Parameters.Length > 0)
     {
         this.trans2Parameters = CifsMessageUtils.ToStuct <
             TRANS2_QUERY_PATH_INFORMATION_Response_Trans2_Parameters>(this.smbData.Trans2_Parameters);
     }
 }
Exemple #10
0
        /// <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)
            {
                switch (this.trans2Parameters.InformationLevel)
                {
                case SetInformationLevel.SMB_INFO_STANDARD:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct
                                           <SMB_INFO_STANDARD_OF_TRANS2_SET_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case SetInformationLevel.SMB_INFO_SET_EAS:
                    using (MemoryStream memoryStream = new MemoryStream(this.smbData.Trans2_Data))
                    {
                        using (Channel channel = new Channel(null, memoryStream))
                        {
                            SMB_INFO_SET_EAS data = new SMB_INFO_SET_EAS();
                            data.SizeOfListInBytes = channel.Read <uint>();
                            uint           sizeOfListInBytes = data.SizeOfListInBytes - sizeOfListInBytesLength;
                            List <SMB_FEA> attributeList     = new List <SMB_FEA>();

                            while (sizeOfListInBytes > 0)
                            {
                                SMB_FEA smbEa = channel.Read <SMB_FEA>();
                                attributeList.Add(smbEa);
                                sizeOfListInBytes -= (uint)(EA.SMB_EA_FIXED_SIZE + smbEa.AttributeName.Length +
                                                            smbEa.ValueName.Length);
                            }
                            data.ExtendedAttributeList = attributeList.ToArray();
                            this.trans2Data.Data       = data;
                        }
                    }
                    break;

                case SetInformationLevel.SMB_SET_FILE_BASIC_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct
                                           <SMB_SET_FILE_BASIC_INFO>(this.smbData.Trans2_Data);
                    break;

                case SetInformationLevel.SMB_SET_FILE_ALLOCATION_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct
                                           <SMB_SET_FILE_ALLOCATION_INFO>(this.smbData.Trans2_Data);
                    break;

                case SetInformationLevel.SMB_SET_FILE_DISPOSITION_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct
                                           <SMB_SET_FILE_DISPOSITION_INFO>(this.smbData.Trans2_Data);
                    break;

                case SetInformationLevel.SMB_SET_FILE_END_OF_FILE_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct
                                           <SMB_SET_FILE_END_OF_FILE_INFO>(this.smbData.Trans2_Data);
                    break;
                }
            }
        }
 /// <summary>
 /// initialize packet from base packet.
 /// </summary>
 /// <param name = "packet">the base packet to initialize this packet. </param>
 public SmbNtTransFsctlSrvCopyChunkRequestPacket(Cifs.SmbNtTransactIoctlRequestPacket packet)
     : base(packet)
 {
     if (packet.NtTransData.Data != null && packet.NtTransData.Data.Length > 0)
     {
         this.ntTransData =
             CifsMessageUtils.ToStuct <NT_TRANSACT_COPY_CHUNK_Request_NT_Trans_Data>(
                 packet.NtTransData.Data);
     }
 }
 /// <summary>
 /// to decode the smb parameters: from the general SmbParameters to the concrete Smb Parameters.
 /// </summary>
 protected override void DecodeParameters()
 {
     if (this.SmbParametersBlock.WordCount > 0)
     {
         this.smbParameters = CifsMessageUtils.ToStuct <SMB_COM_SESSION_SETUP_ANDX_Response_SMB_Parameters>(
             CifsMessageUtils.ToBytes <SmbParameters>(this.smbParametersBlock));
     }
     else
     {
         this.smbParameters.WordCount = this.SmbParametersBlock.WordCount;
     }
 }
Exemple #13
0
        /// <summary>
        /// find the nt transaction packets
        /// </summary>
        /// <param name="command">the command of nt transaction</param>
        /// <param name="setup">the setup contains the sub command</param>
        /// <returns>the target nt transaction packet</returns>
        private static SmbPacket FindTheNtTransPacket(NtTransSubCommand command, byte[] setup)
        {
            SmbPacket smbPacket = null;

            switch (command)
            {
            case NtTransSubCommand.NT_TRANSACT_CREATE:
                smbPacket = new SmbNtTransactCreateRequestPacket();
                break;

            case NtTransSubCommand.NT_TRANSACT_RENAME:
                smbPacket = new SmbNtTransRenameRequestPacket();
                break;

            case NtTransSubCommand.NT_TRANSACT_IOCTL:
                NT_TRANSACT_IOCTL_SETUP subCommand = CifsMessageUtils.ToStuct <NT_TRANSACT_IOCTL_SETUP>(setup);
                switch ((NtTransFunctionCode)subCommand.FunctionCode)
                {
                case NtTransFunctionCode.FSCTL_SRV_ENUMERATE_SNAPSHOTS:
                    smbPacket = new SmbNtTransFsctlSrvEnumerateSnapshotsRequestPacket();
                    break;

                case NtTransFunctionCode.FSCTL_SRV_REQUEST_RESUME_KEY:
                    smbPacket = new SmbNtTransFsctlSrvRequestResumeKeyRequestPacket();
                    break;

                case NtTransFunctionCode.FSCTL_SRV_COPYCHUNK:
                    smbPacket = new SmbNtTransFsctlSrvCopyChunkRequestPacket();
                    break;

                default:
                    smbPacket = new SmbNtTransactIoctlRequestPacket();
                    break;
                }
                break;

            default:
                switch ((SmbNtTransSubCommand)command)
                {
                case SmbNtTransSubCommand.NT_TRANSACT_QUERY_QUOTA:
                    smbPacket = new SmbNtTransQueryQuotaRequestPacket();
                    break;

                case SmbNtTransSubCommand.NT_TRANSACT_SET_QUOTA:
                    smbPacket = new SmbNtTransSetQuotaRequestPacket();
                    break;
                }
                break;
            }

            return(smbPacket);
        }
        /// <summary>
        /// to decode the NtTrans data: from the general NtTransDada to the concrete NtTrans Data.
        /// </summary>
        protected override void DecodeNtTransData()
        {
            NT_TRANSACT_QUERY_QUOTA_Response_NT_Trans_Data data = new NT_TRANSACT_QUERY_QUOTA_Response_NT_Trans_Data();
            int start = 0;

            byte[] bytes = this.smbData.Data;

            do
            {
                data = CifsMessageUtils.ToStuct <NT_TRANSACT_QUERY_QUOTA_Response_NT_Trans_Data>(bytes);
                this.NtTransDataList.Add(data);

                start += (int)data.NextEntryOffset;
                bytes  = new byte[this.smbData.Data.Length - start];
                Array.Copy(this.smbData.Data, start, bytes, 0, bytes.Length);
            }while(data.NextEntryOffset != 0);
        }
        /// <summary>
        /// to decode the smb parameters: from the general SmbParameters to the concrete Smb Parameters.
        /// </summary>
        protected override void DecodeParameters()
        {
            // if smb packet, the word count must be 7.
            // end with more 2-int fields: MaximalShareAccessRights and GuestMaximalShareAccessRights.
            if (this.smbParametersBlock.WordCount == 7)
            {
                this.SmbParameters = CifsMessageUtils.ToStuct <SMB_COM_TREE_CONNECT_ANDX_Response_SMB_Parameters>(
                    CifsMessageUtils.ToBytes <SmbParameters>(this.smbParametersBlock));
            }
            // if cifs packet, the word count must be 3.
            else if (this.smbParametersBlock.WordCount == 3)
            {
                Cifs.SMB_COM_TREE_CONNECT_ANDX_Response_SMB_Parameters param =
                    CifsMessageUtils.ToStuct <Cifs.SMB_COM_TREE_CONNECT_ANDX_Response_SMB_Parameters>(
                        CifsMessageUtils.ToBytes <SmbParameters>(this.smbParametersBlock));

                this.SmbParameters = SmbMessageUtils.ConvertSmbComTreeConnectPacketPayload(param);
            }
            else
            {
                this.smbParameters.WordCount = this.smbParametersBlock.WordCount;
            }
        }
        /// <summary>
        /// create the nt transaction packet
        /// </summary>
        /// <param name="request">the request packet</param>
        /// <param name="smbHeader">the smb header of response packet</param>
        /// <param name="channel">the channel contains the packet bytes</param>
        /// <returns>the response packet</returns>
        private SmbPacket CreateNtTransactionResponsePacket(SmbPacket request, SmbHeader smbHeader, Channel channel)
        {
            SmbPacket smbPacket = null;

            if (smbHeader.Status == 0 && channel.Peek <byte>(0) == 0 && channel.Peek <ushort>(1) == 0)
            {
                return(smbPacket);
            }

            SmbNtTransactRequestPacket ntTransactRequest = request as SmbNtTransactRequestPacket;

            if (ntTransactRequest == null)
            {
                return(smbPacket);
            }

            // find regular packet
            switch ((uint)ntTransactRequest.SmbParameters.Function)
            {
            case (uint)NtTransSubCommand.NT_TRANSACT_RENAME:
                smbPacket = new SmbNtTransRenameResponsePacket();
                break;

            case (uint)NtTransSubCommand.NT_TRANSACT_CREATE:
                smbPacket = new SmbNtTransactCreateResponsePacket();
                break;

            case (uint)NtTransSubCommand.NT_TRANSACT_IOCTL:

                NT_TRANSACT_IOCTL_SETUP setup =
                    CifsMessageUtils.ToStuct <NT_TRANSACT_IOCTL_SETUP>(
                        CifsMessageUtils.ToBytesArray <ushort>(ntTransactRequest.SmbParameters.Setup));

                switch ((NtTransFunctionCode)setup.FunctionCode)
                {
                case NtTransFunctionCode.FSCTL_SRV_ENUMERATE_SNAPSHOTS:
                    smbPacket = new SmbNtTransFsctlSrvEnumerateSnapshotsResponsePacket();
                    break;

                case NtTransFunctionCode.FSCTL_SRV_REQUEST_RESUME_KEY:
                    smbPacket = new SmbNtTransFsctlSrvRequestResumeKeyResponsePacket();
                    break;

                case NtTransFunctionCode.FSCTL_SRV_COPYCHUNK:
                    smbPacket = new SmbNtTransFsctlSrvCopyChunkResponsePacket();
                    break;

                default:
                    smbPacket = new SmbNtTransactIoctlResponsePacket();
                    break;
                }

                break;

            case (uint)SmbNtTransSubCommand.NT_TRANSACT_QUERY_QUOTA:
                smbPacket = new SmbNtTransQueryQuotaResponsePacket();
                break;

            case (uint)SmbNtTransSubCommand.NT_TRANSACT_SET_QUOTA:
                smbPacket = new SmbNtTransSetQuotaResponsePacket();
                break;

            default:
                break;
            }

            return(smbPacket);
        }
 /// <summary>
 /// to decode the NtTrans data: from the general NtTransDada to the concrete NtTrans Data.
 /// </summary>
 protected override void DecodeNtTransData()
 {
     this.NtTransData =
         CifsMessageUtils.ToStuct <NT_TRANSACT_COPY_CHUNK_Request_NT_Trans_Data>(this.smbData.NT_Trans_Data);
 }
 /// <summary>
 /// to decode the NtTrans data: from the general NtTransDada to the concrete NtTrans Data.
 /// </summary>
 protected override void DecodeNtTransData()
 {
     this.ntTransData =
         CifsMessageUtils.ToStuct <NT_TRANSACT_SET_QUOTA_Request_NT_Trans_Data>(
             this.smbData.NT_Trans_Data);
 }
 /// <summary>
 /// Encode the struct of SMB_COM_NEGOTIATE_NtLanManagerResponse_SMB_Parameters into the struct of
 /// SmbParameters
 /// </summary>
 protected override void EncodeParameters()
 {
     this.smbParametersBlock = CifsMessageUtils.ToStuct <SmbParameters>(
         CifsMessageUtils.ToBytes <SMB_COM_NEGOTIATE_NtLanManagerResponse_SMB_Parameters>(this.smbParameters));
 }
 /// <summary>
 /// Encode the struct of SMB_COM_SESSION_SETUP_ANDX_Response_SMB_Parameters into the struct of SmbParameters
 /// </summary>
 protected override void EncodeParameters()
 {
     this.smbParametersBlock = CifsMessageUtils.ToStuct <SmbParameters>(
         CifsMessageUtils.ToBytes <SMB_COM_SESSION_SETUP_ANDX_Response_SMB_Parameters>(this.smbParameters));
 }
 /// <summary>
 /// Encode the struct of SMB_COM_TREE_CONNECT_ANDX_Request_SMB_Parameters into the struct of SmbParameters
 /// </summary>
 protected override void EncodeParameters()
 {
     this.smbParametersBlock = CifsMessageUtils.ToStuct <SmbParameters>(
         CifsMessageUtils.ToBytes <SMB_COM_TREE_CONNECT_ANDX_Request_SMB_Parameters>(this.smbParameters));
 }
 /// <summary>
 /// to decode the NtTrans data: from the general NtTransDada to the concrete NtTrans Data.
 /// </summary>
 protected override void DecodeNtTransData()
 {
     this.NtTransData =
         CifsMessageUtils.ToStuct <NT_TRANSACT_RESUME_KEY_Response_NT_Trans_Data>(this.smbData.Data);
 }
 /// <summary>
 /// to decode the NtTrans parameters: from the general NtTransParameters to the concrete NtTrans Parameters.
 /// </summary>
 protected override void DecodeNtTransParameters()
 {
     this.ntTransParameters =
         CifsMessageUtils.ToStuct <NT_TRANSACT_QUERY_QUOTA_Request_NT_Trans_Parameters>(
             this.smbData.NT_Trans_Parameters);
 }
        protected override void DecodeTrans2Data()
        {
            if (this.smbData.Trans2_Data != null && this.smbData.Trans2_Data.Length > 0)
            {
                switch (this.informationLevel)
                {
                case QueryInformationLevel.SMB_INFO_STANDARD:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_INFO_STANDARD_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
                    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))
                            {
                                SMB_INFO_QUERY_EAS_FROM_LIST_OF_TRANS2_QUERY_PATH_INFORMATION data = new
                                                                                                     SMB_INFO_QUERY_EAS_FROM_LIST_OF_TRANS2_QUERY_PATH_INFORMATION();
                                data.SizeOfListInBytes = channel.Read <uint>();
                                uint           sizeOfListInBytes = data.SizeOfListInBytes - sizeOfListInBytesLength;
                                List <SMB_FEA> attributeList     = new List <SMB_FEA>();

                                while (sizeOfListInBytes > 0)
                                {
                                    SMB_FEA smbEa = channel.Read <SMB_FEA>();
                                    attributeList.Add(smbEa);
                                    sizeOfListInBytes -= (uint)(EA.SMB_EA_FIXED_SIZE + smbEa.AttributeName.Length +
                                                                smbEa.ValueName.Length);
                                }
                                data.ExtendedAttributeList = attributeList.ToArray();
                                this.trans2Data.Data       = data;
                            }
                        }
                    }
                    break;

                case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
                    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))
                            {
                                SMB_INFO_QUERY_ALL_EAS_OF_TRANS2_QUERY_PATH_INFORMATION easData = new
                                                                                                  SMB_INFO_QUERY_ALL_EAS_OF_TRANS2_QUERY_PATH_INFORMATION();
                                easData.SizeOfListInBytes = channel.Read <uint>();
                                uint           sizeOfList = easData.SizeOfListInBytes - sizeOfListInBytesLength;
                                List <SMB_FEA> eaList     = new List <SMB_FEA>();

                                while (sizeOfList > 0)
                                {
                                    SMB_FEA smbEa = channel.Read <SMB_FEA>();
                                    eaList.Add(smbEa);
                                    sizeOfList -= (uint)(EA.SMB_EA_FIXED_SIZE + smbEa.AttributeName.Length +
                                                         smbEa.ValueName.Length);
                                }
                                easData.ExtendedAttributeList = eaList.ToArray();
                                this.trans2Data.Data          = easData;
                            }
                        }
                    }
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_BASIC_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_STANDARD_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_EA_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_ALL_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_ALT_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_STREAM_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;

                case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
                    this.trans2Data.Data = CifsMessageUtils.ToStuct <
                        SMB_QUERY_FILE_COMPRESSION_INFO_OF_TRANS2_QUERY_PATH_INFORMATION>(this.smbData.Trans2_Data);
                    break;
                }
            }
        }