Example #1
0
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbNtCreateAndxResponsePacket(SmbNtCreateAndxResponsePacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.smbParameters.WordCount         = packet.SmbParameters.WordCount;
            this.smbParameters.AndXCommand       = packet.SmbParameters.AndXCommand;
            this.smbParameters.AndXReserved      = packet.SmbParameters.AndXReserved;
            this.smbParameters.AndXOffset        = packet.SmbParameters.AndXOffset;
            this.smbParameters.OplockLevel       = packet.SmbParameters.OplockLevel;
            this.smbParameters.FID               = packet.SmbParameters.FID;
            this.smbParameters.CreateDisposition = packet.SmbParameters.CreateDisposition;
            this.smbParameters.CreateTime        = packet.SmbParameters.CreateTime;
            this.smbParameters.LastAccessTime    = packet.SmbParameters.LastAccessTime;
            this.smbParameters.LastChangeTime    = packet.SmbParameters.LastChangeTime;
            this.smbParameters.ExtFileAttributes = packet.SmbParameters.ExtFileAttributes;
            this.smbParameters.AllocationSize    = packet.SmbParameters.AllocationSize;
            this.smbParameters.EndOfFile         = packet.SmbParameters.EndOfFile;
            this.smbParameters.ResourceType      = packet.SmbParameters.ResourceType;
            this.smbParameters.NMPipeStatus      = packet.SmbParameters.NMPipeStatus;
            this.smbParameters.Directory         = packet.SmbParameters.Directory;
            this.smbData.ByteCount               = packet.SmbData.ByteCount;
        }
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbNtCreateAndxResponsePacket(SmbNtCreateAndxResponsePacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.smbParameters.WordCount = packet.SmbParameters.WordCount;
            this.smbParameters.AndXCommand = packet.SmbParameters.AndXCommand;
            this.smbParameters.AndXReserved = packet.SmbParameters.AndXReserved;
            this.smbParameters.AndXOffset = packet.SmbParameters.AndXOffset;
            this.smbParameters.OplockLevel = packet.SmbParameters.OplockLevel;
            this.smbParameters.FID = packet.SmbParameters.FID;
            this.smbParameters.CreateDisposition = packet.SmbParameters.CreateDisposition;
            this.smbParameters.CreateTime = packet.SmbParameters.CreateTime;
            this.smbParameters.LastAccessTime = packet.SmbParameters.LastAccessTime;
            this.smbParameters.LastChangeTime = packet.SmbParameters.LastChangeTime;
            this.smbParameters.ExtFileAttributes = packet.SmbParameters.ExtFileAttributes;
            this.smbParameters.AllocationSize = packet.SmbParameters.AllocationSize;
            this.smbParameters.EndOfFile = packet.SmbParameters.EndOfFile;
            this.smbParameters.ResourceType = packet.SmbParameters.ResourceType;
            this.smbParameters.NMPipeStatus = packet.SmbParameters.NMPipeStatus;
            this.smbParameters.Directory = packet.SmbParameters.Directory;
            this.smbData.ByteCount = packet.SmbData.ByteCount;
        }
        public SmbNtCreateAndxResponsePacket CreateNtCreateAndxResponse(
            CifsServerPerConnection connection,
            SmbNtCreateAndxRequestPacket request,
            OplockLevelValue opLockLevel,
            ulong allocationSize,
            ulong endOfFile,
            FileTypeValue resourceType,
            SMB_NMPIPE_STATUS nmPipeStatus,
            byte directory,
            SmbPacket andxPacket)
        {
            SmbNtCreateAndxResponsePacket response = new SmbNtCreateAndxResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            SMB_COM_NT_CREATE_ANDX_Response_SMB_Parameters smbParameters = response.SmbParameters;
            smbParameters.AndXCommand =
                andxPacket != null ? andxPacket.SmbHeader.Command : SmbCommand.SMB_COM_NO_ANDX_COMMAND;
            smbParameters.AndXReserved = 0x00;
            smbParameters.AndXOffset = (ushort)(response.HeaderSize + Marshal.SizeOf(response.SmbParameters)
                + Marshal.SizeOf(response.SmbData));
            smbParameters.OplockLevel = opLockLevel;
            smbParameters.FID = (ushort)connection.GenerateFID();
            smbParameters.CreateDisposition = NtTransactCreateDisposition.FILE_CREATE;
            FileTime fileTime = new FileTime();
            fileTime.Time = (ulong)DateTime.Now.ToFileTime();
            smbParameters.CreateTime = fileTime;
            smbParameters.LastAccessTime = fileTime;
            smbParameters.LastChangeTime = fileTime;
            smbParameters.ExtFileAttributes = (SMB_EXT_FILE_ATTR)request.SmbParameters.ExtFileAttributes;
            smbParameters.AllocationSize = allocationSize;
            smbParameters.EndOfFile = endOfFile;
            smbParameters.ResourceType = resourceType;
            smbParameters.NMPipeStatus = nmPipeStatus;
            smbParameters.Directory = directory;
            smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
            response.SmbParameters = smbParameters;

            response.AndxPacket = andxPacket;
            response.UpdateHeader();

            return response;
        }