LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Routine.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_ROUTINE_H
17#define LIEF_MACHO_ROUTINE_H
18#include <memory>
19#include <ostream>
20
21#include "LIEF/visibility.h"
22
24
25
26namespace LIEF::MachO {
27
28class BinaryParser;
29
40 friend class BinaryParser;
41
42 public:
43 Routine() = default;
44
45 template<class T>
46 LIEF_LOCAL Routine(const T& cmd);
47
48 Routine& operator=(const Routine& copy) = default;
49 Routine(const Routine& copy) = default;
50
51 std::unique_ptr<LoadCommand> clone() const override {
52 return std::make_unique<Routine>(*this);
53 }
54
56 uint64_t init_address() const {
57 return init_address_;
58 }
59
60 void init_address(uint64_t addr) {
61 init_address_ = addr;
62 }
63
65 uint64_t init_module() const {
66 return init_module_;
67 }
68
69 void init_module(uint64_t mod) {
70 init_module_ = mod;
71 }
72
73 uint64_t reserved1() const {
74 return reserved1_;
75 }
76
77 void reserved1(uint64_t value) {
78 reserved1_ = value;
79 }
80
81 uint64_t reserved2() const {
82 return reserved2_;
83 }
84
85 void reserved2(uint64_t value) {
86 reserved2_ = value;
87 }
88
89 uint64_t reserved3() const {
90 return reserved3_;
91 }
92
93 void reserved3(uint64_t value) {
94 reserved3_ = value;
95 }
96
97 uint64_t reserved4() const {
98 return reserved4_;
99 }
100
101 void reserved4(uint64_t value) {
102 reserved4_ = value;
103 }
104
105 uint64_t reserved5() const {
106 return reserved5_;
107 }
108
109 void reserved5(uint64_t value) {
110 reserved5_ = value;
111 }
112
113 uint64_t reserved6() const {
114 return reserved6_;
115 }
116
117 void reserved6(uint64_t value) {
118 reserved6_ = value;
119 }
120
121 ~Routine() override = default;
122
123 void accept(Visitor& visitor) const override;
124
125 std::ostream& print(std::ostream& os) const override;
126
127 static bool classof(const LoadCommand* cmd) {
128 return cmd->command() == LoadCommand::TYPE::ROUTINES ||
130 }
131
132 private:
133 uint64_t init_address_ = 0;
134 uint64_t init_module_ = 0;
135 uint64_t reserved1_ = 0;
136 uint64_t reserved2_ = 0;
137 uint64_t reserved3_ = 0;
138 uint64_t reserved4_ = 0;
139 uint64_t reserved5_ = 0;
140 uint64_t reserved6_ = 0;
141};
142
143}
144
145#endif
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:79
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
@ ROUTINES
Definition LoadCommand.hpp:65
@ ROUTINES_64
Definition LoadCommand.hpp:74
static bool classof(const LoadCommand *cmd)
Definition Routine.hpp:127
uint64_t reserved4() const
Definition Routine.hpp:97
std::unique_ptr< LoadCommand > clone() const override
Definition Routine.hpp:51
void init_module(uint64_t mod)
Definition Routine.hpp:69
uint64_t reserved2() const
Definition Routine.hpp:81
void accept(Visitor &visitor) const override
Routine(const Routine &copy)=default
std::ostream & print(std::ostream &os) const override
uint64_t reserved6() const
Definition Routine.hpp:113
uint64_t reserved1() const
Definition Routine.hpp:73
friend class BinaryParser
Definition Routine.hpp:40
uint64_t init_address() const
address of initialization routine
Definition Routine.hpp:56
void reserved3(uint64_t value)
Definition Routine.hpp:93
void reserved5(uint64_t value)
Definition Routine.hpp:109
void reserved6(uint64_t value)
Definition Routine.hpp:117
Routine & operator=(const Routine &copy)=default
void reserved1(uint64_t value)
Definition Routine.hpp:77
void reserved2(uint64_t value)
Definition Routine.hpp:85
uint64_t init_module() const
Index into the module table that the init routine is defined in.
Definition Routine.hpp:65
void init_address(uint64_t addr)
Definition Routine.hpp:60
Routine(const T &cmd)
void reserved4(uint64_t value)
Definition Routine.hpp:101
uint64_t reserved5() const
Definition Routine.hpp:105
uint64_t reserved3() const
Definition Routine.hpp:89
~Routine() override=default
Definition Visitor.hpp:212
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46