QueryFileStreamInfo.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (C) 2014-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. /// SMB_QUERY_FILE_STREAM_INFO
  15. /// </summary>
  16. public class QueryFileStreamInfo : QueryInformation
  17. {
  18. public const int FixedLength = 24;
  19. public uint NextEntryOffset;
  20. //uint StreamNameLength; // In bytes
  21. public long StreamSize;
  22. public long StreamAllocationSize;
  23. public string StreamName; // Unicode
  24. public QueryFileStreamInfo()
  25. {
  26. }
  27. public QueryFileStreamInfo(byte[] buffer, int offset)
  28. {
  29. NextEntryOffset = LittleEndianReader.ReadUInt32(buffer, ref offset);
  30. uint streamNameLength = LittleEndianReader.ReadUInt32(buffer, ref offset);
  31. StreamSize = LittleEndianReader.ReadInt64(buffer, ref offset);
  32. StreamAllocationSize = LittleEndianReader.ReadInt64(buffer, ref offset);
  33. StreamName = ByteReader.ReadUTF16String(buffer, ref offset, (int)(streamNameLength / 2));
  34. }
  35. public override byte[] GetBytes()
  36. {
  37. uint streamNameLength = (uint)(StreamName.Length * 2);
  38. byte[] buffer = new byte[FixedLength + streamNameLength];
  39. int offset = 0;
  40. LittleEndianWriter.WriteUInt32(buffer, ref offset, NextEntryOffset);
  41. LittleEndianWriter.WriteUInt32(buffer, ref offset, streamNameLength);
  42. LittleEndianWriter.WriteInt64(buffer, ref offset, StreamSize);
  43. LittleEndianWriter.WriteInt64(buffer, ref offset, StreamAllocationSize);
  44. ByteWriter.WriteUTF16String(buffer, ref offset, StreamName);
  45. return buffer;
  46. }
  47. public override QueryInformationLevel InformationLevel
  48. {
  49. get
  50. {
  51. return QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO;
  52. }
  53. }
  54. }
  55. }