LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
MainCommand.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_MAIN_COMMAND_H
17#define LIEF_MACHO_MAIN_COMMAND_H
18#include <memory>
19#include <ostream>
20
21#include "LIEF/visibility.h"
22
24
25
26namespace LIEF::MachO {
27
28namespace details {
29struct entry_point_command;
30}
31
35 public:
36 MainCommand() = default;
37 MainCommand(const details::entry_point_command& cmd);
38 MainCommand(uint64_t entrypoint, uint64_t stacksize);
39
40 MainCommand& operator=(const MainCommand& copy) = default;
41 MainCommand(const MainCommand& copy) = default;
42
43 std::unique_ptr<LoadCommand> clone() const override {
44 return std::make_unique<MainCommand>(*this);
45 }
46
47 ~MainCommand() override = default;
48
51 uint64_t entrypoint() const {
52 return entrypoint_;
53 }
54
56 uint64_t stack_size() const {
57 return stack_size_;
58 }
59
60 void entrypoint(uint64_t entrypoint) {
61 entrypoint_ = entrypoint;
62 }
63 void stack_size(uint64_t stacksize) {
64 stack_size_ = stacksize;
65 }
66
67 std::ostream& print(std::ostream& os) const override;
68
69 void accept(Visitor& visitor) const override;
70
71 static bool classof(const LoadCommand* cmd) {
72 return cmd->command() == LoadCommand::TYPE::MAIN;
73 }
74
75 private:
76 uint64_t entrypoint_ = 0;
77 uint64_t stack_size_ = 0;
78};
79
80}
81
82#endif
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
@ MAIN
Definition LoadCommand.hpp:89
uint64_t entrypoint() const
Offset of the main function relative to the __TEXT segment.
Definition MainCommand.hpp:51
MainCommand(const MainCommand &copy)=default
void entrypoint(uint64_t entrypoint)
Definition MainCommand.hpp:60
MainCommand(uint64_t entrypoint, uint64_t stacksize)
uint64_t stack_size() const
The initial stack size.
Definition MainCommand.hpp:56
std::unique_ptr< LoadCommand > clone() const override
Definition MainCommand.hpp:43
~MainCommand() override=default
MainCommand(const details::entry_point_command &cmd)
std::ostream & print(std::ostream &os) const override
void accept(Visitor &visitor) const override
void stack_size(uint64_t stacksize)
Definition MainCommand.hpp:63
static bool classof(const LoadCommand *cmd)
Definition MainCommand.hpp:71
MainCommand & operator=(const MainCommand &copy)=default
Definition Visitor.hpp:212
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
#define LIEF_API
Definition visibility.h:45