LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
LIEF::PE::Parser Class Reference

Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used to get a LIEF::PE::Binary. More...

#include <Parser.hpp>

Inheritance diagram for LIEF::PE::Parser:
Collaboration diagram for LIEF::PE::Parser:

Public Member Functions

Parseroperator= (const Parser &copy)=delete
 
 Parser (const Parser &copy)=delete
 
COFFStringfind_coff_string (uint32_t offset) const
 
ExceptionInfofind_exception_info (uint32_t rva) const
 
const Binarybin () const
 
Binarybin ()
 
BinaryStreamstream ()
 
const ParserConfigconfig () const
 
void memoize (ExceptionInfo &info)
 
void memoize (COFFString str)
 
void add_non_resolved (ExceptionInfo &info, uint32_t target)
 
std::unique_ptr< SpanStreamstream_from_rva (uint32_t rva, size_t size=0)
 
void record_relocation (uint32_t rva, span< const uint8_t > data)
 
ok_error_t record_delta_relocation (uint32_t rva, int64_t delta, size_t size)
 

Static Public Member Functions

static bool is_valid_import_name (const std::string &name)
 Check if the given name is a valid import.
 
static bool is_valid_dll_name (const std::string &name)
 Check if the given name is a valid DLL name.
 
static std::unique_ptr< Binaryparse (const std::string &filename, const ParserConfig &conf=ParserConfig::default_conf())
 Parse a PE binary from the given filename.
 
static std::unique_ptr< Binaryparse (std::vector< uint8_t > data, const ParserConfig &conf=ParserConfig::default_conf())
 Parse a PE binary from a data buffer.
 
static std::unique_ptr< Binaryparse (const uint8_t *buffer, size_t size, const ParserConfig &conf=ParserConfig::default_conf())
 
static std::unique_ptr< Binaryparse (std::unique_ptr< BinaryStream > stream, const ParserConfig &conf=ParserConfig::default_conf())
 Parse a PE binary from the given BinaryStream.
 
- Static Public Member Functions inherited from LIEF::Parser
static std::unique_ptr< Binaryparse (const std::string &filename)
 Construct an LIEF::Binary from the given filename.
 
static std::unique_ptr< Binaryparse (const std::vector< uint8_t > &raw)
 Construct an LIEF::Binary from the given raw data.
 
static std::unique_ptr< Binaryparse (std::unique_ptr< BinaryStream > stream)
 Construct an LIEF::Binary from the given stream.
 

Static Public Attributes

static constexpr size_t MAX_DATA_SIZE = 3_GB
 Maximum size of the data read.
 
static constexpr size_t MAX_TLS_CALLBACKS = 3000
 
static constexpr size_t MAX_DLL_NAME_SIZE = 255
 
static constexpr size_t MAX_PADDING_SIZE = 1_GB
 Max size of the padding section.
 

Detailed Description

Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used to get a LIEF::PE::Binary.

Constructor & Destructor Documentation

◆ Parser()

LIEF::PE::Parser::Parser ( const Parser & copy)
delete

Member Function Documentation

◆ add_non_resolved()

void LIEF::PE::Parser::add_non_resolved ( ExceptionInfo & info,
uint32_t target )
inline

◆ bin() [1/2]

Binary & LIEF::PE::Parser::bin ( )
inline

◆ bin() [2/2]

const Binary & LIEF::PE::Parser::bin ( ) const
inline

◆ config()

const ParserConfig & LIEF::PE::Parser::config ( ) const
inline

◆ find_coff_string()

COFFString * LIEF::PE::Parser::find_coff_string ( uint32_t offset) const

◆ find_exception_info()

ExceptionInfo * LIEF::PE::Parser::find_exception_info ( uint32_t rva) const
inline

◆ is_valid_dll_name()

static bool LIEF::PE::Parser::is_valid_dll_name ( const std::string & name)
static

Check if the given name is a valid DLL name.

This check verifies that:

  1. The name of the DLL is at 4
  2. All the characters are printable

◆ is_valid_import_name()

static bool LIEF::PE::Parser::is_valid_import_name ( const std::string & name)
static

Check if the given name is a valid import.

This check verified that:

  1. The name is not too large or empty (cf. https://stackoverflow.com/a/23340781)
  2. All the characters are printable

◆ memoize() [1/2]

void LIEF::PE::Parser::memoize ( COFFString str)

◆ memoize() [2/2]

void LIEF::PE::Parser::memoize ( ExceptionInfo & info)

◆ operator=()

Parser & LIEF::PE::Parser::operator= ( const Parser & copy)
delete

◆ parse() [1/4]

static std::unique_ptr< Binary > LIEF::PE::Parser::parse ( const std::string & filename,
const ParserConfig & conf = ParserConfig::default_conf() )
static

Parse a PE binary from the given filename.

◆ parse() [2/4]

static std::unique_ptr< Binary > LIEF::PE::Parser::parse ( const uint8_t * buffer,
size_t size,
const ParserConfig & conf = ParserConfig::default_conf() )
static

◆ parse() [3/4]

static std::unique_ptr< Binary > LIEF::PE::Parser::parse ( std::unique_ptr< BinaryStream > stream,
const ParserConfig & conf = ParserConfig::default_conf() )
static

Parse a PE binary from the given BinaryStream.

◆ parse() [4/4]

static std::unique_ptr< Binary > LIEF::PE::Parser::parse ( std::vector< uint8_t > data,
const ParserConfig & conf = ParserConfig::default_conf() )
static

Parse a PE binary from a data buffer.

◆ record_delta_relocation()

ok_error_t LIEF::PE::Parser::record_delta_relocation ( uint32_t rva,
int64_t delta,
size_t size )

◆ record_relocation()

void LIEF::PE::Parser::record_relocation ( uint32_t rva,
span< const uint8_t > data )

◆ stream()

BinaryStream & LIEF::PE::Parser::stream ( )
inline

◆ stream_from_rva()

std::unique_ptr< SpanStream > LIEF::PE::Parser::stream_from_rva ( uint32_t rva,
size_t size = 0 )

Member Data Documentation

◆ MAX_DATA_SIZE

size_t LIEF::PE::Parser::MAX_DATA_SIZE = 3_GB
staticconstexpr

Maximum size of the data read.

◆ MAX_DLL_NAME_SIZE

size_t LIEF::PE::Parser::MAX_DLL_NAME_SIZE = 255
staticconstexpr

◆ MAX_PADDING_SIZE

size_t LIEF::PE::Parser::MAX_PADDING_SIZE = 1_GB
staticconstexpr

Max size of the padding section.

◆ MAX_TLS_CALLBACKS

size_t LIEF::PE::Parser::MAX_TLS_CALLBACKS = 3000
staticconstexpr

The documentation for this class was generated from the following file: