Ejemplo n.º 1
0
 public unsafe AssemblyInfo(string url, byte[] assembly, byte[] pdb)
 {
     debugId           = -1;
     this.id           = Interlocked.Increment(ref next_id);
     asmStream         = new MemoryStream(assembly);
     peReader          = new PEReader(asmStream);
     asmMetadataReader = PEReaderExtensions.GetMetadataReader(peReader);
     Name = asmMetadataReader.GetAssemblyDefinition().GetAssemblyName().Name + ".dll";
     AssemblyNameUnqualified = Name;
     if (pdb != null)
     {
         pdbStream = new MemoryStream(pdb);
         try
         {
             pdbMetadataReader = MetadataReaderProvider.FromPortablePdbStream(pdbStream).GetMetadataReader();
         }
         catch (BadImageFormatException)
         {
             Console.WriteLine($"Warning: Unable to read debug information of: {Name} (use DebugType=Portable/Embedded)");
         }
     }
     else
     {
         var entries          = peReader.ReadDebugDirectory();
         var embeddedPdbEntry = entries.FirstOrDefault(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb);
         if (embeddedPdbEntry.DataSize != 0)
         {
             pdbMetadataReader = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdbEntry).GetMetadataReader();
         }
     }
     Populate();
 }
Ejemplo n.º 2
0
        public unsafe AssemblyInfo(MonoProxy monoProxy, SessionId sessionId, string url, byte[] assembly, byte[] pdb, CancellationToken token)
        {
            debugId             = -1;
            this.id             = Interlocked.Increment(ref next_id);
            using var asmStream = new MemoryStream(assembly);
            peReader            = new PEReader(asmStream);
            var entries = peReader.ReadDebugDirectory();

            if (entries.Length > 0)
            {
                var codeView = entries[0];
                CodeViewDebugDirectoryData codeViewData = peReader.ReadCodeViewDebugDirectoryData(codeView);
                PdbAge  = codeViewData.Age;
                PdbGuid = codeViewData.Guid;
                PdbName = codeViewData.Path;
                PdbInformationAvailable = true;
            }
            asmMetadataReader = PEReaderExtensions.GetMetadataReader(peReader);
            var asmDef = asmMetadataReader.GetAssemblyDefinition();

            Name = asmDef.GetAssemblyName().Name + ".dll";
            if (pdb != null)
            {
                var pdbStream = new MemoryStream(pdb);
                try
                {
                    // MetadataReaderProvider.FromPortablePdbStream takes ownership of the stream
                    pdbMetadataReader = MetadataReaderProvider.FromPortablePdbStream(pdbStream).GetMetadataReader();
                }
                catch (BadImageFormatException)
                {
                    monoProxy.SendLog(sessionId, $"Warning: Unable to read debug information of: {Name} (use DebugType=Portable/Embedded)", token);
                }
            }
            else
            {
                var embeddedPdbEntry = entries.FirstOrDefault(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb);
                if (embeddedPdbEntry.DataSize != 0)
                {
                    pdbMetadataReader = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdbEntry).GetMetadataReader();
                }
            }
            Populate();
        }
Ejemplo n.º 3
0
 public unsafe AssemblyInfo(string url, byte[] assembly, byte[] pdb)
 {
     this.id           = Interlocked.Increment(ref next_id);
     asmStream         = new MemoryStream(assembly);
     peReader          = new PEReader(asmStream);
     asmMetadataReader = PEReaderExtensions.GetMetadataReader(peReader);
     if (pdb != null)
     {
         pdbStream         = new MemoryStream(pdb);
         pdbMetadataReader = MetadataReaderProvider.FromPortablePdbStream(pdbStream).GetMetadataReader();
     }
     else
     {
         var entries          = peReader.ReadDebugDirectory();
         var embeddedPdbEntry = entries.FirstOrDefault(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb);
         if (embeddedPdbEntry.DataSize != 0)
         {
             pdbMetadataReader = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdbEntry).GetMetadataReader();
         }
     }
     Name = asmMetadataReader.GetAssemblyDefinition().GetAssemblyName().Name + ".dll";
     AssemblyNameUnqualified = asmMetadataReader.GetAssemblyDefinition().GetAssemblyName().Name + ".dll";
     Populate();
 }