Transaction2SetFileInformationRequest.cs 2.3 KB

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