Esempio n. 1
0
        static bool IsMatchingEntry(PdbHeap heap, ImageDebugHeaderEntry entry)
        {
            if (entry.Directory.Type != ImageDebugType.CodeView)
            {
                return(false);
            }

            var data = entry.Data;

            if (data.Length < 24)
            {
                return(false);
            }

            var magic = ReadInt32(data, 0);

            if (magic != 0x53445352)
            {
                return(false);
            }

            var buffer = new byte [16];

            Buffer.BlockCopy(data, 4, buffer, 0, 16);

            var module_guid = new Guid(buffer);

            Buffer.BlockCopy(heap.Id, 0, buffer, 0, 16);

            var pdb_guid = new Guid(buffer);

            return(module_guid == pdb_guid);
        }
Esempio n. 2
0
        private void ReadPdbHeap()
        {
            PdbHeap    pdbHeap    = image.PdbHeap;
            ByteBuffer byteBuffer = new ByteBuffer(pdbHeap.data);

            pdbHeap.Id                  = byteBuffer.ReadBytes(20);
            pdbHeap.EntryPoint          = byteBuffer.ReadUInt32();
            pdbHeap.TypeSystemTables    = byteBuffer.ReadInt64();
            pdbHeap.TypeSystemTableRows = new uint[58];
            for (int i = 0; i < 58; i++)
            {
                Table table = (Table)i;
                if (pdbHeap.HasTable(table))
                {
                    pdbHeap.TypeSystemTableRows[i] = byteBuffer.ReadUInt32();
                }
            }
        }
Esempio n. 3
0
        DotNetHeap[] CreateCompressedHeaps()
        {
            var         list        = new List <DotNetHeap>();
            StringsHeap stringsHeap = null;
            USHeap      usHeap      = null;
            BlobHeap    blobHeap    = null;
            GUIDHeap    guidHeap    = null;
            TablesHeap  tablesHeap  = null;
            PdbHeap     pdbHeap     = null;

            for (int i = storageStreamHeaders.Length - 1; i >= 0; i--)
            {
                var ssh  = storageStreamHeaders[i];
                var span = new HexBufferSpan(file.Buffer, ssh.DataSpan);

                switch (ssh.Name)
                {
                case "#Strings":
                    if (stringsHeap == null)
                    {
                        stringsHeap = new StringsHeapImpl(span);
                        list.Add(stringsHeap);
                        continue;
                    }
                    break;

                case "#US":
                    if (usHeap == null)
                    {
                        usHeap = new USHeapImpl(span);
                        list.Add(usHeap);
                        continue;
                    }
                    break;

                case "#Blob":
                    if (blobHeap == null)
                    {
                        blobHeap = new BlobHeapImpl(span);
                        list.Add(blobHeap);
                        continue;
                    }
                    break;

                case "#GUID":
                    if (guidHeap == null)
                    {
                        guidHeap = new GUIDHeapImpl(span);
                        list.Add(guidHeap);
                        continue;
                    }
                    break;

                case "#~":
                    if (tablesHeap == null && span.Length >= TablesHeapImpl.MinimumSize)
                    {
                        tablesHeap = new TablesHeapImpl(span, TablesHeapType.Compressed);
                        list.Add(tablesHeap);
                        continue;
                    }
                    break;

                case "#!":
                    list.Add(new HotHeapImpl(span));
                    continue;

                case "#Pdb":
                    if (pdbHeap == null && span.Length >= PdbHeapImpl.MinimumSize)
                    {
                        pdbHeap = new PdbHeapImpl(span);
                        list.Add(pdbHeap);
                        continue;
                    }
                    break;
                }
                list.Add(new UnknownHeapImpl(span));
            }

            list.Reverse();
            return(list.ToArray());
        }