/// <summary> /// Reads a permission set signature from the provided input blob stream. /// </summary> /// <param name="parentModule">The module the permission set resides in.</param> /// <param name="reader">The input blob stream.</param> /// <returns>The permission set.</returns> public static PermissionSetSignature FromReader(ModuleDefinition parentModule, IBinaryStreamReader reader) { var result = new PermissionSetSignature(); if (reader.ReadByte() != '.') { return(result); } if (!reader.TryReadCompressedUInt32(out uint count)) { return(result); } for (int i = 0; i < count && reader.CanRead(1); i++) { result.Attributes.Add(SecurityAttribute.FromReader(parentModule, reader)); } return(result); }
/// <summary> /// Reads a single security attribute from the provided input blob stream. /// </summary> /// <param name="parentModule">The module that the security attribute resides in.</param> /// <param name="reader">The input blob stream.</param> /// <returns>The security attribute.</returns> public static SecurityAttribute FromReader(ModuleDefinition parentModule, IBinaryStreamReader reader) { var type = TypeNameParser.Parse(parentModule, reader.ReadSerString()); var result = new SecurityAttribute(type); if (!reader.TryReadCompressedUInt32(out uint size)) { return(result); } if (!reader.TryReadCompressedUInt32(out uint namedArgumentCount)) { return(result); } for (int i = 0; i < namedArgumentCount; i++) { var argument = CustomAttributeNamedArgument.FromReader(parentModule, reader); result.NamedArguments.Add(argument); } return(result); }