mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-21 16:55:54 +02:00
Added SMB_GEA_LIST / SMB_GEA structures
This commit is contained in:
parent
cd03f7c946
commit
794b1b30e1
3 changed files with 116 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
||||||
|
/* Copyright (C) 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>
|
||||||
|
/// [MS-CIFS] 2.2.1.2.1 - SMB_GEA
|
||||||
|
/// </summary>
|
||||||
|
public class ExtendedAttributeName
|
||||||
|
{
|
||||||
|
private byte AttributeNameLengthInBytes;
|
||||||
|
public string AttributeName; // ANSI, AttributeNameLengthInBytes + 1 byte null termination
|
||||||
|
|
||||||
|
public ExtendedAttributeName()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedAttributeName(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
AttributeNameLengthInBytes = ByteReader.ReadByte(buffer, offset + 0);
|
||||||
|
AttributeName = ByteReader.ReadAnsiString(buffer, offset + 1, AttributeNameLengthInBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteBytes(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
AttributeNameLengthInBytes = (byte)AttributeName.Length;
|
||||||
|
ByteWriter.WriteByte(buffer, offset + 0, AttributeNameLengthInBytes);
|
||||||
|
ByteWriter.WriteAnsiString(buffer, offset + 1, AttributeName, AttributeName.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1 + AttributeName.Length + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* Copyright (C) 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>
|
||||||
|
/// [MS-CIFS] 2.2.1.2.1.1 - SMB_GEA_LIST
|
||||||
|
/// </summary>
|
||||||
|
public class ExtendedAttributeNameList : List<ExtendedAttributeName>
|
||||||
|
{
|
||||||
|
public ExtendedAttributeNameList()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedAttributeNameList(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
// [MS-CIFS] length MUST contain the total size of the GEAList field, plus the size of the SizeOfListInBytes field
|
||||||
|
int length = (int)LittleEndianConverter.ToUInt32(buffer, offset + 0);
|
||||||
|
int position = offset + 4;
|
||||||
|
int eof = offset + length;
|
||||||
|
while (position < eof)
|
||||||
|
{
|
||||||
|
ExtendedAttributeName attribute = new ExtendedAttributeName(buffer, position);
|
||||||
|
this.Add(attribute);
|
||||||
|
position += attribute.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetBytes()
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[this.Length];
|
||||||
|
WriteBytes(buffer, 0);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteBytes(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
LittleEndianWriter.WriteUInt32(buffer, ref offset, (uint)Length);
|
||||||
|
foreach (ExtendedAttributeName entry in this)
|
||||||
|
{
|
||||||
|
entry.WriteBytes(buffer, offset);
|
||||||
|
offset += entry.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int length = 4;
|
||||||
|
foreach (ExtendedAttributeName entry in this)
|
||||||
|
{
|
||||||
|
length += entry.Length;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -328,6 +328,8 @@
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\DFSReferral\DfsReferralEntry.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\DFSReferral\DfsReferralEntry.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\DFSReferral\RequestGetDfsReferral.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\DFSReferral\RequestGetDfsReferral.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\DFSReferral\ResponseGetDfsReferral.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\DFSReferral\ResponseGetDfsReferral.cs" />
|
||||||
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\ExtendedAttributeName.cs" />
|
||||||
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\ExtendedAttributeNameList.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileBothDirectoryInfo.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileBothDirectoryInfo.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileDirectoryInfo.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileDirectoryInfo.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileFullDirectoryInfo.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindFileFullDirectoryInfo.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue