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