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
34struct pe_export_directory_table;
43 using entries_t = std::vector<ExportEntry>;
44 using it_entries = ref_iterator<entries_t&>;
45 using it_const_entries = const_ref_iterator<const entries_t&>;
49 Export(std::string name,
const entries_t& entries) :
50 name_(std::move(name))
52 for (
const ExportEntry&
E : entries) {
58 Export(std::move(name), {})
61 Export(
const details::pe_export_directory_table& header);
84 return major_version_;
89 return minor_version_;
96 const std::string&
name()
const {
118 return exp_addr_table_rva_;
123 return exp_addr_table_cnt_;
128 return names_addr_table_rva_;
133 return names_addr_table_cnt_;
138 return ord_addr_table_rva_;
142 export_flags_ = flags;
146 timestamp_ = timestamp;
150 major_version_ = major_version;
154 minor_version_ = minor_version;
158 ordinal_base_ = ordinal_base;
162 name_ = std::move(name);
164 const ExportEntry*
find_entry(
const std::string& name)
const;
169 return const_cast<ExportEntry*
>(
static_cast<const Export*
>(
this)->find_entry(name));
171 const ExportEntry*
find_entry(uint32_t ordinal)
const;
176 return const_cast<ExportEntry*
>(
static_cast<const Export*
>(
this)->find_entry(ordinal));
183 return const_cast<ExportEntry*
>(
static_cast<const Export*
>(
this)->find_entry_at(rva));
185 ExportEntry&
add_entry(
const ExportEntry& exp);
189 ExportEntry&
add_entry(std::string name, uint32_t rva) {
190 return add_entry(ExportEntry(std::move(name), rva));
198 if (
const ExportEntry* entry = find_entry(name)) {
199 return remove_entry(*entry);
206 if (
const ExportEntry* entry = find_entry_at(rva)) {
207 return remove_entry(*entry);
212 void accept(Visitor& visitor)
const override;
217 uint32_t export_flags_ = 0;
218 uint32_t name_rva_ = 0;
219 uint32_t timestamp_ = 0;
220 uint16_t major_version_ = 0;
221 uint16_t minor_version_ = 0;
222 uint32_t ordinal_base_ = 0;
223 uint32_t exp_addr_table_rva_ = 0;
224 uint32_t exp_addr_table_cnt_ = 0;
225 uint32_t names_addr_table_rva_ = 0;
226 uint32_t names_addr_table_cnt_ = 0;
227 uint32_t ord_addr_table_rva_ = 0;
228 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:38
uint32_t ord_addr_table_rva() const
RVA to the list of exported ordinals.
Definition Export.hpp:137
uint32_t export_flags() const
According to the PE specifications this value is reserved and should be set to 0.
Definition Export.hpp:73
void minor_version(uint16_t minor_version)
Definition Export.hpp:153
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:83
Export & operator=(Export &&)=default
bool remove_entry(uint32_t rva)
Remove the export entry with the given RVA.
Definition Export.hpp:205
uint16_t minor_version() const
The minor version number (can be user-defined)
Definition Export.hpp:88
Export(Export &&)=default
uint32_t ordinal_base() const
The starting number for the exports. Usually this value is set to 1.
Definition Export.hpp:93
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:161
ExportEntry & add_entry(std::string name, uint32_t rva)
Definition Export.hpp:189
void major_version(uint16_t major_version)
Definition Export.hpp:149
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(const Export &)=default
Export(std::string name, const entries_t &entries)
Definition Export.hpp:49
Export(std::string name)
Definition Export.hpp:57
it_const_entries entries() const
Definition Export.hpp:107
void accept(Visitor &visitor) const override
void export_flags(uint32_t flags)
Definition Export.hpp:141
~Export() override=default
Export & operator=(const Export &)=default
uint32_t export_addr_table_cnt() const
Number of entries in the export address table.
Definition Export.hpp:122
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:112
ExportEntry * find_entry(const std::string &name)
Definition Export.hpp:168
void ordinal_base(uint32_t ordinal_base)
Definition Export.hpp:157
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:127
const std::string & name() const
The name of the library exported (e.g. KERNEL32.dll)
Definition Export.hpp:98
bool remove_entry(const std::string &name)
Remove the export entry with the given name.
Definition Export.hpp:197
it_entries entries()
Iterator over the ExportEntry.
Definition Export.hpp:103
uint32_t timestamp() const
The time and date that the export data was created.
Definition Export.hpp:78
uint32_t export_addr_table_rva() const
RVA of the export address table.
Definition Export.hpp:117
ExportEntry * find_entry_at(uint32_t rva)
Definition Export.hpp:182
void timestamp(uint32_t timestamp)
Definition Export.hpp:145
ExportEntry * find_entry(uint32_t ordinal)
Definition Export.hpp:175
uint32_t names_addr_table_cnt() const
Number of exports by name.
Definition Export.hpp:132
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:36
#define LIEF_API
Definition visibility.h:41