NTTransactSetSecurityDescriptorRequest.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /// NT_TRANSACT_SET_SECURITY_DESC Request
  14. /// </summary>
  15. public class NTTransactSetSecurityDescriptorRequest : NTTransactSubcommand
  16. {
  17. public const int ParametersLength = 8;
  18. // Parameters:
  19. public ushort FID;
  20. public ushort Reserved;
  21. public SecurityInformation SecurityInformation;
  22. // Data:
  23. public SecurityDescriptor SecurityDescriptor;
  24. public NTTransactSetSecurityDescriptorRequest()
  25. {
  26. }
  27. public NTTransactSetSecurityDescriptorRequest(byte[] parameters, byte[] data)
  28. {
  29. FID = LittleEndianConverter.ToUInt16(parameters, 0);
  30. Reserved = LittleEndianConverter.ToUInt16(parameters, 2);
  31. SecurityInformation = (SecurityInformation)LittleEndianConverter.ToUInt32(parameters, 4);
  32. SecurityDescriptor = new SecurityDescriptor(data, 0);
  33. }
  34. public override byte[] GetParameters(bool isUnicode)
  35. {
  36. byte[] parameters = new byte[ParametersLength];
  37. LittleEndianWriter.WriteUInt16(parameters, 0, FID);
  38. LittleEndianWriter.WriteUInt16(parameters, 2, Reserved);
  39. LittleEndianWriter.WriteUInt32(parameters, 4, (uint)SecurityInformation);
  40. return parameters;
  41. }
  42. public override byte[] GetData()
  43. {
  44. return SecurityDescriptor.GetBytes();
  45. }
  46. public override NTTransactSubcommandName SubcommandName
  47. {
  48. get
  49. {
  50. return NTTransactSubcommandName.NT_TRANSACT_SET_SECURITY_DESC;
  51. }
  52. }
  53. }
  54. }