Esempio n. 1
0
        /// <summary>
        /// The constructor
        /// </summary>
        /// <param name="binary">The input binary</param>
        /// <param name="offset">The offset in the binary</param>
        public _NonObjectAce(byte[] binary, int offset) : base(binary, offset)
        {
            int length = BitConverter.ToUInt16(binary, offset + 2);

            if (offset > binary.Length - length)
            {
                throw new ArgumentException(nameof(offset));
            }

            if (length < 8 + DtypUtility.MinLengthOfSecurityIdentifier)
            {
                throw new ArgumentException(nameof(length));
            }

            _AccessMask         = BitConverter.ToInt32(binary, offset + 4);
            _SecurityIdentifier = new _SecurityIdentifier(binary, offset + 8);

            int dataLength = length - (8 + _SecurityIdentifier.Size);

            if (dataLength > 0)// If there is still other application data exists
            {
                this.applicationData = new byte[dataLength];
                Array.Copy(binary, offset + 8 + _SecurityIdentifier.Size, this.applicationData, 0, dataLength);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// the constructor
 /// </summary>
 /// <param name="flags">the security descriptor control flag</param>
 /// <param name="owner">the owner sid</param>
 /// <param name="group">the group sid</param>
 /// <param name="sacl">the sacl</param>
 /// <param name="dacl">the dacl</param>
 public _RawSecurityDescriptor(SECURITY_DESCRIPTOR_Control flags,
                               _SecurityIdentifier owner,
                               _SecurityIdentifier group,
                               _RawAcl sacl,
                               _RawAcl dacl)
 {
     controlFlags = flags;
     ownerSid     = owner;
     groupSid     = group;
     this.sacl    = sacl;
     this.dacl    = dacl;
 }
Esempio n. 3
0
        /// <summary>
        /// the constructor
        /// </summary>
        /// <param name="binary">the input binary</param>
        /// <param name="offset">the offset in the binary</param>
        public _RawSecurityDescriptor(byte[] binary, int offset)
        {
            if (binary == null)
            {
                throw new ArgumentNullException(nameof(binary));
            }

            if (offset < 0 || offset > binary.Length - 0x14)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }

            controlFlags = (SECURITY_DESCRIPTOR_Control)BitConverter.ToUInt16(binary, offset + 0x02);

            //Get owner sid
            int ownerStart = BitConverter.ToInt32(binary, offset + 0x04);

            if (ownerStart != 0)
            {
                ownerSid = new _SecurityIdentifier(binary, ownerStart);
            }

            //Get group sid
            int groupStart = BitConverter.ToInt32(binary, offset + 0x08);

            if (groupStart != 0)
            {
                groupSid = new _SecurityIdentifier(binary, groupStart);
            }

            //Get sacl
            int saclStart = BitConverter.ToInt32(binary, offset + 0x0C);

            if (saclStart != 0)
            {
                sacl = new _RawAcl(binary, saclStart);
            }

            //Get dacl
            int daclStart = BitConverter.ToInt32(binary, offset + 0x10);

            if (daclStart != 0)
            {
                dacl = new _RawAcl(binary, daclStart);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// The constructor
        /// </summary>
        /// <param name="binary">The input binary</param>
        /// <param name="offset">The offset in the binary</param>
        public _ObjectAce(byte[] binary, int offset) : base(binary, offset)
        {
            int length = BitConverter.ToUInt16(binary, offset + 2);

            if (offset > binary.Length - length)
            {
                throw new ArgumentException(nameof(offset));
            }

            _AccessMask = BitConverter.ToInt32(binary, offset + 4);
            ObjectFlags = (_ObjectAceFlags)BitConverter.ToInt32(binary, offset + 8);

            int pointer = 12;

            if (ObjectFlags.HasFlag(_ObjectAceFlags.ObjectAceTypePresent))
            {
                ObjectType = DtypUtility.ReadGuid(binary, offset + pointer);
                pointer   += 16;
            }
            if (ObjectFlags.HasFlag(_ObjectAceFlags.InheritedObjectAceTypePresent))
            {
                InheritedObjectType = DtypUtility.ReadGuid(binary, offset + pointer);
                pointer            += 16;
            }

            _SecurityIdentifier = new _SecurityIdentifier(binary, offset + pointer);
            pointer            += _SecurityIdentifier.Size;

            int appDataLength = length - pointer;

            if (appDataLength > 0)
            {
                this.applicationData = new byte[appDataLength];
                Array.Copy(binary, offset + pointer, this.applicationData, 0, appDataLength);
            }
        }