Beispiel #1
0
 internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out int accessMask, out CompoundAceType compoundAceType, out SecurityIdentifier sid)
 {
     GenericAce.VerifyHeader(binaryForm, offset);
     if (binaryForm.Length - offset >= 12 + SecurityIdentifier.MinBinaryLength)
     {
         int num1 = offset + 4;
         int num2 = 0;
         accessMask = (int)binaryForm[num1 + 0] + ((int)binaryForm[num1 + 1] << 8) + ((int)binaryForm[num1 + 2] << 16) + ((int)binaryForm[num1 + 3] << 24);
         int num3 = num2 + 4;
         compoundAceType = (CompoundAceType)((int)binaryForm[num1 + num3 + 0] + ((int)binaryForm[num1 + num3 + 1] << 8));
         int num4 = num3 + 4;
         sid = new SecurityIdentifier(binaryForm, num1 + num4);
         return(true);
     }
     accessMask      = 0;
     compoundAceType = (CompoundAceType)0;
     sid             = (SecurityIdentifier)null;
     return(false);
 }
Beispiel #2
0
 internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out int accessMask, out System.Security.AccessControl.CompoundAceType compoundAceType, out SecurityIdentifier sid)
 {
     GenericAce.VerifyHeader(binaryForm, offset);
     if ((binaryForm.Length - offset) >= (12 + SecurityIdentifier.MinBinaryLength))
     {
         int index = offset + 4;
         int num2  = 0;
         accessMask      = ((binaryForm[index] + (binaryForm[index + 1] << 8)) + (binaryForm[index + 2] << 0x10)) + (binaryForm[index + 3] << 0x18);
         num2           += 4;
         compoundAceType = (System.Security.AccessControl.CompoundAceType)(binaryForm[index + num2] + (binaryForm[(index + num2) + 1] << 8));
         num2           += 4;
         sid             = new SecurityIdentifier(binaryForm, index + num2);
         return(true);
     }
     accessMask      = 0;
     compoundAceType = (System.Security.AccessControl.CompoundAceType) 0;
     sid             = null;
     return(false);
 }
        /// <summary>Creates a <see cref="T:System.Security.AccessControl.GenericAce" /> object from the specified binary data.</summary>
        /// <param name="binaryForm">The binary data from which to create the new <see cref="T:System.Security.AccessControl.GenericAce" /> object.</param>
        /// <param name="offset">The offset at which to begin unmarshaling.</param>
        /// <returns>The <see cref="T:System.Security.AccessControl.GenericAce" /> object this method creates.</returns>
        // Token: 0x06001E46 RID: 7750 RVA: 0x00069C80 File Offset: 0x00067E80
        public static GenericAce CreateFromBinaryForm(byte[] binaryForm, int offset)
        {
            GenericAce.VerifyHeader(binaryForm, offset);
            AceType    aceType = (AceType)binaryForm[offset];
            GenericAce genericAce;

            if (aceType == AceType.AccessAllowed || aceType == AceType.AccessDenied || aceType == AceType.SystemAudit || aceType == AceType.SystemAlarm || aceType == AceType.AccessAllowedCallback || aceType == AceType.AccessDeniedCallback || aceType == AceType.SystemAuditCallback || aceType == AceType.SystemAlarmCallback)
            {
                AceQualifier       qualifier;
                int                accessMask;
                SecurityIdentifier sid;
                bool               isCallback;
                byte[]             opaque;
                if (!CommonAce.ParseBinaryForm(binaryForm, offset, out qualifier, out accessMask, out sid, out isCallback, out opaque))
                {
                    goto IL_1A8;
                }
                AceFlags flags = (AceFlags)binaryForm[offset + 1];
                genericAce = new CommonAce(flags, qualifier, accessMask, sid, isCallback, opaque);
            }
            else if (aceType == AceType.AccessAllowedObject || aceType == AceType.AccessDeniedObject || aceType == AceType.SystemAuditObject || aceType == AceType.SystemAlarmObject || aceType == AceType.AccessAllowedCallbackObject || aceType == AceType.AccessDeniedCallbackObject || aceType == AceType.SystemAuditCallbackObject || aceType == AceType.SystemAlarmCallbackObject)
            {
                AceQualifier       qualifier2;
                int                accessMask2;
                SecurityIdentifier sid2;
                ObjectAceFlags     flags2;
                Guid               type;
                Guid               inheritedType;
                bool               isCallback2;
                byte[]             opaque2;
                if (!ObjectAce.ParseBinaryForm(binaryForm, offset, out qualifier2, out accessMask2, out sid2, out flags2, out type, out inheritedType, out isCallback2, out opaque2))
                {
                    goto IL_1A8;
                }
                AceFlags aceFlags = (AceFlags)binaryForm[offset + 1];
                genericAce = new ObjectAce(aceFlags, qualifier2, accessMask2, sid2, flags2, type, inheritedType, isCallback2, opaque2);
            }
            else if (aceType == AceType.AccessAllowedCompound)
            {
                int                accessMask3;
                CompoundAceType    compoundAceType;
                SecurityIdentifier sid3;
                if (!CompoundAce.ParseBinaryForm(binaryForm, offset, out accessMask3, out compoundAceType, out sid3))
                {
                    goto IL_1A8;
                }
                AceFlags flags3 = (AceFlags)binaryForm[offset + 1];
                genericAce = new CompoundAce(flags3, accessMask3, compoundAceType, sid3);
            }
            else
            {
                AceFlags flags4 = (AceFlags)binaryForm[offset + 1];
                byte[]   array  = null;
                int      num    = (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8);
                if (num % 4 != 0)
                {
                    goto IL_1A8;
                }
                int num2 = num - 4;
                if (num2 > 0)
                {
                    array = new byte[num2];
                    for (int i = 0; i < num2; i++)
                    {
                        array[i] = binaryForm[offset + num - num2 + i];
                    }
                }
                genericAce = new CustomAce(aceType, flags4, array);
            }
            if ((genericAce is ObjectAce || (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8) == genericAce.BinaryLength) && (!(genericAce is ObjectAce) || (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8) == genericAce.BinaryLength || (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8) - 32 == genericAce.BinaryLength))
            {
                return(genericAce);
            }
IL_1A8:
            throw new ArgumentException(Environment.GetResourceString("ArgumentException_InvalidAceBinaryForm"), "binaryForm");
        }
Beispiel #4
0
        // Token: 0x06001E7A RID: 7802 RVA: 0x0006A800 File Offset: 0x00068A00
        internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out AceQualifier qualifier, out int accessMask, out SecurityIdentifier sid, out ObjectAceFlags objectFlags, out Guid objectAceType, out Guid inheritedObjectAceType, out bool isCallback, out byte[] opaque)
        {
            byte[] array = new byte[16];
            GenericAce.VerifyHeader(binaryForm, offset);
            if (binaryForm.Length - offset >= 12 + SecurityIdentifier.MinBinaryLength)
            {
                AceType aceType = (AceType)binaryForm[offset];
                if (aceType == AceType.AccessAllowedObject || aceType == AceType.AccessDeniedObject || aceType == AceType.SystemAuditObject || aceType == AceType.SystemAlarmObject)
                {
                    isCallback = false;
                }
                else
                {
                    if (aceType != AceType.AccessAllowedCallbackObject && aceType != AceType.AccessDeniedCallbackObject && aceType != AceType.SystemAuditCallbackObject && aceType != AceType.SystemAlarmCallbackObject)
                    {
                        goto IL_209;
                    }
                    isCallback = true;
                }
                if (aceType == AceType.AccessAllowedObject || aceType == AceType.AccessAllowedCallbackObject)
                {
                    qualifier = AceQualifier.AccessAllowed;
                }
                else if (aceType == AceType.AccessDeniedObject || aceType == AceType.AccessDeniedCallbackObject)
                {
                    qualifier = AceQualifier.AccessDenied;
                }
                else if (aceType == AceType.SystemAuditObject || aceType == AceType.SystemAuditCallbackObject)
                {
                    qualifier = AceQualifier.SystemAudit;
                }
                else
                {
                    if (aceType != AceType.SystemAlarmObject && aceType != AceType.SystemAlarmCallbackObject)
                    {
                        goto IL_209;
                    }
                    qualifier = AceQualifier.SystemAlarm;
                }
                int num  = offset + 4;
                int num2 = 0;
                accessMask  = (int)binaryForm[num] + ((int)binaryForm[num + 1] << 8) + ((int)binaryForm[num + 2] << 16) + ((int)binaryForm[num + 3] << 24);
                num2       += 4;
                objectFlags = (ObjectAceFlags)((int)binaryForm[num + num2] + ((int)binaryForm[num + num2 + 1] << 8) + ((int)binaryForm[num + num2 + 2] << 16) + ((int)binaryForm[num + num2 + 3] << 24));
                num2       += 4;
                if ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) != ObjectAceFlags.None)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        array[i] = binaryForm[num + num2 + i];
                    }
                    num2 += 16;
                }
                else
                {
                    for (int j = 0; j < 16; j++)
                    {
                        array[j] = 0;
                    }
                }
                objectAceType = new Guid(array);
                if ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) != ObjectAceFlags.None)
                {
                    for (int k = 0; k < 16; k++)
                    {
                        array[k] = binaryForm[num + num2 + k];
                    }
                    num2 += 16;
                }
                else
                {
                    for (int l = 0; l < 16; l++)
                    {
                        array[l] = 0;
                    }
                }
                inheritedObjectAceType = new Guid(array);
                sid    = new SecurityIdentifier(binaryForm, num + num2);
                opaque = null;
                int num3 = ((int)binaryForm[offset + 3] << 8) + (int)binaryForm[offset + 2];
                if (num3 % 4 == 0)
                {
                    int num4 = num3 - 4 - 4 - 4 - (int)((byte)sid.BinaryLength);
                    if ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) != ObjectAceFlags.None)
                    {
                        num4 -= 16;
                    }
                    if ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) != ObjectAceFlags.None)
                    {
                        num4 -= 16;
                    }
                    if (num4 > 0)
                    {
                        opaque = new byte[num4];
                        for (int m = 0; m < num4; m++)
                        {
                            opaque[m] = binaryForm[offset + num3 - num4 + m];
                        }
                    }
                    return(true);
                }
            }
IL_209:
            qualifier              = AceQualifier.AccessAllowed;
            accessMask             = 0;
            sid                    = null;
            objectFlags            = ObjectAceFlags.None;
            objectAceType          = Guid.NewGuid();
            inheritedObjectAceType = Guid.NewGuid();
            isCallback             = false;
            opaque                 = null;
            return(false);
        }
Beispiel #5
0
        // Token: 0x06001E71 RID: 7793 RVA: 0x0006A4FC File Offset: 0x000686FC
        internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out AceQualifier qualifier, out int accessMask, out SecurityIdentifier sid, out bool isCallback, out byte[] opaque)
        {
            GenericAce.VerifyHeader(binaryForm, offset);
            if (binaryForm.Length - offset >= 8 + SecurityIdentifier.MinBinaryLength)
            {
                AceType aceType = (AceType)binaryForm[offset];
                if (aceType == AceType.AccessAllowed || aceType == AceType.AccessDenied || aceType == AceType.SystemAudit || aceType == AceType.SystemAlarm)
                {
                    isCallback = false;
                }
                else
                {
                    if (aceType != AceType.AccessAllowedCallback && aceType != AceType.AccessDeniedCallback && aceType != AceType.SystemAuditCallback && aceType != AceType.SystemAlarmCallback)
                    {
                        goto IL_114;
                    }
                    isCallback = true;
                }
                if (aceType == AceType.AccessAllowed || aceType == AceType.AccessAllowedCallback)
                {
                    qualifier = AceQualifier.AccessAllowed;
                }
                else if (aceType == AceType.AccessDenied || aceType == AceType.AccessDeniedCallback)
                {
                    qualifier = AceQualifier.AccessDenied;
                }
                else if (aceType == AceType.SystemAudit || aceType == AceType.SystemAuditCallback)
                {
                    qualifier = AceQualifier.SystemAudit;
                }
                else
                {
                    if (aceType != AceType.SystemAlarm && aceType != AceType.SystemAlarmCallback)
                    {
                        goto IL_114;
                    }
                    qualifier = AceQualifier.SystemAlarm;
                }
                int num  = offset + 4;
                int num2 = 0;
                accessMask = (int)binaryForm[num] + ((int)binaryForm[num + 1] << 8) + ((int)binaryForm[num + 2] << 16) + ((int)binaryForm[num + 3] << 24);
                num2      += 4;
                sid        = new SecurityIdentifier(binaryForm, num + num2);
                opaque     = null;
                int num3 = ((int)binaryForm[offset + 3] << 8) + (int)binaryForm[offset + 2];
                if (num3 % 4 == 0)
                {
                    int num4 = num3 - 4 - 4 - (int)((byte)sid.BinaryLength);
                    if (num4 > 0)
                    {
                        opaque = new byte[num4];
                        for (int i = 0; i < num4; i++)
                        {
                            opaque[i] = binaryForm[offset + num3 - num4 + i];
                        }
                    }
                    return(true);
                }
            }
IL_114:
            qualifier  = AceQualifier.AccessAllowed;
            accessMask = 0;
            sid        = null;
            isCallback = false;
            opaque     = null;
            return(false);
        }
Beispiel #6
0
        internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out AceQualifier qualifier, out int accessMask, out SecurityIdentifier sid, out System.Security.AccessControl.ObjectAceFlags objectFlags, out Guid objectAceType, out Guid inheritedObjectAceType, out bool isCallback, out byte[] opaque)
        {
            int num;

            byte[] b = new byte[0x10];
            GenericAce.VerifyHeader(binaryForm, offset);
            if ((binaryForm.Length - offset) < (12 + SecurityIdentifier.MinBinaryLength))
            {
                goto Label_0209;
            }
            AceType type = (AceType)binaryForm[offset];

            switch (type)
            {
            case AceType.AccessAllowedObject:
            case AceType.AccessDeniedObject:
            case AceType.SystemAuditObject:
            case AceType.SystemAlarmObject:
                isCallback = false;
                break;

            default:
                if (((type != AceType.AccessAllowedCallbackObject) && (type != AceType.AccessDeniedCallbackObject)) && ((type != AceType.SystemAuditCallbackObject) && (type != AceType.SystemAlarmCallbackObject)))
                {
                    goto Label_0209;
                }
                isCallback = true;
                break;
            }
            switch (type)
            {
            case AceType.AccessAllowedObject:
            case AceType.AccessAllowedCallbackObject:
                qualifier = AceQualifier.AccessAllowed;
                break;

            default:
                switch (type)
                {
                case AceType.AccessDeniedObject:
                case AceType.AccessDeniedCallbackObject:
                    qualifier = AceQualifier.AccessDenied;
                    goto Label_008F;

                case AceType.SystemAuditObject:
                case AceType.SystemAuditCallbackObject:
                    qualifier = AceQualifier.SystemAudit;
                    goto Label_008F;
                }
                if ((type != AceType.SystemAlarmObject) && (type != AceType.SystemAlarmCallbackObject))
                {
                    goto Label_0209;
                }
                qualifier = AceQualifier.SystemAlarm;
                break;
            }
Label_008F:
            num = offset + 4;
            int num2 = 0;

            accessMask  = ((binaryForm[num] + (binaryForm[num + 1] << 8)) + (binaryForm[num + 2] << 0x10)) + (binaryForm[num + 3] << 0x18);
            num2       += 4;
            objectFlags = (System.Security.AccessControl.ObjectAceFlags)(((binaryForm[num + num2] + (binaryForm[(num + num2) + 1] << 8)) + (binaryForm[(num + num2) + 2] << 0x10)) + (binaryForm[(num + num2) + 3] << 0x18));
            num2       += 4;
            if ((objectFlags & System.Security.AccessControl.ObjectAceFlags.ObjectAceTypePresent) != System.Security.AccessControl.ObjectAceFlags.None)
            {
                for (int i = 0; i < 0x10; i++)
                {
                    b[i] = binaryForm[(num + num2) + i];
                }
                num2 += 0x10;
            }
            else
            {
                for (int j = 0; j < 0x10; j++)
                {
                    b[j] = 0;
                }
            }
            objectAceType = new Guid(b);
            if ((objectFlags & System.Security.AccessControl.ObjectAceFlags.InheritedObjectAceTypePresent) != System.Security.AccessControl.ObjectAceFlags.None)
            {
                for (int k = 0; k < 0x10; k++)
                {
                    b[k] = binaryForm[(num + num2) + k];
                }
                num2 += 0x10;
            }
            else
            {
                for (int m = 0; m < 0x10; m++)
                {
                    b[m] = 0;
                }
            }
            inheritedObjectAceType = new Guid(b);
            sid    = new SecurityIdentifier(binaryForm, num + num2);
            opaque = null;
            int num7 = (binaryForm[offset + 3] << 8) + binaryForm[offset + 2];

            if ((num7 % 4) == 0)
            {
                int num8 = (((num7 - 4) - 4) - 4) - ((byte)sid.BinaryLength);
                if ((objectFlags & System.Security.AccessControl.ObjectAceFlags.ObjectAceTypePresent) != System.Security.AccessControl.ObjectAceFlags.None)
                {
                    num8 -= 0x10;
                }
                if ((objectFlags & System.Security.AccessControl.ObjectAceFlags.InheritedObjectAceTypePresent) != System.Security.AccessControl.ObjectAceFlags.None)
                {
                    num8 -= 0x10;
                }
                if (num8 > 0)
                {
                    opaque = new byte[num8];
                    for (int n = 0; n < num8; n++)
                    {
                        opaque[n] = binaryForm[((offset + num7) - num8) + n];
                    }
                }
                return(true);
            }
Label_0209:
            qualifier              = AceQualifier.AccessAllowed;
            accessMask             = 0;
            sid                    = null;
            objectFlags            = System.Security.AccessControl.ObjectAceFlags.None;
            objectAceType          = Guid.NewGuid();
            inheritedObjectAceType = Guid.NewGuid();
            isCallback             = false;
            opaque                 = null;
            return(false);
        }
Beispiel #7
0
        internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out AceQualifier qualifier, out int accessMask, out SecurityIdentifier sid, out bool isCallback, out byte[] opaque)
        {
            int num;

            GenericAce.VerifyHeader(binaryForm, offset);
            if ((binaryForm.Length - offset) < (8 + SecurityIdentifier.MinBinaryLength))
            {
                goto Label_0114;
            }
            AceType type = (AceType)binaryForm[offset];

            switch (type)
            {
            case AceType.AccessAllowed:
            case AceType.AccessDenied:
            case AceType.SystemAudit:
            case AceType.SystemAlarm:
                isCallback = false;
                break;

            default:
                if (((type != AceType.AccessAllowedCallback) && (type != AceType.AccessDeniedCallback)) && ((type != AceType.SystemAuditCallback) && (type != AceType.SystemAlarmCallback)))
                {
                    goto Label_0114;
                }
                isCallback = true;
                break;
            }
            switch (type)
            {
            case AceType.AccessAllowed:
            case AceType.AccessAllowedCallback:
                qualifier = AceQualifier.AccessAllowed;
                break;

            default:
                switch (type)
                {
                case AceType.AccessDenied:
                case AceType.AccessDeniedCallback:
                    qualifier = AceQualifier.AccessDenied;
                    goto Label_0084;

                case AceType.SystemAudit:
                case AceType.SystemAuditCallback:
                    qualifier = AceQualifier.SystemAudit;
                    goto Label_0084;
                }
                if ((type != AceType.SystemAlarm) && (type != AceType.SystemAlarmCallback))
                {
                    goto Label_0114;
                }
                qualifier = AceQualifier.SystemAlarm;
                break;
            }
Label_0084:
            num = offset + 4;
            int num2 = 0;

            accessMask = ((binaryForm[num] + (binaryForm[num + 1] << 8)) + (binaryForm[num + 2] << 0x10)) + (binaryForm[num + 3] << 0x18);
            num2      += 4;
            sid        = new SecurityIdentifier(binaryForm, num + num2);
            opaque     = null;
            int num3 = (binaryForm[offset + 3] << 8) + binaryForm[offset + 2];

            if ((num3 % 4) == 0)
            {
                int num4 = ((num3 - 4) - 4) - ((byte)sid.BinaryLength);
                if (num4 > 0)
                {
                    opaque = new byte[num4];
                    for (int i = 0; i < num4; i++)
                    {
                        opaque[i] = binaryForm[((offset + num3) - num4) + i];
                    }
                }
                return(true);
            }
Label_0114:
            qualifier  = AceQualifier.AccessAllowed;
            accessMask = 0;
            sid        = null;
            isCallback = false;
            opaque     = null;
            return(false);
        }
Beispiel #8
0
        internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out AceQualifier qualifier, out int accessMask, out SecurityIdentifier sid, out bool isCallback, out byte[] opaque)
        {
            GenericAce.VerifyHeader(binaryForm, offset);
            if (binaryForm.Length - offset >= 8 + SecurityIdentifier.MinBinaryLength)
            {
                AceType aceType = (AceType)binaryForm[offset];
                switch (aceType)
                {
                case AceType.AccessAllowed:
                case AceType.AccessDenied:
                case AceType.SystemAudit:
                case AceType.SystemAlarm:
                    isCallback = false;
                    break;

                case AceType.AccessAllowedCallback:
                case AceType.AccessDeniedCallback:
                case AceType.SystemAuditCallback:
                case AceType.SystemAlarmCallback:
                    isCallback = true;
                    break;

                default:
                    goto label_18;
                }
                if (aceType == AceType.AccessAllowed || aceType == AceType.AccessAllowedCallback)
                {
                    qualifier = AceQualifier.AccessAllowed;
                }
                else if (aceType == AceType.AccessDenied || aceType == AceType.AccessDeniedCallback)
                {
                    qualifier = AceQualifier.AccessDenied;
                }
                else if (aceType == AceType.SystemAudit || aceType == AceType.SystemAuditCallback)
                {
                    qualifier = AceQualifier.SystemAudit;
                }
                else if (aceType == AceType.SystemAlarm || aceType == AceType.SystemAlarmCallback)
                {
                    qualifier = AceQualifier.SystemAlarm;
                }
                else
                {
                    goto label_18;
                }
                int num1 = offset + 4;
                int num2 = 0;
                accessMask = (int)binaryForm[num1 + 0] + ((int)binaryForm[num1 + 1] << 8) + ((int)binaryForm[num1 + 2] << 16) + ((int)binaryForm[num1 + 3] << 24);
                int num3 = num2 + 4;
                sid    = new SecurityIdentifier(binaryForm, num1 + num3);
                opaque = (byte[])null;
                int num4 = ((int)binaryForm[offset + 3] << 8) + (int)binaryForm[offset + 2];
                if (num4 % 4 == 0)
                {
                    int length = num4 - 4 - 4 - (int)(byte)sid.BinaryLength;
                    if (length > 0)
                    {
                        opaque = new byte[length];
                        for (int index = 0; index < length; ++index)
                        {
                            opaque[index] = binaryForm[offset + num4 - length + index];
                        }
                    }
                    return(true);
                }
            }
label_18:
            qualifier  = AceQualifier.AccessAllowed;
            accessMask = 0;
            sid        = (SecurityIdentifier)null;
            isCallback = false;
            opaque     = (byte[])null;
            return(false);
        }
Beispiel #9
0
        internal static bool ParseBinaryForm(byte[] binaryForm, int offset, out AceQualifier qualifier, out int accessMask, out SecurityIdentifier sid, out ObjectAceFlags objectFlags, out Guid objectAceType, out Guid inheritedObjectAceType, out bool isCallback, out byte[] opaque)
        {
            byte[] b = new byte[16];
            GenericAce.VerifyHeader(binaryForm, offset);
            if (binaryForm.Length - offset >= 12 + SecurityIdentifier.MinBinaryLength)
            {
                AceType aceType = (AceType)binaryForm[offset];
                switch (aceType)
                {
                case AceType.AccessAllowedObject:
                case AceType.AccessDeniedObject:
                case AceType.SystemAuditObject:
                case AceType.SystemAlarmObject:
                    isCallback = false;
                    break;

                case AceType.AccessAllowedCallbackObject:
                case AceType.AccessDeniedCallbackObject:
                case AceType.SystemAuditCallbackObject:
                case AceType.SystemAlarmCallbackObject:
                    isCallback = true;
                    break;

                default:
                    goto label_38;
                }
                if (aceType == AceType.AccessAllowedObject || aceType == AceType.AccessAllowedCallbackObject)
                {
                    qualifier = AceQualifier.AccessAllowed;
                }
                else if (aceType == AceType.AccessDeniedObject || aceType == AceType.AccessDeniedCallbackObject)
                {
                    qualifier = AceQualifier.AccessDenied;
                }
                else if (aceType == AceType.SystemAuditObject || aceType == AceType.SystemAuditCallbackObject)
                {
                    qualifier = AceQualifier.SystemAudit;
                }
                else if (aceType == AceType.SystemAlarmObject || aceType == AceType.SystemAlarmCallbackObject)
                {
                    qualifier = AceQualifier.SystemAlarm;
                }
                else
                {
                    goto label_38;
                }
                int num1 = offset + 4;
                int num2 = 0;
                accessMask = (int)binaryForm[num1 + 0] + ((int)binaryForm[num1 + 1] << 8) + ((int)binaryForm[num1 + 2] << 16) + ((int)binaryForm[num1 + 3] << 24);
                int num3 = num2 + 4;
                objectFlags = (ObjectAceFlags)((int)binaryForm[num1 + num3 + 0] + ((int)binaryForm[num1 + num3 + 1] << 8) + ((int)binaryForm[num1 + num3 + 2] << 16) + ((int)binaryForm[num1 + num3 + 3] << 24));
                int num4 = num3 + 4;
                if ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) != ObjectAceFlags.None)
                {
                    for (int index = 0; index < 16; ++index)
                    {
                        b[index] = binaryForm[num1 + num4 + index];
                    }
                    num4 += 16;
                }
                else
                {
                    for (int index = 0; index < 16; ++index)
                    {
                        b[index] = (byte)0;
                    }
                }
                objectAceType = new Guid(b);
                if ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) != ObjectAceFlags.None)
                {
                    for (int index = 0; index < 16; ++index)
                    {
                        b[index] = binaryForm[num1 + num4 + index];
                    }
                    num4 += 16;
                }
                else
                {
                    for (int index = 0; index < 16; ++index)
                    {
                        b[index] = (byte)0;
                    }
                }
                inheritedObjectAceType = new Guid(b);
                sid    = new SecurityIdentifier(binaryForm, num1 + num4);
                opaque = (byte[])null;
                int num5 = ((int)binaryForm[offset + 3] << 8) + (int)binaryForm[offset + 2];
                if (num5 % 4 == 0)
                {
                    int length = num5 - 4 - 4 - 4 - (int)(byte)sid.BinaryLength;
                    if ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) != ObjectAceFlags.None)
                    {
                        length -= 16;
                    }
                    if ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) != ObjectAceFlags.None)
                    {
                        length -= 16;
                    }
                    if (length > 0)
                    {
                        opaque = new byte[length];
                        for (int index = 0; index < length; ++index)
                        {
                            opaque[index] = binaryForm[offset + num5 - length + index];
                        }
                    }
                    return(true);
                }
            }
label_38:
            qualifier              = AceQualifier.AccessAllowed;
            accessMask             = 0;
            sid                    = (SecurityIdentifier)null;
            objectFlags            = ObjectAceFlags.None;
            objectAceType          = Guid.NewGuid();
            inheritedObjectAceType = Guid.NewGuid();
            isCallback             = false;
            opaque                 = (byte[])null;
            return(false);
        }
Beispiel #10
0
        /// <summary>从指定的二进制数据创建一个 <see cref="T:System.Security.AccessControl.GenericAce" /> 对象。</summary>
        /// <returns>此方法创建的 <see cref="T:System.Security.AccessControl.GenericAce" /> 对象。</returns>
        /// <param name="binaryForm">用于创建新 <see cref="T:System.Security.AccessControl.GenericAce" /> 对象的二进制数据。</param>
        /// <param name="offset">开始取消封送的偏移量。</param>
        public static GenericAce CreateFromBinaryForm(byte[] binaryForm, int offset)
        {
            GenericAce.VerifyHeader(binaryForm, offset);
            AceType    type = (AceType)binaryForm[offset];
            GenericAce genericAce;

            switch (type)
            {
            case AceType.AccessAllowed:
            case AceType.AccessDenied:
            case AceType.SystemAudit:
            case AceType.SystemAlarm:
            case AceType.AccessAllowedCallback:
            case AceType.AccessDeniedCallback:
            case AceType.SystemAuditCallback:
            case AceType.SystemAlarmCallback:
                AceQualifier       qualifier1;
                int                accessMask1;
                SecurityIdentifier sid1;
                bool               isCallback1;
                byte[]             opaque1;
                if (CommonAce.ParseBinaryForm(binaryForm, offset, out qualifier1, out accessMask1, out sid1, out isCallback1, out opaque1))
                {
                    genericAce = (GenericAce) new CommonAce((AceFlags)binaryForm[offset + 1], qualifier1, accessMask1, sid1, isCallback1, opaque1);
                    break;
                }
                goto label_15;

            case AceType.AccessAllowedObject:
            case AceType.AccessDeniedObject:
            case AceType.SystemAuditObject:
            case AceType.SystemAlarmObject:
            case AceType.AccessAllowedCallbackObject:
            case AceType.AccessDeniedCallbackObject:
            case AceType.SystemAuditCallbackObject:
            case AceType.SystemAlarmCallbackObject:
                AceQualifier       qualifier2;
                int                accessMask2;
                SecurityIdentifier sid2;
                ObjectAceFlags     objectFlags;
                Guid               objectAceType;
                Guid               inheritedObjectAceType;
                bool               isCallback2;
                byte[]             opaque2;
                if (ObjectAce.ParseBinaryForm(binaryForm, offset, out qualifier2, out accessMask2, out sid2, out objectFlags, out objectAceType, out inheritedObjectAceType, out isCallback2, out opaque2))
                {
                    genericAce = (GenericAce) new ObjectAce((AceFlags)binaryForm[offset + 1], qualifier2, accessMask2, sid2, objectFlags, objectAceType, inheritedObjectAceType, isCallback2, opaque2);
                    break;
                }
                goto label_15;

            case AceType.AccessAllowedCompound:
                int                accessMask3;
                CompoundAceType    compoundAceType;
                SecurityIdentifier sid3;
                if (CompoundAce.ParseBinaryForm(binaryForm, offset, out accessMask3, out compoundAceType, out sid3))
                {
                    genericAce = (GenericAce) new CompoundAce((AceFlags)binaryForm[offset + 1], accessMask3, compoundAceType, sid3);
                    break;
                }
                goto label_15;

            default:
                AceFlags flags   = (AceFlags)binaryForm[offset + 1];
                byte[]   opaque3 = (byte[])null;
                int      num     = (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8);
                if (num % 4 == 0)
                {
                    int length = num - 4;
                    if (length > 0)
                    {
                        opaque3 = new byte[length];
                        for (int index = 0; index < length; ++index)
                        {
                            opaque3[index] = binaryForm[offset + num - length + index];
                        }
                    }
                    genericAce = (GenericAce) new CustomAce(type, flags, opaque3);
                    break;
                }
                goto label_15;
            }
            if ((genericAce is ObjectAce || (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8) == genericAce.BinaryLength) && (!(genericAce is ObjectAce) || (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8) == genericAce.BinaryLength || (int)binaryForm[offset + 2] + ((int)binaryForm[offset + 3] << 8) - 32 == genericAce.BinaryLength))
            {
                return(genericAce);
            }
label_15:
            throw new ArgumentException(Environment.GetResourceString("ArgumentException_InvalidAceBinaryForm"), "binaryForm");
        }