LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
CodeViewPDB.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_DEBUG_CODE_VIEW_PDB_H
17#define LIEF_PE_DEBUG_CODE_VIEW_PDB_H
18#include <string_view>
19
22
23#include <array>
24#include <cstdint>
25
26
27namespace LIEF::PE {
28class Parser;
29class Builder;
30
31namespace details {
32struct pe_pdb_70;
33struct pe_pdb_20;
34}
35
38 friend class Parser;
39 friend class Builder;
40
41 public:
42 using signature_t = std::array<uint8_t, 16>;
45
46 CodeViewPDB(std::string filename) :
48 signature_{0},
49 filename_(std::move(filename)) {}
50
51 CodeViewPDB(const details::pe_debug& debug_info,
52 const details::pe_pdb_70& pdb_70, Section* sec);
53
54 CodeViewPDB(const details::pe_debug& debug_info,
55 const details::pe_pdb_20& pdb_70, Section* sec);
56
57 CodeViewPDB(const CodeViewPDB& other) = default;
58 CodeViewPDB& operator=(const CodeViewPDB& other) = default;
59
60 CodeViewPDB(CodeViewPDB&& other) = default;
61 CodeViewPDB& operator=(CodeViewPDB&& other) = default;
62
65 std::string guid() const;
66
70 uint32_t age() const {
71 return age_;
72 }
73
75 const signature_t& signature() const {
76 return signature_;
77 }
78
80 std::string_view filename() const LIEF_LIFETIMEBOUND {
81 return filename_;
82 }
83
84 void age(uint32_t age) {
85 age_ = age;
86 }
87
88 void signature(const signature_t& sig) {
89 signature_ = sig;
90 }
91
92 void filename(std::string filename) {
93 filename_ = std::move(filename);
94 }
95
96 std::unique_ptr<Debug> clone() const override {
97 return std::unique_ptr<Debug>(new CodeViewPDB(*this));
98 }
99
100 static bool classof(const Debug* debug) {
101 if (!CodeView::classof(debug)) {
102 return false;
103 }
104 const auto& cv = static_cast<const CodeView&>(*debug);
105
106 return cv.signature() == SIGNATURES::PDB_20 ||
107 cv.signature() == SIGNATURES::PDB_70;
108 }
109
110 void accept(Visitor& visitor) const override;
111
112 std::string to_string() const override;
113
114 ~CodeViewPDB() override = default;
115
116 protected:
117 uint32_t age_ = 0;
118 signature_t signature_ = {0};
119 std::string filename_;
120};
121
122}
123
124#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:44
CodeViewPDB & operator=(const CodeViewPDB &other)=default
CodeViewPDB(std::string filename)
Definition CodeViewPDB.hpp:46
std::string guid() const
The GUID signature to verify against the .pdb file signature. This attribute might be used to lookup ...
std::string_view filename() const
The path to the .pdb file.
Definition CodeViewPDB.hpp:80
void age(uint32_t age)
Definition CodeViewPDB.hpp:84
void accept(Visitor &visitor) const override
std::array< uint8_t, 16 > signature_t
Definition CodeViewPDB.hpp:42
static bool classof(const Debug *debug)
Definition CodeViewPDB.hpp:100
CodeViewPDB(const CodeViewPDB &other)=default
uint32_t age() const
Age value to verify. The age does not necessarily correspond to any known time value,...
Definition CodeViewPDB.hpp:70
friend class Builder
Definition CodeViewPDB.hpp:39
void signature(const signature_t &sig)
Definition CodeViewPDB.hpp:88
CodeViewPDB(CodeViewPDB &&other)=default
CodeViewPDB()
Definition CodeViewPDB.hpp:43
friend class Parser
Definition CodeViewPDB.hpp:38
CodeViewPDB(const details::pe_debug &debug_info, const details::pe_pdb_70 &pdb_70, Section *sec)
~CodeViewPDB() override=default
const signature_t & signature() const
The 32-bit signature to verify against the .pdb file signature.
Definition CodeViewPDB.hpp:75
CodeViewPDB & operator=(CodeViewPDB &&other)=default
std::string to_string() const override
void filename(std::string filename)
Definition CodeViewPDB.hpp:92
CodeViewPDB(const details::pe_debug &debug_info, const details::pe_pdb_20 &pdb_70, Section *sec)
std::unique_ptr< Debug > clone() const override
Definition CodeViewPDB.hpp:96
static bool classof(const Debug *debug)
Definition CodeView.hpp:69
SIGNATURES
Code view signatures.
Definition CodeView.hpp:33
@ PDB_20
Definition CodeView.hpp:37
@ PDB_70
Definition CodeView.hpp:36
CodeView()
Definition CodeView.hpp:42
This class represents a generic entry in the debug data directory. For known types,...
Definition debug/Debug.hpp:40
Main interface to parse PE binaries. In particular, the static Parser::parse functions should be used...
Definition PE/Parser.hpp:53
Class which represents a PE section.
Definition PE/Section.hpp:47
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DataDirectory.hpp:37
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
#define LIEF_API
Definition visibility.h:45