LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
EncryptionInfo.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_ENCRYPTION_INFO_COMMAND_H
17#define LIEF_MACHO_ENCRYPTION_INFO_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21
23
24namespace LIEF {
25namespace MachO {
26
27namespace details {
28struct encryption_info_command;
29}
30
36 public:
37 EncryptionInfo() = default;
38 EncryptionInfo(const details::encryption_info_command& cmd);
39
40 EncryptionInfo& operator=(const EncryptionInfo& copy) = default;
41 EncryptionInfo(const EncryptionInfo& copy) = default;
42
43 ~EncryptionInfo() override = default;
44
45 std::unique_ptr<LoadCommand> clone() const override {
46 return std::unique_ptr<EncryptionInfo>(new EncryptionInfo(*this));
47 }
48
50 uint32_t crypt_offset() const {
51 return coff_;
52 }
53
55 uint32_t crypt_size() const {
56 return csize_;
57 }
58
60 uint32_t crypt_id() const {
61 return cid_;
62 }
63
64 void crypt_offset(uint32_t offset) {
65 coff_ = offset;
66 }
67
68 void crypt_size(uint32_t size) {
69 csize_ = size;
70 }
71 void crypt_id(uint32_t id) {
72 cid_ = id;
73 }
74
75 void accept(Visitor& visitor) const override;
76
77 std::ostream& print(std::ostream& os) const override;
78
79 static bool classof(const LoadCommand* cmd) {
80 const LoadCommand::TYPE type = cmd->command();
81 return type == LoadCommand::TYPE::ENCRYPTION_INFO ||
82 type == LoadCommand::TYPE::ENCRYPTION_INFO_64;
83 }
84
85 private:
86 uint32_t coff_ = 0;
87 uint32_t csize_ = 0;
88 uint32_t cid_ = 0;
89};
90
91}
92}
93#endif
Class that represents the LC_ENCRYPTION_INFO / LC_ENCRYPTION_INFO_64 commands.
Definition EncryptionInfo.hpp:35
void accept(Visitor &visitor) const override
~EncryptionInfo() override=default
uint32_t crypt_offset() const
The beginning of the encrypted area.
Definition EncryptionInfo.hpp:50
EncryptionInfo & operator=(const EncryptionInfo &copy)=default
uint32_t crypt_id() const
The encryption system. 0 means no encrypted.
Definition EncryptionInfo.hpp:60
void crypt_offset(uint32_t offset)
Definition EncryptionInfo.hpp:64
void crypt_id(uint32_t id)
Definition EncryptionInfo.hpp:71
EncryptionInfo(const details::encryption_info_command &cmd)
uint32_t crypt_size() const
The size of the encrypted area.
Definition EncryptionInfo.hpp:55
static bool classof(const LoadCommand *cmd)
Definition EncryptionInfo.hpp:79
EncryptionInfo(const EncryptionInfo &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition EncryptionInfo.hpp:45
void crypt_size(uint32_t size)
Definition EncryptionInfo.hpp:68
std::ostream & print(std::ostream &os) const override
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:122
TYPE
Definition LoadCommand.hpp:42
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41