public static GenericAce CreateFromBinaryForm(byte[] binaryForm, int offset) { GenericAce ace; VerifyHeader(binaryForm, offset); System.Security.AccessControl.AceType type = (System.Security.AccessControl.AceType)binaryForm[offset]; switch (type) { case System.Security.AccessControl.AceType.AccessAllowed: case System.Security.AccessControl.AceType.AccessDenied: case System.Security.AccessControl.AceType.SystemAudit: case System.Security.AccessControl.AceType.SystemAlarm: case System.Security.AccessControl.AceType.AccessAllowedCallback: case System.Security.AccessControl.AceType.AccessDeniedCallback: case System.Security.AccessControl.AceType.SystemAuditCallback: case System.Security.AccessControl.AceType.SystemAlarmCallback: { AceQualifier qualifier; int num; SecurityIdentifier identifier; bool flag; byte[] buffer; if (!CommonAce.ParseBinaryForm(binaryForm, offset, out qualifier, out num, out identifier, out flag, out buffer)) { goto Label_01A8; } System.Security.AccessControl.AceFlags flags = (System.Security.AccessControl.AceFlags)binaryForm[offset + 1]; ace = new CommonAce(flags, qualifier, num, identifier, flag, buffer); break; } case System.Security.AccessControl.AceType.AccessAllowedObject: case System.Security.AccessControl.AceType.AccessDeniedObject: case System.Security.AccessControl.AceType.SystemAuditObject: case System.Security.AccessControl.AceType.SystemAlarmObject: case System.Security.AccessControl.AceType.AccessAllowedCallbackObject: case System.Security.AccessControl.AceType.AccessDeniedCallbackObject: case System.Security.AccessControl.AceType.SystemAuditCallbackObject: case System.Security.AccessControl.AceType.SystemAlarmCallbackObject: { AceQualifier qualifier2; int num2; SecurityIdentifier identifier2; ObjectAceFlags flags2; Guid guid; Guid guid2; bool flag2; byte[] buffer2; if (!ObjectAce.ParseBinaryForm(binaryForm, offset, out qualifier2, out num2, out identifier2, out flags2, out guid, out guid2, out flag2, out buffer2)) { goto Label_01A8; } System.Security.AccessControl.AceFlags aceFlags = (System.Security.AccessControl.AceFlags)binaryForm[offset + 1]; ace = new ObjectAce(aceFlags, qualifier2, num2, identifier2, flags2, guid, guid2, flag2, buffer2); break; } case System.Security.AccessControl.AceType.AccessAllowedCompound: { int num3; CompoundAceType type2; SecurityIdentifier identifier3; if (!CompoundAce.ParseBinaryForm(binaryForm, offset, out num3, out type2, out identifier3)) { goto Label_01A8; } System.Security.AccessControl.AceFlags flags4 = (System.Security.AccessControl.AceFlags)binaryForm[offset + 1]; ace = new CompoundAce(flags4, num3, type2, identifier3); break; } default: { System.Security.AccessControl.AceFlags flags5 = (System.Security.AccessControl.AceFlags)binaryForm[offset + 1]; byte[] opaque = null; int num4 = binaryForm[offset + 2] + (binaryForm[offset + 3] << 8); if ((num4 % 4) != 0) { goto Label_01A8; } int num5 = num4 - 4; if (num5 > 0) { opaque = new byte[num5]; for (int i = 0; i < num5; i++) { opaque[i] = binaryForm[((offset + num4) - num5) + i]; } } ace = new CustomAce(type, flags5, opaque); break; } } if (((ace is ObjectAce) || ((binaryForm[offset + 2] + (binaryForm[offset + 3] << 8)) == ace.BinaryLength)) && ((!(ace is ObjectAce) || ((binaryForm[offset + 2] + (binaryForm[offset + 3] << 8)) == ace.BinaryLength)) || (((binaryForm[offset + 2] + (binaryForm[offset + 3] << 8)) - 0x20) == ace.BinaryLength))) { return(ace); } Label_01A8: throw new ArgumentException(Environment.GetResourceString("ArgumentException_InvalidAceBinaryForm"), "binaryForm"); }
/// <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"); }
/// <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"); }