LIEF: Library to Instrument Executable Formats Version 2.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 <memory>
19#include <ostream>
20#include <vector>
21
23#include "LIEF/iterators.hpp"
24#include "LIEF/span.hpp"
25#include "LIEF/visibility.h"
26
28
29
30namespace LIEF::MachO {
31
32class BinaryParser;
33class Builder;
34class LinkEdit;
35
36namespace details {
37struct twolevel_hints_command;
38}
39
42 friend class BinaryParser;
43 friend class LinkEdit;
44 friend class Builder;
45
46 public:
47 using hints_list_t = std::vector<uint32_t>;
50
51 TwoLevelHints() = default;
52 TwoLevelHints(const details::twolevel_hints_command& cmd);
53
54 TwoLevelHints& operator=(const TwoLevelHints& copy) = default;
55 TwoLevelHints(const TwoLevelHints& copy) = default;
56
57 std::unique_ptr<LoadCommand> clone() const override {
58 return std::make_unique<TwoLevelHints>(*this);
59 }
60
63 return content_;
64 }
66 return content_;
67 }
68
71 return hints_;
72 }
74 return hints_;
75 }
76
79 uint32_t offset() const {
80 return offset_;
81 }
82 void offset(uint32_t offset) {
83 offset_ = offset;
84 }
85
86 uint32_t original_nb_hints() const {
87 return original_nb_hints_;
88 }
89
90 ~TwoLevelHints() override = default;
91
92 void accept(Visitor& visitor) const override;
93
94 std::ostream& print(std::ostream& os) const override;
95
96 static bool classof(const LoadCommand* cmd) {
98 }
99
100 private:
101 uint32_t offset_ = 0;
102 hints_list_t hints_;
103 span<uint8_t> content_;
104 uint32_t original_nb_hints_ = 0;
105};
106
107}
108
109#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:132
@ TWOLEVEL_HINTS
Definition LoadCommand.hpp:70
static bool classof(const LoadCommand *cmd)
Definition TwoLevelHints.hpp:96
std::ostream & print(std::ostream &os) const override
std::unique_ptr< LoadCommand > clone() const override
Definition TwoLevelHints.hpp:57
uint32_t original_nb_hints() const
Definition TwoLevelHints.hpp:86
friend class BinaryParser
Definition TwoLevelHints.hpp:42
it_const_hints_t hints() const
Definition TwoLevelHints.hpp:73
~TwoLevelHints() override=default
TwoLevelHints(const TwoLevelHints &copy)=default
span< const uint8_t > content() const
Original payload of the command.
Definition TwoLevelHints.hpp:62
void offset(uint32_t offset)
Definition TwoLevelHints.hpp:82
friend class Builder
Definition TwoLevelHints.hpp:44
uint32_t offset() const
Original offset of the command. It should point in the __LINKEDIT segment.
Definition TwoLevelHints.hpp:79
ref_iterator< hints_list_t & > it_hints_t
Definition TwoLevelHints.hpp:48
friend class LinkEdit
Definition TwoLevelHints.hpp:43
std::vector< uint32_t > hints_list_t
Definition TwoLevelHints.hpp:47
it_hints_t hints()
Iterator over the hints (uint32_t integers).
Definition TwoLevelHints.hpp:70
void accept(Visitor &visitor) const override
const_ref_iterator< const hints_list_t & > it_const_hints_t
Definition TwoLevelHints.hpp:49
TwoLevelHints(const details::twolevel_hints_command &cmd)
TwoLevelHints & operator=(const TwoLevelHints &copy)=default
span< uint8_t > content()
Definition TwoLevelHints.hpp:65
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:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
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:316
#define LIEF_API
Definition visibility.h:45