LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
CoreFile.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_ELF_CORE_FILE_H
17#define LIEF_ELF_CORE_FILE_H
18
19#include <vector>
20#include <ostream>
21
22#include "LIEF/visibility.h"
23
24#include "LIEF/ELF/Note.hpp"
25
26namespace LIEF {
27namespace ELF {
28class LIEF_API CoreFile : public Note {
32 public: struct entry_t {
35 uint64_t start = 0;
36 uint64_t end = 0;
37 uint64_t file_ofs = 0;
38 std::string path;
39
40 LIEF_API friend
41 std::ostream& operator<<(std::ostream& os, const entry_t& entry);
42 };
43
44 using files_t = std::vector<entry_t>;
45 using iterator = files_t::iterator;
46 using const_iterator = files_t::const_iterator;
47
48 public:
49 CoreFile(ARCH arch, Header::CLASS cls, std::string name,
50 uint32_t type, Note::description_t description);
51
52 std::unique_ptr<Note> clone() const override {
53 return std::unique_ptr<Note>(new CoreFile(*this));
54 }
55 uint64_t count() const {
58 return files_.size();
59 }
60 const files_t& files() const {
63 return files_;
64 }
65
66 iterator begin() {
67 return files_.begin();
68 }
69
70 iterator end() {
71 return files_.end();
72 }
73
74 const_iterator begin() const {
75 return files_.begin();
76 }
77
78 const_iterator end() const {
79 return files_.end();
80 }
81
82 void files(const files_t& file);
83
84 void dump(std::ostream& os) const override;
85 void accept(Visitor& visitor) const override;
86
87 static bool classof(const Note* note) {
88 return note->type() == Note::TYPE::CORE_FILE;
89 }
90
91 ~CoreFile() override = default;
92
93 LIEF_API friend
94 std::ostream& operator<<(std::ostream& os, const CoreFile& note) {
95 note.dump(os);
96 return os;
97 }
98
99 protected:
100 template<class T>
101 LIEF_LOCAL void read_files();
102
103 template<class T>
104 LIEF_LOCAL void write_files();
105
106 files_t files_;
107 uint64_t page_size_ = 0;
108 ARCH arch_ = ARCH::NONE;
109 Header::CLASS class_ = Header::CLASS::NONE;
110};
111
112} // namepsace ELF
113} // namespace LIEF
114
115#endif
Note.hpp
LIEF::ELF::CoreFile
Class representing a core NT_FILE which describes the mapped files of the process.
Definition CoreFile.hpp:31
LIEF::ELF::CoreFile::begin
iterator begin()
Definition CoreFile.hpp:66
LIEF::ELF::CoreFile::dump
void dump(std::ostream &os) const override
LIEF::ELF::CoreFile::accept
void accept(Visitor &visitor) const override
LIEF::ELF::CoreFile::clone
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition CoreFile.hpp:52
LIEF::ELF::CoreFile::CoreFile
CoreFile(ARCH arch, Header::CLASS cls, std::string name, uint32_t type, Note::description_t description)
LIEF::ELF::CoreFile::end
const_iterator end() const
Definition CoreFile.hpp:78
LIEF::ELF::CoreFile::files
void files(const files_t &file)
LIEF::ELF::CoreFile::operator<<
friend std::ostream & operator<<(std::ostream &os, const CoreFile &note)
Definition CoreFile.hpp:94
LIEF::ELF::CoreFile::classof
static bool classof(const Note *note)
Definition CoreFile.hpp:87
LIEF::ELF::CoreFile::begin
const_iterator begin() const
Definition CoreFile.hpp:74
LIEF::ELF::CoreFile::files
const files_t & files() const
Coredump file entries.
Definition CoreFile.hpp:62
LIEF::ELF::CoreFile::end
iterator end()
Definition CoreFile.hpp:70
LIEF::ELF::CoreFile::~CoreFile
~CoreFile() override=default
LIEF::ELF::CoreFile::count
uint64_t count() const
Number of coredump file entries.
Definition CoreFile.hpp:57
LIEF::ELF::Note
Class which represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:39
LIEF::ELF::Note::type
TYPE type() const
Return the type of the note. This type does not match the NT_ type value. For accessing the original ...
Definition Note.hpp:195
LIEF::ELF
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF::ELF::ARCH
ARCH
Definition ELF/enums.hpp:30
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
LIEF::ELF::CoreFile::entry_t::operator<<
friend std::ostream & operator<<(std::ostream &os, const entry_t &entry)
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41
LIEF_LOCAL
#define LIEF_LOCAL
Definition visibility.h:42