AccessAllowedACE.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  11. {
  12. /// <summary>
  13. /// [MS-DTYP] ACCESS_ALLOWED_ACE
  14. /// </summary>
  15. public class AccessAllowedACE : ACE
  16. {
  17. public const int FixedLength = 8;
  18. public AceHeader Header;
  19. public AccessMask Mask;
  20. public SID Sid;
  21. public AccessAllowedACE()
  22. {
  23. Header = new AceHeader();
  24. Header.AceType = AceType.ACCESS_ALLOWED_ACE_TYPE;
  25. }
  26. public AccessAllowedACE(byte[] buffer, int offset)
  27. {
  28. Header = new AceHeader(buffer, offset + 0);
  29. Mask = (AccessMask)LittleEndianConverter.ToUInt32(buffer, offset + 4);
  30. Sid = new SID(buffer, offset + 8);
  31. }
  32. public override void WriteBytes(byte[] buffer, ref int offset)
  33. {
  34. Header.AceSize = (ushort)this.Length;
  35. Header.WriteBytes(buffer, ref offset);
  36. LittleEndianWriter.WriteUInt32(buffer, ref offset, (uint)Mask);
  37. Sid.WriteBytes(buffer, ref offset);
  38. }
  39. public override int Length
  40. {
  41. get
  42. {
  43. return FixedLength + Sid.Length;
  44. }
  45. }
  46. }
  47. }