NTTransactQuerySecurityDescriptorResponse.cs 2.0 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_QUERY_SECURITY_DESC Response
  15. /// </summary>
  16. public class NTTransactQuerySecurityDescriptorResponse : NTTransactSubcommand
  17. {
  18. public const int ParametersLength = 4;
  19. // Parameters:
  20. public uint LengthNeeded;
  21. // Data
  22. public SecurityDescriptor SecurityDescriptor; // We might return STATUS_BUFFER_TOO_SMALL without the SecurityDescriptor field
  23. public NTTransactQuerySecurityDescriptorResponse()
  24. {
  25. }
  26. public NTTransactQuerySecurityDescriptorResponse(byte[] parameters, byte[] data)
  27. {
  28. LengthNeeded = LittleEndianConverter.ToUInt32(parameters, 0);
  29. if (data.Length == LengthNeeded)
  30. {
  31. SecurityDescriptor = new SecurityDescriptor(data, 0);
  32. }
  33. }
  34. public override byte[] GetParameters(bool isUnicode)
  35. {
  36. byte[] parameters = new byte[ParametersLength];
  37. LittleEndianWriter.WriteUInt32(parameters, 0, LengthNeeded);
  38. return parameters;
  39. }
  40. public override byte[] GetData()
  41. {
  42. if (SecurityDescriptor != null)
  43. {
  44. return SecurityDescriptor.GetBytes();
  45. }
  46. else
  47. {
  48. return new byte[0];
  49. }
  50. }
  51. public override NTTransactSubcommandName SubcommandName
  52. {
  53. get
  54. {
  55. return NTTransactSubcommandName.NT_TRANSACT_QUERY_SECURITY_DESC;
  56. }
  57. }
  58. }
  59. }