Beispiel #1
0
 /// <summary>Gets the InheritedObjectType for an ACE, if defined.</summary>
 /// <param name="pAce">A pointer to an ACE.</param>
 /// <returns>The InheritedObjectType value, if this is an object ACE, otherwise <see langword="null"/>.</returns>
 /// <exception cref="ArgumentNullException">pAce</exception>
 public static Guid?GetInheritedObjectType(this PACE pAce)
 {
     if (pAce.IsNull)
     {
         throw new ArgumentNullException(nameof(pAce));
     }
     return(!pAce.IsObjectAce() ? null : pAce.DangerousGetHandle().ToStructure <ACCESS_ALLOWED_OBJECT_ACE>().InheritedObjectType);
 }
Beispiel #2
0
 /// <summary>Gets the Flags for an ACE, if defined.</summary>
 /// <param name="pAce">A pointer to an ACE.</param>
 /// <returns>The Flags value, if this is an object ACE, otherwise <see langword="null"/>.</returns>
 /// <exception cref="ArgumentNullException">pAce</exception>
 public static AdvApi32.ObjectAceFlags?GetFlags(this PACE pAce)
 {
     if (pAce.IsNull)
     {
         throw new ArgumentNullException(nameof(pAce));
     }
     return(!pAce.IsObjectAce() ? null : pAce.DangerousGetHandle().ToStructure <ACCESS_ALLOWED_OBJECT_ACE>().Flags);
 }
Beispiel #3
0
        /// <summary>Determines if a ACE is an object ACE.</summary>
        /// <param name="pAce">A pointer to an ACE.</param>
        /// <returns><see langword="true"/> if is this is an object ACE; otherwise, <see langword="false"/>.</returns>
        /// <exception cref="ArgumentNullException">pAce</exception>
        /// <exception cref="ArgumentOutOfRangeException">pAce - Unknown ACE type.</exception>
        public static bool IsObjectAce(this PACE pAce)
        {
            if (pAce.IsNull)
            {
                throw new ArgumentNullException(nameof(pAce));
            }
            var aceType = (byte)GetHeader(pAce).AceType;

            if (aceType > 0x15)
            {
                throw new ArgumentOutOfRangeException(nameof(pAce), "Unknown ACE type.");
            }
            return((aceType >= 0x5 && aceType <= 0x8) || aceType == 0xB || aceType == 0xC || aceType == 0xF || aceType == 0x10);
        }
Beispiel #4
0
        /// <summary>Gets the SID for an ACE.</summary>
        /// <param name="pAce">A pointer to an ACE.</param>
        /// <returns>The SID value.</returns>
        /// <exception cref="ArgumentNullException">pAce</exception>
        public static SafePSID GetSid(this PACE pAce)
        {
            if (pAce.IsNull)
            {
                throw new ArgumentNullException(nameof(pAce));
            }
            var offset = Marshal.SizeOf(typeof(ACE_HEADER)) + sizeof(uint);

            if (pAce.IsObjectAce())
            {
                offset += sizeof(uint) + Marshal.SizeOf(typeof(Guid)) * 2;
            }
            return(SafePSID.CreateFromPtr(pAce.DangerousGetHandle().Offset(offset)));
        }
Beispiel #5
0
 /// <summary>Gets the header for an ACE.</summary>
 /// <param name="pAce">A pointer to an ACE.</param>
 /// <returns>The <see cref="ACE_HEADER"/> value.</returns>
 /// <exception cref="ArgumentNullException">pAce</exception>
 public static ACE_HEADER GetHeader(this PACE pAce) => !pAce.IsNull ? pAce.DangerousGetHandle().ToStructure <ACE_HEADER>() : throw new ArgumentNullException(nameof(pAce));
Beispiel #6
0
 /// <summary>Gets the size, in bytes, of an ACE.</summary>
 /// <param name="pAce">The pointer to the ACE structure to query.</param>
 /// <returns>The size, in bytes, of the ACE.</returns>
 public static uint Length(this PACE pAce) => GetHeader(pAce).AceSize;
Beispiel #7
0
 /// <summary>Gets the AceType for an ACE, if defined.</summary>
 /// <param name="pAce">A pointer to an ACE.</param>
 /// <returns>The AceType value.</returns>
 public static AceType GetAceType(this PACE pAce) => GetHeader(pAce).AceType;
Beispiel #8
0
 /// <summary>Gets the mask for an ACE.</summary>
 /// <param name="pAce">A pointer to an ACE.</param>
 /// <returns>The ACCESS_MASK value.</returns>
 /// <exception cref="ArgumentNullException">pAce</exception>
 public static uint GetMask(this PACE pAce) => !pAce.IsNull ? pAce.DangerousGetHandle().ToStructure <ACCESS_ALLOWED_ACE>().Mask : throw new ArgumentNullException(nameof(pAce));