/// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbNtTransactQuerySecurityDescRequestPacket(SmbNtTransactQuerySecurityDescRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.ntTransParameters.FID = packet.ntTransParameters.FID;
            this.ntTransParameters.Reserved = packet.ntTransParameters.Reserved;
            this.ntTransParameters.SecurityInfoFields = packet.ntTransParameters.SecurityInfoFields;
        }
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbNtTransactQuerySecurityDescRequestPacket(SmbNtTransactQuerySecurityDescRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.ntTransParameters.FID                = packet.ntTransParameters.FID;
            this.ntTransParameters.Reserved           = packet.ntTransParameters.Reserved;
            this.ntTransParameters.SecurityInfoFields = packet.ntTransParameters.SecurityInfoFields;
        }
        /// <summary>
        /// to create a NtTransactSetSecurityDesc 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="maxParameterCount">The maximum number of parameter bytes that the client will accept in the
        /// transaction reply. The server MUST NOT return more than this number of parameter bytes.</param>
        /// <param name="maxDataCount">The maximum number of data bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of data bytes.</param>
        /// <param name="maxSetupCount">Maximum number of setup bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of setup bytes</param>
        /// <param name="securityInfoFields">A 32-bit field representing the requested fields of the security
        /// descriptor to be retrieved. </param>
        /// <param name="fid">MUST contain a valid FID obtained from a previously successful SMB open command.</param>
        /// <returns>a NtTransactSetSecurityDesc request packet</returns>
        public SmbNtTransactQuerySecurityDescRequestPacket CreateNtTransactQuerySecurityDescRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            byte maxSetupCount,
            uint maxParameterCount,
            uint maxDataCount,
            ushort fid,
            NtTransactSecurityInformation securityInfoFields)
        {
            SmbNtTransactQuerySecurityDescRequestPacket packet = new SmbNtTransactQuerySecurityDescRequestPacket();
            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_NT_TRANSACT,
                messageId, uid, treeId, flags, flags2);

            // Set Smb_Parameters
            SMB_COM_NT_TRANSACT_Request_SMB_Parameters smbParameters =
                new SMB_COM_NT_TRANSACT_Request_SMB_Parameters();
            smbParameters.MaxSetupCount = maxSetupCount;
            smbParameters.MaxParameterCount = maxParameterCount;
            smbParameters.MaxDataCount = maxDataCount;
            smbParameters.SetupCount = 0; // the correct count in word of the Setup is always 0.
            smbParameters.Function = NtTransSubCommand.NT_TRANSACT_QUERY_SECURITY_DESC;
            smbParameters.Setup = new ushort[0];
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_NT_TRANSACT_Request_SMB_Parameters>(
                smbParameters) / NumBytesOfWord);

            // Set Smb_Data
            SMB_COM_NT_TRANSACT_Request_SMB_Data smbData = new SMB_COM_NT_TRANSACT_Request_SMB_Data();

            // Set NT_TransParameters
            NT_TRANSACT_QUERY_SECURITY_DESC_Request_NT_Trans_Parameters ntTransParameters =
                new NT_TRANSACT_QUERY_SECURITY_DESC_Request_NT_Trans_Parameters();
            ntTransParameters.FID = fid;
            ntTransParameters.SecurityInfoFields = securityInfoFields;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.NtTransParameters = ntTransParameters;
            packet.UpdateCountAndOffset();

            return packet;
        }
        public SmbNtTransactQuerySecurityDescResponsePacket CreateNtTransactQuerySecurityDescResponse(
            CifsServerPerConnection connection,
            SmbNtTransactQuerySecurityDescRequestPacket request,
            RawSecurityDescriptor securityInformation)
        {
            SmbNtTransactQuerySecurityDescResponsePacket response = new SmbNtTransactQuerySecurityDescResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            NT_TRANSACT_QUERY_SECURITY_DESC_Response_NT_Trans_Parameters ntTransParameters = response.NtTransParameters;
            ntTransParameters.LengthNeeded = (uint)(securityInformation == null ? 0 : securityInformation.BinaryLength);
            response.NtTransParameters = ntTransParameters;

            NT_TRANSACT_QUERY_SECURITY_DESC_Response_NT_Trans_Data ntTransData = response.NtTransData;
            ntTransData.SecurityInformation = securityInformation;
            response.NtTransData = ntTransData;

            response.UpdateCountAndOffset();

            return response;
        }