NTTransactIOCTLRequest.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_IOCTL Request
  15. /// </summary>
  16. public class NTTransactIOCTLRequest : NTTransactSubcommand
  17. {
  18. public const int SetupLength = 8;
  19. // Setup:
  20. public uint FunctionCode;
  21. public ushort FID;
  22. public bool IsFsctl;
  23. public bool IsFlags;
  24. // Data:
  25. public byte[] Data;
  26. public NTTransactIOCTLRequest() : base()
  27. {
  28. Data = new byte[0];
  29. }
  30. public NTTransactIOCTLRequest(byte[] setup, byte[] data) : base()
  31. {
  32. FunctionCode = LittleEndianConverter.ToUInt32(setup, 0);
  33. FID = LittleEndianConverter.ToUInt16(setup, 4);
  34. IsFsctl = (ByteReader.ReadByte(setup, 6) != 0);
  35. IsFlags = (ByteReader.ReadByte(setup, 7) != 0);
  36. Data = data;
  37. }
  38. public override byte[] GetSetup()
  39. {
  40. byte[] setup = new byte[SetupLength];
  41. LittleEndianWriter.WriteUInt32(setup, 0, FunctionCode);
  42. LittleEndianWriter.WriteUInt32(setup, 4, FID);
  43. ByteWriter.WriteByte(setup, 6, Convert.ToByte(IsFsctl));
  44. ByteWriter.WriteByte(setup, 7, Convert.ToByte(IsFlags));
  45. return setup;
  46. }
  47. public override byte[] GetData()
  48. {
  49. return Data;
  50. }
  51. public override NTTransactSubcommandName SubcommandName
  52. {
  53. get
  54. {
  55. return NTTransactSubcommandName.NT_TRANSACT_IOCTL;
  56. }
  57. }
  58. }
  59. }