LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
ContentInfo.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_PE_CONTENT_INFO_H
17#define LIEF_PE_CONTENT_INFO_H
18
19#include <vector>
20#include <ostream>
21#include <memory>
22
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25
27#include "LIEF/PE/enums.hpp"
28
29namespace LIEF {
30namespace PE {
31
32class Parser;
33class SignatureParser;
34
78class LIEF_API ContentInfo : public Object {
79 friend class Parser;
80 friend class SignatureParser;
81
82 public:
83 class Content : public Object {
84 public:
86 type_(std::move(oid))
87 {}
88
89 const oid_t& content_type() const {
90 return type_;
91 }
92
93 virtual std::unique_ptr<Content> clone() const = 0;
94 virtual void print(std::ostream& os) const = 0;
95
96 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Content& content) {
97 content.print(os);
98 return os;
99 }
100
101 ~Content() override = default;
102 private:
103 oid_t type_;
104 };
107 ContentInfo(ContentInfo&& other) noexcept = default;
109
110 void swap(ContentInfo& other) noexcept;
111
115 return value_->content_type();
116 }
117
119 return *value_;
120 }
121
122 const Content& value() const {
123 return *value_;
124 }
125
128 std::vector<uint8_t> digest() const;
129
132
133 void accept(Visitor& visitor) const override;
134
135 ~ContentInfo() override = default;
136
137 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ContentInfo& content_info);
138
139 private:
140 std::unique_ptr<Content> value_;
141};
142
143}
144}
145
146#endif
Definition Object.hpp:25
Definition ContentInfo.hpp:83
~Content() override=default
const oid_t & content_type() const
Definition ContentInfo.hpp:89
Content(oid_t oid)
Definition ContentInfo.hpp:85
virtual std::unique_ptr< Content > clone() const =0
virtual void print(std::ostream &os) const =0
friend std::ostream & operator<<(std::ostream &os, const Content &content)
Definition ContentInfo.hpp:96
Definition ContentInfo.hpp:78
std::vector< uint8_t > digest() const
Return the digest (authentihash) if the underlying content type is SPC_INDIRECT_DATA_OBJID Otherwise,...
ALGORITHMS digest_algorithm() const
Return the digest used to hash the file.
void accept(Visitor &visitor) const override
ContentInfo(ContentInfo &&other) noexcept=default
ContentInfo(const ContentInfo &other)
const Content & value() const
Definition ContentInfo.hpp:122
oid_t content_type() const
Return the OID that describes the content wrapped by this object. It should match SPC_INDIRECT_DATA_O...
Definition ContentInfo.hpp:114
~ContentInfo() override=default
Content & value()
Definition ContentInfo.hpp:118
void swap(ContentInfo &other) noexcept
ContentInfo & operator=(ContentInfo other)
friend std::ostream & operator<<(std::ostream &os, const ContentInfo &content_info)
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition SignatureParser.hpp:37
Definition Visitor.hpp:224
ALGORITHMS
Cryptography algorithms.
Definition PE/enums.hpp:686
std::string oid_t
Definition PE/signature/types.hpp:23
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41