PipeWaitRequest.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.3.31 - FSCTL_PIPE_WAIT Request
  14. /// </summary>
  15. public class PipeWaitRequest
  16. {
  17. public const int FixedLength = 14;
  18. public ulong Timeout;
  19. private uint NameLength;
  20. public bool TimeSpecified;
  21. public byte Padding;
  22. public string Name;
  23. public PipeWaitRequest()
  24. {
  25. }
  26. public PipeWaitRequest(byte[] buffer, int offset)
  27. {
  28. Timeout = LittleEndianConverter.ToUInt64(buffer, offset + 0);
  29. NameLength = LittleEndianConverter.ToUInt32(buffer, offset + 8);
  30. TimeSpecified = Convert.ToBoolean(ByteReader.ReadByte(buffer, offset + 12));
  31. Padding = ByteReader.ReadByte(buffer, offset + 13);
  32. Name = ByteReader.ReadUTF16String(buffer, offset + 14, (int)(NameLength / 2));
  33. }
  34. public byte[] GetBytes()
  35. {
  36. byte[] buffer = new byte[this.Length];
  37. LittleEndianWriter.WriteUInt64(buffer, 0, Timeout);
  38. LittleEndianWriter.WriteUInt32(buffer, 8, (uint)(Name.Length * 2));
  39. ByteWriter.WriteByte(buffer, 12, Convert.ToByte(TimeSpecified));
  40. ByteWriter.WriteByte(buffer, 13, Padding);
  41. ByteWriter.WriteUTF16String(buffer, 14, Name);
  42. return buffer;
  43. }
  44. public int Length
  45. {
  46. get
  47. {
  48. return FixedLength + Name.Length * 2;
  49. }
  50. }
  51. }
  52. }