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.
- 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! }
- virtual std::optional<uint64_t> find_function_address(const std::string &name) const override¶
Attempt to resolve the address of the function specified by
name.
- 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)¶
- using compilation_units_it = iterator_range<CompilationUnit::Iterator>¶
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
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 LIEF::iterator_facade_base<Iterator, std::forward_iterator_tag, PublicSymbol, std::ptrdiff_t, const PublicSymbol*, const PublicSymbol&>¶
Public Types
- using implementation = details::PublicSymbolIt¶
Public Functions
- Iterator()¶
- Iterator(std::unique_ptr<details::PublicSymbolIt> impl)¶
- ~Iterator()¶
- const PublicSymbol &operator*() const¶
- const PublicSymbol *operator->() const¶
- std::unique_ptr<PublicSymbol> yield()¶
Transfer ownership of the public symbol at the current position to the caller. Returns
nullptrif the iterator is past-the-end.
- inline DerivedT operator++(int)¶
- using implementation = details::PublicSymbolIt¶
- PublicSymbol(std::unique_ptr<details::PublicSymbol> impl)¶
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 source files (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 or 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_decl(const DeclOpt &opt = DeclOpt()) const¶
Generate a C/C++ definition for the functions defined in this compilation unit.
- std::string to_string() const¶
Friends
- inline friend std::ostream &operator<<(std::ostream &os, const CompilationUnit &CU)¶
- class Iterator : public LIEF::iterator_facade_base<Iterator, std::bidirectional_iterator_tag, CompilationUnit, std::ptrdiff_t, const CompilationUnit*, const CompilationUnit&>¶
Public Types
- using implementation = details::CompilationUnitIt¶
Public Functions
- Iterator()¶
- Iterator(std::unique_ptr<details::CompilationUnitIt> impl)¶
- ~Iterator()¶
- const CompilationUnit &operator*() const¶
- const CompilationUnit *operator->() const¶
- std::unique_ptr<CompilationUnit> yield()¶
Transfer ownership of the compilation unit at the current position to the caller. Returns
nullptrif the iterator is past-the-end.
- inline DerivedT operator++(int)¶
- inline DerivedT operator--(int)¶
- using implementation = details::CompilationUnitIt¶
- using sources_iterator = iterator_range<std::vector<std::string>::const_iterator>¶
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¶
- enumerator C = 0x00¶
- 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¶
- enumerator INTEL_8080 = 0x0¶
Public Functions
- BuildMetadata(std::unique_ptr<details::BuildMetadata> impl)¶
- ~BuildMetadata()¶
- std::string version() const¶
Version of the tool as a string. For instance,
Microsoft (R) CVTRES,Microsoft (R) LINK.
- std::optional<build_info_t> build_info() const¶
Build information represented by the
S_BUILDINFOsymbol.
- std::vector<std::string> env() const¶
Environment information represented by the
S_ENVBLOCKsymbol.
- std::string to_string() const¶
Friends
- inline friend std::ostream &operator<<(std::ostream &os, const BuildMetadata &meta)¶
- struct version_t¶
This structure represents a version for the backend or the frontend.
- struct build_info_t¶
This structure represents information wrapped by the
S_BUILDINFOsymbol.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.
- std::string cwd¶
- enum class LANG : uint8_t¶
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_decl(const DeclOpt &opt = DeclOpt()) const¶
Generate a C/C++ definition for this function.
- std::string to_string() const¶
- Function(std::unique_ptr<details::Function> impl)¶
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
Public Functions
- Type(std::unique_ptr<details::Type> impl)¶
- std::optional<uint64_t> size() const¶
Size of the type. This size should match the value of
sizeof(...)applied to this type.
- std::string to_decl(const DeclOpt &opt = DeclOpt()) const¶
Generates a C/C++ definition for this type.
- virtual ~Type()¶
- Type(std::unique_ptr<details::Type> impl)¶
Array¶
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.
- uint64_t field_offset() const¶
Offset of this attribute in the aggregate.
- ~Attribute()¶
- Attribute(std::unique_ptr<details::Attribute> impl)¶
BitField¶
ClassLike¶
- class ClassLike : public LIEF::pdb::Type¶
This class abstracts the following PDB types:
LF_STRUCTURE,LF_INTERFACE,LF_CLASSorLF_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
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline ClassLike(Args&&... args)¶
- std::string unique_name() const¶
Mangled 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.
- ~ClassLike() override¶
- using attributes_iterator = iterator_range<Attribute::Iterator>¶
Structure¶
Class¶
Interface¶
Enum¶
- class Enum : public LIEF::pdb::Type¶
This class represents a
LF_ENUMPDB type.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline Enum(Args&&... args)¶
- ~Enum() override¶
- class Entry¶
This class represents an enum entry which is essentially composed of a name and its value (integer).
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
Function (type)¶
Method (type)¶
- class Method¶
This class represents a Method (
LF_ONEMETHOD) that can be defined in a ClassLike PDB type (Class, Structure, Union, Interface).Public Types
- enum class TYPE¶
The type (or property) of the method.
Values:
- enumerator VANILLA = 0x00¶
Regular instance method.
- enumerator VIRTUAL = 0x01¶
Virtual method.
- enumerator STATIC = 0x02¶
Static method.
- enumerator FRIEND = 0x03¶
Friend method.
- enumerator INTRODUCING_VIRTUAL = 0x04¶
Virtual method that introduces a new vtable slot.
- enumerator PURE_VIRTUAL = 0x05¶
Pure virtual method (abstract).
- enumerator PURE_INTRODUCING_VIRTUAL = 0x06¶
Pure virtual method that introduces a new vtable slot.
- enumerator VANILLA = 0x00¶
Public Functions
- Method(std::unique_ptr<details::Method> impl)¶
- std::string name() const¶
Name of the method.
- ~Method()¶
- enum class TYPE¶
Modifier¶
Pointer¶
Simple¶
- class Simple : public LIEF::pdb::Type¶
This class represents primitive types (int, float, …) which are also named simple types in the PDB format.
Public Types
- enum class TYPES¶
Identifier of the primitive type.
These values correspond to the low bits of the CodeView Type Index.
Values:
- enumerator UNKNOWN = 0¶
- enumerator VOID_ = 0x0003¶
- enumerator SCHAR = 0x0010¶
Signed Character.
- enumerator UCHAR = 0x0020¶
Unsigned Character.
- enumerator RCHAR = 0x0070¶
“Real” Character (char)
- enumerator WCHAR = 0x0071¶
Wide Character (wchar_t).
- enumerator CHAR16 = 0x007a¶
16-bit Character (char16_t)
- enumerator CHAR32 = 0x007b¶
32-bit Character (char32_t)
- enumerator CHAR8 = 0x007c¶
8-bit Character (char8_t)
- enumerator SBYTE = 0x0068¶
Signed Byte.
- enumerator UBYTE = 0x0069¶
Unsigned Byte.
- enumerator SSHORT = 0x0011¶
Signed Short.
- enumerator USHORT = 0x0021¶
Unsigned Short.
- enumerator SINT16 = 0x0072¶
Explicit Signed 16-bit Integer.
- enumerator UINT16 = 0x0073¶
Explicit Unsigned 16-bit Integer.
- enumerator SLONG = 0x0012¶
Signed Long.
- enumerator ULONG = 0x0022¶
Unsigned Long.
- enumerator SINT32 = 0x0074¶
Explicit Signed 32-bit Integer.
- enumerator UINT32 = 0x0075¶
Explicit Unsigned 32-bit Integer.
- enumerator SQUAD = 0x0013¶
Signed Quadword.
- enumerator UQUAD = 0x0023¶
Unsigned Quadword.
- enumerator SINT64 = 0x0076¶
Explicit Signed 64-bit Integer.
- enumerator UINT64 = 0x0077¶
Explicit Unsigned 64-bit Integer.
- enumerator SOCTA = 0x0014¶
Signed Octaword.
- enumerator UOCTA = 0x0024¶
Unsigned Octaword.
- enumerator SINT128 = 0x0078¶
Explicit Signed 128-bit Integer.
- enumerator UINT128 = 0x0079¶
Explicit Unsigned 128-bit Integer.
- enumerator FLOAT16 = 0x0046¶
16-bit Floating point
- enumerator FLOAT32 = 0x0040¶
32-bit Floating point (float)
- enumerator FLOAT32_PARTIAL_PRECISION = 0x45¶
- enumerator FLOAT48 = 0x0044¶
48-bit Floating point
- enumerator FLOAT64 = 0x0041¶
64-bit Floating point (double)
- enumerator FLOAT80 = 0x0042¶
80-bit Floating point
- enumerator FLOAT128 = 0x0043¶
128-bit Floating point
- enumerator COMPLEX16 = 0x0056¶
- enumerator COMPLEX32 = 0x0050¶
- enumerator COMPLEX32_PARTIAL_PRECISION = 0x0055¶
- enumerator COMPLEX48 = 0x0054¶
- enumerator COMPLEX64 = 0x0051¶
- enumerator COMPLEX80 = 0x0052¶
- enumerator COMPLEX128 = 0x0053¶
- enumerator BOOL8 = 0x0030¶
8-bit Boolean
- enumerator BOOL16 = 0x0031¶
16-bit Boolean
- enumerator BOOL32 = 0x0032¶
32-bit Boolean
- enumerator BOOL64 = 0x0033¶
64-bit Boolean
- enumerator BOOL128 = 0x0034¶
128-bit Boolean
- enumerator UNKNOWN = 0¶
- enum class MODES : uint32_t¶
Modifier applied to the underlying type.
In the PDB Simple Type encoding, these represent pointer attributes.
Values:
- enumerator DIRECT = 0x00000000¶
Not a pointer (direct access).
- enumerator FAR_POINTER = 0x00000200¶
Far pointer.
- enumerator HUGE_POINTER = 0x00000300¶
Huge pointer.
- enumerator NEAR_POINTER32 = 0x00000400¶
32-bit Near pointer
- enumerator FAR_POINTER32 = 0x00000500¶
32-bit Far pointer
- enumerator NEAR_POINTER64 = 0x00000600¶
64-bit Near pointer
- enumerator NEAR_POINTER128 = 0x00000700¶
128-bit Near pointer
- enumerator DIRECT = 0x00000000¶
Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline Simple(Args&&... args)¶
- inline bool is_pointer() const¶
Check if this simple type is a pointer.
- inline bool is_signed() const¶
Check if the underlying type is signed.
- ~Simple() override¶
- enum class TYPES¶
Union¶
Utilities¶
- bool LIEF::pdb::is_pdb(const std::string &pdb_path)¶
Check if the file given in parameter points to a PDB file.