Transaction2FindNext2Response.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_FIND_NEXT2 Response
  15. /// </summary>
  16. public class Transaction2FindNext2Response : Transaction2Subcommand
  17. {
  18. public const int ParametersLength = 8;
  19. // Parameters:
  20. private ushort SearchCount;
  21. public bool EndOfSearch;
  22. public ushort EaErrorOffset;
  23. public ushort LastNameOffset;
  24. // Data:
  25. private byte[] FindInformationListBytes = new byte[0];
  26. public Transaction2FindNext2Response() : base()
  27. {
  28. }
  29. public Transaction2FindNext2Response(byte[] parameters, byte[] data, bool isUnicode) : base()
  30. {
  31. SearchCount = LittleEndianConverter.ToUInt16(parameters, 0);
  32. EndOfSearch = LittleEndianConverter.ToUInt16(parameters, 2) != 0;
  33. EaErrorOffset = LittleEndianConverter.ToUInt16(parameters, 4);
  34. LastNameOffset = LittleEndianConverter.ToUInt16(parameters, 6);
  35. FindInformationListBytes = data;
  36. }
  37. public override byte[] GetParameters(bool isUnicode)
  38. {
  39. byte[] parameters = new byte[ParametersLength];
  40. LittleEndianWriter.WriteUInt16(parameters, 0, SearchCount);
  41. LittleEndianWriter.WriteUInt16(parameters, 2, Convert.ToUInt16(EndOfSearch));
  42. LittleEndianWriter.WriteUInt16(parameters, 4, EaErrorOffset);
  43. LittleEndianWriter.WriteUInt16(parameters, 6, LastNameOffset);
  44. return parameters;
  45. }
  46. public override byte[] GetData(bool isUnicode)
  47. {
  48. return FindInformationListBytes;
  49. }
  50. public FindInformationList GetFindInformationList(FindInformationLevel findInformationLevel, bool isUnicode, bool returnResumeKeys)
  51. {
  52. return new FindInformationList(FindInformationListBytes, findInformationLevel, isUnicode, returnResumeKeys);
  53. }
  54. public void SetFindInformationList(FindInformationList findInformationList, bool isUnicode)
  55. {
  56. SearchCount = (ushort)findInformationList.Count;
  57. FindInformationListBytes = findInformationList.GetBytes(isUnicode);
  58. }
  59. public override Transaction2SubcommandName SubcommandName
  60. {
  61. get
  62. {
  63. return Transaction2SubcommandName.TRANS2_FIND_NEXT2;
  64. }
  65. }
  66. }
  67. }