LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
CodeSignature.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_CODE_SIGNATURE_COMMAND_H
17#define LIEF_MACHO_CODE_SIGNATURE_COMMAND_H
18#include <ostream>
19#include <cstdint>
20
21#include "LIEF/span.hpp"
22#include "LIEF/visibility.h"
23
25
26namespace LIEF {
27namespace MachO {
28
29class BinaryParser;
30class Builder;
31class LinkEdit;
32
33namespace details {
34struct linkedit_data_command;
35}
36
38 friend class BinaryParser;
39 friend class Builder;
40 friend class LinkEdit;
41
42 public:
43 CodeSignature() = default;
44 CodeSignature(const details::linkedit_data_command& cmd);
45
46 CodeSignature& operator=(const CodeSignature& copy) = default;
47 CodeSignature(const CodeSignature& copy) = default;
48
49 std::unique_ptr<LoadCommand> clone() const override {
50 return std::unique_ptr<CodeSignature>(new CodeSignature(*this));
51 }
52 uint32_t data_offset() const {
55 return data_offset_;
56 }
57 uint32_t data_size() const {
60 return data_size_;
61 }
62
63 void data_offset(uint32_t offset) {
64 data_offset_ = offset;
65 }
66 void data_size(uint32_t size) {
67 data_size_ = size;
68 }
69
70 span<uint8_t> content() {
71 return content_;
72 }
73
74 span<const uint8_t> content() const {
75 return content_;
76 }
77
78 ~CodeSignature() 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::CODE_SIGNATURE;
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:75
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:58
Definition CodeSignature.hpp:37
void data_size(uint32_t size)
Definition CodeSignature.hpp:66
static bool classof(const LoadCommand *cmd)
Definition CodeSignature.hpp:84
uint32_t data_size() const
Size of the raw signature.
Definition CodeSignature.hpp:59
uint32_t data_offset() const
Offset in the binary where the signature starts.
Definition CodeSignature.hpp:54
CodeSignature & operator=(const CodeSignature &copy)=default
span< uint8_t > content()
Definition CodeSignature.hpp:70
CodeSignature(const details::linkedit_data_command &cmd)
std::ostream & print(std::ostream &os) const override
std::unique_ptr< LoadCommand > clone() const override
Definition CodeSignature.hpp:49
void accept(Visitor &visitor) const override
~CodeSignature() override=default
void data_offset(uint32_t offset)
Definition CodeSignature.hpp:63
CodeSignature()=default
span< const uint8_t > content() const
Definition CodeSignature.hpp:74
CodeSignature(const CodeSignature &copy)=default
Definition LinkEdit.hpp:43
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:125
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41