LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
CorePrPsInfo.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_ELF_CORE_PRPSINFO_H
17#define LIEF_ELF_CORE_PRPSINFO_H
18
19#include <ostream>
20
21#include "LIEF/visibility.h"
22#include "LIEF/ELF/enums.hpp"
23#include "LIEF/ELF/Note.hpp"
24
25namespace LIEF {
26namespace ELF {
27
30class LIEF_API CorePrPsInfo : public Note {
31 public:
32 struct info_t {
33 uint8_t state = 0;
34 char sname = ' ';
35 bool zombie = false;
36 uint8_t nice = 0;
37 uint64_t flag = 0;
38 uint32_t uid = 0;
39 uint32_t gid = 0;
40 uint32_t pid = 0;
41 uint32_t ppid = 0;
42 uint32_t pgrp = 0;
43 uint32_t sid = 0;
44 std::string filename;
45 std::string args;
46
48 std::string filename_stripped() const {
49 return filename.c_str();
50 }
51
53 std::string args_stripped() const {
54 return args.c_str();
55 }
56 };
57 CorePrPsInfo(ARCH arch, Header::CLASS cls, std::string name,
58 uint32_t type, description_t description) :
59 Note(std::move(name), TYPE::CORE_PRPSINFO, type, std::move(description), ""),
60 arch_(arch), class_(cls)
61 {}
62
63 std::unique_ptr<Note> clone() const override {
64 return std::unique_ptr<Note>(new CorePrPsInfo(*this));
65 }
66
69 void info(const info_t& info);
70
71 void dump(std::ostream& os) const override;
72
73 void accept(Visitor& visitor) const override;
74
75 static bool classof(const Note* note) {
76 return note->type() == Note::TYPE::CORE_PRPSINFO;
77 }
78
79 ~CorePrPsInfo() override = default;
80
81 LIEF_API friend
82 std::ostream& operator<<(std::ostream& os, const CorePrPsInfo& note) {
83 note.dump(os);
84 return os;
85 }
86 private:
87 [[maybe_unused]] ARCH arch_ = ARCH::NONE;
89};
90
91} // namepsace ELF
92} // namespace LIEF
93
94#endif
static bool classof(const Note *note)
Definition CorePrPsInfo.hpp:75
void info(const info_t &info)
~CorePrPsInfo() override=default
void dump(std::ostream &os) const override
friend std::ostream & operator<<(std::ostream &os, const CorePrPsInfo &note)
Definition CorePrPsInfo.hpp:82
CorePrPsInfo(ARCH arch, Header::CLASS cls, std::string name, uint32_t type, description_t description)
Definition CorePrPsInfo.hpp:57
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition CorePrPsInfo.hpp:63
void accept(Visitor &visitor) const override
result< info_t > info() const
Return a elf_prpsinfo-like structure or an error if it can't be parsed.
CLASS
Match the result of Elfxx_Ehdr.e_ident[EI_CLASS].
Definition ELF/Header.hpp:73
@ NONE
Definition ELF/Header.hpp:74
std::vector< uint8_t > description_t
Container used to handle the description data.
Definition Note.hpp:46
TYPE
LIEF representation of the ELF NT_ values.
Definition Note.hpp:49
@ CORE_PRPSINFO
Coredump that wraps the elf_prpsinfo structure.
Definition Note.hpp:77
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
const std::string & name() const
Return the name of the note (also known as 'owner' ).
Definition Note.hpp:184
Note(const Note &copy)=default
span< const uint8_t > description() const
Return the description associated with the note.
Definition Note.hpp:206
Definition Visitor.hpp:210
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
ARCH
Definition ELF/enums.hpp:30
@ NONE
Definition ELF/enums.hpp:31
LIEF namespace.
Definition Abstract/Binary.hpp:40
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
Definition CorePrPsInfo.hpp:32
uint32_t pgrp
Process parent ID.
Definition CorePrPsInfo.hpp:42
uint32_t ppid
Process ID.
Definition CorePrPsInfo.hpp:41
char sname
Numeric process state.
Definition CorePrPsInfo.hpp:34
uint32_t gid
Process user ID.
Definition CorePrPsInfo.hpp:39
std::string filename_stripped() const
Initial part of the arguments.
Definition CorePrPsInfo.hpp:48
uint8_t state
Definition CorePrPsInfo.hpp:33
uint8_t nice
Whether the process is a zombie.
Definition CorePrPsInfo.hpp:36
uint64_t flag
Nice value.
Definition CorePrPsInfo.hpp:37
std::string args
Filename of the executable.
Definition CorePrPsInfo.hpp:45
uint32_t uid
Process flag.
Definition CorePrPsInfo.hpp:38
uint32_t sid
Process group.
Definition CorePrPsInfo.hpp:43
uint32_t pid
Process group ID.
Definition CorePrPsInfo.hpp:40
bool zombie
printable character representing state
Definition CorePrPsInfo.hpp:35
std::string filename
Process session id.
Definition CorePrPsInfo.hpp:44
std::string args_stripped() const
Return the args without the ending \x00.
Definition CorePrPsInfo.hpp:53
#define LIEF_API
Definition visibility.h:41