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

            this.smbParameters.WordCount = packet.SmbParameters.WordCount;
            this.smbParameters.FileAttributes = packet.SmbParameters.FileAttributes;
            this.smbParameters.LastWriteTime = new UTime();
            this.smbParameters.LastWriteTime.Time = packet.SmbParameters.LastWriteTime.Time;
            this.smbParameters.FileSize = packet.SmbParameters.FileSize;

            if (packet.smbParameters.Reserved != null)
            {
                this.smbParameters.Reserved = new ushort[packet.smbParameters.Reserved.Length];
                Array.Copy(packet.smbParameters.Reserved,
                    this.smbParameters.Reserved, packet.smbParameters.Reserved.Length);
            }
            else
            {
                this.smbParameters.Reserved = new ushort[0];
            }

            this.smbData.ByteCount = packet.SmbData.ByteCount;
        }
Esempio n. 2
0
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbQueryInformationResponsePacket(SmbQueryInformationResponsePacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.smbParameters.WordCount          = packet.SmbParameters.WordCount;
            this.smbParameters.FileAttributes     = packet.SmbParameters.FileAttributes;
            this.smbParameters.LastWriteTime      = new UTime();
            this.smbParameters.LastWriteTime.Time = packet.SmbParameters.LastWriteTime.Time;
            this.smbParameters.FileSize           = packet.SmbParameters.FileSize;

            if (packet.smbParameters.Reserved != null)
            {
                this.smbParameters.Reserved = new ushort[packet.smbParameters.Reserved.Length];
                Array.Copy(packet.smbParameters.Reserved,
                           this.smbParameters.Reserved, packet.smbParameters.Reserved.Length);
            }
            else
            {
                this.smbParameters.Reserved = new ushort[0];
            }

            this.smbData.ByteCount = packet.SmbData.ByteCount;
        }
        public SmbQueryInformationResponsePacket CreateQueryInformationResponse(
            CifsServerPerConnection connection,
            SmbQueryInformationRequestPacket request,
            SmbFileAttributes fileAttributes,
            UTime lastWriteTime,
            uint fileSize)
        {
            SmbQueryInformationResponsePacket response = new SmbQueryInformationResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            SMB_COM_QUERY_INFORMATION_Response_SMB_Parameters smbParameters = response.SmbParameters;
            smbParameters.FileAttributes = fileAttributes;
            smbParameters.FileSize = fileSize;
            smbParameters.LastWriteTime = lastWriteTime;
            smbParameters.Reserved = new ushort[5];
            smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
            response.SmbParameters = smbParameters;

            return response;
        }