LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
CorePrPsInfo.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_ELF_CORE_PRPSINFO_H
17#define LIEF_ELF_CORE_PRPSINFO_H
18
19#include <ostream>
20
22#include "LIEF/visibility.h"
23#include "LIEF/ELF/enums.hpp"
24#include "LIEF/ELF/Note.hpp"
25
26namespace LIEF {
27namespace ELF {
28
31class LIEF_API CorePrPsInfo : public Note {
32 public:
33 struct info_t {
34 uint8_t state = 0;
35 char sname = ' ';
36 bool zombie = false;
37 uint8_t nice = 0;
38 uint64_t flag = 0;
39 uint32_t uid = 0;
40 uint32_t gid = 0;
41 uint32_t pid = 0;
42 uint32_t ppid = 0;
43 uint32_t pgrp = 0;
44 uint32_t sid = 0;
45 std::string filename;
46 std::string args;
47
49 std::string filename_stripped() const {
50 return filename.c_str();
51 }
52
54 std::string args_stripped() const {
55 return args.c_str();
56 }
57 };
58 CorePrPsInfo(ARCH arch, Header::CLASS cls, std::string name, uint32_t type,
60 Note(std::move(name), TYPE::CORE_PRPSINFO, type, std::move(description), ""),
61 arch_(arch),
62 class_(cls) {}
63
64 std::unique_ptr<Note> clone() const override {
65 return std::unique_ptr<Note>(new CorePrPsInfo(*this));
66 }
67
70 void info(const info_t& info);
71
72 void dump(std::ostream& os) const override;
73
74 void accept(Visitor& visitor) const override;
75
76 static bool classof(const Note* note) {
77 return note->type() == Note::TYPE::CORE_PRPSINFO;
78 }
79
80 ~CorePrPsInfo() override = default;
81
82 LIEF_API friend std::ostream& operator<<(std::ostream& os,
83 const CorePrPsInfo& note) {
84 note.dump(os);
85 return os;
86 }
87
88 private:
91};
92
93} // namepsace ELF
94} // namespace LIEF
95
96#endif
static bool classof(const Note *note)
Definition CorePrPsInfo.hpp:76
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:58
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition CorePrPsInfo.hpp:64
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:74
@ NONE
Definition ELF/Header.hpp:75
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:196
const std::string & name() const
Return the name of the note (also known as 'owner' ).
Definition Note.hpp:185
Note(const Note &copy)=default
span< const uint8_t > description() const
Return the description associated with the note.
Definition Note.hpp:207
Definition Visitor.hpp:212
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:77
#define LIEF_MAYBE_UNUSED
Definition compiler_attributes.hpp:61
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
Definition string.h:155
Definition CorePrPsInfo.hpp:33
uint32_t pgrp
Process parent ID.
Definition CorePrPsInfo.hpp:43
uint32_t ppid
Process ID.
Definition CorePrPsInfo.hpp:42
char sname
Numeric process state.
Definition CorePrPsInfo.hpp:35
uint32_t gid
Process user ID.
Definition CorePrPsInfo.hpp:40
std::string filename_stripped() const
Initial part of the arguments.
Definition CorePrPsInfo.hpp:49
uint8_t state
Definition CorePrPsInfo.hpp:34
uint8_t nice
Whether the process is a zombie.
Definition CorePrPsInfo.hpp:37
uint64_t flag
Nice value.
Definition CorePrPsInfo.hpp:38
std::string args
Filename of the executable.
Definition CorePrPsInfo.hpp:46
uint32_t uid
Process flag.
Definition CorePrPsInfo.hpp:39
uint32_t sid
Process group.
Definition CorePrPsInfo.hpp:44
uint32_t pid
Process group ID.
Definition CorePrPsInfo.hpp:41
bool zombie
printable character representing state
Definition CorePrPsInfo.hpp:36
std::string filename
Process session id.
Definition CorePrPsInfo.hpp:45
std::string args_stripped() const
Return the args without the ending \x00.
Definition CorePrPsInfo.hpp:54
#define LIEF_API
Definition visibility.h:43