Inheritance: BlobSignature
Exemplo n.º 1
0
        /// <summary>
        /// Reads a single property signature at the current position of the provided stream reader.
        /// </summary>
        /// <param name="image">The image the signature resides in.</param>
        /// <param name="reader">The reader to use.</param>
        /// <param name="readToEnd">Determines whether any extra data after the signature should be read and
        /// put into the <see cref="ExtendableBlobSignature.ExtraData"/> property.</param>
        /// <param name="protection">The recursion protection that is used to detect malicious loops in the metadata.</param>
        /// <returns>The read signature.</returns>
        public new static PropertySignature FromReader(
            MetadataImage image,
            IBinaryStreamReader reader,
            bool readToEnd,
            RecursionProtection protection)
        {
            var signature = new PropertySignature
            {
                Attributes = (CallingConventionAttributes)reader.ReadByte(),
            };

            if (!reader.TryReadCompressedUInt32(out uint paramCount))
            {
                return(null);
            }

            signature.PropertyType = TypeSignature.FromReader(image, reader, false, protection);

            for (int i = 0; i < paramCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(image, reader, protection));
            }

            if (readToEnd)
            {
                signature.ExtraData = reader.ReadToEnd();
            }

            return(signature);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads a single method signature at the current position of the provided stream reader.
        /// </summary>
        /// <param name="image">The image the field is defined in.</param>
        /// <param name="reader">The reader to use.</param>
        /// <param name="readToEnd">Determines whether any extra data after the signature should be read and
        /// put into the <see cref="ExtendableBlobSignature.ExtraData"/> property.</param>
        /// <param name="protection">The recursion protection that is used to detect malicious loops in the metadata.</param>
        /// <returns>The read signature.</returns>
        public new static MethodSignature FromReader(
            MetadataImage image,
            IBinaryStreamReader reader,
            bool readToEnd,
            RecursionProtection protection)
        {
            if (!reader.CanRead(sizeof(byte)))
            {
                return(null);
            }

            var signature = new MethodSignature
            {
                Attributes = (CallingConventionAttributes)reader.ReadByte()
            };

            if (signature.IsGeneric)
            {
                if (!reader.TryReadCompressedUInt32(out uint genericParameterCount))
                {
                    return(signature);
                }
                signature.GenericParameterCount = (int)genericParameterCount;
            }

            if (!reader.TryReadCompressedUInt32(out uint parameterCount))
            {
                return(signature);
            }

            signature.ReturnType = TypeSignature.FromReader(image, reader);

            for (int i = 0; i < parameterCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(image, reader, protection));
            }

            if (readToEnd)
            {
                signature.ExtraData = reader.ReadToEnd();
            }

            return(signature);
        }
Exemplo n.º 3
0
        public new static MethodSignature FromReader(MetadataHeader header, IBinaryStreamReader reader)
        {
            if (!reader.CanRead(sizeof(byte)))
            {
                return(null);
            }

            var signature = new MethodSignature
            {
                StartOffset = reader.Position,
                Attributes  = (CallingConventionAttributes)reader.ReadByte()
            };

            if (signature.IsGeneric)
            {
                uint genericParameterCount;
                if (!reader.TryReadCompressedUInt32(out genericParameterCount))
                {
                    return(signature);
                }
                signature.GenericParameterCount = (int)genericParameterCount;
            }

            uint parameterCount;

            if (!reader.TryReadCompressedUInt32(out parameterCount))
            {
                return(signature);
            }

            signature.ReturnType = TypeSignature.FromReader(header, reader);
            for (int i = 0; i < parameterCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(header, reader));
            }

            return(signature);
        }
Exemplo n.º 4
0
        public new static PropertySignature FromReader(MetadataImage image, IBinaryStreamReader reader)
        {
            var signature = new PropertySignature
            {
                Attributes = (CallingConventionAttributes)reader.ReadByte(),
            };

            uint paramCount;

            if (!reader.TryReadCompressedUInt32(out paramCount))
            {
                return(null);
            }

            signature.PropertyType = TypeSignature.FromReader(image, reader);

            for (int i = 0; i < paramCount; i++)
            {
                signature.Parameters.Add(ParameterSignature.FromReader(image, reader));
            }

            return(signature);
        }
Exemplo n.º 5
0
 public int GetParameterIndex(ParameterSignature parameter)
 {
     return _owner.Method.Signature.Parameters.IndexOf(parameter);
 }
Exemplo n.º 6
0
 public static MsilInstruction Create(MsilOpCode code, ParameterSignature operand)
 {
     if (code.OperandType != MsilOperandType.InlineArgument && code.OperandType != MsilOperandType.ShortInlineArgument)
         throw new ArgumentException("Opcode does not accept a parameter operand.", "code");
     return new MsilInstruction(0, code, operand);
 }
 internal AssemblyParameterDefinition(Symbols.AbstractMethodDefinition method, ParameterSignature signature, ParameterDefinition definition)
 {
     _method = method;
     _signature = signature;
     _definition = definition;
 }