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>
impl<F: ReadAt> Pdb<F>
Sourcepub fn read_dbi_stream_header(&self) -> Result<DbiStreamHeader>
pub fn read_dbi_stream_header(&self) -> Result<DbiStreamHeader>
Reads the header of the DBI stream. This does not validate the header.
Sourcepub fn read_dbi_stream(&self) -> Result<DbiStream<Vec<u8>>, Error>
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.
Sourcepub fn read_modules(&self) -> Result<ModInfoSubstream<Vec<u8>>>
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.
Sourcepub fn modules(&self) -> Result<&ModInfoSubstream<Vec<u8>>>
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.
Sourcepub fn read_sources_data(&self) -> Result<Vec<u8>>
pub fn read_sources_data(&self) -> Result<Vec<u8>>
Reads the DBI Sources Substream. This always reads the data, and does not cache it.
Sourcepub fn sources_data(&self) -> Result<&[u8]>
pub fn sources_data(&self) -> Result<&[u8]>
Gets access to the DBI Sources Substream data.
Sourcepub fn sources(&self) -> Result<DbiSourcesSubstream<'_>>
pub fn sources(&self) -> Result<DbiSourcesSubstream<'_>>
Gets access to the DBI Sources Substream and parses the header.
Sourcepub fn drop_sources(&mut self)
pub fn drop_sources(&mut self)
Drops the cached DBI Sources Substream data, if any.
Sourcepub fn read_section_contributions(&self) -> Result<Vec<u8>>
pub fn read_section_contributions(&self) -> Result<Vec<u8>>
Reads the contents of the DBI Section Contributions Substream. This function never caches the data; it is always read unconditionally.
Source§impl<F: ReadAt> Pdb<F>
impl<F: ReadAt> Pdb<F>
Sourcepub fn read_gss(&self) -> Result<GlobalSymbolStream>
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.
Sourcepub fn read_gsi(&self) -> Result<GlobalSymbolIndex>
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.
Sourcepub fn read_psi(&self) -> Result<PublicSymbolIndex>
pub fn read_psi(&self) -> Result<PublicSymbolIndex>
Reads the Public Symbol Index.
Source§impl<F: ReadAt> Pdb<F>
impl<F: ReadAt> Pdb<F>
Sourcepub fn read_module_stream(
&self,
mod_info: &ModuleInfo<'_>,
) -> Result<Option<ModiStreamData<StreamData>>, Error>
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§impl<F: ReadAt> Pdb<F>
impl<F: ReadAt> Pdb<F>
Sourcepub fn add_embedded_source(
&mut self,
file_path: &str,
file_contents: &[u8],
) -> Result<bool>where
F: WriteAt,
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.
Sourcepub fn add_or_replace_named_stream(
&mut self,
stream_name: &str,
stream_contents: &[u8],
) -> Result<bool>where
F: WriteAt,
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>
impl<F: ReadAt> Pdb<F>
Sourcepub fn read_type_stream(&self) -> Result<TypeStream<Vec<u8>>>
pub fn read_type_stream(&self) -> Result<TypeStream<Vec<u8>>>
Reads the TPI stream.
Sourcepub fn read_ipi_stream(&self) -> Result<TypeStream<Vec<u8>>>
pub fn read_ipi_stream(&self) -> Result<TypeStream<Vec<u8>>>
Reads the IPI stream.
Sourcepub fn read_tpi_or_ipi_stream(
&self,
stream_index: Stream,
) -> Result<TypeStream<Vec<u8>>>
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>
impl<F: ReadAt> Pdb<F>
Sourcepub fn pdbi(&self) -> &PdbiStream
pub fn pdbi(&self) -> &PdbiStream
Gets access to the PDB Information Stream.
This loads the PDBI on-demand. The PDBI is usually fairly small.
Sourcepub fn named_streams(&self) -> &NamedStreams
pub fn named_streams(&self) -> &NamedStreams
Gets access to the Named Streams table.
Sourcepub fn named_streams_mut(&mut self) -> &mut NamedStreams
pub fn named_streams_mut(&mut self) -> &mut NamedStreams
Gets mutable access to the Named Streams table.
Sourcepub fn named_stream(&self, name: &str) -> Option<u32>
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.
Sourcepub fn named_stream_err(&self, name: &str) -> Result<u32>
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.
Sourcepub fn dbi_header(&self) -> &DbiStreamHeader
pub fn dbi_header(&self) -> &DbiStreamHeader
The header of the DBI Stream.
Sourcepub fn dbi_substreams(&self) -> &DbiSubstreamRanges
pub fn dbi_substreams(&self) -> &DbiSubstreamRanges
The byte ranges of the DBI substreams.
Sourcepub fn tpi_header(&self) -> Result<&CachedTypeStreamHeader>
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.
Sourcepub fn ipi_header(&self) -> Result<&CachedTypeStreamHeader>
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.
Sourcepub fn names(&self) -> Result<&NamesStream<Vec<u8>>>
pub fn names(&self) -> Result<&NamesStream<Vec<u8>>>
Gets the Names Stream
This loads the Names Stream on-demand.
Sourcepub fn binding_key(&self) -> BindingKey
pub fn binding_key(&self) -> BindingKey
The binding key that associates this PDB with a given PE executable.
Sourcepub fn has_feature(&self, feature_code: FeatureCode) -> bool
pub fn has_feature(&self, feature_code: FeatureCode) -> bool
Checks whether this PDB has a given feature enabled.
Sourcepub fn mini_pdb(&self) -> bool
pub fn mini_pdb(&self) -> bool
Indicates that this PDB was built using the “Mini PDB” option, i.e. /DEBUG:FASTLINK.
Sourcepub fn gss(&self) -> Result<&GlobalSymbolStream>
pub fn gss(&self) -> Result<&GlobalSymbolStream>
Gets a reference to the Global Symbol Stream (GSS). This loads the GSS on-demand.
Sourcepub fn gss_drop(&mut self)
pub fn gss_drop(&mut self)
If the GSS has been loaded by using the gss() function, then this method frees it.
Sourcepub fn gsi(&self) -> Result<&GlobalSymbolIndex>
pub fn gsi(&self) -> Result<&GlobalSymbolIndex>
Gets a reference to the Global Symbol Index (GSI). This loads the GSI on-demand.
Sourcepub fn gsi_drop(&mut self)
pub fn gsi_drop(&mut self)
If the GSI has been loaded by using the gsi() function, then this method frees it.
Sourcepub fn psi(&self) -> Result<&PublicSymbolIndex>
pub fn psi(&self) -> Result<&PublicSymbolIndex>
Gets a reference to the Public Symbol Index (PSI). This loads the PSI on-demand.
Sourcepub fn psi_drop(&mut self)
pub fn psi_drop(&mut self)
If the PSI has been loaded by using the psi() function, then this method frees it.
Sourcepub fn find_public_by_name(&self, name: &BStr) -> Result<Option<Pub<'_>>>
pub fn find_public_by_name(&self, name: &BStr) -> Result<Option<Pub<'_>>>
Searches for an S_PUB32 symbol by name.
Sourcepub fn find_global_by_name(&self, name: &BStr) -> Result<Option<Sym<'_>>>
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.
Sourcepub fn flush_all(&mut self) -> Result<bool>where
F: WriteAt,
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§impl Pdb<RandomAccessFile>
impl Pdb<RandomAccessFile>
Sourcepub fn open_from_file(file: File) -> Result<Box<Self>>
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.
Sourcepub fn modify(filename: &Path) -> Result<Box<Pdb<RandomAccessFile>>>
pub fn modify(filename: &Path) -> Result<Box<Pdb<RandomAccessFile>>>
Opens a PDB file for editing. The file must use the MSF container format.
Sourcepub fn modify_from_file(file: File) -> Result<Box<Self>>
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>
impl<F: ReadAt> Pdb<F>
Sourcepub fn open_from_random_file(random_file: F) -> Result<Box<Self>>
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.
Sourcepub fn modify_from_random_file(random_file: F) -> Result<Box<Self>>
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>>§
Sourcepub fn msf(&self) -> Option<&Msf<F>>
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.
Sourcepub fn msf_mut(&mut self) -> Option<&mut Msf<F>>
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.
Sourcepub fn msf_mut_err(&mut self) -> Result<&mut Msf<F>>
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.
Sourcepub fn num_streams(&self) -> u32
pub fn num_streams(&self) -> u32
The total number of streams in this PDB.
Some streams may be NIL.
Sourcepub fn get_stream_reader(&self, stream: u32) -> Result<StreamReader<'_, F>>
pub fn get_stream_reader(&self, stream: u32) -> Result<StreamReader<'_, F>>
Sourcepub fn read_stream_to_vec(&self, stream: u32) -> Result<Vec<u8>>
pub fn read_stream_to_vec(&self, stream: u32) -> Result<Vec<u8>>
Reads an entire stream to a vector.
Sourcepub fn read_stream(&self, stream: u32) -> Result<StreamData>
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.
Sourcepub fn read_stream_to_vec_mut(
&self,
stream: u32,
stream_data: &mut Vec<u8>,
) -> Result<()>
pub fn read_stream_to_vec_mut( &self, stream: u32, stream_data: &mut Vec<u8>, ) -> Result<()>
Reads an entire stream into an existing vector.
Sourcepub fn stream_len(&self, stream: u32) -> u64
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.
Sourcepub fn is_stream_valid(&self, stream: u32) -> bool
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.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
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.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
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.