Transaction2QueryFSInformationRequest.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Utilities;
  10. namespace SMBLibrary.SMB1
  11. {
  12. /// <summary>
  13. /// TRANS2_QUERY_FS_INFORMATION Request
  14. /// </summary>
  15. public class Transaction2QueryFSInformationRequest : Transaction2Subcommand
  16. {
  17. private const ushort SMB_INFO_PASSTHROUGH = 0x03E8;
  18. public const int ParametersLength = 2;
  19. // Parameters:
  20. public ushort InformationLevel;
  21. public Transaction2QueryFSInformationRequest() : base()
  22. {
  23. }
  24. public Transaction2QueryFSInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
  25. {
  26. InformationLevel = LittleEndianConverter.ToUInt16(parameters, 0);
  27. }
  28. public override byte[] GetSetup()
  29. {
  30. return LittleEndianConverter.GetBytes((ushort)SubcommandName);
  31. }
  32. public override byte[] GetParameters(bool isUnicode)
  33. {
  34. byte[] parameters = new byte[ParametersLength];
  35. LittleEndianWriter.WriteUInt16(parameters, 0, InformationLevel);
  36. return parameters;
  37. }
  38. public bool IsPassthroughInformationLevel
  39. {
  40. get
  41. {
  42. return (InformationLevel >= SMB_INFO_PASSTHROUGH);
  43. }
  44. }
  45. public QueryFSInformationLevel QueryFSInformationLevel
  46. {
  47. get
  48. {
  49. return (QueryFSInformationLevel)InformationLevel;
  50. }
  51. set
  52. {
  53. InformationLevel = (ushort)value;
  54. }
  55. }
  56. public FileSystemInformationClass FileSystemInformationClass
  57. {
  58. get
  59. {
  60. return (FileSystemInformationClass)(InformationLevel - SMB_INFO_PASSTHROUGH);
  61. }
  62. set
  63. {
  64. InformationLevel = (ushort)((ushort)value + SMB_INFO_PASSTHROUGH);
  65. }
  66. }
  67. public override Transaction2SubcommandName SubcommandName
  68. {
  69. get
  70. {
  71. return Transaction2SubcommandName.TRANS2_QUERY_FS_INFORMATION;
  72. }
  73. }
  74. }
  75. }