本文整理汇总了C#中PEReader.ReadEmbeddedPortablePdbDebugDirectoryData方法的典型用法代码示例。如果您正苦于以下问题:C# PEReader.ReadEmbeddedPortablePdbDebugDirectoryData方法的具体用法?C# PEReader.ReadEmbeddedPortablePdbDebugDirectoryData怎么用?C# PEReader.ReadEmbeddedPortablePdbDebugDirectoryData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEReader
的用法示例。
在下文中一共展示了PEReader.ReadEmbeddedPortablePdbDebugDirectoryData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DebugDirectoryData_Errors
public void DebugDirectoryData_Errors()
{
var reader = new PEReader(new MemoryStream(Misc.Members));
Assert.Throws<ArgumentException>("entry", () => reader.ReadCodeViewDebugDirectoryData(new DebugDirectoryEntry(0, 0, 0, DebugDirectoryEntryType.Coff, 0, 0, 0)));
Assert.Throws<BadImageFormatException>(() => reader.ReadCodeViewDebugDirectoryData(new DebugDirectoryEntry(0, 0, 0, DebugDirectoryEntryType.CodeView, 0, 0, 0)));
Assert.Throws<ArgumentException>("entry", () => reader.ReadEmbeddedPortablePdbDebugDirectoryData(new DebugDirectoryEntry(0, 0, 0, DebugDirectoryEntryType.Coff, 0, 0, 0)));
Assert.Throws<BadImageFormatException>(() => reader.ReadEmbeddedPortablePdbDebugDirectoryData(new DebugDirectoryEntry(0, 0, 0, DebugDirectoryEntryType.EmbeddedPortablePdb, 0, 0, 0)));
}
示例2: Dispose
public void Dispose()
{
var peStream = new MemoryStream(PortablePdbs.DocumentsEmbeddedDll);
var reader = new PEReader(peStream);
MetadataReaderProvider pdbProvider;
string pdbPath;
Assert.True(reader.TryOpenAssociatedPortablePdb(@"x", _ => null, out pdbProvider, out pdbPath));
Assert.NotNull(pdbProvider);
Assert.Null(pdbPath);
var ddEntries = reader.ReadDebugDirectory();
var ddCodeView = ddEntries[0];
var ddEmbedded = ddEntries[2];
var embeddedPdbProvider = reader.ReadEmbeddedPortablePdbDebugDirectoryData(ddEmbedded);
// dispose the PEReader:
reader.Dispose();
Assert.False(reader.IsEntireImageAvailable);
Assert.Throws<ObjectDisposedException>(() => reader.PEHeaders);
Assert.Throws<ObjectDisposedException>(() => reader.HasMetadata);
Assert.Throws<ObjectDisposedException>(() => reader.GetMetadata());
Assert.Throws<ObjectDisposedException>(() => reader.GetSectionData(1000));
Assert.Throws<ObjectDisposedException>(() => reader.GetMetadataReader());
Assert.Throws<ObjectDisposedException>(() => reader.GetMethodBody(0));
Assert.Throws<ObjectDisposedException>(() => reader.GetEntireImage());
Assert.Throws<ObjectDisposedException>(() => reader.ReadDebugDirectory());
Assert.Throws<ObjectDisposedException>(() => reader.ReadCodeViewDebugDirectoryData(ddCodeView));
Assert.Throws<ObjectDisposedException>(() => reader.ReadEmbeddedPortablePdbDebugDirectoryData(ddEmbedded));
MetadataReaderProvider __;
string ___;
Assert.Throws<ObjectDisposedException>(() => reader.TryOpenAssociatedPortablePdb(@"x", _ => null, out __, out ___));
// ok to use providers after PEReader disposed:
var pdbReader = pdbProvider.GetMetadataReader();
Assert.Equal(13, pdbReader.Documents.Count);
pdbReader = embeddedPdbProvider.GetMetadataReader();
Assert.Equal(13, pdbReader.Documents.Count);
embeddedPdbProvider.Dispose();
}
示例3: ValidateEmbeddedPortablePdb
private void ValidateEmbeddedPortablePdb(PEReader reader)
{
var entries = reader.ReadDebugDirectory();
Assert.Equal(DebugDirectoryEntryType.CodeView, entries[0].Type);
Assert.Equal(DebugDirectoryEntryType.Reproducible, entries[1].Type);
Assert.Equal(DebugDirectoryEntryType.EmbeddedPortablePdb, entries[2].Type);
var provider = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entries[2]);
var pdbReader = provider.GetMetadataReader();
var document = pdbReader.GetDocument(pdbReader.Documents.First());
Assert.Equal(@"C:\Documents.cs", pdbReader.GetString(document.Name));
}
示例4: TryOpenAssociatedPortablePdb_EmbeddedUnused
public unsafe void TryOpenAssociatedPortablePdb_EmbeddedUnused()
{
var peStream = new MemoryStream(PortablePdbs.DocumentsEmbeddedDll);
using (var reader = new PEReader(peStream))
{
using (MetadataReaderProvider embeddedProvider = reader.ReadEmbeddedPortablePdbDebugDirectoryData(reader.ReadDebugDirectory()[2]))
{
var embeddedReader = embeddedProvider.GetMetadataReader();
var embeddedBytes = new BlobReader(embeddedReader.MetadataPointer, embeddedReader.MetadataLength).ReadBytes(embeddedReader.MetadataLength);
string pathQueried = null;
Func<string, Stream> streamProvider = p =>
{
Assert.Null(pathQueried);
pathQueried = p;
return new MemoryStream(embeddedBytes);
};
MetadataReaderProvider pdbProvider;
string pdbPath;
Assert.True(reader.TryOpenAssociatedPortablePdb(Path.Combine("pedir", "file.exe"), streamProvider, out pdbProvider, out pdbPath));
Assert.Equal(Path.Combine("pedir", "Documents.Embedded.pdb"), pathQueried);
Assert.Equal(Path.Combine("pedir", "Documents.Embedded.pdb"), pdbPath);
var pdbReader = pdbProvider.GetMetadataReader();
Assert.Equal(13, pdbReader.Documents.Count);
}
}
}