diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/FindInformationLevel.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/FindInformationLevel.cs index 756e424..d7df7ac 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/FindInformationLevel.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/FindInformationLevel.cs @@ -3,9 +3,9 @@ namespace SMBLibrary.SMB1 { public enum FindInformationLevel : ushort { - SMB_INFO_STANDARD = 0x0001, - SMB_INFO_QUERY_EA_SIZE = 0x0002, - SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003, + SMB_INFO_STANDARD = 0x0001, // LANMAN2.0 + SMB_INFO_QUERY_EA_SIZE = 0x0002, // LANMAN2.0 + SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003, // LANMAN2.0 SMB_FIND_FILE_DIRECTORY_INFO = 0x0101, SMB_FIND_FILE_FULL_DIRECTORY_INFO = 0x0102, SMB_FIND_FILE_NAMES_INFO = 0x0103, diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryFSInformationLevel.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryFSInformationLevel.cs index 92b2fd9..77808ea 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryFSInformationLevel.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryFSInformationLevel.cs @@ -3,8 +3,8 @@ namespace SMBLibrary.SMB1 { public enum QueryFSInformationLevel : ushort { - SMB_INFO_ALLOCATION = 0x0001, - SMB_INFO_VOLUME = 0x0002, + SMB_INFO_ALLOCATION = 0x0001, // LANMAN2.0 + SMB_INFO_VOLUME = 0x0002, // LANMAN2.0 SMB_QUERY_FS_VOLUME_INFO = 0x0102, SMB_QUERY_FS_SIZE_INFO = 0x0103, SMB_QUERY_FS_DEVICE_INFO = 0x0104, diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryInformationLevel.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryInformationLevel.cs index c11380c..3f441ea 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryInformationLevel.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/QueryInformationLevel.cs @@ -3,9 +3,9 @@ namespace SMBLibrary.SMB1 { public enum QueryInformationLevel : ushort { - SMB_INFO_STANDARD = 0x0001, - SMB_INFO_QUERY_EA_SIZE = 0x0002, - SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003, + SMB_INFO_STANDARD = 0x0001, // LANMAN2.0 + SMB_INFO_QUERY_EA_SIZE = 0x0002, // LANMAN2.0 + SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003, // LANMAN2.0 SMB_INFO_QUERY_ALL_EAS = 0x0004, SMB_INFO_IS_NAME_VALID = 0x0006, SMB_QUERY_FILE_BASIC_INFO = 0x0101, diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/SetInformationLevel.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/SetInformationLevel.cs index a17a91b..765ecff 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Enums/SetInformationLevel.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Enums/SetInformationLevel.cs @@ -3,8 +3,8 @@ namespace SMBLibrary.SMB1 { public enum SetInformationLevel : ushort { - SMB_INFO_STANDARD = 0x0001, - SMB_INFO_SET_EAS = 0x0002, + SMB_INFO_STANDARD = 0x0001, // LANMAN2.0 + SMB_INFO_SET_EAS = 0x0002, // LANMAN2.0 SMB_SET_FILE_BASIC_INFO = 0x0101, SMB_SET_FILE_DISPOSITION_INFO = 0x0102, SMB_SET_FILE_ALLOCATION_INFO = 0x0103, diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoQueryEASize.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoQueryEASize.cs deleted file mode 100644 index ae1ae7a..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoQueryEASize.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_QUERY_EA_SIZE - /// - public class FindInfoQueryEASize : FindInformation - { - public uint ResumeKey; // Optional - public DateTime CreationDateTime; - public DateTime LastAccessDateTime; - public DateTime LastWriteDateTime; - public uint FileDataSize; - public uint AllocationSize; - public SMBFileAttributes Attributes; - public uint EASize; - //byte FileNameLength; // In bytes, MUST exclude the null termination. - public string FileName; // OEM / Unicode character array. MUST be written as SMB_STRING, and read as fixed length string. - - public FindInfoQueryEASize(bool returnResumeKeys) : base(returnResumeKeys) - { - } - - public FindInfoQueryEASize(byte[] buffer, ref int offset, bool isUnicode, bool returnResumeKeys) : base(returnResumeKeys) - { - if (returnResumeKeys) - { - ResumeKey = LittleEndianReader.ReadUInt32(buffer, ref offset); - } - CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset); - EASize = LittleEndianReader.ReadUInt32(buffer, ref offset); - byte fileNameLength = ByteReader.ReadByte(buffer, ref offset); - FileName = SMB1Helper.ReadFixedLengthString(buffer, ref offset, isUnicode, fileNameLength); - } - - public override void WriteBytes(byte[] buffer, ref int offset, bool isUnicode) - { - byte fileNameLength = (byte)(isUnicode ? FileName.Length * 2 : FileName.Length); - - if (ReturnResumeKeys) - { - LittleEndianWriter.WriteUInt32(buffer, ref offset, ResumeKey); - } - SMB1Helper.WriteSMBDateTime(buffer, ref offset, CreationDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastAccessDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastWriteDateTime); - LittleEndianWriter.WriteUInt32(buffer, ref offset, FileDataSize); - LittleEndianWriter.WriteUInt32(buffer, ref offset, AllocationSize); - LittleEndianWriter.WriteUInt16(buffer, ref offset, (ushort)Attributes); - LittleEndianWriter.WriteUInt32(buffer, ref offset, EASize); - ByteWriter.WriteByte(buffer, ref offset, fileNameLength); - SMB1Helper.WriteSMBString(buffer, ref offset, isUnicode, FileName); - } - - public override int GetLength(bool isUnicode) - { - int length = 31; - if (ReturnResumeKeys) - { - length += 4; - } - - if (isUnicode) - { - length += FileName.Length * 2 + 2; - } - else - { - length += FileName.Length + 1; - } - return length; - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoQueryExtendedAttributesFromList.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoQueryExtendedAttributesFromList.cs deleted file mode 100644 index e8981a8..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoQueryExtendedAttributesFromList.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_QUERY_EAS_FROM_LIST - /// - public class FindInfoQueryExtendedAttributesFromList : FindInformation - { - public uint ResumeKey; // Optional - public DateTime CreationDateTime; - public DateTime LastAccessDateTime; - public DateTime LastWriteDateTime; - public uint FileDataSize; - public uint AllocationSize; - public SMBFileAttributes Attributes; - public FullExtendedAttributeList ExtendedAttributeList; - //byte FileNameLength; // In bytes, MUST exclude the null termination. - public string FileName; // OEM / Unicode character array. MUST be written as SMB_STRING, and read as fixed length string. - - public FindInfoQueryExtendedAttributesFromList(bool returnResumeKeys) : base(returnResumeKeys) - { - } - - public FindInfoQueryExtendedAttributesFromList(byte[] buffer, ref int offset, bool isUnicode, bool returnResumeKeys) : base(returnResumeKeys) - { - if (returnResumeKeys) - { - ResumeKey = LittleEndianReader.ReadUInt32(buffer, ref offset); - } - CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset); - ExtendedAttributeList = new FullExtendedAttributeList(buffer, offset); - byte fileNameLength = ByteReader.ReadByte(buffer, ref offset); - FileName = SMB1Helper.ReadFixedLengthString(buffer, ref offset, isUnicode, fileNameLength); - } - - public override void WriteBytes(byte[] buffer, ref int offset, bool isUnicode) - { - byte fileNameLength = (byte)(isUnicode ? FileName.Length * 2 : FileName.Length); - - if (ReturnResumeKeys) - { - LittleEndianWriter.WriteUInt32(buffer, ref offset, ResumeKey); - } - SMB1Helper.WriteSMBDateTime(buffer, ref offset, CreationDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastAccessDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastWriteDateTime); - LittleEndianWriter.WriteUInt32(buffer, ref offset, FileDataSize); - LittleEndianWriter.WriteUInt32(buffer, ref offset, AllocationSize); - LittleEndianWriter.WriteUInt16(buffer, ref offset, (ushort)Attributes); - ExtendedAttributeList.WriteBytes(buffer, ref offset); - ByteWriter.WriteByte(buffer, ref offset, fileNameLength); - SMB1Helper.WriteSMBString(buffer, ref offset, isUnicode, FileName); - } - - public override int GetLength(bool isUnicode) - { - int length = 27 + ExtendedAttributeList.Length; - if (ReturnResumeKeys) - { - length += 4; - } - - if (isUnicode) - { - length += FileName.Length * 2 + 2; - } - else - { - length += FileName.Length + 1; - } - return length; - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoStandard.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoStandard.cs deleted file mode 100644 index 5580497..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInfoStandard.cs +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_STANDARD - /// - public class FindInfoStandard : FindInformation - { - public const int FixedLength = 23; - - public uint ResumeKey; // Optional - public DateTime CreationDateTime; - public DateTime LastAccessDateTime; - public DateTime LastWriteDateTime; - public uint FileDataSize; - public uint AllocationSize; - public SMBFileAttributes Attributes; - //byte FileNameLength; - public string FileName; // SMB_STRING - - public FindInfoStandard(bool returnResumeKeys) : base(returnResumeKeys) - { - } - - public FindInfoStandard(byte[] buffer, ref int offset, bool isUnicode, bool returnResumeKeys) : base(returnResumeKeys) - { - if (returnResumeKeys) - { - ResumeKey = LittleEndianReader.ReadUInt32(buffer, ref offset); - } - CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset); - byte fileNameLength = ByteReader.ReadByte(buffer, ref offset); - FileName = SMB1Helper.ReadSMBString(buffer, ref offset, isUnicode); - } - - public override void WriteBytes(byte[] buffer, ref int offset, bool isUnicode) - { - byte fileNameLength = (byte)(isUnicode ? FileName.Length * 2 : FileName.Length); - - if (ReturnResumeKeys) - { - LittleEndianWriter.WriteUInt32(buffer, ref offset, ResumeKey); - } - SMB1Helper.WriteSMBDateTime(buffer, ref offset, CreationDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastAccessDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastWriteDateTime); - LittleEndianWriter.WriteUInt32(buffer, ref offset, FileDataSize); - LittleEndianWriter.WriteUInt32(buffer, ref offset, AllocationSize); - LittleEndianWriter.WriteUInt16(buffer, ref offset, (ushort)Attributes); - ByteWriter.WriteByte(buffer, ref offset, fileNameLength); - SMB1Helper.WriteSMBString(buffer, ref offset, isUnicode, FileName); - } - - public override int GetLength(bool isUnicode) - { - int length = FixedLength; - if (ReturnResumeKeys) - { - length += 4; - } - - if (isUnicode) - { - length += FileName.Length * 2 + 2; - } - else - { - length += FileName.Length + 1; - } - return length; - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInformation.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInformation.cs index 1689740..50ebcf1 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInformation.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/FindInformation/FindInformation.cs @@ -35,12 +35,6 @@ namespace SMBLibrary.SMB1 { switch (informationLevel) { - case FindInformationLevel.SMB_INFO_STANDARD: - return new FindInfoStandard(buffer, ref offset, isUnicode, returnResumeKeys); - case FindInformationLevel.SMB_INFO_QUERY_EA_SIZE: - return new FindInfoQueryEASize(buffer, ref offset, isUnicode, returnResumeKeys); - case FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST: - return new FindInfoQueryExtendedAttributesFromList(buffer, ref offset, isUnicode, returnResumeKeys); case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO: return new FindFileDirectoryInfo(buffer, ref offset, isUnicode); case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO: diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInfoAllocation.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInfoAllocation.cs deleted file mode 100644 index ad3c200..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInfoAllocation.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_ALLOCATION - /// - public class QueryFSInfoAllocation : QueryFSInformation - { - public const int Length = 18; - - public uint FileSystemID; // File system identifier, Windows Server will set it to 0 - public uint SectorUnit; // Number of sectors per allocation unit - public uint UnitsTotal; // Total number of allocation units - public uint UnitsAvailable; // Total number of available allocation units - public ushort Sector; // Number of bytes per sector - - public QueryFSInfoAllocation() - { - } - - public QueryFSInfoAllocation(byte[] buffer, int offset) - { - FileSystemID = LittleEndianConverter.ToUInt32(buffer, offset + 0); - SectorUnit = LittleEndianConverter.ToUInt32(buffer, offset + 4); - UnitsTotal = LittleEndianConverter.ToUInt32(buffer, offset + 8); - UnitsAvailable = LittleEndianConverter.ToUInt32(buffer, offset + 12); - Sector = LittleEndianConverter.ToUInt16(buffer, offset + 16); - } - - public override byte[] GetBytes(bool isUnicode) - { - byte[] buffer = new byte[Length]; - LittleEndianWriter.WriteUInt32(buffer, 0, FileSystemID); - LittleEndianWriter.WriteUInt32(buffer, 4, SectorUnit); - LittleEndianWriter.WriteUInt32(buffer, 8, UnitsTotal); - LittleEndianWriter.WriteUInt32(buffer, 12, UnitsAvailable); - LittleEndianWriter.WriteUInt16(buffer, 16, Sector); - return buffer; - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInfoVolume.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInfoVolume.cs deleted file mode 100644 index 3d7b062..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInfoVolume.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_VOLUME - /// - public class QueryFSInfoVolume : QueryFSInformation - { - public uint VolumeSerialNumber; - //byte CharCount; - public string VolumeLabel; // SMB_STRING - - public QueryFSInfoVolume() - { - } - - public QueryFSInfoVolume(bool isUnicode, byte[] buffer, int offset) - { - VolumeSerialNumber = LittleEndianConverter.ToUInt32(buffer, offset + 0); - byte charCount = ByteReader.ReadByte(buffer, offset + 4); - VolumeLabel = SMB1Helper.ReadSMBString(buffer, offset + 5, isUnicode); - } - - public override byte[] GetBytes(bool isUnicode) - { - byte charCount = (byte)VolumeLabel.Length; - - int length = GetLength(isUnicode); - byte[] buffer = new byte[length]; - LittleEndianWriter.WriteUInt32(buffer, 0, VolumeSerialNumber); - ByteWriter.WriteByte(buffer, 4, charCount); - SMB1Helper.WriteSMBString(buffer, 5, isUnicode, VolumeLabel); - return buffer; - } - - public int GetLength(bool isUnicode) - { - int length = 5; - if (isUnicode) - { - length += VolumeLabel.Length * 2; - } - else - { - length += VolumeLabel.Length; - } - return length; - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInformation.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInformation.cs index 61ab50c..fab7d4c 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInformation.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryFSInformation/QueryFSInformation.cs @@ -19,10 +19,6 @@ namespace SMBLibrary.SMB1 { switch (informationLevel) { - case QueryFSInformationLevel.SMB_INFO_ALLOCATION: - return new QueryFSInfoAllocation(buffer, 0); - case QueryFSInformationLevel.SMB_INFO_VOLUME: - return new QueryFSInfoVolume(isUnicode, buffer, 0); case QueryFSInformationLevel.SMB_QUERY_FS_VOLUME_INFO: return new QueryFSVolumeInfo(buffer, 0); case QueryFSInformationLevel.SMB_QUERY_FS_SIZE_INFO: diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryEASize.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryEASize.cs deleted file mode 100644 index 0184e0c..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryEASize.cs +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_QUERY_EA_SIZE - /// - public class QueryEASize : QueryInformation - { - public const int Length = 26; - - public DateTime CreationDateTime; - public DateTime LastAccessDateTime; - public DateTime LastWriteDateTime; - public uint FileDataSize; - public uint AllocationSize; - public SMBFileAttributes Attributes; - public uint EASize; - - public QueryEASize() - { - } - - public QueryEASize(byte[] buffer, int offset) - { - CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset); - EASize = LittleEndianReader.ReadUInt32(buffer, ref offset); - } - - public override byte[] GetBytes() - { - byte[] buffer = new byte[Length]; - int offset = 0; - SMB1Helper.WriteSMBDateTime(buffer, ref offset, CreationDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastAccessDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastWriteDateTime); - LittleEndianWriter.WriteUInt32(buffer, ref offset, FileDataSize); - LittleEndianWriter.WriteUInt32(buffer, ref offset, AllocationSize); - LittleEndianWriter.WriteUInt16(buffer, ref offset, (ushort)Attributes); - LittleEndianWriter.WriteUInt32(buffer, ref offset, EASize); - return buffer; - } - - public override QueryInformationLevel InformationLevel - { - get - { - return QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE; - } - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryExtendedAttributesFromList.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryExtendedAttributesFromList.cs deleted file mode 100644 index 166a6a6..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryExtendedAttributesFromList.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_QUERY_EAS_FROM_LIST - /// - public class QueryExtendedAttributesFromList : QueryInformation - { - public FullExtendedAttributeList ExtendedAttributeList; - - public QueryExtendedAttributesFromList() - { - ExtendedAttributeList = new FullExtendedAttributeList(); - } - - public QueryExtendedAttributesFromList(byte[] buffer, int offset) - { - ExtendedAttributeList = new FullExtendedAttributeList(buffer, offset); - } - - public override byte[] GetBytes() - { - return ExtendedAttributeList.GetBytes(); - } - - public override QueryInformationLevel InformationLevel - { - get - { - return QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST; - } - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInfoStandard.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInfoStandard.cs deleted file mode 100644 index b6e9c9b..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInfoStandard.cs +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2014 Tal Aloni . 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 -{ - /// - /// SMB_INFO_STANDARD - /// - public class QueryInfoStandard : QueryInformation - { - public const int Length = 22; - - public DateTime CreationDateTime; - public DateTime LastAccessDateTime; - public DateTime LastWriteDateTime; - public uint FileDataSize; - public uint AllocationSize; - public SMBFileAttributes Attributes; - - public QueryInfoStandard() - { - } - - public QueryInfoStandard(byte[] buffer, int offset) - { - CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset); - FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset); - Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset); - } - - public override byte[] GetBytes() - { - byte[] buffer = new byte[Length]; - int offset = 0; - SMB1Helper.WriteSMBDateTime(buffer, ref offset, CreationDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastAccessDateTime); - SMB1Helper.WriteSMBDateTime(buffer, ref offset, LastWriteDateTime); - LittleEndianWriter.WriteUInt32(buffer, ref offset, FileDataSize); - LittleEndianWriter.WriteUInt32(buffer, ref offset, AllocationSize); - LittleEndianWriter.WriteUInt16(buffer, ref offset, (ushort)Attributes); - return buffer; - } - - public override QueryInformationLevel InformationLevel - { - get - { - return QueryInformationLevel.SMB_INFO_STANDARD; - } - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInformation.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInformation.cs index 8dd0cd7..e97e45e 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInformation.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/QueryInformation/QueryInformation.cs @@ -27,12 +27,6 @@ namespace SMBLibrary.SMB1 { switch (informationLevel) { - case QueryInformationLevel.SMB_INFO_STANDARD: - return new QueryInfoStandard(buffer, 0); - case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE: - return new QueryEASize(buffer, 0); - case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST: - return new QueryExtendedAttributesFromList(buffer, 0); case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS: return new QueryAllExtendedAttributes(buffer, 0); case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO: diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetExtendedAttributes.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetExtendedAttributes.cs deleted file mode 100644 index a264eb6..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetExtendedAttributes.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2014-2017 Tal Aloni . 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 -{ - /// - /// SMB_INFO_SET_EAS - /// - public class SetExtendedAttributes : SetInformation - { - public FullExtendedAttributeList ExtendedAttributeList; - - public SetExtendedAttributes() - { - ExtendedAttributeList = new FullExtendedAttributeList(); - } - - public SetExtendedAttributes(byte[] buffer) : this(buffer, 0) - { - } - - public SetExtendedAttributes(byte[] buffer, int offset) - { - ExtendedAttributeList = new FullExtendedAttributeList(buffer, offset); - } - - public override byte[] GetBytes() - { - return ExtendedAttributeList.GetBytes(); - } - - public override SetInformationLevel InformationLevel - { - get - { - return SetInformationLevel.SMB_INFO_SET_EAS; - } - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInfoStandard.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInfoStandard.cs deleted file mode 100644 index 8093ffd..0000000 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInfoStandard.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2014-2017 Tal Aloni . 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 -{ - /// - /// SMB_INFO_STANDARD - /// - public class SetInfoStandard : SetInformation - { - public const int Length = 22; - - public DateTime CreationDateTime; - public DateTime LastAccessDateTime; - public DateTime LastWriteDateTime; - public byte[] Reserved; // 10 bytes - - public SetInfoStandard() - { - Reserved = new byte[10]; - } - - public SetInfoStandard(byte[] buffer) : this(buffer, 0) - { - } - - public SetInfoStandard(byte[] buffer, int offset) - { - CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, offset + 0); - LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, offset + 4); - LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, offset + 8); - Reserved = ByteReader.ReadBytes(buffer, offset + 12, 10); - } - - public override byte[] GetBytes() - { - byte[] buffer = new byte[Length]; - SMB1Helper.WriteSMBDateTime(buffer, 0, CreationDateTime); - SMB1Helper.WriteSMBDateTime(buffer, 4, LastAccessDateTime); - SMB1Helper.WriteSMBDateTime(buffer, 8, LastWriteDateTime); - ByteWriter.WriteBytes(buffer, 12, Reserved); - return buffer; - } - - public override SetInformationLevel InformationLevel - { - get - { - return SetInformationLevel.SMB_INFO_STANDARD; - } - } - } -} diff --git a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInformation.cs b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInformation.cs index 37c319e..de594b4 100644 --- a/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInformation.cs +++ b/SMBLibrary/SMB1/Transaction2Subcommands/Structures/SetInformation/SetInformation.cs @@ -24,10 +24,6 @@ namespace SMBLibrary.SMB1 { switch (informationLevel) { - case SetInformationLevel.SMB_INFO_STANDARD: - return new SetInfoStandard(buffer); - case SetInformationLevel.SMB_INFO_SET_EAS: - return new SetExtendedAttributes(buffer); case SetInformationLevel.SMB_SET_FILE_BASIC_INFO: return new SetFileBasicInfo(buffer); case SetInformationLevel.SMB_SET_FILE_DISPOSITION_INFO: diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 2606433..05b8e4c 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -382,23 +382,16 @@ - - - - - - - @@ -408,14 +401,11 @@ - - - diff --git a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Find.cs b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Find.cs index 9562cd1..152d16a 100644 --- a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Find.cs +++ b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Find.cs @@ -36,43 +36,6 @@ namespace SMBLibrary.Server.SMB1 { switch (informationLevel) { - case FindInformationLevel.SMB_INFO_STANDARD: - { - FindInfoStandard result = new FindInfoStandard(returnResumeKeys); - result.CreationDateTime = entry.CreationTime; - result.LastAccessDateTime = entry.LastAccessTime; - result.LastWriteDateTime = entry.LastWriteTime; - result.FileDataSize = (uint)Math.Min(entry.Size, UInt32.MaxValue); - result.AllocationSize = (uint)Math.Min(NTFileSystemHelper.GetAllocationSize(entry.Size), UInt32.MaxValue); - result.Attributes = GetFileAttributes(entry); - result.FileName = entry.Name; - return result; - } - case FindInformationLevel.SMB_INFO_QUERY_EA_SIZE: - { - FindInfoQueryEASize result = new FindInfoQueryEASize(returnResumeKeys); - result.CreationDateTime = entry.CreationTime; - result.LastAccessDateTime = entry.LastAccessTime; - result.LastWriteDateTime = entry.LastWriteTime; - result.FileDataSize = (uint)Math.Min(entry.Size, UInt32.MaxValue); - result.AllocationSize = (uint)Math.Min(NTFileSystemHelper.GetAllocationSize(entry.Size), UInt32.MaxValue); - result.Attributes = GetFileAttributes(entry); - result.EASize = 0; - result.FileName = entry.Name; - return result; - } - case FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST: - { - FindInfoQueryExtendedAttributesFromList result = new FindInfoQueryExtendedAttributesFromList(returnResumeKeys); - result.CreationDateTime = entry.CreationTime; - result.LastAccessDateTime = entry.LastAccessTime; - result.LastWriteDateTime = entry.LastWriteTime; - result.FileDataSize = (uint)Math.Min(entry.Size, UInt32.MaxValue); - result.AllocationSize = (uint)Math.Min(NTFileSystemHelper.GetAllocationSize(entry.Size), UInt32.MaxValue); - result.Attributes = GetFileAttributes(entry); - result.ExtendedAttributeList = new FullExtendedAttributeList(); - return result; - } case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO: { FindFileDirectoryInfo result = new FindFileDirectoryInfo(); diff --git a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Query.cs b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Query.cs index 9c8f9d0..308c3ed 100644 --- a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Query.cs +++ b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Query.cs @@ -18,35 +18,6 @@ namespace SMBLibrary.Server.SMB1 { switch (informationLevel) { - case QueryInformationLevel.SMB_INFO_STANDARD: - { - QueryInfoStandard information = new QueryInfoStandard(); - information.CreationDateTime = entry.CreationTime; - information.LastAccessDateTime = entry.LastAccessTime; - information.LastWriteDateTime = entry.LastWriteTime; - information.FileDataSize = (uint)Math.Min(entry.Size, UInt32.MaxValue); - information.AllocationSize = (uint)Math.Min(NTFileSystemHelper.GetAllocationSize(entry.Size), UInt32.MaxValue); - result = information; - return NTStatus.STATUS_SUCCESS; - } - case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE: - { - QueryEASize information = new QueryEASize(); - information.CreationDateTime = entry.CreationTime; - information.LastAccessDateTime = entry.LastAccessTime; - information.LastWriteDateTime = entry.LastWriteTime; - information.FileDataSize = (uint)Math.Min(entry.Size, UInt32.MaxValue); - information.AllocationSize = (uint)Math.Min(NTFileSystemHelper.GetAllocationSize(entry.Size), UInt32.MaxValue); - information.Attributes = GetFileAttributes(entry); - information.EASize = 0; - result = information; - return NTStatus.STATUS_SUCCESS; - } - case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST: - { - result = null; - return NTStatus.STATUS_NOT_IMPLEMENTED; - } case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS: { result = null; diff --git a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.QueryFileSystem.cs b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.QueryFileSystem.cs index 483014b..1701376 100644 --- a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.QueryFileSystem.cs +++ b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.QueryFileSystem.cs @@ -18,25 +18,6 @@ namespace SMBLibrary.Server.SMB1 { switch (informationLevel) { - case QueryFSInformationLevel.SMB_INFO_ALLOCATION: - { - QueryFSInfoAllocation information = new QueryFSInfoAllocation(); - information.FileSystemID = 0; - information.SectorUnit = NTFileSystemHelper.ClusterSize / NTFileSystemHelper.BytesPerSector; - information.UnitsTotal = (uint)Math.Min(fileSystem.Size / NTFileSystemHelper.ClusterSize, UInt32.MaxValue); - information.UnitsAvailable = (uint)Math.Min(fileSystem.FreeSpace / NTFileSystemHelper.ClusterSize, UInt32.MaxValue); - information.Sector = NTFileSystemHelper.BytesPerSector; - result = information; - return NTStatus.STATUS_SUCCESS; - } - case QueryFSInformationLevel.SMB_INFO_VOLUME: - { - QueryFSInfoVolume information = new QueryFSInfoVolume(); - information.VolumeLabel = String.Empty; - information.VolumeSerialNumber = 0; - result = information; - return NTStatus.STATUS_SUCCESS; - } case QueryFSInformationLevel.SMB_QUERY_FS_VOLUME_INFO: { QueryFSVolumeInfo information = new QueryFSVolumeInfo(); diff --git a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Set.cs b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Set.cs index 0ba254a..8f8074a 100644 --- a/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Set.cs +++ b/SMBLibrary/Server/SMB1/SMB1FileSystemHelper.Set.cs @@ -17,15 +17,7 @@ namespace SMBLibrary.Server.SMB1 { public static NTStatus SetFileInformation(IFileSystem fileSystem, OpenFileObject openFile, SetInformation information, ConnectionState state) { - if (information is SetInfoStandard) - { - return NTStatus.STATUS_SUCCESS; - } - else if (information is SetExtendedAttributes) - { - return NTStatus.STATUS_NOT_IMPLEMENTED; - } - else if (information is SetFileBasicInfo) + if (information is SetFileBasicInfo) { SetFileBasicInfo basicInfo = (SetFileBasicInfo)information; bool isHidden = (basicInfo.ExtFileAttributes & ExtendedFileAttributes.Hidden) > 0;