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.

std::string to_string() const

Pretty representation.

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)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const DebugInfo &dbg)

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.

std::string to_string() const

Friends

inline friend std::ostream &operator<<(std::ostream &os, const PublicSymbol &sym)
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.

std::unique_ptr<BuildMetadata> build_metadata() const

Return build metadata such as the version of the compiler or the original source language of this compilation unit.

std::string to_string() const

Friends

inline friend std::ostream &operator<<(std::ostream &os, const CompilationUnit &CU)
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

BuildMetadata

class BuildMetadata

This class wraps build metadata represented by the codeview symbols: S_COMPILE3, S_COMPILE2, S_BUILDINFO, S_ENVBLOCK

Public Types

enum class LANG : uint8_t

Values:

enumerator C = 0x00
enumerator CPP = 0x01
enumerator FORTRAN = 0x02
enumerator MASM = 0x03
enumerator PASCAL_LANG = 0x04
enumerator BASIC = 0x05
enumerator COBOL = 0x06
enumerator LINK = 0x07
enumerator CVTRES = 0x08
enumerator CVTPGD = 0x09
enumerator CSHARP = 0x0a
enumerator VB = 0x0b
enumerator ILASM = 0x0c
enumerator JAVA = 0x0d
enumerator JSCRIPT = 0x0e
enumerator MSIL = 0x0f
enumerator HLSL = 0x10
enumerator OBJC = 0x11
enumerator OBJCPP = 0x12
enumerator SWIFT = 0x13
enumerator ALIASOBJ = 0x14
enumerator RUST = 0x15
enumerator GO = 0x16
enumerator UNKNOWN = 0xFF
enum class CPU : uint16_t

Values:

enumerator INTEL_8080 = 0x0
enumerator INTEL_8086 = 0x1
enumerator INTEL_80286 = 0x2
enumerator INTEL_80386 = 0x3
enumerator INTEL_80486 = 0x4
enumerator PENTIUM = 0x5
enumerator PENTIUMPRO = 0x6
enumerator PENTIUM3 = 0x7
enumerator MIPS = 0x10
enumerator MIPS16 = 0x11
enumerator MIPS32 = 0x12
enumerator MIPS64 = 0x13
enumerator MIPSI = 0x14
enumerator MIPSII = 0x15
enumerator MIPSIII = 0x16
enumerator MIPSIV = 0x17
enumerator MIPSV = 0x18
enumerator M68000 = 0x20
enumerator M68010 = 0x21
enumerator M68020 = 0x22
enumerator M68030 = 0x23
enumerator M68040 = 0x24
enumerator ALPHA = 0x30
enumerator ALPHA_21164 = 0x31
enumerator ALPHA_21164A = 0x32
enumerator ALPHA_21264 = 0x33
enumerator ALPHA_21364 = 0x34
enumerator PPC601 = 0x40
enumerator PPC603 = 0x41
enumerator PPC604 = 0x42
enumerator PPC620 = 0x43
enumerator PPCFP = 0x44
enumerator PPCBE = 0x45
enumerator SH3 = 0x50
enumerator SH3E = 0x51
enumerator SH3DSP = 0x52
enumerator SH4 = 0x53
enumerator SHMEDIA = 0x54
enumerator ARM3 = 0x60
enumerator ARM4 = 0x61
enumerator ARM4T = 0x62
enumerator ARM5 = 0x63
enumerator ARM5T = 0x64
enumerator ARM6 = 0x65
enumerator ARM_XMAC = 0x66
enumerator ARM_WMMX = 0x67
enumerator ARM7 = 0x68
enumerator OMNI = 0x70
enumerator IA64 = 0x80
enumerator IA64_2 = 0x81
enumerator CEE = 0x90
enumerator AM33 = 0xa0
enumerator M32R = 0xb0
enumerator TRICORE = 0xc0
enumerator X64 = 0xd0
enumerator EBC = 0xe0
enumerator THUMB = 0xf0
enumerator ARMNT = 0xf4
enumerator ARM64 = 0xf6
enumerator HYBRID_X86ARM64 = 0xf7
enumerator ARM64EC = 0xf8
enumerator ARM64X = 0xf9
enumerator D3D11_SHADER = 0x100
enumerator UNKNOWN = 0xff

Public Functions

BuildMetadata(std::unique_ptr<details::BuildMetadata> impl)
~BuildMetadata()
version_t frontend_version() const

Version of the frontend (e.g. 19.36.32537)

version_t backend_version() const

Version of the backend (e.g. 14.36.32537)

std::string version() const

Version of the tool as a string. For instance, Microsoft (R) CVTRES, Microsoft (R) LINK.

LANG language() const

Source language.

CPU target_cpu() const

Target CPU.

optional<build_info_t> build_info() const

Build information represented by the S_BUILDINFO symbol.

std::vector<std::string> env() const

Environment information represented by the S_ENVBLOCK symbol.

std::string to_string() const

Friends

inline friend std::ostream &operator<<(std::ostream &os, const BuildMetadata &meta)
struct build_info_t

This structure represents information wrapped by the S_BUILDINFO symbol.

Public Members

std::string cwd

Working directory where the build tool was invoked.

std::string build_tool

Path to the build tool (e.g. C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64\CL.exe)

std::string source_file

Source file consumed by the build tool

std::string pdb

PDB path.

std::string command_line

Command line arguments used to invoke the build tool

struct version_t

This structure represents a version for the backend or the frontend.

Public Members

uint16_t major = 0

Major version.

uint16_t minor = 0

Minor version.

uint16_t build = 0

Build version.

uint16_t qfe = 0

Quick Fix Engineeringa version.


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.

std::string to_string() const

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Function &F)
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)