Exemplo n.º 1
0
        public GuidHeapTreeNode(PEFile module, MetadataReader metadata)
            : base(HandleKind.Guid, module, metadata)
        {
            list = new List <GuidHeapEntry>();
            int count = metadata.GetHeapSize(HeapIndex.Guid) >> 4;

            for (int i = 1; i <= count; i++)
            {
                GuidHeapEntry entry = new GuidHeapEntry(metadata, MetadataTokens.GuidHandle(i));
                list.Add(entry);
            }
        }
Exemplo n.º 2
0
        private void WriteUserStrings()
        {
            int size = reader.GetHeapSize(HeapIndex.UserString);

            if (size == 0)
            {
                return;
            }

            // TODO: the heap is aligned, don't display the trailing empty strings
            writer.WriteLine(string.Format("#US (size = {0}):", size));
            var handle = MetadataTokens.UserStringHandle(0);

            do
            {
                string value = reader.GetUserString(handle);
                writer.WriteLine("  {0:x}: '{1}'", reader.GetHeapOffset(handle), value);
                handle = reader.GetNextHandle(handle);
            }while (!handle.IsNil);

            writer.WriteLine();
        }
Exemplo n.º 3
0
            public FieldMarshalEntry(PEFile module, byte *ptr, int metadataOffset, int row)
            {
                this.module   = module;
                this.metadata = module.Metadata;
                this.RID      = row;
                var rowOffset = metadata.GetTableMetadataOffset(TableIndex.FieldMarshal)
                                + metadata.GetTableRowSize(TableIndex.FieldMarshal) * (row - 1);

                this.Offset = metadataOffset + rowOffset;
                int hasFieldMarshalRefSize = metadata.ComputeCodedTokenSize(32768, TableMask.Field | TableMask.Param);
                int blobHeapSize           = metadata.GetHeapSize(HeapIndex.Blob) < ushort.MaxValue ? 2 : 4;

                this.fieldMarshal = new FieldMarshal(ptr + rowOffset, blobHeapSize, hasFieldMarshalRefSize);
            }
Exemplo n.º 4
0
            public unsafe ImplMapEntry(PEFile module, byte *ptr, int metadataOffset, int row)
            {
                this.module   = module;
                this.metadata = module.Metadata;
                this.RID      = row;
                var rowOffset = metadata.GetTableMetadataOffset(TableIndex.ImplMap)
                                + metadata.GetTableRowSize(TableIndex.ImplMap) * (row - 1);

                this.Offset = metadataOffset + rowOffset;
                int moduleRefSize             = metadata.GetTableRowCount(TableIndex.ModuleRef) < ushort.MaxValue ? 2 : 4;
                int memberForwardedTagRefSize = metadata.ComputeCodedTokenSize(32768, TableMask.MethodDef | TableMask.Field);
                int stringHandleSize          = metadata.GetHeapSize(HeapIndex.String) < ushort.MaxValue ? 2 : 4;

                this.implMap = new ImplMap(ptr + rowOffset, moduleRefSize, memberForwardedTagRefSize, stringHandleSize);
            }
Exemplo n.º 5
0
        private static void CalculateBaseCounts(
            MetadataReader baseReader,
            out IReadOnlyList <int> baseTableRowCounts,
            out IReadOnlyList <int> baseHeapSizes)
        {
            int[] rowCounts = new int[MetadataTokens.TableCount];
            int[] heapSizes = new int[MetadataTokens.HeapCount];

            for (int i = 0; i < rowCounts.Length; i++)
            {
                rowCounts[i] = baseReader.GetTableRowCount((TableIndex)i);
            }

            for (int i = 0; i < heapSizes.Length; i++)
            {
                heapSizes[i] = baseReader.GetHeapSize((HeapIndex)i);
            }

            baseTableRowCounts = rowCounts;
            baseHeapSizes      = heapSizes;
        }