LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
GenericType.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_PE_ATTRIBUTES_GENERIC_TYPE_H
17#define LIEF_PE_ATTRIBUTES_GENERIC_TYPE_H
18#include <memory>
19#include <vector>
20
21#include "LIEF/visibility.h"
22#include "LIEF/errors.hpp"
23#include "LIEF/span.hpp"
24#include "LIEF/PE/signature/Attribute.hpp"
25#include "LIEF/PE/signature/types.hpp"
26
27
28namespace LIEF {
29class VectorStream;
30namespace PE {
31
33class LIEF_API GenericType : public Attribute {
34 friend class Parser;
35 friend class SignatureParser;
36
37 public:
38 GenericType() :
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 {}
46 GenericType(const GenericType&) = default;
47 GenericType& operator=(const GenericType&) = default;
48
49 std::unique_ptr<Attribute> clone() const override {
50 return std::unique_ptr<Attribute>(new GenericType{*this});
51 }
52
54 const oid_t& oid() const {
55 return oid_;
56 }
57
59 span<const uint8_t> raw_content() const {
60 return raw_;
61 }
62
64 std::string print() const override;
65
66 void accept(Visitor& visitor) const override;
67
68 ~GenericType() override = default;
69
70 static bool classof(const Attribute* attr) {
71 return attr->type() == Attribute::TYPE::GENERIC_TYPE;
72 }
73
74 private:
75 oid_t oid_;
76 std::vector<uint8_t> raw_;
77};
78
79}
80}
81
82#endif
Interface over PKCS #7 attribute.
Definition Attribute.hpp:30
virtual TYPE type() const
Concrete type of the attribute.
Definition Attribute.hpp:60
Interface over an attribute for which the internal structure is not supported by LIEF.
Definition GenericType.hpp:33
span< const uint8_t > raw_content() const
Original DER blob of the attribute.
Definition GenericType.hpp:59
const oid_t & oid() const
OID of the original attribute.
Definition GenericType.hpp:54
std::string print() const override
Print information about the attribute.
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:219
LIEF namespace.
Definition Abstract/Binary.hpp:32