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 - 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 {
28class 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 std::string filename_stripped() const {
50 return filename.c_str();
51 }
52 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 result<info_t> info() const;
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
enums.hpp
Note.hpp
LIEF::ELF::CorePrPsInfo
Class representing the NT_PRPSINFO core note. This kind of note represents general information about ...
Definition CorePrPsInfo.hpp:31
LIEF::ELF::CorePrPsInfo::classof
static bool classof(const Note *note)
Definition CorePrPsInfo.hpp:76
LIEF::ELF::CorePrPsInfo::info
void info(const info_t &info)
LIEF::ELF::CorePrPsInfo::~CorePrPsInfo
~CorePrPsInfo() override=default
LIEF::ELF::CorePrPsInfo::dump
void dump(std::ostream &os) const override
LIEF::ELF::CorePrPsInfo::operator<<
friend std::ostream & operator<<(std::ostream &os, const CorePrPsInfo &note)
Definition CorePrPsInfo.hpp:83
LIEF::ELF::CorePrPsInfo::CorePrPsInfo
CorePrPsInfo(ARCH arch, Header::CLASS cls, std::string name, uint32_t type, description_t description)
Definition CorePrPsInfo.hpp:58
LIEF::ELF::CorePrPsInfo::clone
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition CorePrPsInfo.hpp:64
LIEF::ELF::CorePrPsInfo::accept
void accept(Visitor &visitor) const override
LIEF::ELF::CorePrPsInfo::info
result< info_t > info() const
Return a elf_prpsinfo-like structure or an error if it can't be parsed.
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::CorePrPsInfo::info_t::filename_stripped
std::string filename_stripped() const
Initial part of the arguments.
Definition CorePrPsInfo.hpp:49
LIEF::ELF::CorePrPsInfo::info_t::args_stripped
std::string args_stripped() const
Return the args without the ending \x00
Definition CorePrPsInfo.hpp:54
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41