本文整理汇总了C#中PEReader.ReadCodeViewDebugDirectoryData方法的典型用法代码示例。如果您正苦于以下问题:C# PEReader.ReadCodeViewDebugDirectoryData方法的具体用法?C# PEReader.ReadCodeViewDebugDirectoryData怎么用?C# PEReader.ReadCodeViewDebugDirectoryData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEReader
的用法示例。
在下文中一共展示了PEReader.ReadCodeViewDebugDirectoryData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CodeView
public void CodeView()
{
var peStream = new MemoryStream(Misc.Debug);
using (var reader = new PEReader(peStream))
{
// dumpbin:
//
// Debug Directories
//
// Time Type Size RVA Pointer
// -------------- - ------------------------
// 5670C4E6 cv 11C 0000230C 50C Format: RSDS, { 0C426227-31E6-4EC2-BD5F-712C4D96C0AB}, 1, C:\Temp\Debug.pdb
var cvEntry = reader.ReadDebugDirectory().Single();
Assert.Equal(DebugDirectoryEntryType.CodeView, cvEntry.Type);
Assert.Equal(0x050c, cvEntry.DataPointer);
Assert.Equal(0x230c, cvEntry.DataRelativeVirtualAddress);
Assert.Equal(0x011c, cvEntry.DataSize); // includes NUL padding
Assert.Equal(0, cvEntry.MajorVersion);
Assert.Equal(0, cvEntry.MinorVersion);
Assert.Equal(0x5670c4e6u, cvEntry.Stamp);
var cv = reader.ReadCodeViewDebugDirectoryData(cvEntry);
Assert.Equal(1, cv.Age);
Assert.Equal(new Guid("0C426227-31E6-4EC2-BD5F-712C4D96C0AB"), cv.Guid);
Assert.Equal(@"C:\Temp\Debug.pdb", cv.Path);
}
}
示例2: Deterministic
public void Deterministic()
{
var peStream = new MemoryStream(Misc.Deterministic);
using (var reader = new PEReader(peStream))
{
// dumpbin:
//
// Debug Directories
//
// Time Type Size RVA Pointer
// -------- ------- -------- -------- --------
// D2FC74D3 cv 32 00002338 538 Format: RSDS, {814C578F-7676-0263-4F8A-2D3E8528EAF1}, 1, C:\Temp\Deterministic.pdb
// 00000000 repro 0 00000000 0
var entries = reader.ReadDebugDirectory();
var cvEntry = entries[0];
Assert.Equal(DebugDirectoryEntryType.CodeView, cvEntry.Type);
Assert.Equal(0x0538, cvEntry.DataPointer);
Assert.Equal(0x2338, cvEntry.DataRelativeVirtualAddress);
Assert.Equal(0x0032, cvEntry.DataSize); // no NUL padding
Assert.Equal(0, cvEntry.MajorVersion);
Assert.Equal(0, cvEntry.MinorVersion);
Assert.Equal(0xD2FC74D3u, cvEntry.Stamp);
var cv = reader.ReadCodeViewDebugDirectoryData(cvEntry);
Assert.Equal(1, cv.Age);
Assert.Equal(new Guid("814C578F-7676-0263-4F8A-2D3E8528EAF1"), cv.Guid);
Assert.Equal(@"C:\Temp\Deterministic.pdb", cv.Path);
var detEntry = entries[1];
Assert.Equal(DebugDirectoryEntryType.Deterministic, detEntry.Type);
Assert.Equal(0, detEntry.DataPointer);
Assert.Equal(0, detEntry.DataRelativeVirtualAddress);
Assert.Equal(0, detEntry.DataSize);
Assert.Equal(0, detEntry.MajorVersion);
Assert.Equal(0, detEntry.MinorVersion);
Assert.Equal(0u, detEntry.Stamp);
Assert.Equal(2, entries.Length);
Assert.Throws<ArgumentException>(() => reader.ReadCodeViewDebugDirectoryData(detEntry));
}
}
示例3: 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)));
}
示例4: ValidateDeterministic
private void ValidateDeterministic(PEReader reader)
{
// dumpbin:
//
// Debug Directories
//
// Time Type Size RVA Pointer
// -------- ------- -------- -------- --------
// D2FC74D3 cv 32 00002338 538 Format: RSDS, {814C578F-7676-0263-4F8A-2D3E8528EAF1}, 1, C:\Temp\Deterministic.pdb
// 00000000 repro 0 00000000 0
var entries = reader.ReadDebugDirectory();
var cvEntry = entries[0];
Assert.Equal(DebugDirectoryEntryType.CodeView, cvEntry.Type);
Assert.False(cvEntry.IsPortableCodeView);
Assert.Equal(0x0538, cvEntry.DataPointer);
Assert.Equal(0x2338, cvEntry.DataRelativeVirtualAddress);
Assert.Equal(0x0032, cvEntry.DataSize); // no NUL padding
Assert.Equal(0, cvEntry.MajorVersion);
Assert.Equal(0, cvEntry.MinorVersion);
Assert.Equal(0xD2FC74D3u, cvEntry.Stamp);
var cv = reader.ReadCodeViewDebugDirectoryData(cvEntry);
Assert.Equal(1, cv.Age);
Assert.Equal(new Guid("814C578F-7676-0263-4F8A-2D3E8528EAF1"), cv.Guid);
Assert.Equal(@"C:\Temp\Deterministic.pdb", cv.Path);
var detEntry = entries[1];
Assert.Equal(DebugDirectoryEntryType.Reproducible, detEntry.Type);
Assert.False(detEntry.IsPortableCodeView);
Assert.Equal(0, detEntry.DataPointer);
Assert.Equal(0, detEntry.DataRelativeVirtualAddress);
Assert.Equal(0, detEntry.DataSize);
Assert.Equal(0, detEntry.MajorVersion);
Assert.Equal(0, detEntry.MinorVersion);
Assert.Equal(0u, detEntry.Stamp);
Assert.Equal(2, entries.Length);
}
示例5: 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();
}