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