NTTransactNotifyChangeRequest.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. /// NT_TRANSACT_NOTIFY_CHANGE Request
  15. /// </summary>
  16. public class NTTransactNotifyChangeRequest : NTTransactSubcommand
  17. {
  18. public const int SetupLength = 8;
  19. // Setup:
  20. public NotifyChangeFilter CompletionFilter;
  21. public ushort FID;
  22. public bool WatchTree;
  23. public byte Reserved;
  24. public NTTransactNotifyChangeRequest() : base()
  25. {
  26. }
  27. public NTTransactNotifyChangeRequest(byte[] setup) : base()
  28. {
  29. CompletionFilter = (NotifyChangeFilter)LittleEndianConverter.ToUInt32(setup, 0);
  30. FID = LittleEndianConverter.ToUInt16(setup, 4);
  31. WatchTree = (ByteReader.ReadByte(setup, 6) != 0);
  32. Reserved = ByteReader.ReadByte(setup, 7);
  33. }
  34. public override byte[] GetSetup()
  35. {
  36. byte[] setup = new byte[SetupLength];
  37. LittleEndianWriter.WriteUInt32(setup, 0, (uint)CompletionFilter);
  38. LittleEndianWriter.WriteUInt32(setup, 4, FID);
  39. ByteWriter.WriteByte(setup, 6, Convert.ToByte(WatchTree));
  40. ByteWriter.WriteByte(setup, 7, Reserved);
  41. return setup;
  42. }
  43. public override NTTransactSubcommandName SubcommandName
  44. {
  45. get
  46. {
  47. return NTTransactSubcommandName.NT_TRANSACT_NOTIFY_CHANGE;
  48. }
  49. }
  50. }
  51. }