SetInfoStandard.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_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 = SMBHelper.ReadSMBDateTime(buffer, offset + 0);
  33. LastAccessDateTime = SMBHelper.ReadSMBDateTime(buffer, offset + 4);
  34. LastWriteDateTime = SMBHelper.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. SMBHelper.WriteSMBDateTime(buffer, 0, CreationDateTime);
  41. SMBHelper.WriteSMBDateTime(buffer, 4, LastAccessDateTime);
  42. SMBHelper.WriteSMBDateTime(buffer, 8, LastWriteDateTime);
  43. ByteWriter.WriteBytes(buffer, 12, Reserved);
  44. return buffer;
  45. }
  46. }
  47. }