QueryFileAltNameInfo.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.SMB1
  12. {
  13. /// <summary>
  14. /// SMB_QUERY_FILE_ALT_NAME_INFO
  15. /// </summary>
  16. public class QueryFileAltNameInfo : QueryInformation
  17. {
  18. //uint FileNameLength; // In bytes
  19. public string FileName; // Unicode, 8.3 name of the file
  20. public QueryFileAltNameInfo()
  21. {
  22. }
  23. public QueryFileAltNameInfo(byte[] buffer, int offset)
  24. {
  25. uint fileNameLength = LittleEndianReader.ReadUInt32(buffer, ref offset);
  26. FileName = ByteReader.ReadUTF16String(buffer, ref offset, (int)(fileNameLength / 2));
  27. }
  28. public override byte[] GetBytes()
  29. {
  30. uint fileNameLength = (uint)(FileName.Length * 2);
  31. byte[] buffer = new byte[4 + fileNameLength];
  32. LittleEndianWriter.WriteUInt32(buffer, 0, fileNameLength);
  33. ByteWriter.WriteUTF16String(buffer, 4, FileName);
  34. return buffer;
  35. }
  36. public override QueryInformationLevel InformationLevel
  37. {
  38. get
  39. {
  40. return QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO;
  41. }
  42. }
  43. }
  44. }