LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
TwoLevelHints.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_MACHO_TWO_LEVEL_HINTS_H
17#define LIEF_MACHO_TWO_LEVEL_HINTS_H
18#include <vector>
19#include <ostream>
20
22#include "LIEF/visibility.h"
23#include "LIEF/span.hpp"
24#include "LIEF/iterators.hpp"
25
27
28namespace LIEF {
29namespace MachO {
30
31class BinaryParser;
32class Builder;
33class LinkEdit;
34
35namespace details {
36struct twolevel_hints_command;
37}
38
41 friend class BinaryParser;
42 friend class LinkEdit;
43 friend class Builder;
44
45 public:
46 using hints_list_t = std::vector<uint32_t>;
49
50 TwoLevelHints() = default;
51 TwoLevelHints(const details::twolevel_hints_command& cmd);
52
53 TwoLevelHints& operator=(const TwoLevelHints& copy) = default;
54 TwoLevelHints(const TwoLevelHints& copy) = default;
55
56 std::unique_ptr<LoadCommand> clone() const override {
57 return std::unique_ptr<TwoLevelHints>(new TwoLevelHints(*this));
58 }
59
62 return content_;
63 }
65 return content_;
66 }
67
70 return hints_;
71 }
73 return hints_;
74 }
75
78 uint32_t offset() const {
79 return offset_;
80 }
81 void offset(uint32_t offset) {
82 offset_ = offset;
83 }
84
85 uint32_t original_nb_hints() const {
86 return original_nb_hints_;
87 }
88
89 ~TwoLevelHints() override = default;
90
91 void accept(Visitor& visitor) const override;
92
93 std::ostream& print(std::ostream& os) const override;
94
95 static bool classof(const LoadCommand* cmd) {
97 }
98
99 private:
100 uint32_t offset_ = 0;
101 hints_list_t hints_;
102 span<uint8_t> content_;
103 uint32_t original_nb_hints_ = 0;
104};
105
106}
107}
108#endif
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:79
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:64
Definition LinkEdit.hpp:47
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:130
@ TWOLEVEL_HINTS
Definition LoadCommand.hpp:69
static bool classof(const LoadCommand *cmd)
Definition TwoLevelHints.hpp:95
std::ostream & print(std::ostream &os) const override
std::unique_ptr< LoadCommand > clone() const override
Definition TwoLevelHints.hpp:56
uint32_t original_nb_hints() const
Definition TwoLevelHints.hpp:85
friend class BinaryParser
Definition TwoLevelHints.hpp:41
it_const_hints_t hints() const
Definition TwoLevelHints.hpp:72
~TwoLevelHints() override=default
TwoLevelHints(const TwoLevelHints &copy)=default
span< const uint8_t > content() const
Original payload of the command.
Definition TwoLevelHints.hpp:61
void offset(uint32_t offset)
Definition TwoLevelHints.hpp:81
friend class Builder
Definition TwoLevelHints.hpp:43
uint32_t offset() const
Original offset of the command. It should point in the __LINKEDIT segment.
Definition TwoLevelHints.hpp:78
ref_iterator< hints_list_t & > it_hints_t
Definition TwoLevelHints.hpp:47
friend class LinkEdit
Definition TwoLevelHints.hpp:42
std::vector< uint32_t > hints_list_t
Definition TwoLevelHints.hpp:46
it_hints_t hints()
Iterator over the hints (uint32_t integers).
Definition TwoLevelHints.hpp:69
void accept(Visitor &visitor) const override
const_ref_iterator< const hints_list_t & > it_const_hints_t
Definition TwoLevelHints.hpp:48
TwoLevelHints(const details::twolevel_hints_command &cmd)
TwoLevelHints & operator=(const TwoLevelHints &copy)=default
span< uint8_t > content()
Definition TwoLevelHints.hpp:64
Definition Visitor.hpp:212
Iterator which returns reference on container's values.
Definition iterators.hpp:47
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition endianness_support.hpp:60
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:41
tcb::span< ElementType, Extent > span
Definition span.hpp:22
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:320
#define LIEF_API
Definition visibility.h:45