LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
AtomInfo.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_ATOM_INFO_COMMAND_H
17#define LIEF_MACHO_ATOM_INFO_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21
22#include "LIEF/span.hpp"
24
25namespace LIEF {
26namespace MachO {
27class BinaryParser;
28class LinkEdit;
29
30namespace details {
31struct linkedit_data_command;
32}
33
36 friend class BinaryParser;
37 friend class LinkEdit;
38
39 public:
41 AtomInfo(const details::linkedit_data_command& cmd);
42
43 AtomInfo& operator=(const AtomInfo& copy) = default;
44 AtomInfo(const AtomInfo& copy) = default;
45
46 std::unique_ptr<LoadCommand> clone() const override {
47 return std::unique_ptr<AtomInfo>(new AtomInfo(*this));
48 }
49
51 uint32_t data_offset() const {
52 return data_offset_;
53 }
54
56 uint32_t data_size() const {
57 return data_size_;
58 }
59
60 void data_offset(uint32_t offset) {
61 data_offset_ = offset;
62 }
63 void data_size(uint32_t size) {
64 data_size_ = size;
65 }
66
68 return content_;
69 }
70
72 return content_;
73 }
74
75 ~AtomInfo() override = default;
76
77 void accept(Visitor& visitor) const override;
78
79 std::ostream& print(std::ostream& os) const override;
80
81 static bool classof(const LoadCommand* cmd) {
83 }
84
85 private:
86 uint32_t data_offset_ = 0;
87 uint32_t data_size_ = 0;
88 span<uint8_t> content_;
89};
90
91}
92}
93#endif
uint32_t data_size() const
Size of the payload.
Definition AtomInfo.hpp:56
span< const uint8_t > content() const
Definition AtomInfo.hpp:67
void data_offset(uint32_t offset)
Definition AtomInfo.hpp:60
friend class BinaryParser
Definition AtomInfo.hpp:36
span< uint8_t > content()
Definition AtomInfo.hpp:71
~AtomInfo() override=default
std::ostream & print(std::ostream &os) const override
AtomInfo & operator=(const AtomInfo &copy)=default
void accept(Visitor &visitor) const override
void data_size(uint32_t size)
Definition AtomInfo.hpp:63
uint32_t data_offset() const
Offset in the __LINKEDIT SegmentCommand where the payload starts.
Definition AtomInfo.hpp:51
friend class LinkEdit
Definition AtomInfo.hpp:37
AtomInfo(const details::linkedit_data_command &cmd)
static bool classof(const LoadCommand *cmd)
Definition AtomInfo.hpp:81
AtomInfo(const AtomInfo &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition AtomInfo.hpp:46
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:78
Definition LinkEdit.hpp:45
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
@ ATOM_INFO
Definition LoadCommand.hpp:100
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