LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
CodeViewPDB.hpp
Go to the documentation of this file.
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_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;
31}
32
35 friend class Parser;
36 friend class Builder;
37
38 public:
39 using signature_t = std::array<uint8_t, 16>;
40 CodeViewPDB() = default;
41 CodeViewPDB(const details::pe_debug& debug_info,
42 const details::pe_pdb_70& pdb_70);
43 CodeViewPDB(const CodeViewPDB& other) = default;
44 CodeViewPDB& operator=(const CodeViewPDB& other) = default;
45
48 std::string guid() const;
49
52 uint32_t age() const {
53 return age_;
54 }
55
57 const signature_t& signature() const {
58 return signature_;
59 }
60
62 const std::string& filename() const {
63 return filename_;
64 }
65
66 void age(uint32_t age) {
67 age_ = age;
68 }
69
70 void signature(const signature_t& sig) {
71 signature_ = sig;
72 }
73
74 void filename(std::string filename) {
75 filename_ = std::move(filename);
76 }
77
78 std::unique_ptr<Debug> clone() const override {
79 return std::unique_ptr<Debug>(new CodeViewPDB(*this));
80 }
81
82 static bool classof(const Debug* debug) {
83 if (!CodeView::classof(debug)) {
84 return false;
85 }
86 const auto& cv = static_cast<const CodeView&>(*debug);
87
88 return cv.signature() == SIGNATURES::PDB_20 ||
89 cv.signature() == SIGNATURES::PDB_70;
90 }
91
92 void accept(Visitor& visitor) const override;
93 LIEF_API friend std::ostream& operator<<(std::ostream& os, const CodeViewPDB& entry);
94
95 ~CodeViewPDB() override = default;
96
97 protected:
98 uint32_t age_ = 0;
99 signature_t signature_;
100 std::string filename_;
101};
102
103} // namespace PE
104} // namespace LIEF
105#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
CodeView PDB specialization.
Definition CodeViewPDB.hpp:34
CodeViewPDB & operator=(const CodeViewPDB &other)=default
std::string guid() const
The GUID signature to verify against the .pdb file signature. This attribute might be used to lookup ...
void age(uint32_t age)
Definition CodeViewPDB.hpp:66
void accept(Visitor &visitor) const override
std::array< uint8_t, 16 > signature_t
Definition CodeViewPDB.hpp:39
static bool classof(const Debug *debug)
Definition CodeViewPDB.hpp:82
CodeViewPDB(const CodeViewPDB &other)=default
const std::string & filename() const
The path to the .pdb file.
Definition CodeViewPDB.hpp:62
uint32_t age() const
Age value to verify. The age does not necessarily correspond to any known time value,...
Definition CodeViewPDB.hpp:52
friend std::ostream & operator<<(std::ostream &os, const CodeViewPDB &entry)
void signature(const signature_t &sig)
Definition CodeViewPDB.hpp:70
~CodeViewPDB() override=default
const signature_t & signature() const
The 32-bit signature to verify against the .pdb file signature.
Definition CodeViewPDB.hpp:57
void filename(std::string filename)
Definition CodeViewPDB.hpp:74
std::unique_ptr< Debug > clone() const override
Definition CodeViewPDB.hpp:78
CodeViewPDB(const details::pe_debug &debug_info, const details::pe_pdb_70 &pdb_70)
Interface for the (generic) Debug CodeView (IMAGE_DEBUG_TYPE_CODEVIEW)
Definition CodeView.hpp:26
SIGNATURES signature() const
The signature that defines the underlying type of the payload.
Definition CodeView.hpp:58
This class represents a generic entry in the debug data directory. For known types,...
Definition debug/Debug.hpp:38
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41