LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
CorePrPsInfo.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_PRPSINFO_H
17#define LIEF_ELF_CORE_PRPSINFO_H
18
19#include <vector>
20#include <ostream>
21
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,
59 uint32_t type, description_t description) :
60 Note(std::move(name), TYPE::CORE_PRPSINFO, type, std::move(description), ""),
61 arch_(arch), class_(cls)
62 {}
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
83 std::ostream& operator<<(std::ostream& os, const CorePrPsInfo& note) {
84 note.dump(os);
85 return os;
86 }
87 private:
88 ARCH arch_ = ARCH::NONE;
89 Header::CLASS class_ = Header::CLASS::NONE;
90};
91
92} // namepsace ELF
93} // namespace LIEF
94
95#endif
Class representing the NT_PRPSINFO core note. This kind of note represents general information about ...
Definition CorePrPsInfo.hpp:31
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:83
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:76
Class which represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:39
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
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
Definition Visitor.hpp:224
ARCH
Machine architectures See current registered ELF machine architectures at: http://www....
Definition ELF/enums.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:32
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:74
Definition CorePrPsInfo.hpp:33
std::string filename_stripped() const
Initial part of the arguments.
Definition CorePrPsInfo.hpp:49
std::string args
Filename of the executable.
Definition CorePrPsInfo.hpp:46
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:41