LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
AtomInfo.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_ATOM_INFO_COMMAND_H
17#define LIEF_MACHO_ATOM_INFO_COMMAND_H
18#include <memory>
19#include <ostream>
20
22#include "LIEF/visibility.h"
23
25#include "LIEF/span.hpp"
26
27
28namespace LIEF::MachO {
29class BinaryParser;
30class LinkEdit;
31
32namespace details {
33struct linkedit_data_command;
34}
35
38 friend class BinaryParser;
39 friend class LinkEdit;
40
41 public:
43 AtomInfo(const details::linkedit_data_command& cmd);
44
45 AtomInfo& operator=(const AtomInfo& copy) = default;
46 AtomInfo(const AtomInfo& copy) = default;
47
48 std::unique_ptr<LoadCommand> clone() const override {
49 return std::make_unique<AtomInfo>(*this);
50 }
51
53 uint32_t data_offset() const {
54 return data_offset_;
55 }
56
58 uint32_t data_size() const {
59 return data_size_;
60 }
61
62 void data_offset(uint32_t offset) {
63 data_offset_ = offset;
64 }
65 void data_size(uint32_t size) {
66 data_size_ = size;
67 }
68
70 return content_;
71 }
72
74 return content_;
75 }
76
77 ~AtomInfo() override = default;
78
79 void accept(Visitor& visitor) const override;
80
81 std::ostream& print(std::ostream& os) const override;
82
83 static bool classof(const LoadCommand* cmd) {
85 }
86
87 private:
88 uint32_t data_offset_ = 0;
89 uint32_t data_size_ = 0;
90 span<uint8_t> content_;
91};
92
93}
94
95#endif
uint32_t data_size() const
Size of the payload.
Definition AtomInfo.hpp:58
span< const uint8_t > content() const
Definition AtomInfo.hpp:69
void data_offset(uint32_t offset)
Definition AtomInfo.hpp:62
friend class BinaryParser
Definition AtomInfo.hpp:38
span< uint8_t > content()
Definition AtomInfo.hpp:73
~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:65
uint32_t data_offset() const
Offset in the __LINKEDIT SegmentCommand where the payload starts.
Definition AtomInfo.hpp:53
friend class LinkEdit
Definition AtomInfo.hpp:39
AtomInfo(const details::linkedit_data_command &cmd)
static bool classof(const LoadCommand *cmd)
Definition AtomInfo.hpp:83
AtomInfo(const AtomInfo &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition AtomInfo.hpp:48
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:79
Definition LinkEdit.hpp:47
uint32_t size() const
Size of the command (should be greater than sizeof(load_command)).
Definition LoadCommand.hpp:137
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
@ ATOM_INFO
Definition LoadCommand.hpp:103
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:45