ExtendedAttributeName.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright (C) 2017 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.SMB1
  12. {
  13. /// <summary>
  14. /// [MS-CIFS] 2.2.1.2.1 - SMB_GEA
  15. /// </summary>
  16. public class ExtendedAttributeName
  17. {
  18. private byte AttributeNameLengthInBytes;
  19. public string AttributeName; // ANSI, AttributeNameLengthInBytes + 1 byte null termination
  20. public ExtendedAttributeName()
  21. {
  22. }
  23. public ExtendedAttributeName(byte[] buffer, int offset)
  24. {
  25. AttributeNameLengthInBytes = ByteReader.ReadByte(buffer, offset + 0);
  26. AttributeName = ByteReader.ReadAnsiString(buffer, offset + 1, AttributeNameLengthInBytes);
  27. }
  28. public void WriteBytes(byte[] buffer, int offset)
  29. {
  30. AttributeNameLengthInBytes = (byte)AttributeName.Length;
  31. ByteWriter.WriteByte(buffer, offset + 0, AttributeNameLengthInBytes);
  32. ByteWriter.WriteAnsiString(buffer, offset + 1, AttributeName, AttributeName.Length);
  33. }
  34. public int Length
  35. {
  36. get
  37. {
  38. return 1 + AttributeName.Length + 1;
  39. }
  40. }
  41. }
  42. }