MemoryAccessor 1
A command-line front-end for exploring virtual memory of a linux process by accessing /proc/PID/mem file.
|
A struct with various tools that are independent or depend on operating system. More...
#include <tools.h>
Public Member Functions | |
void | SetBufferSize (const size_t &buffer_size) |
Set buffer size of an instance. | |
int | SetSigint (void(*handler)(int)) const noexcept |
Attach handler to SIGINT signal. | |
std::FILE * | ShellCommand (const std::string &command) const noexcept |
Do a command in system shell. | |
std::unordered_set< pid_t > | GetAllPids () const noexcept |
Get all PIDs existing in the system. | |
std::unordered_set< std::string > | GetAllProcessNames () const noexcept |
Get all names of processes existing in the system. | |
std::unordered_set< pid_t > | FindPidsByName (const std::string &name) const noexcept |
Get all PIDs by name of the process. | |
uint8_t | PidExists (const pid_t &pid) const noexcept |
Check if a process with the given PID exists. | |
uint8_t | ProcessExists (const std::string &pname) const noexcept |
Check if a process with the given name exists. | |
uint8_t | DecodePermissions (const std::string &permissions) const noexcept |
Get permissions stored as uint8_t from std::string. | |
std::string | EncodePermissions (const uint8_t &mode) const noexcept |
Get permissions stored as std::string from uint8_t. | |
std::array< std::unique_ptr< char[]>, 2 > | FindDifferencesOfLen (const char *old_str, const char *new_str, size_t str_len, size_t &done, const size_t &len) const noexcept |
Find differences of given length comparing two arrays of char. | |
A struct with various tools that are independent or depend on operating system.
This struct provides a set of functions that are useful in some parts of the project, but cannot be attributed to any existing category. These functions do not depend on any parts of the program. The struct includes such functionality as working with signals (SIGINT), getting terminal window size, making shell commands, comparing memory arrays and so on.
|
noexcept |
Get permissions stored as uint8_t from std::string.
[in] | permissions | Permissions stored as std::string, for example, "rwxp". Some additional characters after are not prohibited. |
Process permissions of a memory segment from std::string to uint8_t.
|
noexcept |
Get permissions stored as std::string from uint8_t.
[in] | mode | Value, where the last 4 bits represent permissions (rwxs are 1, others are 0). |
Process permissions of a memory segment from uint8_t to std::string.
|
noexcept |
Find differences of given length comparing two arrays of char.
[in] | old_str | First "old" array of char. |
[in] | new_str | Second "new" array of char. |
[in] | str_len | Length of both arrays. |
[in] | len | Length of different sequences. |
[out] | done | Amount of bytes processed. |
Find first pair of different substrings of given length on equal positions comparing 2 given arrays. Each char of the substrings must be different. If longer substrings differ, their shorter versions are not returned.
|
noexcept |
Get all PIDs by name of the process.
[in] | name | Name of the process in type of std::string. |
Get all process IDs that can be found by running "pgrep -x "process_name"" shell command.
|
noexcept |
Get all PIDs existing in the system.
Get all process IDs that can be found by running "pgrep .+" shell command.
|
noexcept |
Get all names of processes existing in the system.
Get all names of processes that can be found by running "pgrep -l .+" shell command.
|
noexcept |
Check if a process with the given PID exists.
[in] | pid | PID of the process in pid_t type. |
Check if a process with the given process ID exists in the system by checking if /proc/PID directory exists.
|
noexcept |
Check if a process with the given name exists.
[in] | pname | Name of the process in type of std::string. |
Check if a process with the given process name exists in the system by running "pgrep -x "process_name"" shell command.
|
inline |
Set buffer size of an instance.
[in] | buffer_size | Desired buffer size in bytes. |
Set buffer size, a number of bytes that are allocated when needed.
|
noexcept |
Attach handler to SIGINT signal.
[in] | handler | Pointer to handler function. |
Attach handler function to SIGINT, which will be called every time SIGINT is received.
|
noexcept |
Do a command in system shell.
[in] | command | Command in type of std::string. |
Do a command in a shell by calling function "popen" and return stdout pipe of the command.