LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
GenericType.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_PE_ATTRIBUTES_GENERIC_TYPE_H
17#define LIEF_PE_ATTRIBUTES_GENERIC_TYPE_H
18#include <memory>
19#include <vector>
20
24#include "LIEF/span.hpp"
25#include "LIEF/visibility.h"
26
27namespace LIEF {
28class VectorStream;
29namespace PE {
30
34 friend class Parser;
35 friend class SignatureParser;
36
37 public:
39 Attribute(Attribute::TYPE::GENERIC_TYPE) {}
40
41 GenericType(oid_t oid, std::vector<uint8_t> raw) :
42 Attribute(Attribute::TYPE::GENERIC_TYPE),
43 oid_{std::move(oid)},
44 raw_{std::move(raw)} {}
45 GenericType(const GenericType&) = default;
46 GenericType& operator=(const GenericType&) = default;
47
48 std::unique_ptr<Attribute> clone() const override {
49 return std::unique_ptr<Attribute>(new GenericType{*this});
50 }
51
53 const oid_t& oid() const {
54 return oid_;
55 }
56
59 return raw_;
60 }
61
63 std::string print() const override;
64
65 void accept(Visitor& visitor) const override;
66
67 ~GenericType() override = default;
68
69 static bool classof(const Attribute* attr) {
70 return attr->type() == Attribute::TYPE::GENERIC_TYPE;
71 }
72
73 private:
74 oid_t oid_;
75 std::vector<uint8_t> raw_;
76};
77
78}
79}
80
81#endif
TYPE
Definition PE/signature/Attribute.hpp:35
@ GENERIC_TYPE
Definition PE/signature/Attribute.hpp:38
virtual TYPE type() const
Concrete type of the attribute.
Definition PE/signature/Attribute.hpp:62
GenericType & operator=(const GenericType &)=default
std::unique_ptr< Attribute > clone() const override
Definition GenericType.hpp:48
~GenericType() override=default
void accept(Visitor &visitor) const override
GenericType()
Definition GenericType.hpp:38
span< const uint8_t > raw_content() const
Original DER blob of the attribute.
Definition GenericType.hpp:58
GenericType(const GenericType &)=default
GenericType(oid_t oid, std::vector< uint8_t > raw)
Definition GenericType.hpp:41
const oid_t & oid() const
OID of the original attribute.
Definition GenericType.hpp:53
friend class SignatureParser
Definition GenericType.hpp:35
std::string print() const override
Print information about the attribute.
friend class Parser
Definition GenericType.hpp:34
static bool classof(const Attribute *attr)
Definition GenericType.hpp:69
Definition VectorStream.hpp:29
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
std::string oid_t
Definition PE/signature/types.hpp:23
LIEF namespace.
Definition Abstract/Binary.hpp:42
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:45