LIEF: Library to Instrument Executable Formats Version 0.17.0
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}
30class LIEF_API MainCommand : public LoadCommand {
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 uint64_t entrypoint() const {
51 return entrypoint_;
52 }
53 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
LoadCommand.hpp
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:125
LIEF::MachO::MainCommand
Class that represent the LC_MAIN command. This kind of command can be used to determine the entrypoin...
Definition MainCommand.hpp:33
LIEF::MachO::MainCommand::entrypoint
uint64_t entrypoint() const
Offset of the main function relative to the __TEXT segment.
Definition MainCommand.hpp:50
LIEF::MachO::MainCommand::MainCommand
MainCommand(const MainCommand &copy)=default
LIEF::MachO::MainCommand::MainCommand
MainCommand()=default
LIEF::MachO::MainCommand::entrypoint
void entrypoint(uint64_t entrypoint)
Definition MainCommand.hpp:59
LIEF::MachO::MainCommand::MainCommand
MainCommand(uint64_t entrypoint, uint64_t stacksize)
LIEF::MachO::MainCommand::stack_size
uint64_t stack_size() const
The initial stack size.
Definition MainCommand.hpp:55
LIEF::MachO::MainCommand::clone
std::unique_ptr< LoadCommand > clone() const override
Definition MainCommand.hpp:42
LIEF::MachO::MainCommand::~MainCommand
~MainCommand() override=default
LIEF::MachO::MainCommand::MainCommand
MainCommand(const details::entry_point_command &cmd)
LIEF::MachO::MainCommand::print
std::ostream & print(std::ostream &os) const override
LIEF::MachO::MainCommand::accept
void accept(Visitor &visitor) const override
LIEF::MachO::MainCommand::stack_size
void stack_size(uint64_t stacksize)
Definition MainCommand.hpp:62
LIEF::MachO::MainCommand::classof
static bool classof(const LoadCommand *cmd)
Definition MainCommand.hpp:70
LIEF::MachO::MainCommand::operator=
MainCommand & operator=(const MainCommand &copy)=default
LIEF::MachO::details
Definition endianness_support.hpp:59
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