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