QueryInformationResponse.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_QUERY_INFORMATION Response.
  15. /// This command is deprecated.
  16. /// This command is used by Windows NT4 SP6.
  17. /// </summary>
  18. public class QueryInformationResponse : SMB1Command
  19. {
  20. public const int ParameterLength = 20;
  21. // Parameters:
  22. public SMBFileAttributes FileAttributes;
  23. public DateTime? LastWriteTime;
  24. public uint FileSize;
  25. public byte[] Reserved; // 10 bytes
  26. public QueryInformationResponse() : base()
  27. {
  28. Reserved = new byte[10];
  29. }
  30. public QueryInformationResponse(byte[] buffer, int offset) : base(buffer, offset, false)
  31. {
  32. FileAttributes = (SMBFileAttributes)LittleEndianConverter.ToUInt16(this.SMBParameters, 0);
  33. LastWriteTime = UTimeHelper.ReadNullableUTime(this.SMBParameters, 2);
  34. FileSize = LittleEndianConverter.ToUInt32(this.SMBParameters, 6);
  35. Reserved = ByteReader.ReadBytes(this.SMBParameters, 10, 10);
  36. }
  37. public override byte[] GetBytes(bool isUnicode)
  38. {
  39. this.SMBParameters = new byte[ParameterLength];
  40. LittleEndianWriter.WriteUInt16(this.SMBParameters, 0, (ushort)FileAttributes);
  41. UTimeHelper.WriteUTime(this.SMBParameters, 2, LastWriteTime);
  42. LittleEndianWriter.WriteUInt32(this.SMBParameters, 6, FileSize);
  43. ByteWriter.WriteBytes(this.SMBParameters, 10, Reserved, 10);
  44. return base.GetBytes(isUnicode);
  45. }
  46. public override CommandName CommandName
  47. {
  48. get
  49. {
  50. return CommandName.SMB_COM_QUERY_INFORMATION;
  51. }
  52. }
  53. }
  54. }