LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
CodeSignatureDir.hpp
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_CODE_SIGNATURE_DIR_COMMAND_H
17#define LIEF_MACHO_CODE_SIGNATURE_DIR_COMMAND_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/span.hpp"
22
23#include "LIEF/MachO/LoadCommand.hpp"
24
25namespace LIEF {
26namespace MachO {
27
28class BinaryParser;
29class Builder;
30class LinkEdit;
31
32namespace details {
33struct linkedit_data_command;
34}
35
36class LIEF_API CodeSignatureDir : public LoadCommand {
37 friend class BinaryParser;
38 friend class Builder;
39 friend class LinkEdit;
40
41 public:
42 CodeSignatureDir() = default;
43 CodeSignatureDir(const details::linkedit_data_command& cmd);
44
45 CodeSignatureDir& operator=(const CodeSignatureDir& copy) = default;
46 CodeSignatureDir(const CodeSignatureDir& copy) = default;
47
48 std::unique_ptr<LoadCommand> clone() const override {
49 return std::unique_ptr<CodeSignatureDir>(new CodeSignatureDir(*this));
50 }
51
53 uint32_t data_offset() const {
54 return data_offset_;
55 }
56
58 uint32_t data_size() const {
59 return data_size_;
60 }
61
62 void data_offset(uint32_t offset) {
63 data_offset_ = offset;
64 }
65
66 void data_size(uint32_t size) {
67 data_size_ = size;
68 }
69
70 span<const uint8_t> content() const {
71 return content_;
72 }
73
74 span<uint8_t> content() {
75 return content_;
76 }
77
78 ~CodeSignatureDir() override = default;
79
80 void accept(Visitor& visitor) const override;
81
82 std::ostream& print(std::ostream& os) const override;
83
84 static bool classof(const LoadCommand* cmd) {
85 return cmd->command() == LoadCommand::TYPE::DYLIB_CODE_SIGN_DRS;
86 }
87
88 private:
89 uint32_t data_offset_ = 0;
90 uint32_t data_size_ = 0;
91 span<uint8_t> content_;
92
93};
94
95}
96}
97#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:73
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:54
Definition CodeSignatureDir.hpp:36
uint32_t data_offset() const
Offset in the binary where the signature starts.
Definition CodeSignatureDir.hpp:53
uint32_t data_size() const
Size of the raw signature.
Definition CodeSignatureDir.hpp:58
Definition LinkEdit.hpp:42
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:32