FileFullEAInformation.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SMBLibrary
  12. {
  13. /// <summary>
  14. /// [MS-FSCC] FILE_FULL_EA_INFORMATION data element
  15. /// </summary>
  16. public class FileFullEAInformation
  17. {
  18. public uint NextEntryOffset;
  19. public byte Flags;
  20. //byte EaNameLength;
  21. //ushort EaValueLength;
  22. public string EaName; // ASCII
  23. public string EaValue; // ASCII
  24. public FileFullEAInformation()
  25. {
  26. }
  27. public FileFullEAInformation(byte[] buffer, int offset)
  28. {
  29. NextEntryOffset = LittleEndianReader.ReadUInt32(buffer, ref offset);
  30. Flags = ByteReader.ReadByte(buffer, ref offset);
  31. byte eaNameLength = ByteReader.ReadByte(buffer, ref offset);
  32. ushort eaValueLength = LittleEndianReader.ReadUInt16(buffer, ref offset);
  33. EaName = ByteReader.ReadAnsiString(buffer, ref offset, eaNameLength);
  34. EaValue = ByteReader.ReadAnsiString(buffer, ref offset, eaValueLength);
  35. }
  36. public void WriteBytes(byte[] buffer, int offset)
  37. {
  38. byte eaNameLength = (byte)EaName.Length;
  39. ushort eaValueLength = (ushort)EaValue.Length;
  40. LittleEndianWriter.WriteUInt32(buffer, ref offset, NextEntryOffset);
  41. ByteWriter.WriteByte(buffer, ref offset, Flags);
  42. ByteWriter.WriteByte(buffer, ref offset, eaNameLength);
  43. LittleEndianWriter.WriteUInt16(buffer, ref offset, eaValueLength);
  44. ByteWriter.WriteAnsiString(buffer, ref offset, EaName);
  45. ByteWriter.WriteAnsiString(buffer, ref offset, EaValue);
  46. }
  47. public int Length
  48. {
  49. get
  50. {
  51. return 8 + EaName.Length + EaValue.Length;
  52. }
  53. }
  54. }
  55. }