LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
EncryptionInfo.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_ENCRYPTION_INFO_COMMAND_H
17#define LIEF_MACHO_ENCRYPTION_INFO_COMMAND_H
18#include <memory>
19#include <ostream>
20
21#include "LIEF/visibility.h"
22
24
25
26namespace LIEF::MachO {
27
28namespace details {
29struct encryption_info_command;
30}
31
37 public:
38 EncryptionInfo() = default;
39 EncryptionInfo(const details::encryption_info_command& cmd);
40
41 EncryptionInfo& operator=(const EncryptionInfo& copy) = default;
42 EncryptionInfo(const EncryptionInfo& copy) = default;
43
44 ~EncryptionInfo() override = default;
45
46 std::unique_ptr<LoadCommand> clone() const override {
47 return std::make_unique<EncryptionInfo>(*this);
48 }
49
51 uint32_t crypt_offset() const {
52 return coff_;
53 }
54
56 uint32_t crypt_size() const {
57 return csize_;
58 }
59
61 uint32_t crypt_id() const {
62 return cid_;
63 }
64
65 void crypt_offset(uint32_t offset) {
66 coff_ = offset;
67 }
68
69 void crypt_size(uint32_t size) {
70 csize_ = size;
71 }
72 void crypt_id(uint32_t id) {
73 cid_ = id;
74 }
75
76 void accept(Visitor& visitor) const override;
77
78 std::ostream& print(std::ostream& os) const override;
79
80 static bool classof(const LoadCommand* cmd) {
81 const LoadCommand::TYPE type = cmd->command();
84 }
85
86 private:
87 uint32_t coff_ = 0;
88 uint32_t csize_ = 0;
89 uint32_t cid_ = 0;
90};
91
92}
93
94#endif
void accept(Visitor &visitor) const override
~EncryptionInfo() override=default
uint32_t crypt_offset() const
The beginning of the encrypted area.
Definition EncryptionInfo.hpp:51
EncryptionInfo & operator=(const EncryptionInfo &copy)=default
uint32_t crypt_id() const
The encryption system. 0 means not encrypted.
Definition EncryptionInfo.hpp:61
void crypt_offset(uint32_t offset)
Definition EncryptionInfo.hpp:65
void crypt_id(uint32_t id)
Definition EncryptionInfo.hpp:72
EncryptionInfo(const details::encryption_info_command &cmd)
uint32_t crypt_size() const
The size of the encrypted area.
Definition EncryptionInfo.hpp:56
static bool classof(const LoadCommand *cmd)
Definition EncryptionInfo.hpp:80
EncryptionInfo(const EncryptionInfo &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition EncryptionInfo.hpp:46
void crypt_size(uint32_t size)
Definition EncryptionInfo.hpp:69
std::ostream & print(std::ostream &os) const override
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
TYPE
Definition LoadCommand.hpp:47
@ ENCRYPTION_INFO
Definition LoadCommand.hpp:81
@ ENCRYPTION_INFO_64
Definition LoadCommand.hpp:93
Definition Visitor.hpp:212
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