MemoryAccessor 1
A command-line front-end for exploring virtual memory of a linux process by accessing /proc/PID/mem file.
Loading...
Searching...
No Matches
processapi.h
Go to the documentation of this file.
1// MemoryAccessor - A tool for accessing /proc/PID/mem
2// Copyright (C) 2024 zloymish
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
23
24#ifndef MEMORYACCESSOR_SRC_PROCESSAPI_H_
25#define MEMORYACCESSOR_SRC_PROCESSAPI_H_
26
27#include <sys/types.h>
28
29#include <cstdint>
30#include <cstdio>
31#include <string>
32#include <unordered_set>
33
42public:
49 void SetBufferSize(const size_t &buffer_size) { buffer_size_ = buffer_size; }
50
51 std::unordered_set<pid_t> GetAllPids() const noexcept;
52 std::unordered_set<std::string> GetAllProcessNames() const noexcept;
53 std::unordered_set<pid_t>
54 FindPidsByName(const std::string &name) const noexcept;
55 uint8_t PidExists(const pid_t &pid) const noexcept;
56 uint8_t ProcessExists(const std::string &pname) const noexcept;
57
58private:
59 std::FILE *ShellCommand(const std::string &command) const noexcept;
60
61 size_t buffer_size_{
62 0x1000};
63};
64
65#endif // MEMORYACCESSOR_SRC_PROCESSAPI_H_
A class with functionality to work with system processes.
Definition processapi.h:41
uint8_t ProcessExists(const std::string &pname) const noexcept
Check if a process with the given name exists.
Definition processapi.cc:159
std::unordered_set< pid_t > FindPidsByName(const std::string &name) const noexcept
Get all PIDs by name of the process.
Definition processapi.cc:108
std::unordered_set< pid_t > GetAllPids() const noexcept
Get all PIDs existing in the system.
Definition processapi.cc:44
void SetBufferSize(const size_t &buffer_size)
Set buffer size of an instance.
Definition processapi.h:49
std::unordered_set< std::string > GetAllProcessNames() const noexcept
Get all names of processes existing in the system.
Definition processapi.cc:74
uint8_t PidExists(const pid_t &pid) const noexcept
Check if a process with the given PID exists.
Definition processapi.cc:140