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

Class that is used to rebuild a raw PE binary from a PE::Binary object. More...

#include <Builder.hpp>

Public Member Functions

 Builder ()=delete
 
 Builder (Binary &binary)
 
 ~Builder ()
 
ok_error_t build ()
 Perform the build process.
 
Builderbuild_imports (bool flag=true)
 Rebuild the import table in new section.
 
Builderpatch_imports (bool flag=true)
 Patch the original import table in order to redirect functions to the new import table.
 
Builderbuild_relocations (bool flag=true)
 Rebuild the relocation table in another section.
 
Builderbuild_tls (bool flag=true)
 Rebuild TLS object in another section.
 
Builderbuild_resources (bool flag)
 Rebuid the resources in another section.
 
Builderbuild_overlay (bool flag)
 Rebuild the binary's overlay.
 
Builderbuild_dos_stub (bool flag)
 Rebuild the DOS stub content.
 
const std::vector< uint8_t > & get_build ()
 Return the build result.
 
void write (const std::string &filename) const
 Write the build result into the output file.
 
void write (std::ostream &os) const
 Write the build result into the os stream.
 
ok_error_t build (const DosHeader &dos_header)
 
ok_error_t build (const Header &bHeader)
 
ok_error_t build (const OptionalHeader &optional_header)
 
ok_error_t build (const DataDirectory &data_directory)
 
ok_error_t build (const Section &section)
 

Static Public Member Functions

template<typename PE_T >
static std::vector< uint8_t > build_jmp (uint64_t from, uint64_t address)
 Construct a jmp [address] @ from.
 
template<typename PE_T >
static std::vector< uint8_t > build_jmp_hook (uint64_t from, uint64_t address)
 Construct a jmp far address @ from.
 

Detailed Description

Class that is used to rebuild a raw PE binary from a PE::Binary object.

Constructor & Destructor Documentation

◆ Builder() [1/2]

LIEF::PE::Builder::Builder ( )
delete

◆ Builder() [2/2]

LIEF::PE::Builder::Builder ( Binary & binary)

◆ ~Builder()

LIEF::PE::Builder::~Builder ( )

Member Function Documentation

◆ build() [1/6]

ok_error_t LIEF::PE::Builder::build ( )

Perform the build process.

◆ build() [2/6]

ok_error_t LIEF::PE::Builder::build ( const DataDirectory & data_directory)

◆ build() [3/6]

ok_error_t LIEF::PE::Builder::build ( const DosHeader & dos_header)

◆ build() [4/6]

ok_error_t LIEF::PE::Builder::build ( const Header & bHeader)

◆ build() [5/6]

ok_error_t LIEF::PE::Builder::build ( const OptionalHeader & optional_header)

◆ build() [6/6]

ok_error_t LIEF::PE::Builder::build ( const Section & section)

◆ build_dos_stub()

Builder & LIEF::PE::Builder::build_dos_stub ( bool flag)

Rebuild the DOS stub content.

◆ build_imports()

Builder & LIEF::PE::Builder::build_imports ( bool flag = true)

Rebuild the import table in new section.

◆ build_jmp()

template<typename PE_T >
static std::vector< uint8_t > LIEF::PE::Builder::build_jmp ( uint64_t from,
uint64_t address )
static

Construct a jmp [address] @ from.

It is used when patching import table

◆ build_jmp_hook()

template<typename PE_T >
static std::vector< uint8_t > LIEF::PE::Builder::build_jmp_hook ( uint64_t from,
uint64_t address )
static

Construct a jmp far address @ from.

It is used for hooking

◆ build_overlay()

Builder & LIEF::PE::Builder::build_overlay ( bool flag)

Rebuild the binary's overlay.

◆ build_relocations()

Builder & LIEF::PE::Builder::build_relocations ( bool flag = true)

Rebuild the relocation table in another section.

◆ build_resources()

Builder & LIEF::PE::Builder::build_resources ( bool flag)

Rebuid the resources in another section.

◆ build_tls()

Builder & LIEF::PE::Builder::build_tls ( bool flag = true)

Rebuild TLS object in another section.

◆ get_build()

const std::vector< uint8_t > & LIEF::PE::Builder::get_build ( )

Return the build result.

◆ patch_imports()

Builder & LIEF::PE::Builder::patch_imports ( bool flag = true)

Patch the original import table in order to redirect functions to the new import table.

This setting should be used with LIEF::PE::Builder::build_imports set to true

◆ write() [1/2]

void LIEF::PE::Builder::write ( const std::string & filename) const

Write the build result into the output file.

◆ write() [2/2]

void LIEF::PE::Builder::write ( std::ostream & os) const

Write the build result into the os stream.


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