/// <summary> /// Create the binary from the buffer /// </summary> /// <param name="binary">The binary</param> /// <param name="offset">The offset in the binary</param> public override void GetBinaryForm(byte[] binary, int offset) { int len = Size; binary[offset++] = (byte)this.AceType; binary[offset++] = (byte)this.AceFlags; DtypUtility.WriteUInt16ToByteArray((ushort)len, binary, offset); offset += 2; DtypUtility.WriteInt32ToByteArray(_AccessMask, binary, offset); offset += 4; DtypUtility.WriteInt32ToByteArray((int)ObjectFlags, binary, offset); offset += 4; if (ObjectFlags.HasFlag(_ObjectAceFlags.ObjectAceTypePresent)) { DtypUtility.WriteGuid(ObjectType, binary, offset); offset += 16; } if (ObjectFlags.HasFlag(_ObjectAceFlags.InheritedObjectAceTypePresent)) { DtypUtility.WriteGuid(InheritedObjectType, binary, offset); offset += 16; } _SecurityIdentifier.GetBinaryForm(binary, offset); offset += _SecurityIdentifier.Size; if (this.applicationData != null) { Array.Copy(this.applicationData, 0, binary, offset, this.applicationData.Length); offset += this.applicationData.Length; } }
/// <summary> /// Create the binary from the buffer /// </summary> /// <param name="binary">The binary</param> /// <param name="offset">The offset in the binaryForm</param> public void GetBinaryForm(byte[] binary, int offset) { if (binary == null) { throw new ArgumentNullException(nameof(binary)); } if (offset < 0 || offset > binary.Length - Size) { throw new ArgumentException(nameof(offset)); } binary[offset] = Revision; binary[offset + 1] = 0; DtypUtility.WriteUInt16ToByteArray((ushort)Size, binary, offset + 2); DtypUtility.WriteUInt16ToByteArray((ushort)list.Count, binary, offset + 4); DtypUtility.WriteUInt16ToByteArray((ushort)0, binary, offset + 6); int pointer = offset + DtypUtility.ACL_HEADER_LENGTH; foreach (var ace in list) { ace.GetBinaryForm(binary, pointer); pointer += ace.Size; } }
/// <summary> /// Create the binary from the buffer /// </summary> /// <param name="binary">The binary</param> /// <param name="offset">The offset in the binaryForm</param> public override void GetBinaryForm(byte[] binary, int offset) { int len = Size; binary[offset] = (byte)this.AceType; binary[offset + 1] = (byte)this.AceFlags; DtypUtility.WriteUInt16ToByteArray((ushort)len, binary, offset + 2); DtypUtility.WriteInt32ToByteArray(_AccessMask, binary, offset + DtypUtility.ACE_HEADER_LENGTH); _SecurityIdentifier.GetBinaryForm(binary, offset + DtypUtility.SHORT_FIXED_ACE_LENGTH); if (this.applicationData != null) { Array.Copy(this.applicationData, 0, binary, offset + DtypUtility.SHORT_FIXED_ACE_LENGTH + _SecurityIdentifier.Size, this.applicationData.Length); } }
/// <summary> /// Create the binary from the buffer /// </summary> /// <param name="binary">The input binary</param> /// <param name="offset">The offset in the binary</param> public void GetBinaryForm(byte[] binary, int offset) { if (binary == null) { throw new ArgumentNullException(nameof(binary)); } int binaryLength = Size; if (offset < 0 || offset > binary.Length - binaryLength) { throw new ArgumentOutOfRangeException(nameof(offset)); } SECURITY_DESCRIPTOR_Control controlFlags = this.controlFlags; binary[offset] = 1; //revision binary[offset + 1] = 0; //Sbz1 DtypUtility.WriteUInt16ToByteArray((ushort)controlFlags, binary, offset + 2); int pointer = DtypUtility.SECURITY_DESCRIPTOR_FIXED_LENGTH; if (Owner != null) { DtypUtility.WriteInt32ToByteArray(pointer, binary, offset + 4); Owner.Value.GetBinaryForm(binary, offset + pointer); pointer += Owner.Value.Size; } else { DtypUtility.WriteInt32ToByteArray(0, binary, offset + 4); } if (Group != null) { DtypUtility.WriteInt32ToByteArray(pointer, binary, offset + 8); Group.Value.GetBinaryForm(binary, offset + pointer); pointer += Group.Value.Size; } else { DtypUtility.WriteInt32ToByteArray(0, binary, offset + 8); } _RawAcl sacl = this.SACL; if (this.controlFlags.HasFlag(SECURITY_DESCRIPTOR_Control.SACLPresent)) { DtypUtility.WriteInt32ToByteArray(pointer, binary, offset + 12); sacl.GetBinaryForm(binary, offset + pointer); pointer += this.SACL.Size; } else { DtypUtility.WriteInt32ToByteArray(0, binary, offset + 12); } _RawAcl dacl = this.DACL; if (this.controlFlags.HasFlag(SECURITY_DESCRIPTOR_Control.DACLPresent)) { DtypUtility.WriteInt32ToByteArray(pointer, binary, offset + 16); dacl.GetBinaryForm(binary, offset + pointer); pointer += this.DACL.Size; } else { DtypUtility.WriteInt32ToByteArray(0, binary, offset + 16); } }