123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- /* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
- *
- * You can redistribute this program and/or modify it under the terms of
- * the GNU Lesser Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- */
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.SMB1
- {
- /// <summary>
- /// SMB_COM_NT_CREATE_ANDX Extended Response
- /// </summary>
- public class NTCreateAndXResponseExtended : SMBAndXCommand
- {
- public const int ParametersLength = 100;
- // Parameters:
- // CommandName AndXCommand;
- // byte AndXReserved;
- // ushort AndXOffset;
- public OpLockLevel OpLockLevel;
- public ushort FID;
- public CreateDisposition CreateDisposition;
- public DateTime? CreateTime;
- public DateTime? LastAccessTime;
- public DateTime? LastWriteTime;
- public DateTime? LastChangeTime;
- public ExtendedFileAttributes ExtFileAttributes;
- public long AllocationSize;
- public long EndOfFile;
- public ResourceType ResourceType;
- public ushort NMPipeStatus_or_FileStatusFlags;
- public bool Directory;
- public Guid VolumeGuid;
- public ulong FileID;
- public AccessMask MaximalAccessRights;
- public AccessMask GuestMaximalAccessRights;
-
- public NTCreateAndXResponseExtended() : base()
- {
- }
- public NTCreateAndXResponseExtended(byte[] buffer, int offset) : base(buffer, offset, false)
- {
- int parametersOffset = 4;
- OpLockLevel = (OpLockLevel)ByteReader.ReadByte(this.SMBParameters, ref parametersOffset);
- FID = LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
- CreateDisposition = (CreateDisposition)LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
- CreateTime = FileTimeHelper.ReadNullableFileTime(buffer, ref parametersOffset);
- LastAccessTime = FileTimeHelper.ReadNullableFileTime(buffer, ref parametersOffset);
- LastWriteTime = FileTimeHelper.ReadNullableFileTime(buffer, ref parametersOffset);
- LastChangeTime = FileTimeHelper.ReadNullableFileTime(buffer, ref parametersOffset);
- ExtFileAttributes = (ExtendedFileAttributes)LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
- AllocationSize = LittleEndianReader.ReadInt64(buffer, ref parametersOffset);
- EndOfFile = LittleEndianReader.ReadInt64(buffer, ref parametersOffset);
- ResourceType = (ResourceType)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
- NMPipeStatus_or_FileStatusFlags = LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
- Directory = (ByteReader.ReadByte(this.SMBParameters, ref parametersOffset) > 0);
- VolumeGuid = LittleEndianReader.ReadGuid(this.SMBParameters, ref parametersOffset);
- FileID = LittleEndianReader.ReadUInt64(this.SMBParameters, ref parametersOffset);
- MaximalAccessRights = (AccessMask)LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
- GuestMaximalAccessRights = (AccessMask)LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);
- }
- public override byte[] GetBytes(bool isUnicode)
- {
- this.SMBParameters = new byte[ParametersLength];
- int parametersOffset = 4;
- ByteWriter.WriteByte(this.SMBParameters, ref parametersOffset, (byte)OpLockLevel);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, FID);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)CreateDisposition);
- FileTimeHelper.WriteFileTime(this.SMBParameters, ref parametersOffset, CreateTime);
- FileTimeHelper.WriteFileTime(this.SMBParameters, ref parametersOffset, LastAccessTime);
- FileTimeHelper.WriteFileTime(this.SMBParameters, ref parametersOffset, LastWriteTime);
- FileTimeHelper.WriteFileTime(this.SMBParameters, ref parametersOffset, LastChangeTime);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)ExtFileAttributes);
- LittleEndianWriter.WriteInt64(this.SMBParameters, ref parametersOffset, AllocationSize);
- LittleEndianWriter.WriteInt64(this.SMBParameters, ref parametersOffset, EndOfFile);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, (ushort)ResourceType);
- LittleEndianWriter.WriteUInt16(this.SMBParameters, ref parametersOffset, NMPipeStatus_or_FileStatusFlags);
- ByteWriter.WriteByte(this.SMBParameters, ref parametersOffset, Convert.ToByte(Directory));
- LittleEndianWriter.WriteGuidBytes(this.SMBParameters, ref parametersOffset, VolumeGuid);
- LittleEndianWriter.WriteUInt64(this.SMBParameters, ref parametersOffset, FileID);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)MaximalAccessRights);
- LittleEndianWriter.WriteUInt32(this.SMBParameters, ref parametersOffset, (uint)GuestMaximalAccessRights);
- return base.GetBytes(isUnicode);
- }
- public NamedPipeStatus NMPipeStatus
- {
- get
- {
- return new NamedPipeStatus(NMPipeStatus_or_FileStatusFlags);
- }
- set
- {
- NMPipeStatus_or_FileStatusFlags = value.ToUInt16();
- }
- }
- public FileStatusFlags FileStatusFlags
- {
- get
- {
- return (FileStatusFlags)NMPipeStatus_or_FileStatusFlags;
- }
- set
- {
- NMPipeStatus_or_FileStatusFlags = (ushort)value;
- }
- }
- public override CommandName CommandName
- {
- get
- {
- return CommandName.SMB_COM_NT_CREATE_ANDX;
- }
- }
- }
- }
|