LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
NoteCommand.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 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_NOTE_COMMAND_H
17#define LIEF_MACHO_NOTE_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/span.hpp"
22
24
25namespace LIEF {
26namespace MachO {
27
28namespace details {
29struct note_command;
30}
31
36 public:
37 NoteCommand() = default;
38 NoteCommand(const details::note_command& cmd);
39
40 NoteCommand& operator=(const NoteCommand& copy) = default;
41 NoteCommand(const NoteCommand& copy) = default;
42
43 std::unique_ptr<LoadCommand> clone() const override {
44 return std::unique_ptr<NoteCommand>(new NoteCommand(*this));
45 }
46
48 uint64_t note_offset() const {
49 return note_offset_;
50 }
51
53 uint64_t note_size() const {
54 return note_size_;
55 }
56
59 return owner_;
60 }
61
63 return owner_;
64 }
65
67 std::string owner_str() const {
68 return std::string(owner_.data(), owner_.size()).c_str();
69 }
70
71 void note_offset(uint64_t offset) {
72 note_offset_ = offset;
73 }
74
75 void note_size(uint64_t size) {
76 note_size_ = size;
77 }
78
79 ~NoteCommand() override = default;
80
81 std::ostream& print(std::ostream& os) const override;
82
83 void accept(Visitor& visitor) const override;
84
85 static bool classof(const LoadCommand* cmd) {
86 return cmd->command() == LoadCommand::TYPE::NOTE;
87 }
88
89 private:
90 std::array<char, 16> owner_;
91 uint64_t note_offset_ = 0;
92 uint64_t note_size_ = 0;
93};
94
95}
96}
97#endif
uint32_t size() const
Size of the command (should be greather than sizeof(load_command)).
Definition LoadCommand.hpp:133
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:128
@ NOTE
Definition LoadCommand.hpp:95
std::ostream & print(std::ostream &os) const override
span< char > owner()
Definition NoteCommand.hpp:62
uint64_t note_offset() const
Offset of the data associated with this note.
Definition NoteCommand.hpp:48
void accept(Visitor &visitor) const override
span< const char > owner() const
Owner of the note (e.g. AIR_METALLIB).
Definition NoteCommand.hpp:58
std::unique_ptr< LoadCommand > clone() const override
Definition NoteCommand.hpp:43
std::string owner_str() const
Owner as a zero-terminated string.
Definition NoteCommand.hpp:67
NoteCommand(const details::note_command &cmd)
void note_size(uint64_t size)
Definition NoteCommand.hpp:75
static bool classof(const LoadCommand *cmd)
Definition NoteCommand.hpp:85
uint64_t note_size() const
Size of the data referenced by the note_offset.
Definition NoteCommand.hpp:53
NoteCommand & operator=(const NoteCommand &copy)=default
~NoteCommand() override=default
NoteCommand(const NoteCommand &copy)=default
void note_offset(uint64_t offset)
Definition NoteCommand.hpp:71
Definition Visitor.hpp:210
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:40
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:41