/// <summary>
        /// to create a Open request packet.
        /// </summary>
        /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with
        /// a request.</param>
        /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
        /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is 
        /// accessing.</param>
        /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the 
        /// message</param>
        /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the 
        /// message. Unspecified bits are reserved and MUST be zero.</param>
        /// <param name="accessMode">A 16-bit field for encoding the requested access mode. See section 3.2.4.5.1 
        /// for a discussion on sharing modes.</param>
        /// <param name="searchAttributes">SMB_FILE_ATTRIBUTES  Specifies the type of file desired. This field is 
        /// used as a search mask. Both the FileName and the SearchAttributes of a file MUST match for the file to 
        /// be opened. </param>
        /// <param name="fileName">STRING A null-terminated string containing the file name of the file to be 
        /// opened.</param>
        /// <returns> to create a Open request packet.</returns>
        public SmbOpenRequestPacket CreateOpenRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            AccessMode accessMode,
            SmbFileAttributes searchAttributes,
            string fileName)
        {
            if (fileName == null)
            {
                fileName = string.Empty;
            }

            SmbOpenRequestPacket packet = new SmbOpenRequestPacket();

            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_OPEN,
                messageId, uid, treeId, flags, flags2);

            SMB_COM_OPEN_Request_SMB_Parameters smbParameters = new SMB_COM_OPEN_Request_SMB_Parameters();
            smbParameters.AccessMode = (ushort)accessMode;
            smbParameters.SearchAttributes = searchAttributes;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_OPEN_Request_SMB_Data smbData = new SMB_COM_OPEN_Request_SMB_Data();
            smbData.BufferFormat = (byte)DataBufferFormat.SmbString;
            smbData.FileName = CifsMessageUtils.ToSmbStringBytes(fileName,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat) + smbData.FileName.Length);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
 /// <summary>
 /// to decode the smb parameters: from the general SmbParameters to the concrete Smb Parameters.
 /// </summary>
 protected override void DecodeParameters()
 {
     this.smbParameters = TypeMarshal.ToStruct<SMB_COM_OPEN_Request_SMB_Parameters>(
         TypeMarshal.ToBytes(this.smbParametersBlock));
 }