LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
FilesetCommand.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_FILESET_COMMAND_H
17#define LIEF_MACHO_FILESET_COMMAND_H
18#include <string_view>
19#include <memory>
20#include <ostream>
21
23#include "LIEF/visibility.h"
24
26
27
28namespace LIEF::MachO {
29class Binary;
30class BinaryParser;
31
32namespace details {
33struct fileset_entry_command;
34}
35
38 public:
39 friend class BinaryParser;
40 using content_t = std::vector<uint8_t>;
41
42 FilesetCommand() = default;
43 FilesetCommand(const details::fileset_entry_command& command);
44 FilesetCommand(std::string name) :
45 name_(std::move(name)) {}
46
49
50 void swap(FilesetCommand& other) noexcept;
51
52 std::unique_ptr<LoadCommand> clone() const override {
53 return std::make_unique<FilesetCommand>(*this);
54 }
55
56 ~FilesetCommand() override = default;
57
59 std::string_view name() const LIEF_LIFETIMEBOUND {
60 return name_;
61 }
62
64 uint64_t virtual_address() const {
65 return virtual_address_;
66 }
67
69 uint64_t file_offset() const {
70 return file_offset_;
71 }
72
76 return binary_;
77 }
78
80 return binary_;
81 }
82
83 void name(std::string name) {
84 name_ = std::move(name);
85 }
86
88 virtual_address_ = virtual_address;
89 }
90 void file_offset(uint64_t file_offset) {
91 file_offset_ = file_offset;
92 }
93
94 std::ostream& print(std::ostream& os) const override;
95
96 static bool classof(const LoadCommand* cmd) {
98 }
99
100 private:
101 std::string name_;
102 uint64_t virtual_address_ = 0;
103 uint64_t file_offset_ = 0;
104 Binary* binary_ = nullptr;
105};
106
107}
108
109#endif
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:79
Class which represents a MachO binary.
Definition MachO/Binary.hpp:94
void virtual_address(uint64_t virtual_address)
Definition FilesetCommand.hpp:87
uint64_t file_offset() const
Original offset in the kernel cache.
Definition FilesetCommand.hpp:69
std::unique_ptr< LoadCommand > clone() const override
Definition FilesetCommand.hpp:52
void name(std::string name)
Definition FilesetCommand.hpp:83
std::string_view name() const
Name of the underlying MachO binary (e.g. com.apple.security.quarantine).
Definition FilesetCommand.hpp:59
friend class BinaryParser
Definition FilesetCommand.hpp:39
uint64_t virtual_address() const
Memory address where the MachO file should be mapped.
Definition FilesetCommand.hpp:64
static bool classof(const LoadCommand *cmd)
Definition FilesetCommand.hpp:96
void swap(FilesetCommand &other) noexcept
FilesetCommand & operator=(FilesetCommand copy)
FilesetCommand(std::string name)
Definition FilesetCommand.hpp:44
std::ostream & print(std::ostream &os) const override
const Binary * binary() const
Return a pointer on the LIEF::MachO::Binary associated with this entry.
Definition FilesetCommand.hpp:75
FilesetCommand(const details::fileset_entry_command &command)
std::vector< uint8_t > content_t
Definition FilesetCommand.hpp:40
void file_offset(uint64_t file_offset)
Definition FilesetCommand.hpp:90
FilesetCommand(const FilesetCommand &copy)
~FilesetCommand() override=default
Binary * binary()
Definition FilesetCommand.hpp:79
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
friend class Binary
Definition LoadCommand.hpp:41
@ FILESET_ENTRY
Definition LoadCommand.hpp:102
#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
#define LIEF_API
Definition visibility.h:45