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