Transaction2CreateDirectoryRequest.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_CREATE_DIRECTORY Request
  15. /// </summary>
  16. public class Transaction2CreateDirectoryRequest : Transaction2Subcommand
  17. {
  18. // Parameters
  19. public uint Reserved;
  20. public string DirectoryName; // SMB_STRING
  21. // Data
  22. public FullExtendedAttributeList ExtendedAttributeList;
  23. public Transaction2CreateDirectoryRequest() : base()
  24. {}
  25. public Transaction2CreateDirectoryRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
  26. {
  27. Reserved = LittleEndianConverter.ToUInt32(parameters, 0);
  28. DirectoryName = SMB1Helper.ReadSMBString(parameters, 4, isUnicode);
  29. ExtendedAttributeList = new FullExtendedAttributeList(data);
  30. }
  31. public override byte[] GetSetup()
  32. {
  33. return LittleEndianConverter.GetBytes((ushort)SubcommandName);
  34. }
  35. public override byte[] GetParameters(bool isUnicode)
  36. {
  37. int length = 4;
  38. length += isUnicode ? DirectoryName.Length * 2 + 2 : DirectoryName.Length + 1 + 1;
  39. byte[] parameters = new byte[length];
  40. LittleEndianWriter.WriteUInt32(parameters, 0, Reserved);
  41. SMB1Helper.WriteSMBString(parameters, 4, isUnicode, DirectoryName);
  42. return parameters;
  43. }
  44. public override byte[] GetData(bool isUnicode)
  45. {
  46. return ExtendedAttributeList.GetBytes();
  47. }
  48. public override Transaction2SubcommandName SubcommandName
  49. {
  50. get
  51. {
  52. return Transaction2SubcommandName.TRANS2_CREATE_DIRECTORY;
  53. }
  54. }
  55. }
  56. }