Skip to main content

Pdb

Struct Pdb 

Source
pub struct Pdb<F = RandomAccessFile> { /* private fields */ }
Expand description

Allows reading the contents of a PDB file.

This type provides read-only access. It does not provide any means to modify a PDB file or to create a new one.

Implementations§

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn read_fixups(&self) -> Result<Option<Vec<Fixup>>>

Reads (uncached) the FIXUP_DATA optional debug stream.

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn read_dbi_stream_header(&self) -> Result<DbiStreamHeader>

Reads the header of the DBI stream. This does not validate the header.

Source

pub fn read_dbi_stream(&self) -> Result<DbiStream<Vec<u8>>, Error>

Reads the entire DBI Stream, validates the header, and then returns an object that can be used for further queries of the DBI Stream.

Source

pub fn read_modules(&self) -> Result<ModInfoSubstream<Vec<u8>>>

Reads the module substream data from the DBI stream.

This function always reads the data from the file. It does not cache the data.

Source

pub fn modules(&self) -> Result<&ModInfoSubstream<Vec<u8>>>

Gets access to the DBI Modules Substream. This will read the DBI Modules Substream on-demand, and will cache it.

Source

pub fn read_sources_data(&self) -> Result<Vec<u8>>

Reads the DBI Sources Substream. This always reads the data, and does not cache it.

Source

pub fn sources_data(&self) -> Result<&[u8]>

Gets access to the DBI Sources Substream data.

Source

pub fn sources(&self) -> Result<DbiSourcesSubstream<'_>>

Gets access to the DBI Sources Substream and parses the header.

Source

pub fn drop_sources(&mut self)

Drops the cached DBI Sources Substream data, if any.

Source

pub fn read_section_contributions(&self) -> Result<Vec<u32>>

Reads the contents of the DBI Section Contributions Substream. This function never caches the data; it is always read unconditionally.

The returned buffer is Vec<u32> instead of Vec<u8> so that natural alignment is guaranteed.

Source

pub fn read_optional_debug_streams(&self) -> Result<OptionalDebugHeaders>

Reads (uncached) the DBI Optional Debug Streams Substream.

Source

pub fn fixup_stream(&self) -> Result<Option<u32>>

Gets the stream index of the FIXUP_DATA optional debug stream.

Source

pub fn optional_debug_streams(&self) -> Result<&OptionalDebugHeaders>

Gets the DBI Optional Debug Streams Substream.

Source

pub fn optional_debug_stream( &self, i: OptionalDebugStream, ) -> Result<Option<u32>>

Gets the stream index of a specific Optional Debug Stream.

Source

pub fn read_section_headers(&self) -> Result<Box<[IMAGE_SECTION_HEADER]>>

Reads (uncached) the contents of the “Section Headers” Optional Debug Stream.

Source

pub fn section_headers(&self) -> Result<&[IMAGE_SECTION_HEADER]>

Gets the contents of the “Section Headers” Optional Debug Stream.

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn read_gss(&self) -> Result<GlobalSymbolStream>

Reads the Global Symbol Stream (GSS). This stream contains global symbol records.

This function does not validate the contents of the stream.

Source

pub fn read_gsi(&self) -> Result<GlobalSymbolIndex>

Reads the Global Symbol Index (GSI). This stream contains a name-to-symbol lookup table. It indexes many global symbols, such as S_GPROCREF, S_CONSTANT, etc.

Source

pub fn read_psi(&self) -> Result<PublicSymbolIndex>

Reads the Public Symbol Index.

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn read_module_stream( &self, mod_info: &ModuleInfo<'_>, ) -> Result<Option<ModiStreamData<StreamData>>, Error>

Reads a Module Info stream. The caller must provide a ModuleInfo structure, which comes from the DBI Stream. Use crate::dbi::read_dbi_stream to enumerate ModuleInfo values.

If the Module Info record has a NIL stream, then this function returns Ok(None).

Source

pub fn read_module_symbols(&self, module: &ModuleInfo<'_>) -> Result<Vec<u32>>

Reads the symbol data for a specific module.

The returned buffer will contain a 4-byte header. The caller can use SymIter::for_module_syms on the returned buffer.

If the given module does not have a module stream, then this function will return Ok with a zero-length buffer, so callers should be prepared to deal with the presence or absence of the 4-byte header.

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn add_embedded_source( &mut self, file_path: &str, file_contents: &[u8], ) -> Result<bool>
where F: WriteAt,

Embeds the contents of a source file into the PDB.

Source

pub fn add_or_replace_named_stream( &mut self, stream_name: &str, stream_contents: &[u8], ) -> Result<bool>
where F: WriteAt,

Sets the contents of a named stream to the given value.

If there is already a named stream with the given name, then the stream’s contents are replaced with stream_contents. First, though, this function reads the contents of the existing stream and compares them to stream_contents. If they are identical, then the stream is not modified and this function will return Ok(true). If the contents are not identical, then this function returns Ok(true).

If there is not already a named stream with given name, then a new stream is created and an entry is added to the Named Streams Map. In this case, the function returns Ok(false).

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn read_type_stream(&self) -> Result<TypeStream<Vec<u8>>>

Reads the TPI stream.

Source

pub fn read_ipi_stream(&self) -> Result<TypeStream<Vec<u8>>>

Reads the IPI stream.

Source

pub fn read_tpi_or_ipi_stream( &self, stream_index: Stream, ) -> Result<TypeStream<Vec<u8>>>

Reads the TPI or IPI stream.

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn pdbi(&self) -> &PdbiStream

Gets access to the PDB Information Stream.

This loads the PDBI on-demand. The PDBI is usually fairly small.

Source

pub fn named_streams(&self) -> &NamedStreams

Gets access to the Named Streams table.

Source

pub fn named_streams_mut(&mut self) -> &mut NamedStreams

Gets mutable access to the Named Streams table.

Source

pub fn named_stream(&self, name: &str) -> Option<u32>

Searches the Named Streams table for a stream with a given name. Returns None if the stream is not found.

Source

pub fn named_stream_err(&self, name: &str) -> Result<u32>

Searches the Named Streams table for a stream with a given name. Returns an error if the stream is not found.

Source

pub fn dbi_header(&self) -> &DbiStreamHeader

The header of the DBI Stream.

Source

pub fn dbi_substreams(&self) -> &DbiSubstreamRanges

The byte ranges of the DBI substreams.

Source

pub fn tpi_header(&self) -> Result<&CachedTypeStreamHeader>

Gets the TPI Stream Header.

This loads the TPI Stream Header on-demand. This does not load the rest of the TPI Stream.

Source

pub fn ipi_header(&self) -> Result<&CachedTypeStreamHeader>

Gets the IPI Stream Header.

This loads the IPI Stream Header on-demand. This does not load the rest of the TPI Stream.

Source

pub fn names(&self) -> Result<&NamesStream<Vec<u8>>>

Gets the Names Stream

This loads the Names Stream on-demand.

Source

pub fn get_name(&self, offset: NameIndex) -> Result<&BStr>

Gets a name from the Names Stream.

Source

pub fn binding_key(&self) -> BindingKey

The binding key that associates this PDB with a given PE executable.

Source

pub fn has_feature(&self, feature_code: FeatureCode) -> bool

Checks whether this PDB has a given feature enabled.

Source

pub fn mini_pdb(&self) -> bool

Indicates that this PDB was built using the “Mini PDB” option, i.e. /DEBUG:FASTLINK.

Source

pub fn gss(&self) -> Result<&GlobalSymbolStream>

Gets a reference to the Global Symbol Stream (GSS). This loads the GSS on-demand.

Source

pub fn gss_drop(&mut self)

If the GSS has been loaded by using the gss() function, then this method frees it.

Source

pub fn gsi(&self) -> Result<&GlobalSymbolIndex>

Gets a reference to the Global Symbol Index (GSI). This loads the GSI on-demand.

Source

pub fn gsi_drop(&mut self)

If the GSI has been loaded by using the gsi() function, then this method frees it.

Source

pub fn psi(&self) -> Result<&PublicSymbolIndex>

Gets a reference to the Public Symbol Index (PSI). This loads the PSI on-demand.

Source

pub fn psi_drop(&mut self)

If the PSI has been loaded by using the psi() function, then this method frees it.

Source

pub fn find_public_by_name(&self, name: &BStr) -> Result<Option<Pub<'_>>>

Searches for an S_PUB32 symbol by name.

Source

pub fn find_global_by_name(&self, name: &BStr) -> Result<Option<Sym<'_>>>

Searches for a global symbol symbol by name.

This uses the Global Symbol Index (GSI). This index does not contain S_PUB32 records. Use find_public_by_name to search for S_PUB32 records.

Source

pub fn flush_all(&mut self) -> Result<bool>
where F: WriteAt,

Writes any changes that have been buffered in memory to disk. However, this does not commit the changes. It is still necessary to call the commit() method.

The return value indicates whether any changes were written to disk. Ok(true) indicates that some change were written to disk. Ok(false) indicates that there were no buffered changes and nothing has been written to disk.

Source

pub fn container(&self) -> &Container<F>

Gets access to the underlying container.

Source

pub fn linker_module(&self) -> Result<ModuleInfo<'_>>

Find the "* Linker *" module, which contains the S_COFFGROUP symbols.

If the PDB does not contain a linker module then this returns Err.

Source

pub fn linker_module_opt(&self) -> Result<Option<ModuleInfo<'_>>>

Find the "* Linker *" module, which contains the S_COFFGROUP symbols.

If the PDB does not contain a linker module then this returns Ok(None).

Source

pub fn coff_groups(&self) -> Result<&CoffGroups>

Gets the list of COFF groups defined in this binary.

Source

pub fn read_coff_groups(&self) -> Result<CoffGroups>

Reads (uncached) the list of COFF groups defined in this binary.

Source

pub fn machine(&self) -> IMAGE_FILE_MACHINE

Returns the target architecture for this PE binary.

Source

pub fn arch(&self) -> Result<Arch>

Returns the target CPU architecture.

Source§

impl Pdb<RandomAccessFile>

Source

pub fn open(file_name: &Path) -> Result<Box<Pdb<RandomAccessFile>>>

Opens a PDB file.

Source

pub fn open_from_file(file: File) -> Result<Box<Self>>

Reads the header of a PDB file and provides access to the streams contained within the PDB file.

This function reads the MSF File Header, which is the header for the entire file. It also reads the stream directory, so it knows how to find each of the streams and the pages of the streams.

Source

pub fn modify(filename: &Path) -> Result<Box<Pdb<RandomAccessFile>>>

Opens a PDB file for editing. The file must use the MSF container format.

Source

pub fn modify_from_file(file: File) -> Result<Box<Self>>

Opens an existing PDB file for read/write access, given a file name.

The file must use the MSF container format. MSFZ is not supported for read/write access.

Source§

impl<F: ReadAt> Pdb<F>

Source

pub fn open_from_random_file(random_file: F) -> Result<Box<Self>>

Reads the header of a PDB file and provides access to the streams contained within the PDB file.

This function reads the MSF File Header, which is the header for the entire file. It also reads the stream directory, so it knows how to find each of the streams and the pages of the streams.

Source

pub fn modify_from_random_file(random_file: F) -> Result<Box<Self>>

Opens an existing PDB file for read/write access, given a file name.

The file must using the MSF container format. MSFZ is not supported for read/write access.

Methods from Deref<Target = Container<F>>§

Source

pub fn msf(&self) -> Option<&Msf<F>>

Provides direct access to the MSF layer. If this PDB file is using MSFZ instead of MSF, then this function returns None.

Source

pub fn msf_mut(&mut self) -> Option<&mut Msf<F>>

Provides direct, mutable access to the MSF layer. If this PDB file is using MSFZ instead of MSF, then this function returns None.

Source

pub fn msf_mut_err(&mut self) -> Result<&mut Msf<F>>

Provides direct, mutable access to the MSF layer. If this PDB file is using MSFZ instead of MSF, then this function returns None.

Source

pub fn num_streams(&self) -> u32

The total number of streams in this PDB.

Some streams may be NIL.

Source

pub fn get_stream_reader(&self, stream: u32) -> Result<StreamReader<'_, F>>

Returns an object which can read from a given stream. The returned object implements the Read, Seek, and ReadAt traits.

Source

pub fn read_stream_to_vec(&self, stream: u32) -> Result<Vec<u8>>

Reads an entire stream to a vector.

Source

pub fn read_stream(&self, stream: u32) -> Result<StreamData>

Reads an entire stream to a vector.

If the stream data is stored within a single compressed chunk, then this function returns a reference to the decompressed stream data.

Source

pub fn read_stream_to_vec_mut( &self, stream: u32, stream_data: &mut Vec<u8>, ) -> Result<()>

Reads an entire stream into an existing vector.

Source

pub fn stream_len(&self, stream: u32) -> u64

Gets the length of a given stream, in bytes.

The stream value must be in a valid range of 0..num_streams().

If stream is a NIL stream, this function returns 0.

Source

pub fn is_stream_valid(&self, stream: u32) -> bool

Returns true if stream is a valid stream index and is not a nil stream.

Trait Implementations§

Source§

impl<F> Deref for Pdb<F>

Source§

type Target = Container<F>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<F> DerefMut for Pdb<F>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<F = RandomAccessFile> !Freeze for Pdb<F>

§

impl<F = RandomAccessFile> !RefUnwindSafe for Pdb<F>

§

impl<F> Send for Pdb<F>
where F: Send,

§

impl<F = RandomAccessFile> !Sync for Pdb<F>

§

impl<F> Unpin for Pdb<F>
where F: Unpin,

§

impl<F> UnwindSafe for Pdb<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more