SetInformation2Request.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_COM_SET_INFORMATION2 Request
  15. /// </summary>
  16. public class SetInformation2Request : SMB1Command
  17. {
  18. public const int ParametersLength = 14;
  19. // Parameters:
  20. public ushort FID;
  21. public DateTime? CreationDateTime; // A date and time value of 0 indicates to the server that the values MUST NOT be changed
  22. public DateTime? LastAccessDateTime; // A date and time value of 0 indicates to the server that the values MUST NOT be changed
  23. public DateTime? LastWriteDateTime; // A date and time value of 0 indicates to the server that the values MUST NOT be changed
  24. public SetInformation2Request() : base()
  25. {
  26. }
  27. public SetInformation2Request(byte[] buffer, int offset) : base(buffer, offset, false)
  28. {
  29. FID = LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
  30. CreationDateTime = SMB1Helper.ReadNullableSMBDateTime(this.SMBParameters, 2);
  31. LastAccessDateTime = SMB1Helper.ReadNullableSMBDateTime(this.SMBParameters, 6);
  32. LastWriteDateTime = SMB1Helper.ReadNullableSMBDateTime(this.SMBParameters, 10);
  33. }
  34. public override byte[] GetBytes(bool isUnicode)
  35. {
  36. this.SMBParameters = new byte[ParametersLength];
  37. LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, FID);
  38. SMB1Helper.WriteSMBDateTime(this.SMBParameters, 2, CreationDateTime);
  39. SMB1Helper.WriteSMBDateTime(this.SMBParameters, 6, LastAccessDateTime);
  40. SMB1Helper.WriteSMBDateTime(this.SMBParameters, 10, LastWriteDateTime);
  41. return base.GetBytes(isUnicode);
  42. }
  43. public override CommandName CommandName
  44. {
  45. get
  46. {
  47. return CommandName.SMB_COM_SET_INFORMATION2;
  48. }
  49. }
  50. }
  51. }