Transaction2QueryFileInformationRequest.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /// TRANS2_QUERY_FILE_INFORMATION Request
  15. /// </summary>
  16. public class Transaction2QueryFileInformationRequest : Transaction2Subcommand
  17. {
  18. public int ParametersLength = 4;
  19. // Parameters:
  20. public ushort FID;
  21. public QueryInformationLevel InformationLevel;
  22. // Data:
  23. FullExtendedAttributeList GetExtendedAttributeList; // Used with QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST
  24. public Transaction2QueryFileInformationRequest() : base()
  25. {
  26. GetExtendedAttributeList = new FullExtendedAttributeList();
  27. }
  28. public Transaction2QueryFileInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
  29. {
  30. FID = LittleEndianConverter.ToUInt16(parameters, 0);
  31. InformationLevel = (QueryInformationLevel)LittleEndianConverter.ToUInt16(parameters, 2);
  32. if (InformationLevel == QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
  33. {
  34. GetExtendedAttributeList = new FullExtendedAttributeList(data, 0);
  35. }
  36. }
  37. public override byte[] GetSetup()
  38. {
  39. return LittleEndianConverter.GetBytes((ushort)SubcommandName);
  40. }
  41. public override byte[] GetParameters(bool isUnicode)
  42. {
  43. byte[] parameters = new byte[ParametersLength];
  44. LittleEndianWriter.WriteUInt16(parameters, 0, FID);
  45. LittleEndianWriter.WriteUInt16(parameters, 2, (ushort)InformationLevel);
  46. return parameters;
  47. }
  48. public override byte[] GetData(bool isUnicode)
  49. {
  50. if (InformationLevel == QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
  51. {
  52. return GetExtendedAttributeList.GetBytes();
  53. }
  54. else
  55. {
  56. return new byte[0];
  57. }
  58. }
  59. public override Transaction2SubcommandName SubcommandName
  60. {
  61. get
  62. {
  63. return Transaction2SubcommandName.TRANS2_QUERY_FILE_INFORMATION;
  64. }
  65. }
  66. }
  67. }