mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-22 01:05:54 +02:00
Corrected SMB_FEA / SMB_FEA_LIST implementation
This commit is contained in:
parent
9f79f939b6
commit
dfb8822a4f
2 changed files with 23 additions and 18 deletions
|
@ -12,34 +12,38 @@ using Utilities;
|
||||||
namespace SMBLibrary.SMB1
|
namespace SMBLibrary.SMB1
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SMB_FEA
|
/// [MS-CIFS] 2.2.1.2.2 - SMB_FEA
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FullExtendedAttribute
|
public class FullExtendedAttribute
|
||||||
{
|
{
|
||||||
public ExtendedAttributeFlag ExtendedAttributeFlag;
|
public ExtendedAttributeFlag ExtendedAttributeFlag;
|
||||||
//byte AttributeNameLengthInBytes;
|
private byte AttributeNameLengthInBytes;
|
||||||
//ushort AttributeValueLengthInBytes;
|
private ushort AttributeValueLengthInBytes;
|
||||||
public string AttributeName; // ANSI, AttributeNameLengthInBytes + 1 byte null termination
|
public string AttributeName; // ANSI, AttributeNameLengthInBytes + 1 byte null termination
|
||||||
public string AttributeValue; // ANSI
|
public string AttributeValue; // ANSI
|
||||||
|
|
||||||
|
public FullExtendedAttribute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public FullExtendedAttribute(byte[] buffer, int offset)
|
public FullExtendedAttribute(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
ExtendedAttributeFlag = (ExtendedAttributeFlag)ByteReader.ReadByte(buffer, offset);
|
ExtendedAttributeFlag = (ExtendedAttributeFlag)ByteReader.ReadByte(buffer, offset);
|
||||||
byte attributeNameLengthInBytes = ByteReader.ReadByte(buffer, offset + 1);
|
AttributeNameLengthInBytes = ByteReader.ReadByte(buffer, offset + 1);
|
||||||
ushort attributeValueLengthInBytes = LittleEndianConverter.ToUInt16(buffer, offset + 2);
|
AttributeValueLengthInBytes = LittleEndianConverter.ToUInt16(buffer, offset + 2);
|
||||||
AttributeName = ByteReader.ReadAnsiString(buffer, offset + 4, attributeNameLengthInBytes);
|
AttributeName = ByteReader.ReadAnsiString(buffer, offset + 4, AttributeNameLengthInBytes);
|
||||||
AttributeValue = ByteReader.ReadAnsiString(buffer, offset + 4 + attributeNameLengthInBytes + 1, attributeValueLengthInBytes);
|
AttributeValue = ByteReader.ReadAnsiString(buffer, offset + 4 + AttributeNameLengthInBytes + 1, AttributeValueLengthInBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteBytes(byte[] buffer, int offset)
|
public void WriteBytes(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
byte attributeNameLengthInBytes = (byte)AttributeName.Length;
|
AttributeNameLengthInBytes = (byte)AttributeName.Length;
|
||||||
ushort attributeValueLengthInBytes = (ushort)AttributeValue.Length;
|
AttributeValueLengthInBytes = (ushort)AttributeValue.Length;
|
||||||
ByteWriter.WriteByte(buffer, offset, (byte)ExtendedAttributeFlag);
|
ByteWriter.WriteByte(buffer, offset, (byte)ExtendedAttributeFlag);
|
||||||
ByteWriter.WriteByte(buffer, offset + 1, attributeNameLengthInBytes);
|
ByteWriter.WriteByte(buffer, offset + 1, AttributeNameLengthInBytes);
|
||||||
LittleEndianWriter.WriteUInt16(buffer, offset + 2, attributeValueLengthInBytes);
|
LittleEndianWriter.WriteUInt16(buffer, offset + 2, AttributeValueLengthInBytes);
|
||||||
ByteWriter.WriteAnsiString(buffer, offset + 4, AttributeName, AttributeValue.Length);
|
ByteWriter.WriteAnsiString(buffer, offset + 4, AttributeName, AttributeName.Length);
|
||||||
ByteWriter.WriteAnsiString(buffer, offset + 4 + attributeNameLengthInBytes + 1, AttributeValue, AttributeValue.Length);
|
ByteWriter.WriteAnsiString(buffer, offset + 4 + AttributeNameLengthInBytes + 1, AttributeValue, AttributeValue.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Length
|
public int Length
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Utilities;
|
||||||
namespace SMBLibrary.SMB1
|
namespace SMBLibrary.SMB1
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SMB_FEA_LIST
|
/// [MS-CIFS] 2.2.1.2.2.1 - SMB_FEA_LIST
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FullExtendedAttributeList : List<FullExtendedAttribute>
|
public class FullExtendedAttributeList : List<FullExtendedAttribute>
|
||||||
{
|
{
|
||||||
|
@ -26,14 +26,14 @@ namespace SMBLibrary.SMB1
|
||||||
|
|
||||||
public FullExtendedAttributeList(byte[] buffer, ref int offset) : this(buffer, offset)
|
public FullExtendedAttributeList(byte[] buffer, ref int offset) : this(buffer, offset)
|
||||||
{
|
{
|
||||||
// length MUST contain the total size of the FEAList field, plus the size of the SizeOfListInBytes field
|
// [MS-CIFS] length MUST contain the total size of the FEAList field, plus the size of the SizeOfListInBytes field
|
||||||
int length = (int)LittleEndianConverter.ToUInt32(buffer, offset);
|
int length = (int)LittleEndianConverter.ToUInt32(buffer, offset + 0);
|
||||||
offset += length;
|
offset += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FullExtendedAttributeList(byte[] buffer, int offset)
|
public FullExtendedAttributeList(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
// length MUST contain the total size of the FEAList field, plus the size of the SizeOfListInBytes field
|
// [MS-CIFS] length MUST contain the total size of the FEAList field, plus the size of the SizeOfListInBytes field
|
||||||
int length = (int)LittleEndianConverter.ToUInt32(buffer, offset);
|
int length = (int)LittleEndianConverter.ToUInt32(buffer, offset);
|
||||||
int position = offset + 4;
|
int position = offset + 4;
|
||||||
int eof = offset + length;
|
int eof = offset + length;
|
||||||
|
@ -60,6 +60,7 @@ namespace SMBLibrary.SMB1
|
||||||
|
|
||||||
public void WriteBytes(byte[] buffer, int offset)
|
public void WriteBytes(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
|
LittleEndianWriter.WriteUInt32(buffer, ref offset, (uint)Length);
|
||||||
foreach (FullExtendedAttribute entry in this)
|
foreach (FullExtendedAttribute entry in this)
|
||||||
{
|
{
|
||||||
entry.WriteBytes(buffer, offset);
|
entry.WriteBytes(buffer, offset);
|
||||||
|
@ -71,7 +72,7 @@ namespace SMBLibrary.SMB1
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int length = 0;
|
int length = 4;
|
||||||
foreach (FullExtendedAttribute entry in this)
|
foreach (FullExtendedAttribute entry in this)
|
||||||
{
|
{
|
||||||
length += entry.Length;
|
length += entry.Length;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue