/// <summary>
        /// to unmarshal the SmbParameters struct from a channel.
        /// </summary>
        /// <param name="channel">the channel started with SmbParameters.</param>
        /// <returns>the size in bytes of the SmbParameters.</returns>
        protected override int ReadParametersFromChannel(Channel channel)
        {
            this.smbParametersBlock = channel.Read <SmbParameters>();

            if (channel.Stream.Position <= channel.Stream.Length - WINDOWS_BEHAVIOR_ADDITIONAL_DATA_LENGTH)
            {
                byte[] data = CifsMessageUtils.ToBytesArray <ushort>(this.smbParametersBlock.Words);

                this.smbParametersBlock.Words = CifsMessageUtils.ToTypeArray <ushort>(
                    ArrayUtility.ConcatenateArrays <byte>(
                        data, channel.ReadBytes(WINDOWS_BEHAVIOR_ADDITIONAL_DATA_LENGTH)));
            }

            this.DecodeParameters();

            int sizeOfWordCount = sizeof(byte);
            int sizeOfWords     = this.smbParametersBlock.WordCount * sizeof(ushort);

            return(sizeOfWordCount + sizeOfWords);
        }
        /// <summary>
        /// Encode the struct of SMB_COM_TREE_CONNECT_ANDX_Response_SMB_Parameters into the struct of SmbParameters
        /// </summary>
        protected override void EncodeParameters()
        {
            List <byte> bytes = new List <byte>();

            bytes.AddRange(TypeMarshal.ToBytes <SmbCommand>(this.smbParameters.AndXCommand));
            bytes.AddRange(TypeMarshal.ToBytes <byte>(this.smbParameters.AndXReserved));
            bytes.AddRange(TypeMarshal.ToBytes <ushort>(this.smbParameters.AndXOffset));
            bytes.AddRange(TypeMarshal.ToBytes <OplockLevelValue>(this.smbParameters.OplockLevel));
            bytes.AddRange(TypeMarshal.ToBytes <ushort>(this.smbParameters.FID));
            bytes.AddRange(TypeMarshal.ToBytes <uint>(this.smbParameters.CreationAction));
            bytes.AddRange(TypeMarshal.ToBytes <Cifs.FileTime>(this.smbParameters.CreateTime));
            bytes.AddRange(TypeMarshal.ToBytes <Cifs.FileTime>(this.smbParameters.LastAccessTime));
            bytes.AddRange(TypeMarshal.ToBytes <Cifs.FileTime>(this.smbParameters.LastWriteTime));
            bytes.AddRange(TypeMarshal.ToBytes <Cifs.FileTime>(this.smbParameters.LastChangeTime));
            bytes.AddRange(TypeMarshal.ToBytes <uint>(this.smbParameters.ExtFileAttributes));
            bytes.AddRange(TypeMarshal.ToBytes <ulong>(this.smbParameters.AllocationSize));
            bytes.AddRange(TypeMarshal.ToBytes <ulong>(this.smbParameters.EndOfFile));
            bytes.AddRange(TypeMarshal.ToBytes <FileTypeValue>(this.smbParameters.ResourceType));
            bytes.AddRange(TypeMarshal.ToBytes <SMB_NMPIPE_STATUS>(this.smbParameters.NMPipeStatus_or_FileStatusFlags));
            bytes.AddRange(TypeMarshal.ToBytes <byte>(this.smbParameters.Directory));

            if (this.smbParameters.VolumeGUID != null)
            {
                bytes.AddRange(this.smbParameters.VolumeGUID);
            }
            if (this.smbParameters.FileId != null)
            {
                bytes.AddRange(this.smbParameters.FileId);
            }
            if (this.smbParameters.MaximalAccessRights != null)
            {
                bytes.AddRange(this.smbParameters.MaximalAccessRights);
            }
            if (this.smbParameters.GuestMaximalAccessRights != null)
            {
                bytes.AddRange(this.smbParameters.GuestMaximalAccessRights);
            }

            this.smbParametersBlock.WordCount = (byte)this.smbParameters.WordCount;
            this.smbParametersBlock.Words     = CifsMessageUtils.ToTypeArray <ushort>(bytes.ToArray());
        }