LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
PDBChecksum.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_PDBCHECKSUM_H
17#define LIEF_PE_PDBCHECKSUM_H
18#include <vector>
19
20#include "LIEF/visibility.h"
22
23namespace LIEF {
24namespace PE {
25
28class LIEF_API PDBChecksum : public Debug {
29 public:
30 static std::unique_ptr<PDBChecksum>
31 parse(const details::pe_debug& hdr, Section* section, span<uint8_t> payload);
32
33 enum class HASH_ALGO : uint32_t {
34 UNKNOWN = 0,
35 SHA256,
36 };
37
38 PDBChecksum(HASH_ALGO algo, std::vector<uint8_t> hash) :
39 Debug(Debug::TYPES::PDBCHECKSUM),
40 algo_(algo),
41 hash_(std::move(hash)) {}
42
43 PDBChecksum(const details::pe_debug& dbg, Section* sec, HASH_ALGO algo,
44 std::vector<uint8_t> hash) :
45 Debug(dbg, sec),
46 algo_(algo),
47 hash_(std::move(hash)) {}
48
49 PDBChecksum(const PDBChecksum& other) = default;
50 PDBChecksum& operator=(const PDBChecksum& other) = default;
51
53 PDBChecksum& operator=(PDBChecksum&& other) = default;
54
55 std::unique_ptr<Debug> clone() const override {
56 return std::unique_ptr<Debug>(new PDBChecksum(*this));
57 }
58
61 return hash_;
62 }
63
65 return hash_;
66 }
67
68 void hash(std::vector<uint8_t> h) {
69 hash_ = std::move(h);
70 }
71
74 return algo_;
75 }
76
77 void algorithm(HASH_ALGO algo) {
78 algo_ = algo;
79 }
80
81 static bool classof(const Debug* debug) {
82 return debug->type() == Debug::TYPES::PDBCHECKSUM;
83 }
84
85 ~PDBChecksum() override = default;
86
87 std::string to_string() const override;
88
89 private:
91 std::vector<uint8_t> hash_;
92};
93
95
96}
97}
98
99#endif
span< uint8_t > payload()
Debug data associated with this entry.
Debug()=default
const Section * section() const
The section where debug data is located.
Definition debug/Debug.hpp:170
TYPES
The entry types.
Definition debug/Debug.hpp:46
@ PDBCHECKSUM
Checksum of the PDB file.
Definition debug/Debug.hpp:97
PDBChecksum(HASH_ALGO algo, std::vector< uint8_t > hash)
Definition PDBChecksum.hpp:38
PDBChecksum & operator=(const PDBChecksum &other)=default
PDBChecksum & operator=(PDBChecksum &&other)=default
HASH_ALGO algorithm() const
Algorithm used for hashing the PDB content.
Definition PDBChecksum.hpp:73
std::unique_ptr< Debug > clone() const override
Definition PDBChecksum.hpp:55
std::string to_string() const override
void algorithm(HASH_ALGO algo)
Definition PDBChecksum.hpp:77
span< uint8_t > hash()
Definition PDBChecksum.hpp:64
PDBChecksum(PDBChecksum &&)=default
PDBChecksum(const details::pe_debug &dbg, Section *sec, HASH_ALGO algo, std::vector< uint8_t > hash)
Definition PDBChecksum.hpp:43
span< const uint8_t > hash() const
Hash of the PDB content.
Definition PDBChecksum.hpp:60
~PDBChecksum() override=default
static bool classof(const Debug *debug)
Definition PDBChecksum.hpp:81
void hash(std::vector< uint8_t > h)
Definition PDBChecksum.hpp:68
HASH_ALGO
Definition PDBChecksum.hpp:33
@ UNKNOWN
Definition PDBChecksum.hpp:34
PDBChecksum(const PDBChecksum &other)=default
static std::unique_ptr< PDBChecksum > parse(const details::pe_debug &hdr, Section *section, span< uint8_t > payload)
Class which represents a PE section.
Definition PE/Section.hpp:46
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
const char * to_string(CODE_PAGES e)
LIEF namespace.
Definition Abstract/Binary.hpp:40
tcb::span< ElementType, Extent > span
Definition span.hpp:22
Definition string.h:155
#define LIEF_API
Definition visibility.h:43