SetInfoStandard.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_INFO_STANDARD
  15. /// </summary>
  16. public class SetInfoStandard : SetInformation
  17. {
  18. public const int Length = 22;
  19. public DateTime CreationDateTime;
  20. public DateTime LastAccessDateTime;
  21. public DateTime LastWriteDateTime;
  22. public byte[] Reserved; // 10 bytes
  23. public SetInfoStandard()
  24. {
  25. Reserved = new byte[10];
  26. }
  27. public SetInfoStandard(byte[] buffer) : this(buffer, 0)
  28. {
  29. }
  30. public SetInfoStandard(byte[] buffer, int offset)
  31. {
  32. CreationDateTime = SMB1Helper.ReadSMBDateTime(buffer, offset + 0);
  33. LastAccessDateTime = SMB1Helper.ReadSMBDateTime(buffer, offset + 4);
  34. LastWriteDateTime = SMB1Helper.ReadSMBDateTime(buffer, offset + 8);
  35. Reserved = ByteReader.ReadBytes(buffer, offset + 12, 10);
  36. }
  37. public override byte[] GetBytes()
  38. {
  39. byte[] buffer = new byte[Length];
  40. SMB1Helper.WriteSMBDateTime(buffer, 0, CreationDateTime);
  41. SMB1Helper.WriteSMBDateTime(buffer, 4, LastAccessDateTime);
  42. SMB1Helper.WriteSMBDateTime(buffer, 8, LastWriteDateTime);
  43. ByteWriter.WriteBytes(buffer, 12, Reserved);
  44. return buffer;
  45. }
  46. public override SetInformationLevel InformationLevel
  47. {
  48. get
  49. {
  50. return SetInformationLevel.SMB_INFO_STANDARD;
  51. }
  52. }
  53. }
  54. }