NTTransactSetSecurityDescriptor.cs 2.0 KB

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