LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
AuxiliaryFile.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_AUXILIARY_FILE_H
17#define LIEF_PE_AUXILIARY_FILE_H
18
19#include <string_view>
20#include <memory>
21
24#include "LIEF/visibility.h"
25
26
27namespace LIEF::COFF {
28
37 public:
38 LIEF_LOCAL static std::unique_ptr<AuxiliaryFile>
39 parse(const std::vector<uint8_t>& payload);
40
43
44 AuxiliaryFile(std::string file) :
46 filename_(std::move(file)) {}
47
48 AuxiliaryFile(const AuxiliaryFile&) = default;
50
53
54 std::unique_ptr<AuxiliarySymbol> clone() const override {
55 return std::make_unique<AuxiliaryFile>(*this);
56 }
57
59 std::string_view filename() const LIEF_LIFETIMEBOUND {
60 return filename_;
61 }
62
63 AuxiliaryFile& filename(std::string file) {
64 filename_ = std::move(file);
65 return *this;
66 }
67
68 std::string to_string() const override {
69 std::string out = "AuxiliaryFile {\n";
70 out += " " + filename_ + "\n}";
71 return out;
72 }
73
74 ~AuxiliaryFile() override = default;
75
76 static bool classof(const AuxiliarySymbol* sym) {
77 return sym->type() == AuxiliarySymbol::TYPE::FILE;
78 }
79
80 protected:
81 std::string filename_;
82};
83
84}
85
86#endif
AuxiliaryFile & filename(std::string file)
Definition AuxiliaryFile.hpp:63
std::string to_string() const override
Definition AuxiliaryFile.hpp:68
AuxiliaryFile(std::string file)
Definition AuxiliaryFile.hpp:44
AuxiliaryFile(const AuxiliaryFile &)=default
std::string_view filename() const
The associated filename.
Definition AuxiliaryFile.hpp:59
AuxiliaryFile & operator=(AuxiliaryFile &&)=default
AuxiliaryFile(AuxiliaryFile &&)=default
std::unique_ptr< AuxiliarySymbol > clone() const override
Definition AuxiliaryFile.hpp:54
AuxiliaryFile()
Definition AuxiliaryFile.hpp:41
static std::unique_ptr< AuxiliaryFile > parse(const std::vector< uint8_t > &payload)
AuxiliaryFile & operator=(const AuxiliaryFile &)=default
~AuxiliaryFile() override=default
static bool classof(const AuxiliarySymbol *sym)
Definition AuxiliaryFile.hpp:76
span< const uint8_t > payload() const
For unknown type only, return the raw representation of this symbol.
Definition AuxiliarySymbol.hpp:85
TYPE type() const
Definition AuxiliarySymbol.hpp:80
TYPE
Type discriminator for the subclasses.
Definition AuxiliarySymbol.hpp:56
@ FILE
Auxiliary Format 4: Files from the PE-COFF documentation.
Definition AuxiliarySymbol.hpp:69
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition AuxiliarySymbol.hpp:30
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46