Transaction2QueryPathInformationResponse.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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_PATH_INFORMATION Response
  15. /// </summary>
  16. public class Transaction2QueryPathInformationResponse : Transaction2Subcommand
  17. {
  18. // Parameters:
  19. public ushort EaErrorOffset;
  20. // Data:
  21. public QueryInformation QueryInfo;
  22. public Transaction2QueryPathInformationResponse() : base()
  23. {
  24. }
  25. public Transaction2QueryPathInformationResponse(byte[] parameters, byte[] data, QueryInformationLevel informationLevel, bool isUnicode) : base()
  26. {
  27. if ((ushort)informationLevel > 0x0100)
  28. {
  29. EaErrorOffset = LittleEndianConverter.ToUInt16(parameters, 0);
  30. }
  31. QueryInfo = QueryInformation.GetQueryInformation(data, informationLevel);
  32. }
  33. public override byte[] GetParameters(bool isUnicode)
  34. {
  35. if ((ushort)QueryInfo.InformationLevel > 0x0100)
  36. {
  37. byte[] parameters = new byte[2];
  38. LittleEndianWriter.WriteUInt16(parameters, 0, EaErrorOffset);
  39. return parameters;
  40. }
  41. return new byte[0];
  42. }
  43. public override byte[] GetData(bool isUnicode)
  44. {
  45. if (QueryInfo == null)
  46. {
  47. // SMB_INFO_IS_NAME_VALID
  48. return new byte[0];
  49. }
  50. else
  51. {
  52. return QueryInfo.GetBytes();
  53. }
  54. }
  55. public override Transaction2SubcommandName SubcommandName
  56. {
  57. get
  58. {
  59. return Transaction2SubcommandName.TRANS2_QUERY_PATH_INFORMATION;
  60. }
  61. }
  62. }
  63. }