LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
MappingInfo.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_DSC_MAPPING_INFO_H
17#define LIEF_DSC_MAPPING_INFO_H
18#include "LIEF/visibility.h"
19#include "LIEF/iterators.hpp"
20
21#include <memory>
22#include <cstdint>
23
24namespace LIEF {
25namespace dsc {
26
27namespace details {
28class MappingInfo;
29class MappingInfoIt;
30}
31
37 public:
40 : public iterator_facade_base<Iterator, std::random_access_iterator_tag,
41 MappingInfo, std::ptrdiff_t, const MappingInfo*,
42 const MappingInfo&> {
43 public:
44 using implementation = details::MappingInfoIt;
45
47
48 Iterator(std::unique_ptr<details::MappingInfoIt> impl);
51
52 Iterator(Iterator&&) noexcept;
53 Iterator& operator=(Iterator&&) noexcept;
54
56 bool operator<(const Iterator& rhs) const;
57
58 std::ptrdiff_t operator-(const Iterator& R) const;
59
60 Iterator& operator+=(std::ptrdiff_t n);
61 Iterator& operator-=(std::ptrdiff_t n);
62
63 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
64
65 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
66 return !(LHS == RHS);
67 }
68
69 const MappingInfo& operator*() const;
70
71 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
72 const MappingInfo* operator->() const;
73
76 std::unique_ptr<MappingInfo> yield();
77
78 private:
79 void load() const;
80
81 std::unique_ptr<details::MappingInfoIt> impl_;
82 mutable std::unique_ptr<MappingInfo> cached_;
83 };
84
85 MappingInfo(std::unique_ptr<details::MappingInfo> impl);
87
89 uint64_t address() const;
90
92 uint64_t size() const;
93
95 uint64_t end_address() const {
96 return address() + size();
97 }
98
100 uint64_t file_offset() const;
101
103 uint32_t max_prot() const;
104
106 uint32_t init_prot() const;
107
108 private:
109 std::unique_ptr<details::MappingInfo> impl_;
110};
111
112}
113}
114#endif
Iterator(Iterator &&) noexcept
Iterator & operator=(const Iterator &)
details::MappingInfoIt implementation
Definition MappingInfo.hpp:44
std::unique_ptr< MappingInfo > yield()
Transfer ownership of the mapping info at the current position to the caller. Returns nullptr if the ...
const MappingInfo & operator*() const
const MappingInfo * operator->() const
Iterator(std::unique_ptr< details::MappingInfoIt > impl)
uint64_t size() const
Size of the region being mapped.
uint32_t max_prot() const
Max memory protection.
uint64_t file_offset() const
On-disk file offset.
uint64_t end_address() const
End virtual address of the region.
Definition MappingInfo.hpp:95
uint32_t init_prot() const
Initial memory protection.
MappingInfo(std::unique_ptr< details::MappingInfo > impl)
uint64_t address() const
The in-memory address where this dyld shared cache region is mapped.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:729
Definition DyldSharedCache/DyldSharedCache.hpp:35
Namespace related to the dyld shared cache support.
Definition caching.hpp:22
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:45