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}
33 public:
34 class LIEF_API Iterator {
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;
39 using pointer = PublicSymbol*;
40 using reference = PublicSymbol&;
41 using implementation = details::PublicSymbolIt;
42
43 class LIEF_API PointerProxy {
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
56 Iterator(const Iterator&);
57 Iterator(Iterator&&);
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
67 Iterator& operator++();
68
69 Iterator operator++(int) {
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
77 PointerProxy operator->() const {
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 std::string name() const;
97 std::string demangled_name() const;
100 std::string section_name() const;
105 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
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
PointerProxy operator->() const
Definition PublicSymbol.hpp:77
friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
Definition PublicSymbol.hpp:63
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).
uint32_t RVA() const
Relative Virtual Address of this symbol.
Definition PDB/CompilationUnit.hpp:29
Definition PDB/CompilationUnit.hpp:27
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41