FileNamesInformation.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 Utilities;
  10. namespace SMBLibrary
  11. {
  12. /// <summary>
  13. /// [MS-FSCC] 2.4.26 - FileNamesInformation
  14. /// </summary>
  15. public class FileNamesInformation : QueryDirectoryFileInformation
  16. {
  17. public const int FixedLength = 12;
  18. private uint FileNameLength;
  19. public string FileName = String.Empty;
  20. public FileNamesInformation()
  21. {
  22. }
  23. public FileNamesInformation(byte[] buffer, int offset) : base(buffer, offset)
  24. {
  25. FileNameLength = LittleEndianConverter.ToUInt32(buffer, offset + 8);
  26. FileName = ByteReader.ReadUTF16String(buffer, offset + 12, (int)FileNameLength / 2);
  27. }
  28. public override void WriteBytes(byte[] buffer, int offset)
  29. {
  30. base.WriteBytes(buffer, offset);
  31. FileNameLength = (uint)(FileName.Length * 2);
  32. LittleEndianWriter.WriteUInt32(buffer, offset + 8, FileNameLength);
  33. ByteWriter.WriteUTF16String(buffer, offset + 12, FileName);
  34. }
  35. public override FileInformationClass FileInformationClass
  36. {
  37. get
  38. {
  39. return FileInformationClass.FileNamesInformation;
  40. }
  41. }
  42. public override int Length
  43. {
  44. get
  45. {
  46. return FixedLength + FileName.Length * 2;
  47. }
  48. }
  49. }
  50. }