Exemplo n.º 1
0
        internal CliMetadataMethodHeader(ICliMetadataRoot metadataRoot, uint relativeVirtualAddress, Action <byte[]> bodyBuilder)
        {
            var image           = metadataRoot.SourceImage;
            var rvaLocationScan = image.ResolveRelativeVirtualAddress(relativeVirtualAddress);

            if (rvaLocationScan.Resolved)
            {
                var section       = rvaLocationScan.Section;
                var bodySubstream = new Substream(section.SectionData, rvaLocationScan.Offset, 65536, false);
                var bodyReader    = new EndianAwareBinaryReader(bodySubstream, Endianness.LittleEndian, false);
                var peekedChar    = bodyReader.PeekByte();
                if (peekedChar != -1)
                {
                    MethodHeaderFlags headerType = ((MethodHeaderFlags)peekedChar) & MethodHeaderFlags.WideFormat;
                    if (headerType == MethodHeaderFlags.NarrowFormat)
                    {
                        this.ReadNarrow(bodyReader, metadataRoot, bodyBuilder);
                    }
                    else
                    {
                        this.ReadWide(bodyReader, metadataRoot, bodyBuilder);
                    }
                }
            }
        }