51 public unsafe
PEReader(
byte* peImage,
int size)
52 : this(peImage, size, isLoadedImage: false)
56 public unsafe
PEReader(
byte* peImage,
int size,
bool isLoadedImage)
149 if (lazyPESectionBlocks !=
null)
152 for (
int i = 0; i <
array.Length; i++)
265 if (relativeVirtualAddress < 0)
270 if (containingSectionIndex < 0)
276 if (num > pESectionBlock.
Size)
285 if (sectionName ==
null)
300 if (debugTableDirectory.
Size == 0)
308 if (debugTableDirectory.
Size % 28 != 0)
318 int num = reader.Length / 28;
320 for (
int i = 0; i < num; i++)
331 int dataRelativeVirtualAddress = reader.
ReadInt32();
333 builder.Add(
new DebugDirectoryEntry(stamp, majorVersion, minorVersion,
type, dataSize, dataRelativeVirtualAddress, dataPointer));
335 return builder.MoveToImmutable();
382 if (
text.Length == 0 ||
array.Length == 0)
391 if (peImagePath ==
null)
395 if (pdbFileStreamProvider ==
null)
399 pdbReaderProvider =
null;
401 string directoryName;
413 if (codeViewEntry.
DataSize != 0 &&
TryOpenCodeViewPortablePdb(codeViewEntry, directoryName, pdbFileStreamProvider, out pdbReaderProvider, out pdbPath, ref errorToReport))
420 bool openedEmbeddedPdb =
false;
421 pdbReaderProvider =
null;
423 if (openedEmbeddedPdb)
428 if (errorToReport !=
null)
472 stream = pdbFileStreamProvider(path);
491 provider = metadataReaderProvider;
505 if (provider ==
null)
507 metadataReaderProvider?.
Dispose();
520 provider = metadataReaderProvider;
521 openedEmbeddedPdb =
true;
530 openedEmbeddedPdb =
false;
534 if (provider ==
null)
536 metadataReaderProvider?.
Dispose();
555 if (majorVersion < 256)
560 if (minorVersion != 256)
593 num2 = deflateStream.TryReadAll(
new Span<byte>(nativeHeapMemoryBlock.
Pointer, nativeHeapMemoryBlock.
Size));
599 if (num2 != nativeHeapMemoryBlock.
Size)
614 nativeHeapMemoryBlock.
Dispose();
617 return nativeHeapMemoryBlock;
static readonly ImmutableArray< T > Empty
Exception? InnerException
static ? string GetDirectoryName(string? path)
static byte Min(byte val1, byte val2)
unsafe BlobReader GetReader()
static bool IsFileStream(Stream stream)
static ImmutableArray< byte > DangerousCreateFromUnderlyingArray(ref byte[]? array)
Stream GetStream(out StreamConstraints constraints)
AbstractMemoryBlock GetMemoryBlock()
void Dispose(bool disposing)
unsafe override byte * Pointer
static int GetAndValidateSize(Stream stream, int size, string streamParameterName)
static unsafe NativeHeapMemoryBlock ReadMemoryBlockNoLock(Stream stream, bool isFileStream, long start, int size)
AbstractMemoryBlock _lazyMetadataBlock
MemoryBlockProvider GetPEImage()
bool IsEntireImageAvailable
PEMemoryBlock GetEntireImage()
unsafe PEReader(byte *peImage, int size, bool isLoadedImage)
static ImmutableArray< DebugDirectoryEntry > ReadDebugDirectoryEntries(BlobReader reader)
bool TryOpenPortablePdbFile(string path, BlobContentId id, Func< string, Stream > pdbFileStreamProvider, out MetadataReaderProvider provider, ref Exception errorToReport)
bool TryOpenAssociatedPortablePdb(string peImagePath, Func< string, Stream?> pdbFileStreamProvider, out MetadataReaderProvider? pdbReaderProvider, out string? pdbPath)
static PEHeaders ReadPEHeadersNoLock(Stream stream, long imageStartPosition, int imageSize, bool isLoadedImage)
AbstractMemoryBlock[] _lazyPESectionBlocks
ImmutableArray< DebugDirectoryEntry > ReadDebugDirectory()
static unsafe NativeHeapMemoryBlock DecodeEmbeddedPortablePdbDebugDirectoryData(AbstractMemoryBlock block)
MetadataReaderProvider ReadEmbeddedPortablePdbDebugDirectoryData(DebugDirectoryEntry entry)
AbstractMemoryBlock GetPESectionBlock(int index)
AbstractMemoryBlock _lazyImageBlock
PEMemoryBlock GetSectionData(int relativeVirtualAddress)
unsafe PEReader(byte *peImage, int size)
static void ValidateEmbeddedPortablePdbVersion(DebugDirectoryEntry entry)
CodeViewDebugDirectoryData ReadCodeViewDebugDirectoryData(DebugDirectoryEntry entry)
PEReader(ImmutableArray< byte > peImage)
PEMemoryBlock GetMetadata()
AbstractMemoryBlock GetEntireImageBlock()
AbstractMemoryBlock GetDebugDirectoryEntryDataBlock(DebugDirectoryEntry entry)
static PdbChecksumDebugDirectoryData DecodePdbChecksumDebugDirectoryData(AbstractMemoryBlock block)
void InitializePEHeaders()
PEMemoryBlock GetSectionData(string sectionName)
PEReader(Stream peStream, PEStreamOptions options)
static CodeViewDebugDirectoryData DecodeCodeViewDebugDirectoryData(AbstractMemoryBlock block)
void TryOpenEmbeddedPortablePdb(DebugDirectoryEntry embeddedPdbEntry, ref bool openedEmbeddedPdb, ref MetadataReaderProvider provider, ref Exception errorToReport)
MemoryBlockProvider _peImage
PdbChecksumDebugDirectoryData ReadPdbChecksumDebugDirectoryData(DebugDirectoryEntry entry)
bool TryOpenCodeViewPortablePdb(DebugDirectoryEntry codeViewEntry, string peImageDirectory, Func< string, Stream > pdbFileStreamProvider, out MetadataReaderProvider provider, out string pdbPath, ref Exception errorToReport)
AbstractMemoryBlock GetMetadataBlock()
PEReader(Stream peStream)
unsafe PEReader(Stream peStream, PEStreamOptions options, int size)
static void ArgumentNull(string parameterName)
static void InvalidOperation_PEImageNotAvailable()
static void ArgumentOutOfRange(string parameterName)
static void PEReaderDisposed()
static void InvalidArgument(string message, string parameterName)
static ExceptionDispatchInfo Capture(Exception source)
static string InvalidPdbChecksumDataFormat
static string InvalidDirectoryRVA
static string InvalidDirectorySize
static string SizeMismatch
static string Format(string resourceFormat, object p1)
static string InvalidDebugDirectoryEntryCharacteristics
static string PEImageDoesNotHaveMetadata
static string UnexpectedDebugDirectoryType
static string UnsupportedFormatVersion
static string StreamMustSupportReadAndSeek
static string UnexpectedEmbeddedPortablePdbDataSignature
static string UnexpectedCodeViewDataSignature
static int CompareExchange(ref int location1, int value, int comparand)
readonly? object GuardOpt
DebugDirectoryEntryType Type