C++

Note

You can also find the Doxygen documentation here: here

inline std::unique_ptr<DebugInfo> LIEF::pdb::load(const std::string &pdb_path)

Load the PDB file from the given path.

DebugInfo

class DebugInfo : public LIEF::DebugInfo

This class provides an interface for PDB files. One can instantiate this class using LIEF::pdb::load() or LIEF::pdb::DebugInfo::from_file.

Public Types

using compilation_units_it = iterator_range<CompilationUnit::Iterator>

Iterator over the CompilationUnit.

using public_symbols_it = iterator_range<PublicSymbol::Iterator>

Iterator over the symbols located in the PDB public symbol stream.

using types_it = iterator_range<Type::Iterator>

Iterator over the PDB’s types.

Public Functions

inline virtual FORMAT format() const override
compilation_units_it compilation_units() const

Iterator over the CompilationUnit from the PDB’s DBI stream. CompilationUnit are also named “Module” in the PDB’s official documentation.

public_symbols_it public_symbols() const

Return an iterator over the public symbol stream.

types_it types() const

Return an iterator over the different types registered in this PDB.

std::unique_ptr<Type> find_type(const std::string &name) const

Find the type with the given name.

std::unique_ptr<PublicSymbol> find_public_symbol(const std::string &name) const

Try to find the PublicSymbol from the given name (based on the public symbol stream)

The function returns a nullptr if the symbol can’t be found

const DebugInfo& info = ...;
if (auto found = info.find_public_symbol("MiSyncSystemPdes")) {
  // FOUND!
}
uint32_t age() const

The number of times the PDB file has been written.

std::string guid() const

Unique identifier of the PDB file.

virtual ~DebugInfo() override = default
DebugInfo(std::unique_ptr<details::DebugInfo> impl)

Public Static Functions

static std::unique_ptr<DebugInfo> from_file(const std::string &pdb_path)

Instantiate this class from the given PDB file. It returns a nullptr if the PDB can’t be processed.

static inline bool classof(const LIEF::DebugInfo *info)

PublicSymbol

class PublicSymbol

This class provides general information (RVA, name) about a symbol from the PDB’s public symbol stream (or Public symbol hash stream)

Public Types

enum class FLAGS : uint32_t

Values:

enumerator NONE = 0
enumerator CODE = 1 << 0
enumerator FUNCTION = 1 << 1
enumerator MANAGED = 1 << 2
enumerator MSIL = 1 << 3

Public Functions

PublicSymbol(std::unique_ptr<details::PublicSymbol> impl)
~PublicSymbol()
std::string name() const

Name of the symbol.

std::string demangled_name() const

Demangled representation of the symbol.

std::string section_name() const

Name of the section in which this symbol is defined (e.g. .text).

This function returns an empty string if the section’s name can’t be found

uint32_t RVA() const

Relative Virtual Address of this symbol.

This function returns 0 if the RVA can’t be computed.

class Iterator

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = std::unique_ptr<PublicSymbol>
using difference_type = std::ptrdiff_t
using pointer = PublicSymbol*
using reference = PublicSymbol&
using implementation = details::PublicSymbolIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&)
Iterator(std::unique_ptr<details::PublicSymbolIt> impl)
~Iterator()
Iterator &operator++()
inline Iterator operator++(int)
std::unique_ptr<PublicSymbol> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

CompilationUnit

class CompilationUnit

This class represents a CompilationUnit (or Module) in a PDB file.

Public Types

using sources_iterator = iterator_range<std::vector<std::string>::const_iterator>

Iterator over the sources file (std::string)

using function_iterator = iterator_range<Function::Iterator>

Public Functions

CompilationUnit(std::unique_ptr<details::CompilationUnit> impl)
~CompilationUnit()
std::string module_name() const

Name (or path) to the COFF object (.obj) associated with this compilation unit (e.g. e:\obj.amd64fre\minkernel\ntos\hvl\mp\objfre\amd64\hvlp.obj)

std::string object_filename() const

Name of path to the original binary object (COFF, Archive) in which the compilation unit was located before being linked. e.g. e:\obj.amd64fre\minkernel\ntos\hvl\mp\objfre\amd64\hvl.lib

sources_iterator sources() const

Iterator over the sources files that compose this compilation unit. These files also include headers (.h, .hpp, …).

function_iterator functions() const

Return an iterator over the function defined in this compilation unit. If the PDB does not contain or has an empty DBI stream, it returns an empty iterator.

class Iterator

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = std::unique_ptr<CompilationUnit>
using difference_type = std::ptrdiff_t
using pointer = CompilationUnit*
using reference = CompilationUnit&
using implementation = details::CompilationUnitIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&)
Iterator(std::unique_ptr<details::CompilationUnitIt> impl)
~Iterator()
Iterator &operator++()
Iterator &operator--()
inline Iterator operator--(int)
inline Iterator operator++(int)
std::unique_ptr<CompilationUnit> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Function

class Function

Public Functions

Function(std::unique_ptr<details::Function> impl)
~Function()
std::string name() const

The name of the function (this name is usually demangled)

uint32_t RVA() const

The Relative Virtual Address of the function.

uint32_t code_size() const

The size of the function.

std::string section_name() const

The name of the section in which this function is defined.

debug_location_t debug_location() const

Original source code location.

class Iterator

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = std::unique_ptr<Function>
using difference_type = std::ptrdiff_t
using pointer = Function*
using reference = Function&
using implementation = details::FunctionIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&)
Iterator(std::unique_ptr<details::FunctionIt> impl)
~Iterator()
Iterator &operator++()
inline Iterator operator++(int)
std::unique_ptr<Function> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Type

class Type

This is the base class for any PDB type.

Subclassed by LIEF::pdb::types::Array, LIEF::pdb::types::BitField, LIEF::pdb::types::ClassLike, LIEF::pdb::types::Enum, LIEF::pdb::types::Function, LIEF::pdb::types::Modifier, LIEF::pdb::types::Pointer, LIEF::pdb::types::Simple

Public Types

enum class KIND

Values:

enumerator UNKNOWN = 0
enumerator CLASS
enumerator POINTER
enumerator SIMPLE
enumerator ENUM
enumerator FUNCTION
enumerator MODIFIER
enumerator BITFIELD
enumerator ARRAY
enumerator UNION
enumerator STRUCTURE
enumerator INTERFACE

Public Functions

KIND kind() const
template<class T>
inline const T *as() const
virtual ~Type()

Public Static Functions

static std::unique_ptr<Type> create(std::unique_ptr<details::Type> impl)
class Iterator

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = std::unique_ptr<Type>
using difference_type = std::ptrdiff_t
using pointer = Type*
using reference = Type&
using implementation = details::TypeIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::TypeIt> impl)
~Iterator()
Iterator &operator++()
inline Iterator operator++(int)
std::unique_ptr<Type> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Array

class Array : public LIEF::pdb::Type

This class represents a LF_ARRAY PDB type.

Public Functions

~Array() override

Public Static Functions

static inline bool classof(const Type *type)

Attribute (type)

class Attribute

This class represents an attribute (LF_MEMBER) in an aggregate (class, struct, union, …)

Public Functions

Attribute(std::unique_ptr<details::Attribute> impl)
std::string name() const

Name of the attribute.

std::unique_ptr<Type> type() const

Type of this attribute.

uint64_t field_offset() const

Offset of this attribute in the aggregate.

~Attribute()
class Iterator

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = std::unique_ptr<Attribute>
using difference_type = std::ptrdiff_t
using pointer = Attribute*
using reference = Attribute&
using implementation = details::AttributeIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::AttributeIt> impl)
~Iterator()
Iterator &operator++()
inline Iterator operator++(int)
std::unique_ptr<Attribute> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

BitField

class BitField : public LIEF::pdb::Type

This class represents a LF_BITFIELD PDB type.

Public Functions

~BitField() override

Public Static Functions

static inline bool classof(const Type *type)

ClassLike

class ClassLike : public LIEF::pdb::Type

This class abstracts the following PDB types: LF_STRUCTURE, LF_INTERFACE, LF_CLASS or LF_UNION.

Subclassed by LIEF::pdb::types::Class, LIEF::pdb::types::Interface, LIEF::pdb::types::Structure, LIEF::pdb::types::Union

Public Types

using attributes_iterator = iterator_range<Attribute::Iterator>

Attributes iterator.

using methods_iterator = iterator_range<Method::Iterator>

Methods iterator.

Public Functions

std::string unique_name() const

Mangled type name.

std::string name() const

Demangled type name.

attributes_iterator attributes() const

Iterator over the different attributes defined in this class-like type.

methods_iterator methods() const

Iterator over the different methods implemented in this class-type type.

uint64_t size() const

Size of the type including all its attributes. This size should match the sizeof(...) this type.

~ClassLike() override

Public Static Functions

template<class T>
static inline bool classof(const T*, typename std::enable_if<std::is_base_of<ClassLike, T>::value>::type* = 0)

Structure

class Structure : public LIEF::pdb::types::ClassLike

Interface for the LF_STRUCTURE PDB type.

Public Functions

~Structure() override

Public Static Functions

static inline bool classof(const Type *type)

Class

class Class : public LIEF::pdb::types::ClassLike

Interface for the LF_CLASS PDB type.

Public Functions

~Class() override

Public Static Functions

static inline bool classof(const Type *type)

Interface

class Interface : public LIEF::pdb::types::ClassLike

Interface for the LF_INTERFACE PDB type.

Public Functions

~Interface() override

Public Static Functions

static inline bool classof(const Type *type)

Enum

class Enum : public LIEF::pdb::Type

This class represents a LF_ENUM PDB type.

Public Functions

~Enum() override

Public Static Functions

static inline bool classof(const Type *type)

Function (type)

class Function : public LIEF::pdb::Type

This class represents a LF_PROCEDURE PDB type.

Public Functions

~Function() override

Public Static Functions

static inline bool classof(const Type *type)

Method (type)

class Method

This class represents a Method (LF_ONEMETHOD) that can be defined in ClassLike PDB type.

Public Functions

Method(std::unique_ptr<details::Method> impl)
std::string name() const

Name of the method.

~Method()
class Iterator

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = std::unique_ptr<Method>
using difference_type = std::ptrdiff_t
using pointer = Method*
using reference = Method&
using implementation = details::MethodIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::MethodIt> impl)
~Iterator()
Iterator &operator++()
inline Iterator operator++(int)
std::unique_ptr<Method> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Modifier

class Modifier : public LIEF::pdb::Type

This class represents a LF_MODIFIER PDB type.

Public Functions

std::unique_ptr<Type> underlying_type() const

Underlying type targeted by this modifier.

~Modifier() override

Public Static Functions

static inline bool classof(const Type *type)

Pointer

class Pointer : public LIEF::pdb::Type

This class represents a LF_POINTER PDB type.

Public Functions

std::unique_ptr<Type> underlying_type() const

The underlying type pointed by this pointer.

~Pointer() override

Public Static Functions

static inline bool classof(const Type *type)

Simple

class Simple : public LIEF::pdb::Type

This class represents a primitive types (int, float, …) which are also named simple types in the PDB format.

Public Functions

~Simple() override

Public Static Functions

static inline bool classof(const Type *type)

Union

class Union : public LIEF::pdb::types::ClassLike

This class represents a LF_UNION PDB type.

Public Functions

~Union() override

Public Static Functions

static inline bool classof(const Type *type)