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_EXPORT_H
17#define LIEF_PE_EXPORT_H
35struct pe_export_directory_table;
44 using entries_t = std::vector<std::unique_ptr<ExportEntry>>;
45 using it_entries = ref_iterator<entries_t&, ExportEntry*>;
46 using it_const_entries = const_ref_iterator<const entries_t&, const ExportEntry*>;
50 Export(std::string name,
const std::vector<ExportEntry>& entries) :
51 name_(std::move(name))
53 for (
const ExportEntry&
E : entries) {
59 Export(std::move(name), {})
62 Export(
const details::pe_export_directory_table& header);
85 return major_version_;
90 return minor_version_;
97 const std::string&
name()
const {
119 return exp_addr_table_rva_;
124 return exp_addr_table_cnt_;
129 return names_addr_table_rva_;
134 return names_addr_table_cnt_;
139 return ord_addr_table_rva_;
143 export_flags_ = flags;
147 timestamp_ = timestamp;
151 major_version_ = major_version;
155 minor_version_ = minor_version;
159 ordinal_base_ = ordinal_base;
163 name_ = std::move(name);
165 const ExportEntry*
find_entry(
const std::string& name)
const;
170 return const_cast<ExportEntry*
>(
static_cast<const Export*
>(
this)->find_entry(name));
172 const ExportEntry*
find_entry(uint32_t ordinal)
const;
177 return const_cast<ExportEntry*
>(
static_cast<const Export*
>(
this)->find_entry(ordinal));
184 return const_cast<ExportEntry*
>(
static_cast<const Export*
>(
this)->find_entry_at(rva));
186 ExportEntry&
add_entry(
const ExportEntry& exp);
190 ExportEntry&
add_entry(std::string name, uint32_t rva) {
191 return add_entry(ExportEntry(std::move(name), rva));
199 if (
const ExportEntry* entry = find_entry(name)) {
200 return remove_entry(*entry);
207 if (
const ExportEntry* entry = find_entry_at(rva)) {
208 return remove_entry(*entry);
213 void accept(Visitor& visitor)
const override;
218 uint32_t export_flags_ = 0;
219 uint32_t name_rva_ = 0;
220 uint32_t timestamp_ = 0;
221 uint16_t major_version_ = 0;
222 uint16_t minor_version_ = 0;
223 uint32_t ordinal_base_ = 0;
224 uint32_t exp_addr_table_rva_ = 0;
225 uint32_t exp_addr_table_cnt_ = 0;
226 uint32_t names_addr_table_rva_ = 0;
227 uint32_t names_addr_table_cnt_ = 0;
228 uint32_t ord_addr_table_rva_ = 0;
229 uint32_t max_ordinal_ = 0;
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
Class which represents a PE Export.
Definition Export.hpp:39
uint32_t ord_addr_table_rva() const
RVA to the list of exported ordinals.
Definition Export.hpp:138
uint32_t export_flags() const
According to the PE specifications this value is reserved and should be set to 0.
Definition Export.hpp:74
Export & operator=(const Export &)
void minor_version(uint16_t minor_version)
Definition Export.hpp:154
ExportEntry & add_entry(const ExportEntry &exp)
Add the given export and return the newly created and added export.
uint16_t major_version() const
The major version number (can be user-defined)
Definition Export.hpp:84
Export & operator=(Export &&)=default
bool remove_entry(uint32_t rva)
Remove the export entry with the given RVA.
Definition Export.hpp:206
uint16_t minor_version() const
The minor version number (can be user-defined)
Definition Export.hpp:89
Export(Export &&)=default
uint32_t ordinal_base() const
The starting number for the exports. Usually this value is set to 1.
Definition Export.hpp:94
const ExportEntry * find_entry(const std::string &name) const
Find the export entry with the given name.
void name(std::string name)
Definition Export.hpp:162
ExportEntry & add_entry(std::string name, uint32_t rva)
Definition Export.hpp:190
void major_version(uint16_t major_version)
Definition Export.hpp:150
Export(const details::pe_export_directory_table &header)
const ExportEntry * find_entry(uint32_t ordinal) const
Find the export entry with the given ordinal number.
Export(std::string name)
Definition Export.hpp:58
it_const_entries entries() const
Definition Export.hpp:108
void accept(Visitor &visitor) const override
void export_flags(uint32_t flags)
Definition Export.hpp:142
~Export() override=default
Export(std::string name, const std::vector< ExportEntry > &entries)
Definition Export.hpp:50
uint32_t export_addr_table_cnt() const
Number of entries in the export address table.
Definition Export.hpp:123
const ExportEntry * find_entry_at(uint32_t rva) const
Find the export entry at the provided RVA.
uint32_t name_rva() const
Address of the ASCII DLL's name (RVA)
Definition Export.hpp:113
ExportEntry * find_entry(const std::string &name)
Definition Export.hpp:169
void ordinal_base(uint32_t ordinal_base)
Definition Export.hpp:158
friend std::ostream & operator<<(std::ostream &os, const Export &exp)
bool remove_entry(const ExportEntry &exp)
Remove the given export entry.
uint32_t names_addr_table_rva() const
RVA to the list of exported names.
Definition Export.hpp:128
const std::string & name() const
The name of the library exported (e.g. KERNEL32.dll)
Definition Export.hpp:99
bool remove_entry(const std::string &name)
Remove the export entry with the given name.
Definition Export.hpp:198
it_entries entries()
Iterator over the ExportEntry.
Definition Export.hpp:104
uint32_t timestamp() const
The time and date that the export data was created.
Definition Export.hpp:79
uint32_t export_addr_table_rva() const
RVA of the export address table.
Definition Export.hpp:118
ExportEntry * find_entry_at(uint32_t rva)
Definition Export.hpp:183
void timestamp(uint32_t timestamp)
Definition Export.hpp:146
ExportEntry * find_entry(uint32_t ordinal)
Definition Export.hpp:176
uint32_t names_addr_table_cnt() const
Number of exports by name.
Definition Export.hpp:133
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:52
Definition DataDirectory.hpp:37
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
@ E
Definition AcceleratorCodes.hpp:82
LIEF namespace.
Definition Abstract/Binary.hpp:39
#define LIEF_API
Definition visibility.h:41