ReadRequest.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_COM_READ Request
  15. /// </summary>
  16. public class ReadRequest : SMB1Command
  17. {
  18. public const int ParametersLength = 10;
  19. // Parameters:
  20. public ushort FID;
  21. public ushort CountOfBytesToRead;
  22. public uint ReadOffsetInBytes;
  23. public ushort EstimateOfRemainingBytesToBeRead;
  24. public ReadRequest() : base()
  25. {
  26. }
  27. public ReadRequest(byte[] buffer, int offset) : base(buffer, offset, false)
  28. {
  29. FID = LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
  30. CountOfBytesToRead = LittleEndianConverter.ToUInt16(this.SMBParameters, 2);
  31. ReadOffsetInBytes = LittleEndianConverter.ToUInt32(this.SMBParameters, 4);
  32. CountOfBytesToRead = LittleEndianConverter.ToUInt16(this.SMBParameters, 8);
  33. }
  34. public override byte[] GetBytes(bool isUnicode)
  35. {
  36. this.SMBParameters = new byte[ParametersLength];
  37. LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, FID);
  38. LittleEndianWriter.WriteUInt16(this.SMBParameters, 2, CountOfBytesToRead);
  39. LittleEndianWriter.WriteUInt32(this.SMBParameters, 4, ReadOffsetInBytes);
  40. LittleEndianWriter.WriteUInt16(this.SMBParameters, 8, CountOfBytesToRead);
  41. return base.GetBytes(isUnicode);
  42. }
  43. public override CommandName CommandName
  44. {
  45. get
  46. {
  47. return CommandName.SMB_COM_READ;
  48. }
  49. }
  50. }
  51. }