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