WriteRawRequest.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_WRITE_RAW Request
  15. /// </summary>
  16. public class WriteRawRequest : SMB1Command
  17. {
  18. public const int ParametersFixedLength = 24; // + 4 optional bytes
  19. // Parameters:
  20. public ushort FID;
  21. public ushort CountOfBytes;
  22. public ushort Reserved1;
  23. public uint Offset;
  24. public uint Timeout;
  25. public WriteMode WriteMode;
  26. public uint Reserved2;
  27. //ushort DataLength;
  28. //ushort DataOffset;
  29. public uint OffsetHigh; // Optional
  30. // Data:
  31. public byte[] Data;
  32. public WriteRawRequest() : base()
  33. {
  34. Data = new byte[0];
  35. }
  36. public WriteRawRequest(byte[] buffer, int offset) : base(buffer, offset, false)
  37. {
  38. FID = LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
  39. CountOfBytes = LittleEndianConverter.ToUInt16(this.SMBParameters, 2);
  40. Reserved1 = LittleEndianConverter.ToUInt16(this.SMBParameters, 4);
  41. Offset = LittleEndianConverter.ToUInt32(this.SMBParameters, 6);
  42. Timeout = LittleEndianConverter.ToUInt32(this.SMBParameters, 10);
  43. WriteMode = (WriteMode)LittleEndianConverter.ToUInt16(this.SMBParameters, 14);
  44. Reserved2 = LittleEndianConverter.ToUInt32(this.SMBParameters, 16);
  45. ushort dataLength = LittleEndianConverter.ToUInt16(this.SMBParameters, 20);
  46. ushort dataOffset = LittleEndianConverter.ToUInt16(this.SMBParameters, 22);
  47. if (SMBParameters.Length == ParametersFixedLength + 4)
  48. {
  49. OffsetHigh = LittleEndianConverter.ToUInt32(this.SMBParameters, 24);
  50. }
  51. Data = ByteReader.ReadBytes(buffer, dataOffset, dataLength);
  52. }
  53. public override byte[] GetBytes(bool isUnicode)
  54. {
  55. throw new NotImplementedException();
  56. }
  57. public override CommandName CommandName
  58. {
  59. get
  60. {
  61. return CommandName.SMB_COM_WRITE_RAW;
  62. }
  63. }
  64. }
  65. }