コード例 #1
0
            private void LoadMethods()
            {
                if (!_metadataStream.Tables.ContainsKey(MetadataTables.MethodDef))
                {
                    return;
                }

                MetadataRow[] table            = _metadataStream.Tables[MetadataTables.MethodDef];
                int           endOfMethodIndex = table.Length + 1;

                if (_nextRowIndex != -1)
                {
                    endOfMethodIndex = ((TypeDefMetadataTableRow)_metadataStream.Tables[MetadataTables.TypeDef][_nextRowIndex]).MethodList;
                }

                // Now load all the methods between our index and the endOfMethodIndex
                for (int i = _fromRow.MethodList; i < endOfMethodIndex; i++)
                {
                    MethodMetadataTableRow methodDefRow = table[i - 1] as MethodMetadataTableRow;
                    MethodDef method = MethodDef.CreateFromMetadata(_references, _builtType, methodDefRow);

                    _map.Add(MetadataTables.MethodDef, methodDefRow, method);
                    _builtType.Methods.Add(method);
                }
            }
コード例 #2
0
        public void Method_WhenCreated_OffsetIsMovedOn()
        {
            byte[]        contents     = new byte[14];
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            MethodMetadataTableRow row = new MethodMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(14, offset.Current);
        }
コード例 #3
0
 public MethodDefEntry(int index, MetadataDirectory directory, MethodMetadataTableRow row)
 {
     this.Index      = index;
     this.FileOffset = string.Format("0x{0:x}", row.FileOffset);
     this.Flags      = string.Format("0x{0:x}", row.Flags);
     this.ImplFlags  = string.Format("0x{0:x}", row.ImplFlags);
     this.Name       = ((StringStream)directory.Streams[Streams.StringStream]).GetString(row.Name.Value);
     this.ParamList  = string.Format("0x{0:x}", row.ParamList.Value);
     this.RVA        = string.Format("0x{0:x}", row.RVA);
     this.Signiture  = string.Format("0x{0:x}", row.Signiture.Value);
 }
コード例 #4
0
            public MethodDefBuilder(BuildReferences references, TypeDef container, MethodMetadataTableRow fromRow)
            {
                _metadata       = references.Metadata;
                _map            = references.Map;
                _assembly       = references.Assembly;
                _container      = container;
                _fromRow        = fromRow;
                _metadataStream = _metadata.Streams[Streams.MetadataStream] as MetadataStream;
                _blobStream     = _metadata.Streams[Streams.BlobStream] as BlobStream;

                _references = references;
            }
コード例 #5
0
        public void Method_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00, 0x00, 0x00,
                0x02, 0x00,
                0x01, 0x00,
                0x03, 0x00,
                0x02, 0x00,
                0x01, 0x00
            };
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            MethodMetadataTableRow row = new MethodMetadataTableRow(contents, 0, indexDetails);

            Assert.AreEqual(1, row.RVA);
            Assert.AreEqual(MethodImplFlags.OPTIL, row.ImplFlags);
            Assert.AreEqual(MethodAttributes.Private, row.Flags);
            Assert.AreEqual(3, row.Name.Value);
            Assert.AreEqual(2, row.Signiture.Value);
            Assert.AreEqual(1, row.ParamList.Value);
        }
コード例 #6
0
        /// <summary>
        /// Initialises a new instance of MethodDef for the provided data
        /// </summary>
        /// <param name="references">The references required to build the methods</param>
        /// <param name="container">The owning type for this method</param>
        /// <param name="row">The row detailing the method</param>
        /// <returns>The initialised MethodDef</returns>
        internal static MethodDef CreateFromMetadata(BuildReferences references, TypeDef container, MethodMetadataTableRow row)
        {
            MethodDefBuilder builder = new MethodDefBuilder(references, container, row);

            return(builder.Build());
        }