mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 02:37:49 +02:00
Merged FileFullEAInformationList into FileFullEAInformation
This commit is contained in:
parent
3b4c50c190
commit
7ab79e6300
5 changed files with 112 additions and 134 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
/* 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
|
* 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,
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||||
|
@ -34,7 +34,7 @@ namespace SMBLibrary.SMB1
|
||||||
public string Name; // OEM / Unicode. NOT null terminated. (MUST be aligned to start on a 2-byte boundary from the start of the NT_Trans_Parameters)
|
public string Name; // OEM / Unicode. NOT null terminated. (MUST be aligned to start on a 2-byte boundary from the start of the NT_Trans_Parameters)
|
||||||
// Data:
|
// Data:
|
||||||
public SecurityDescriptor SecurityDescriptor;
|
public SecurityDescriptor SecurityDescriptor;
|
||||||
public FileFullEAInformationList ExtendedAttributes;
|
public List<FileFullEAInformation> ExtendedAttributes;
|
||||||
|
|
||||||
public NTTransactCreateRequest()
|
public NTTransactCreateRequest()
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@ namespace SMBLibrary.SMB1
|
||||||
{
|
{
|
||||||
SecurityDescriptor = new SecurityDescriptor(data, 0);
|
SecurityDescriptor = new SecurityDescriptor(data, 0);
|
||||||
}
|
}
|
||||||
ExtendedAttributes = new FileFullEAInformationList(data, (int)securityDescriptiorLength);
|
ExtendedAttributes = FileFullEAInformation.ReadList(data, (int)securityDescriptiorLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte[] GetParameters(bool isUnicode)
|
public override byte[] GetParameters(bool isUnicode)
|
||||||
|
|
|
@ -386,8 +386,7 @@
|
||||||
<Compile Include="Structures\ACE\Enums\AceFlags.cs" />
|
<Compile Include="Structures\ACE\Enums\AceFlags.cs" />
|
||||||
<Compile Include="Structures\ACE\Enums\AceType.cs" />
|
<Compile Include="Structures\ACE\Enums\AceType.cs" />
|
||||||
<Compile Include="Structures\ACL.cs" />
|
<Compile Include="Structures\ACL.cs" />
|
||||||
<Compile Include="Structures\FileFullEAInformation.cs" />
|
<Compile Include="Structures\FileInformation\Set\FileFullEAInformation.cs" />
|
||||||
<Compile Include="Structures\FileFullEAInformationList.cs" />
|
|
||||||
<Compile Include="Structures\ObjectIDBufferType1.cs" />
|
<Compile Include="Structures\ObjectIDBufferType1.cs" />
|
||||||
<Compile Include="Structures\SecurityDescriptor.cs" />
|
<Compile Include="Structures\SecurityDescriptor.cs" />
|
||||||
<Compile Include="Structures\SID.cs" />
|
<Compile Include="Structures\SID.cs" />
|
||||||
|
|
|
@ -1,62 +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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// [MS-FSCC] FILE_FULL_EA_INFORMATION data element
|
|
||||||
/// </summary>
|
|
||||||
public class FileFullEAInformation
|
|
||||||
{
|
|
||||||
public const int FixedLength = 8;
|
|
||||||
|
|
||||||
public uint NextEntryOffset;
|
|
||||||
public byte Flags;
|
|
||||||
private byte EaNameLength;
|
|
||||||
private ushort EaValueLength;
|
|
||||||
public string EaName; // ASCII
|
|
||||||
public string EaValue; // ASCII
|
|
||||||
|
|
||||||
public FileFullEAInformation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileFullEAInformation(byte[] buffer, int offset)
|
|
||||||
{
|
|
||||||
NextEntryOffset = LittleEndianReader.ReadUInt32(buffer, ref offset);
|
|
||||||
Flags = ByteReader.ReadByte(buffer, ref offset);
|
|
||||||
EaNameLength = ByteReader.ReadByte(buffer, ref offset);
|
|
||||||
EaValueLength = LittleEndianReader.ReadUInt16(buffer, ref offset);
|
|
||||||
EaName = ByteReader.ReadAnsiString(buffer, ref offset, EaNameLength);
|
|
||||||
EaValue = ByteReader.ReadAnsiString(buffer, ref offset, EaValueLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteBytes(byte[] buffer, int offset)
|
|
||||||
{
|
|
||||||
EaNameLength = (byte)EaName.Length;
|
|
||||||
EaValueLength = (ushort)EaValue.Length;
|
|
||||||
LittleEndianWriter.WriteUInt32(buffer, ref offset, NextEntryOffset);
|
|
||||||
ByteWriter.WriteByte(buffer, ref offset, Flags);
|
|
||||||
ByteWriter.WriteByte(buffer, ref offset, EaNameLength);
|
|
||||||
LittleEndianWriter.WriteUInt16(buffer, ref offset, EaValueLength);
|
|
||||||
ByteWriter.WriteAnsiString(buffer, ref offset, EaName);
|
|
||||||
ByteWriter.WriteAnsiString(buffer, ref offset, EaValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Length
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return FixedLength + EaName.Length + EaValue.Length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +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;
|
|
||||||
|
|
||||||
namespace SMBLibrary
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// [MS-FSCC] FILE_FULL_EA_INFORMATION buffer
|
|
||||||
/// </summary>
|
|
||||||
public class FileFullEAInformationList : List<FileFullEAInformation>
|
|
||||||
{
|
|
||||||
public FileFullEAInformationList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileFullEAInformationList(byte[] buffer, int offset)
|
|
||||||
{
|
|
||||||
FileFullEAInformation entry = new FileFullEAInformation(buffer, offset);
|
|
||||||
this.Add(entry);
|
|
||||||
while (entry.NextEntryOffset != 0)
|
|
||||||
{
|
|
||||||
entry = new FileFullEAInformation(buffer, (int)entry.NextEntryOffset);
|
|
||||||
this.Add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteBytes(byte[] buffer, int offset)
|
|
||||||
{
|
|
||||||
// When multiple FILE_FULL_EA_INFORMATION data elements are present in the buffer, each MUST be aligned on a 4-byte boundary
|
|
||||||
for (int index = 0; index < this.Count; index++)
|
|
||||||
{
|
|
||||||
this[index].WriteBytes(buffer, offset);
|
|
||||||
offset += this[index].Length;
|
|
||||||
if (index < this.Count - 1)
|
|
||||||
{
|
|
||||||
int padding = (4 - (offset % 4)) % 4;
|
|
||||||
offset += padding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Length
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// When multiple FILE_FULL_EA_INFORMATION data elements are present in the buffer, each MUST be aligned on a 4-byte boundary
|
|
||||||
int length = 0;
|
|
||||||
for(int index = 0; index < this.Count; index++)
|
|
||||||
{
|
|
||||||
length += this[index].Length;
|
|
||||||
if (index < this.Count - 1)
|
|
||||||
{
|
|
||||||
int padding = (4 - (length % 4)) % 4;
|
|
||||||
length += padding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/* 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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// [MS-FSCC] 2.4.15 - FILE_FULL_EA_INFORMATION
|
||||||
|
/// </summary>
|
||||||
|
public class FileFullEAInformation
|
||||||
|
{
|
||||||
|
public const int FixedLength = 8;
|
||||||
|
|
||||||
|
public uint NextEntryOffset;
|
||||||
|
public byte Flags;
|
||||||
|
private byte EaNameLength;
|
||||||
|
private ushort EaValueLength;
|
||||||
|
public string EaName; // 8-bit ASCII
|
||||||
|
public string EaValue; // 8-bit ASCII
|
||||||
|
|
||||||
|
public FileFullEAInformation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileFullEAInformation(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
NextEntryOffset = LittleEndianReader.ReadUInt32(buffer, ref offset);
|
||||||
|
Flags = ByteReader.ReadByte(buffer, ref offset);
|
||||||
|
EaNameLength = ByteReader.ReadByte(buffer, ref offset);
|
||||||
|
EaValueLength = LittleEndianReader.ReadUInt16(buffer, ref offset);
|
||||||
|
EaName = ByteReader.ReadAnsiString(buffer, ref offset, EaNameLength);
|
||||||
|
EaValue = ByteReader.ReadAnsiString(buffer, ref offset, EaValueLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteBytes(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
EaNameLength = (byte)EaName.Length;
|
||||||
|
EaValueLength = (ushort)EaValue.Length;
|
||||||
|
LittleEndianWriter.WriteUInt32(buffer, ref offset, NextEntryOffset);
|
||||||
|
ByteWriter.WriteByte(buffer, ref offset, Flags);
|
||||||
|
ByteWriter.WriteByte(buffer, ref offset, EaNameLength);
|
||||||
|
LittleEndianWriter.WriteUInt16(buffer, ref offset, EaValueLength);
|
||||||
|
ByteWriter.WriteAnsiString(buffer, ref offset, EaName);
|
||||||
|
ByteWriter.WriteAnsiString(buffer, ref offset, EaValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return FixedLength + EaName.Length + EaValue.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<FileFullEAInformation> ReadList(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
List<FileFullEAInformation> result = new List<FileFullEAInformation>();
|
||||||
|
FileFullEAInformation entry;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
entry = new FileFullEAInformation(buffer, offset);
|
||||||
|
result.Add(entry);
|
||||||
|
}
|
||||||
|
while (entry.NextEntryOffset != 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteList(byte[] buffer, int offset, List<FileFullEAInformation> list)
|
||||||
|
{
|
||||||
|
// When multiple FILE_FULL_EA_INFORMATION data elements are present in the buffer, each MUST be aligned on a 4-byte boundary
|
||||||
|
for (int index = 0; index < list.Count; index++)
|
||||||
|
{
|
||||||
|
FileFullEAInformation entry = list[index];
|
||||||
|
entry.WriteBytes(buffer, offset);
|
||||||
|
int entryLength = entry.Length;
|
||||||
|
offset += entryLength;
|
||||||
|
if (index < list.Count - 1)
|
||||||
|
{
|
||||||
|
int padding = (4 - (entryLength % 4)) % 4;
|
||||||
|
offset += padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetListLength(List<FileFullEAInformation> list)
|
||||||
|
{
|
||||||
|
// When multiple FILE_FULL_EA_INFORMATION data elements are present in the buffer, each MUST be aligned on a 4-byte boundary
|
||||||
|
int length = 0;
|
||||||
|
for (int index = 0; index < list.Count; index++)
|
||||||
|
{
|
||||||
|
length += list[index].Length;
|
||||||
|
if (index < list.Count - 1)
|
||||||
|
{
|
||||||
|
int padding = (4 - (length % 4)) % 4;
|
||||||
|
length += padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue