Renamed FileAttributes to SMBFileAttributes

This commit is contained in:
Tal Aloni 2017-01-10 11:24:51 +02:00
parent 241eafc732
commit b45cffe099
20 changed files with 48 additions and 48 deletions

View file

@ -19,7 +19,7 @@ namespace SMBLibrary.SMB1
public const int SupportedBufferFormat = 0x04;
public const int ParametersLength = 2;
// Parameters;
public FileAttributes SearchAttributes;
public SMBFileAttributes SearchAttributes;
// Data:
public byte BufferFormat;
public string FileName; // SMB_STRING
@ -31,7 +31,7 @@ namespace SMBLibrary.SMB1
public DeleteRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
{
SearchAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
SearchAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
BufferFormat = ByteReader.ReadByte(this.SMBData, 0);
if (BufferFormat != SupportedBufferFormat)

View file

@ -23,8 +23,8 @@ namespace SMBLibrary.SMB1
//ushort AndXOffset;
public OpenFlags Flags;
public AccessModeOptions AccessMode;
public FileAttributes SearchAttrs;
public FileAttributes FileAttrs;
public SMBFileAttributes SearchAttrs;
public SMBFileAttributes FileAttrs;
public DateTime CreationTime; // UTime
public OpenMode OpenMode;
public uint AllocationSize;
@ -42,8 +42,8 @@ namespace SMBLibrary.SMB1
int parametersOffset = 4;
Flags = (OpenFlags)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
AccessMode = AccessModeOptions.Read(this.SMBParameters, ref parametersOffset);
SearchAttrs = (FileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
FileAttrs = (FileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
SearchAttrs = (SMBFileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
FileAttrs = (SMBFileAttributes)LittleEndianReader.ReadUInt16(this.SMBParameters, ref parametersOffset);
CreationTime = SMB1Helper.ReadUTime(this.SMBParameters, ref parametersOffset);
OpenMode = OpenMode.Read(this.SMBParameters, ref parametersOffset);
AllocationSize = LittleEndianReader.ReadUInt32(this.SMBParameters, ref parametersOffset);

View file

@ -22,7 +22,7 @@ namespace SMBLibrary.SMB1
//byte AndXReserved;
//ushort AndXOffset;
public ushort FID;
public FileAttributes FileAttrs;
public SMBFileAttributes FileAttrs;
public DateTime LastWriteTime; // UTime
public uint FileDataSize;
public AccessRights AccessRights;

View file

@ -22,7 +22,7 @@ namespace SMBLibrary.SMB1
//byte AndXReserved;
//ushort AndXOffset;
public ushort FID;
public FileAttributes FileAttrs;
public SMBFileAttributes FileAttrs;
public DateTime LastWriteTime; // UTime
public uint FileDataSize;
public AccessRights AccessRights;

View file

@ -20,7 +20,7 @@ namespace SMBLibrary.SMB1
{
public const int ParameterLength = 20;
// Parameters:
public FileAttributes FileAttributes;
public SMBFileAttributes FileAttributes;
public DateTime LastWriteTime;
public uint FileSize;
public byte[] Reserved; // 10 bytes
@ -32,7 +32,7 @@ namespace SMBLibrary.SMB1
public QueryInformationResponse(byte[] buffer, int offset) : base(buffer, offset, false)
{
FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
LastWriteTime = SMB1Helper.ReadSMBDateTime(this.SMBParameters, 2);
FileSize = LittleEndianConverter.ToUInt32(this.SMBParameters, 6);
Reserved = ByteReader.ReadBytes(this.SMBParameters, 10, 10);

View file

@ -19,7 +19,7 @@ namespace SMBLibrary.SMB1
public const int SupportedBufferFormat = 0x04;
public const int ParametersLength = 2;
// Parameters:
public FileAttributes SearchAttributes;
public SMBFileAttributes SearchAttributes;
// Data:
public byte BufferFormat1;
public string OldFileName; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header)
@ -34,7 +34,7 @@ namespace SMBLibrary.SMB1
public RenameRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
{
SearchAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
SearchAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
int dataOffset = 0;
BufferFormat1 = ByteReader.ReadByte(this.SMBData, ref dataOffset);

View file

@ -19,7 +19,7 @@ namespace SMBLibrary.SMB1
public const int ParametersLength = 16;
public const int SupportedBufferFormat = 0x04;
// Parameters:
public FileAttributes FileAttributes;
public SMBFileAttributes FileAttributes;
public DateTime LastWriteTime;
public byte[] Reserved; // 10 bytes
// Data:
@ -34,7 +34,7 @@ namespace SMBLibrary.SMB1
public SetInformationRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)
{
FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
LastWriteTime = SMB1Helper.ReadUTime(this.SMBParameters, 2);
Reserved = ByteReader.ReadBytes(this.SMBParameters, 6, 10);

View file

@ -6,7 +6,7 @@ namespace SMBLibrary.SMB1
/// SMB_FILE_ATTRIBUTES
/// </summary>
[Flags]
public enum FileAttributes : ushort
public enum SMBFileAttributes : ushort
{
Normal = 0x0000, // SMB_FILE_ATTRIBUTE_NORMAL
ReadOnly = 0x0001, // SMB_FILE_ATTRIBUTE_READONLY

View file

@ -22,7 +22,7 @@ namespace SMBLibrary.SMB1
public DateTime LastWriteDateTime;
public uint FileDataSize;
public uint AllocationSize;
public FileAttributes Attributes;
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.
@ -42,7 +42,7 @@ namespace SMBLibrary.SMB1
LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
Attributes = (FileAttributes)LittleEndianReader.ReadUInt16(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);

View file

@ -22,7 +22,7 @@ namespace SMBLibrary.SMB1
public DateTime LastWriteDateTime;
public uint FileDataSize;
public uint AllocationSize;
public FileAttributes Attributes;
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.
@ -42,7 +42,7 @@ namespace SMBLibrary.SMB1
LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
Attributes = (FileAttributes)LittleEndianReader.ReadUInt16(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);

View file

@ -24,7 +24,7 @@ namespace SMBLibrary.SMB1
public DateTime LastWriteDateTime;
public uint FileDataSize;
public uint AllocationSize;
public FileAttributes Attributes;
public SMBFileAttributes Attributes;
//byte FileNameLength;
public string FileName; // SMB_STRING
@ -43,7 +43,7 @@ namespace SMBLibrary.SMB1
LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
Attributes = (FileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
byte fileNameLength = ByteReader.ReadByte(buffer, ref offset);
FileName = SMB1Helper.ReadSMBString(buffer, ref offset, isUnicode);
}

View file

@ -23,7 +23,7 @@ namespace SMBLibrary.SMB1
public DateTime LastWriteDateTime;
public uint FileDataSize;
public uint AllocationSize;
public FileAttributes Attributes;
public SMBFileAttributes Attributes;
public uint EASize;
public QueryEASize()
@ -37,7 +37,7 @@ namespace SMBLibrary.SMB1
LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
Attributes = (FileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
EASize = LittleEndianReader.ReadUInt32(buffer, ref offset);
}

View file

@ -23,7 +23,7 @@ namespace SMBLibrary.SMB1
public DateTime LastWriteDateTime;
public uint FileDataSize;
public uint AllocationSize;
public FileAttributes Attributes;
public SMBFileAttributes Attributes;
public QueryInfoStandard()
{
@ -36,7 +36,7 @@ namespace SMBLibrary.SMB1
LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, ref offset);
FileDataSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
AllocationSize = LittleEndianReader.ReadUInt32(buffer, ref offset);
Attributes = (FileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
Attributes = (SMBFileAttributes)LittleEndianReader.ReadUInt16(buffer, ref offset);
}
public override byte[] GetBytes()

View file

@ -17,7 +17,7 @@ namespace SMBLibrary.SMB1
public class Transaction2FindFirst2Request : Transaction2Subcommand
{
// Parameters:
public FileAttributes SearchAttributes;
public SMBFileAttributes SearchAttributes;
public ushort SearchCount;
public FindFlags Flags;
public FindInformationLevel InformationLevel;
@ -33,7 +33,7 @@ namespace SMBLibrary.SMB1
public Transaction2FindFirst2Request(byte[] parameters, byte[] data, bool isUnicode) : base()
{
SearchAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(parameters, 0);
SearchAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(parameters, 0);
SearchCount = LittleEndianConverter.ToUInt16(parameters, 2);
Flags = (FindFlags)LittleEndianConverter.ToUInt16(parameters, 4);
InformationLevel = (FindInformationLevel)LittleEndianConverter.ToUInt16(parameters, 6);

View file

@ -20,7 +20,7 @@ namespace SMBLibrary.SMB1
public Open2Flags Flags;
public AccessModeOptions AccessMode;
public ushort Reserved1;
public FileAttributes FileAttributes;
public SMBFileAttributes FileAttributes;
public DateTime CreationTime; // UTIME (seconds since Jan 1, 1970)
public OpenMode OpenMode;
public uint AllocationSize;
@ -40,7 +40,7 @@ namespace SMBLibrary.SMB1
Flags = (Open2Flags)LittleEndianConverter.ToUInt16(parameters, 0);
AccessMode = new AccessModeOptions(parameters, 2);
Reserved1 = LittleEndianConverter.ToUInt16(parameters, 4);
FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(parameters, 6);
FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(parameters, 6);
CreationTime = SMB1Helper.ReadUTime(parameters, 8);
OpenMode = new OpenMode(parameters, 12);
AllocationSize = LittleEndianConverter.ToUInt32(parameters, 14);

View file

@ -19,7 +19,7 @@ namespace SMBLibrary.SMB1
public int ParametersLength = 30;
// Parameters
public ushort FID;
public FileAttributes FileAttributes;
public SMBFileAttributes FileAttributes;
public DateTime CreationTime;
public uint FileDataSize;
public AccessModeOptions AccessMode;
@ -38,7 +38,7 @@ namespace SMBLibrary.SMB1
public Transaction2Open2Response(byte[] parameters, byte[] data, bool isUnicode) : base()
{
FID = LittleEndianConverter.ToUInt16(parameters, 0);
FileAttributes = (FileAttributes)LittleEndianConverter.ToUInt16(parameters, 2);
FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(parameters, 2);
CreationTime = SMB1Helper.ReadUTime(parameters, 4);
FileDataSize = LittleEndianConverter.ToUInt32(parameters, 8);
AccessMode = new AccessModeOptions(parameters, 12);

View file

@ -239,7 +239,6 @@
<Compile Include="SMB1\Commands\WriteResponse.cs" />
<Compile Include="SMB1\Enums\CommandName.cs" />
<Compile Include="SMB1\Enums\ExtendedFileAttributes.cs" />
<Compile Include="SMB1\Enums\FileAttributes.cs" />
<Compile Include="SMB1\Enums\HeaderFlags.cs" />
<Compile Include="SMB1\Enums\HeaderFlags2.cs" />
<Compile Include="SMB1\Enums\Locking\LockType.cs" />
@ -256,6 +255,7 @@
<Compile Include="SMB1\Enums\Open\OpenResult.cs" />
<Compile Include="SMB1\Enums\ResourceType.cs" />
<Compile Include="SMB1\Enums\SessionSetup\SessionSetupAction.cs" />
<Compile Include="SMB1\Enums\SMBFileAttributes.cs" />
<Compile Include="SMB1\Enums\Transaction\TransactionFlags.cs" />
<Compile Include="SMB1\Enums\TreeConnect\OptionalSupportFlags.cs" />
<Compile Include="SMB1\Enums\TreeConnect\ServiceName.cs" />

View file

@ -117,8 +117,8 @@ namespace SMBLibrary.Server
return new ErrorResponse(CommandName.SMB_COM_DELETE);
}
if (!entry.IsDirectory && (request.SearchAttributes & SMBLibrary.SMB1.FileAttributes.Directory) > 0
|| entry.IsDirectory && (request.SearchAttributes & SMBLibrary.SMB1.FileAttributes.Directory) == 0)
if (!entry.IsDirectory && (request.SearchAttributes & SMBFileAttributes.Directory) > 0
|| entry.IsDirectory && (request.SearchAttributes & SMBFileAttributes.Directory) == 0)
{
header.Status = NTStatus.STATUS_OBJECT_PATH_INVALID;
return new ErrorResponse(CommandName.SMB_COM_DELETE);
@ -227,15 +227,15 @@ namespace SMBLibrary.Server
bool? isHidden = null;
bool? isReadOnly = null;
bool? isArchived = null;
if ((request.FileAttributes & SMBLibrary.SMB1.FileAttributes.Hidden) > 0)
if ((request.FileAttributes & SMBFileAttributes.Hidden) > 0)
{
isHidden = true;
}
if ((request.FileAttributes & SMBLibrary.SMB1.FileAttributes.ReadOnly) > 0)
if ((request.FileAttributes & SMBFileAttributes.ReadOnly) > 0)
{
isReadOnly = true;
}
if ((request.FileAttributes & SMBLibrary.SMB1.FileAttributes.Archive) > 0)
if ((request.FileAttributes & SMBFileAttributes.Archive) > 0)
{
isArchived = true;
}

View file

@ -313,24 +313,24 @@ namespace SMBLibrary.Server
}
public static FileAttributes GetFileAttributes(FileSystemEntry entry)
public static SMBFileAttributes GetFileAttributes(FileSystemEntry entry)
{
FileAttributes attributes = FileAttributes.Normal;
SMBFileAttributes attributes = SMBFileAttributes.Normal;
if (entry.IsHidden)
{
attributes |= FileAttributes.Hidden;
attributes |= SMBFileAttributes.Hidden;
}
if (entry.IsReadonly)
{
attributes |= FileAttributes.ReadOnly;
attributes |= SMBFileAttributes.ReadOnly;
}
if (entry.IsArchived)
{
attributes |= FileAttributes.Archive;
attributes |= SMBFileAttributes.Archive;
}
if (entry.IsDirectory)
{
attributes |= FileAttributes.Directory;
attributes |= SMBFileAttributes.Directory;
}
return attributes;

View file

@ -102,7 +102,7 @@ namespace SMBLibrary.Server
return new ErrorResponse(CommandName.SMB_COM_OPEN_ANDX);
}
if ((request.FileAttrs & SMB1.FileAttributes.Directory) > 0)
if ((request.FileAttrs & SMBFileAttributes.Directory) > 0)
{
System.Diagnostics.Debug.Print("[{0}] OpenAndX: Creating directory '{1}'", DateTime.Now.ToString("HH:mm:ss:ffff"), path);
entry = fileSystem.CreateDirectory(path);
@ -205,11 +205,11 @@ namespace SMBLibrary.Server
OpenAndXResponse response = new OpenAndXResponse();
if (entry.IsDirectory)
{
response.FileAttrs = SMBLibrary.SMB1.FileAttributes.Directory;
response.FileAttrs = SMBFileAttributes.Directory;
}
else
{
response.FileAttrs = SMBLibrary.SMB1.FileAttributes.Normal;
response.FileAttrs = SMBFileAttributes.Normal;
}
response.FID = fileID;
response.LastWriteTime = entry.LastWriteTime;
@ -225,11 +225,11 @@ namespace SMBLibrary.Server
OpenAndXResponseExtended response = new OpenAndXResponseExtended();
if (entry.IsDirectory)
{
response.FileAttrs = SMBLibrary.SMB1.FileAttributes.Directory;
response.FileAttrs = SMBFileAttributes.Directory;
}
else
{
response.FileAttrs = SMBLibrary.SMB1.FileAttributes.Normal;
response.FileAttrs = SMBFileAttributes.Normal;
}
response.FID = fileID;
response.LastWriteTime = entry.LastWriteTime;