Removed LANMAN2.0 FileInformation structures

This commit is contained in:
Tal Aloni 2017-02-10 01:38:33 +02:00
parent dabc3260be
commit c57fed1232
23 changed files with 11 additions and 793 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -1,89 +0,0 @@
/* Copyright (C) 2014 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_INFO_QUERY_EA_SIZE
/// </summary>
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;
}
}
}

View file

@ -1,89 +0,0 @@
/* Copyright (C) 2014 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_INFO_QUERY_EAS_FROM_LIST
/// </summary>
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;
}
}
}

View file

@ -1,88 +0,0 @@
/* Copyright (C) 2014 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_INFO_STANDARD
/// </summary>
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;
}
}
}

View file

@ -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:

View file

@ -1,51 +0,0 @@
/* Copyright (C) 2014 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_INFO_ALLOCATION
/// </summary>
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;
}
}
}

View file

@ -1,60 +0,0 @@
/* Copyright (C) 2014 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_INFO_VOLUME
/// </summary>
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;
}
}
}

View file

@ -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:

View file

@ -1,66 +0,0 @@
/* Copyright (C) 2014 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_INFO_QUERY_EA_SIZE
/// </summary>
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;
}
}
}
}

View file

@ -1,44 +0,0 @@
/* Copyright (C) 2014 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_INFO_QUERY_EAS_FROM_LIST
/// </summary>
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;
}
}
}
}

View file

@ -1,63 +0,0 @@
/* Copyright (C) 2014 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_INFO_STANDARD
/// </summary>
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;
}
}
}
}

View file

@ -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:

View file

@ -1,48 +0,0 @@
/* 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_INFO_SET_EAS
/// </summary>
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;
}
}
}
}

View file

@ -1,61 +0,0 @@
/* 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_INFO_STANDARD
/// </summary>
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;
}
}
}
}

View file

@ -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:

View file

@ -382,23 +382,16 @@
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileDirectoryInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileFullDirectoryInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileNamesInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInfoQueryEASize.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInfoQueryExtendedAttributesFromList.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInformation.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInformationList.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInfoStandard.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FullExtendedAttribute.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\FullExtendedAttributeList.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSAttibuteInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSDeviceInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSInfoAllocation.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSInformation.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSInfoVolume.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSSizeInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryFSInformation\QueryFSVolumeInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryAllExtendedAttributes.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryEASize.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryExtendedAttributesFromList.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryFileAllInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryFileAltNameInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryFileBasicInfo.cs" />
@ -408,14 +401,11 @@
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryFileStandardInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryFileStreamInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryInformation.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\QueryInformation\QueryInfoStandard.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetExtendedAttributes.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetFileAllocationInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetFileBasicInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetFileDispositionInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetFileEndOfFileInfo.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetInformation.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Structures\SetInformation\SetInfoStandard.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Transaction2CreateDirectoryRequest.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Transaction2CreateDirectoryResponse.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Transaction2FindFirst2Request.cs" />

View file

@ -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();

View file

@ -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;

View file

@ -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();

View file

@ -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;