TransactionPeekNamedPipeResponse.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (C) 2014-2019 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. /// TRANS_PEEK_NMPIPE Response
  15. /// </summary>
  16. public class TransactionPeekNamedPipeResponse : TransactionSubcommand
  17. {
  18. public const int ParametersLength = 6;
  19. // Parameters:
  20. public ushort ReadDataAvailable;
  21. public ushort MessageBytesLength;
  22. public NamedPipeState NamedPipeState;
  23. // Data:
  24. public byte[] ReadData;
  25. public TransactionPeekNamedPipeResponse() : base()
  26. { }
  27. public TransactionPeekNamedPipeResponse(byte[] parameters, byte[] data) : base()
  28. {
  29. ReadDataAvailable = LittleEndianConverter.ToUInt16(parameters, 0);
  30. MessageBytesLength = LittleEndianConverter.ToUInt16(parameters, 2);
  31. NamedPipeState = (NamedPipeState)LittleEndianConverter.ToUInt16(parameters, 4);
  32. ReadData = data;
  33. }
  34. public override byte[] GetParameters()
  35. {
  36. byte[] parameters = new byte[ParametersLength];
  37. LittleEndianWriter.WriteUInt16(parameters, 0, ReadDataAvailable);
  38. LittleEndianWriter.WriteUInt16(parameters, 2, MessageBytesLength);
  39. LittleEndianWriter.WriteUInt16(parameters, 4, (ushort)NamedPipeState);
  40. return parameters;
  41. }
  42. public override byte[] GetData(bool isUnicode)
  43. {
  44. return ReadData;
  45. }
  46. public override TransactionSubcommandName SubcommandName
  47. {
  48. get
  49. {
  50. return TransactionSubcommandName.TRANS_PEEK_NMPIPE;
  51. }
  52. }
  53. }
  54. }