LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
Export.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_PE_EXPORT_H
17#define LIEF_PE_EXPORT_H
18
19#include <ostream>
20#include <string>
21
22#include "LIEF/Object.hpp"
23#include "LIEF/visibility.h"
24#include "LIEF/iterators.hpp"
26
27namespace LIEF {
28namespace PE {
29
30class Builder;
31class Parser;
32
33namespace details {
34struct pe_export_directory_table;
35}
36class LIEF_API Export : public Object {
39 friend class Builder;
40 friend class Parser;
41
42 public:
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&>;
46
47 Export() = default;
48 Export(const details::pe_export_directory_table& header);
49 Export(const Export&) = default;
50 Export& operator=(const Export&) = default;
51 ~Export() override = default;
52 uint32_t export_flags() const {
56 return export_flags_;
57 }
58 uint32_t timestamp() const {
61 return timestamp_;
62 }
63 uint16_t major_version() const {
66 return major_version_;
67 }
68 uint16_t minor_version() const {
71 return minor_version_;
72 }
73 uint32_t ordinal_base() const {
76 return ordinal_base_;
77 }
78 const std::string& name() const {
81 return name_;
82 }
83 it_entries entries() {
86 return entries_;
87 }
88
89 it_const_entries entries() const {
90 return entries_;
91 }
92
93 void export_flags(uint32_t flags) {
94 export_flags_ = flags;
95 }
96 void timestamp(uint32_t timestamp) {
97 timestamp_ = timestamp;
98 }
99
100 void major_version(uint16_t major_version) {
101 major_version_ = major_version;
102 }
103
104 void minor_version(uint16_t minor_version) {
105 minor_version_ = minor_version;
106 }
107 void ordinal_base(uint32_t ordinal_base) {
108 ordinal_base_ = ordinal_base;
109 }
110
111 void name(std::string name) {
112 name_ = std::move(name);
113 }
114
115 void accept(Visitor& visitor) const override;
116
117 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Export& exp);
118
119 private:
120 uint32_t export_flags_ = 0;
121 uint32_t timestamp_ = 0;
122 uint16_t major_version_ = 0;
123 uint16_t minor_version_ = 0;
124 uint32_t ordinal_base_ = 0;
125 entries_t entries_;
126 std::string name_;
127
128};
129
130}
131}
132
133#endif /* PE_EXPORT_H */
ExportEntry.hpp
Object.hpp
LIEF::PE::Builder
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
LIEF::PE::Export
Class which represents a PE Export.
Definition Export.hpp:38
LIEF::PE::Export::export_flags
uint32_t export_flags() const
According to the PE specifications this value is reserved and should be set to 0.
Definition Export.hpp:55
LIEF::PE::Export::minor_version
void minor_version(uint16_t minor_version)
Definition Export.hpp:104
LIEF::PE::Export::major_version
uint16_t major_version() const
The major version number (can be user-defined)
Definition Export.hpp:65
LIEF::PE::Export::minor_version
uint16_t minor_version() const
The minor version number (can be user-defined)
Definition Export.hpp:70
LIEF::PE::Export::Export
Export()=default
LIEF::PE::Export::ordinal_base
uint32_t ordinal_base() const
The starting number for the exports. Usually this value is set to 1.
Definition Export.hpp:75
LIEF::PE::Export::name
void name(std::string name)
Definition Export.hpp:111
LIEF::PE::Export::major_version
void major_version(uint16_t major_version)
Definition Export.hpp:100
LIEF::PE::Export::Export
Export(const details::pe_export_directory_table &header)
LIEF::PE::Export::Export
Export(const Export &)=default
LIEF::PE::Export::entries
it_const_entries entries() const
Definition Export.hpp:89
LIEF::PE::Export::accept
void accept(Visitor &visitor) const override
LIEF::PE::Export::export_flags
void export_flags(uint32_t flags)
Definition Export.hpp:93
LIEF::PE::Export::~Export
~Export() override=default
LIEF::PE::Export::operator=
Export & operator=(const Export &)=default
LIEF::PE::Export::ordinal_base
void ordinal_base(uint32_t ordinal_base)
Definition Export.hpp:107
LIEF::PE::Export::operator<<
friend std::ostream & operator<<(std::ostream &os, const Export &exp)
LIEF::PE::Export::name
const std::string & name() const
The name of the library exported (e.g. KERNEL32.dll)
Definition Export.hpp:80
LIEF::PE::Export::entries
it_entries entries()
Iterator over the ExportEntry.
Definition Export.hpp:85
LIEF::PE::Export::timestamp
uint32_t timestamp() const
The time and date that the export data was created.
Definition Export.hpp:60
LIEF::PE::Export::timestamp
void timestamp(uint32_t timestamp)
Definition Export.hpp:96
LIEF::PE::Parser
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
iterators.hpp
LIEF::PE::details
Definition CodeIntegrity.hpp:26
LIEF::PE
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41