LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_PE_BUILDER_H
17#define LIEF_PE_BUILDER_H
46 public:
struct config_t {
bool imports =
false;
66 bool resources =
true;
69 bool relocations =
true;
72 bool load_configuration =
true;
88 std::string rsrc_section =
".rsrc";
92 std::string idata_section =
".idata";
95 std::string tls_section =
".tls";
98 std::string reloc_section =
".reloc";
101 std::string export_section =
".edata";
104 std::string debug_section =
".debug";
108 using resolved_iat_cbk_t =
109 std::function<void(Binary*,
const Import*,
const ImportEntry*, uint32_t)>;
110 resolved_iat_cbk_t resolved_iat_cbk =
nullptr;
111 bool force_relocating =
false;
117 Builder(Binary& binary,
const config_t& config) :
126 const std::vector<uint8_t>&
get_build() {
131 void write(
const std::string& filename)
const;
134 void write(std::ostream& os)
const;
151 template<
typename PE_T>
154 template<
typename PE_T>
157 template<
typename PE_T>
166 std::vector<uint8_t> header;
167 std::vector<uint8_t> callbacks;
170 struct rsrc_sizing_info_t {
171 uint32_t header_size = 0;
172 uint32_t data_size = 0;
173 uint32_t name_size = 0;
176 struct rsrc_build_context_t {
177 uint32_t offset_header = 0;
178 uint32_t offset_data = 0;
179 uint32_t offset_name = 0;
181 std::vector<uint64_t> rva_fixups;
184 template<
typename PE_T>
185 ok_error_t build_optional_header(
const OptionalHeader& optional_header);
187 static ok_error_t compute_resources_size(
const ResourceNode& node,
188 rsrc_sizing_info_t& info);
191 vector_iostream& ios, ResourceNode& node, rsrc_build_context_t& ctx);
194 vector_iostream& ios, ResourceDirectory& dir, rsrc_build_context_t& ctx);
197 vector_iostream& ios, ResourceData& dir, rsrc_build_context_t& ctx);
199 mutable vector_iostream ios_;
200 Binary* binary_ =
nullptr;
202 std::vector<uint8_t> reloc_data_;
203 std::vector<uint8_t> rsrc_data_;
204 tls_data_t tls_data_;
Class which represents a PE binary This is the main interface to manage and modify a PE executable.
Definition PE/Binary.hpp:56
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
ok_error_t build_load_config()
ok_error_t build_relocations()
Builder(Binary &binary, const config_t &config)
Definition PE/Builder.hpp:117
ok_error_t build_overlay()
ok_error_t build_exports()
ok_error_t build_resources()
ok_error_t build(const Header &header)
ok_error_t build_debug_info()
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.
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.
const std::vector< uint8_t > & rsrc_data() const
Definition PE/Builder.hpp:160
ok_error_t build(const DosHeader &dos_header)
ok_error_t build_imports()
const std::vector< uint8_t > & get_build()
Return the build result.
Definition PE/Builder.hpp:128
Class that represents a PE data directory entry.
Definition DataDirectory.hpp:42
Class that represents an entry (i.e. an import) in the import table (Import).
Definition ImportEntry.hpp:36
Class that represents a PE import.
Definition Import.hpp:39
Class which represents a Data Node in the PE resources tree.
Definition ResourceData.hpp:33
Definition ResourceDirectory.hpp:33
Class which represents a Node in the resource tree.
Definition ResourceNode.hpp:45
Class which represents a PE section.
Definition PE/Section.hpp:43
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:36
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:109
#define LIEF_API
Definition visibility.h:41