LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
PublicSymbol.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_PDB_PUBLIC_SYMBOL_H
16#define LIEF_PDB_PUBLIC_SYMBOL_H
17#include <memory>
18#include <string>
19
20#include "LIEF/visibility.h"
21
22namespace LIEF {
23namespace pdb {
24
25namespace details {
26class PublicSymbol;
27class PublicSymbolIt;
28}
29
33 public:
35 public:
36 using iterator_category = std::forward_iterator_tag;
37 using value_type = std::unique_ptr<PublicSymbol>;
38 using difference_type = std::ptrdiff_t;
41 using implementation = details::PublicSymbolIt;
42
44 // Inspired from LLVM's iterator_facade_base
45 friend class Iterator;
46 public:
47 pointer operator->() const { return R.get(); }
48
49 private:
50 value_type R;
51
52 template <typename RefT>
53 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
54 };
55
58 Iterator(std::unique_ptr<details::PublicSymbolIt> impl);
60
61 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
62
63 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
64 return !(LHS == RHS);
65 }
66
68
70 Iterator tmp = *static_cast<Iterator*>(this);
71 ++*static_cast<Iterator *>(this);
72 return tmp;
73 }
74
75 std::unique_ptr<PublicSymbol> operator*() const;
76
78 return static_cast<const Iterator*>(this)->operator*();
79 }
80
81 private:
82 std::unique_ptr<details::PublicSymbolIt> impl_;
83 };
84 PublicSymbol(std::unique_ptr<details::PublicSymbol> impl);
86
87 enum class FLAGS : uint32_t {
88 NONE = 0,
89 CODE = 1 << 0,
90 FUNCTION = 1 << 1,
91 MANAGED = 1 << 2,
92 MSIL = 1 << 3,
93 };
94
96 std::string name() const;
97
99 std::string demangled_name() const;
100
104 std::string section_name() const;
105
109 uint32_t RVA() const;
110
111 private:
112 std::unique_ptr<details::PublicSymbol> impl_;
113};
114
115}
116}
117#endif
118
pointer operator->() const
Definition PublicSymbol.hpp:47
Definition PublicSymbol.hpp:34
Iterator(std::unique_ptr< details::PublicSymbolIt > impl)
friend bool operator==(const Iterator &LHS, const Iterator &RHS)
std::unique_ptr< PublicSymbol > operator*() const
Iterator operator++(int)
Definition PublicSymbol.hpp:69
std::forward_iterator_tag iterator_category
Definition PublicSymbol.hpp:36
std::unique_ptr< PublicSymbol > value_type
Definition PublicSymbol.hpp:37
PointerProxy operator->() const
Definition PublicSymbol.hpp:77
std::ptrdiff_t difference_type
Definition PublicSymbol.hpp:38
friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
Definition PublicSymbol.hpp:63
details::PublicSymbolIt implementation
Definition PublicSymbol.hpp:41
This class provides general information (RVA, name) about a symbol from the PDB's public symbol strea...
Definition PublicSymbol.hpp:32
PublicSymbol(std::unique_ptr< details::PublicSymbol > impl)
std::string name() const
Name of the symbol.
std::string demangled_name() const
Demangled representation of the symbol.
std::string section_name() const
Name of the section in which this symbol is defined (e.g. .text).
FLAGS
Definition PublicSymbol.hpp:87
uint32_t RVA() const
Relative Virtual Address of this symbol.
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41