/// <summary> /// Checks whether given PDB stream has Portable format. /// </summary> /// <param name="pdbStream">Stream.</param> /// <returns>Returns true if the given stream starts with a Portable PDB signature.</returns> /// <exception cref="ArgumentException"><paramref name="pdbStream"/> does not support read and seek operations.</exception> /// <exception cref="ArgumentNullException"><paramref name="pdbStream"/> is null.</exception> /// <exception cref="IOException">IO error while reading from or writing to a stream.</exception> /// <exception cref="ObjectDisposedException">Stream has been disposed while reading.</exception> public static bool IsPortable(Stream pdbStream) { StreamUtilities.ValidateStream(pdbStream, nameof(pdbStream), readRequired: true, seekRequired: true); return(SymReaderHelpers.IsPortable(pdbStream)); }
/// <summary> /// Converts Portable PDB stream to Windows PDB. /// </summary> /// <param name="peStream">PE image stream (.dll or .exe)</param> /// <param name="sourcePdbStream">Source stream of Portable PDB data. Must be readable.</param> /// <param name="targetPdbStream">Target stream of Windows PDB data. Must be writable.</param> /// <param name="options">Conversion options.</param> /// <exception cref="ArgumentNullException"><paramref name="peStream"/>, <paramref name="sourcePdbStream"/>, or <paramref name="targetPdbStream"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="peStream"/> does not support read and seek operations.</exception> /// <exception cref="ArgumentException"><paramref name="sourcePdbStream"/> does not support reading.</exception> /// <exception cref="ArgumentException"><paramref name="targetPdbStream"/> does not support writing.</exception> /// <exception cref="BadImageFormatException">The format of the PE image or the source PDB image is invalid.</exception> /// <exception cref="InvalidDataException">The PDB doesn't match the CodeView Debug Directory record in the PE image.</exception> /// <exception cref="IOException">IO error while reading from or writing to a stream.</exception> /// <exception cref="ObjectDisposedException">Stream has been disposed while reading/writing.</exception> public void ConvertPortableToWindows(Stream peStream, Stream sourcePdbStream, Stream targetPdbStream, PortablePdbConversionOptions?options = null) { StreamUtilities.ValidateStream(peStream, nameof(peStream), readRequired: true, seekRequired: true); using var peReader = new PEReader(peStream, PEStreamOptions.LeaveOpen); ConvertPortableToWindows(peReader, sourcePdbStream, targetPdbStream, options); }