16#ifndef LIEF_PE_BUILDER_H
17#define LIEF_PE_BUILDER_H
58 template<
typename PE_T>
59 static std::vector<uint8_t>
build_jmp(uint64_t from, uint64_t address);
65 template<
typename PE_T>
96 void write(
const std::string& filename)
const;
99 void write(std::ostream& os)
const;
110 template<
typename PE_T>
115 template<
typename PE_T>
116 void build_import_table();
118 template<
typename PE_T>
127 uint32_t *data_size, uint32_t *name_size);
130 uint32_t* offset_header, uint32_t* offset_data, uint32_t* offset_name,
131 uint32_t base_rva, uint32_t depth);
135 Binary* binary_ =
nullptr;
137 bool build_imports_ =
false;
138 bool patch_imports_ =
false;
139 bool build_relocations_ =
false;
140 bool build_tls_ =
false;
141 bool build_resources_ =
false;
142 bool build_overlay_ =
true;
143 bool build_dos_stub_ =
true;
Class which represents a PE binary This is the main interface to manage and modify a PE executable.
Definition PE/Binary.hpp:52
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
friend std::ostream & operator<<(std::ostream &os, const Builder &b)
Builder & build_overlay(bool flag)
Rebuild the binary's overlay.
Builder & build_dos_stub(bool flag)
Rebuild the DOS stub content.
static std::vector< uint8_t > build_jmp_hook(uint64_t from, uint64_t address)
Construct a jmp far address @ from.
Builder & build_imports(bool flag=true)
Rebuild the import table in new section.
ok_error_t build(const DataDirectory &data_directory)
ok_error_t build(const Section §ion)
ok_error_t build(const OptionalHeader &optional_header)
ok_error_t build()
Perform the build process.
static std::vector< uint8_t > build_jmp(uint64_t from, uint64_t address)
Construct a jmp [address] @ from.
void write(std::ostream &os) const
Write the build result into the os stream.
void write(const std::string &filename) const
Write the build result into the output file.
ok_error_t build(const Header &bHeader)
ok_error_t build(const DosHeader &dos_header)
Builder & build_resources(bool flag)
Rebuid the resources in another section.
Builder & build_tls(bool flag=true)
Rebuild TLS object in another section.
Builder & build_relocations(bool flag=true)
Rebuild the relocation table in another section.
const std::vector< uint8_t > & get_build()
Return the build result.
Builder & patch_imports(bool flag=true)
Patch the original import table in order to redirect functions to the new import table.
Class that represents a PE data directory entry.
Definition DataDirectory.hpp:38
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:36
Class which represents a PE section.
Definition PE/Section.hpp:40
Definition iostream.hpp:29
LIEF namespace.
Definition Abstract/Binary.hpp:32
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:108
#define LIEF_API
Definition visibility.h:41