LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
MainCommand.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_MAIN_COMMAND_H
17#define LIEF_MACHO_MAIN_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21
23
24namespace LIEF {
25namespace MachO {
26
27namespace details {
28struct entry_point_command;
29}
30
34 public:
35 MainCommand() = default;
36 MainCommand(const details::entry_point_command& cmd);
37 MainCommand(uint64_t entrypoint, uint64_t stacksize);
38
39 MainCommand& operator=(const MainCommand& copy) = default;
40 MainCommand(const MainCommand& copy) = default;
41
42 std::unique_ptr<LoadCommand> clone() const override {
43 return std::unique_ptr<MainCommand>(new MainCommand(*this));
44 }
45
46 ~MainCommand() override = default;
47
50 uint64_t entrypoint() const {
51 return entrypoint_;
52 }
53
55 uint64_t stack_size() const {
56 return stack_size_;
57 }
58
59 void entrypoint(uint64_t entrypoint) {
60 entrypoint_ = entrypoint;
61 }
62 void stack_size(uint64_t stacksize) {
63 stack_size_ = stacksize;
64 }
65
66 std::ostream& print(std::ostream& os) const override;
67
68 void accept(Visitor& visitor) const override;
69
70 static bool classof(const LoadCommand* cmd) {
71 return cmd->command() == LoadCommand::TYPE::MAIN;
72 }
73
74 private:
75 uint64_t entrypoint_ = 0;
76 uint64_t stack_size_ = 0;
77};
78
79}
80}
81#endif
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:122
Class that represent the LC_MAIN command. This kind of command can be used to determine the entrypoin...
Definition MainCommand.hpp:33
uint64_t entrypoint() const
Offset of the main function relative to the __TEXT segment.
Definition MainCommand.hpp:50
MainCommand(const MainCommand &copy)=default
void entrypoint(uint64_t entrypoint)
Definition MainCommand.hpp:59
MainCommand(uint64_t entrypoint, uint64_t stacksize)
uint64_t stack_size() const
The initial stack size.
Definition MainCommand.hpp:55
std::unique_ptr< LoadCommand > clone() const override
Definition MainCommand.hpp:42
~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:62
static bool classof(const LoadCommand *cmd)
Definition MainCommand.hpp:70
MainCommand & operator=(const MainCommand &copy)=default
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41