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
segmentinfo.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_SEGMENTINFO_H_
25#define MEMORYACCESSOR_SRC_SEGMENTINFO_H_
26
27#include <cstdint>
28#include <string>
29
38public:
39 // SegmentInfo() = default;
40 // SegmentInfo(const SegmentInfo &) = default;
41 // SegmentInfo(SegmentInfo &&) = default;
42 // SegmentInfo &operator=(const SegmentInfo &) = default;
43 // SegmentInfo &operator=(SegmentInfo &&) = default;
44 // ~SegmentInfo() = default;
45
46 uint8_t DecodePermissions(const std::string &permissions) noexcept;
47 std::string EncodePermissions() const noexcept;
48
49 size_t start_{0};
50 size_t
51 end_{0};
52 size_t offset_{0};
54
55 uint8_t mode_{0};
57
58 uint32_t major_id_{0};
59 uint32_t minor_id_{0};
60
61 size_t inode_id_{0};
63
64 std::string path_;
65
66private:
67 static constexpr std::string kModes{"rwxs"};
69 static constexpr uint8_t kModesLength{static_cast<uint8_t>(
70 kModes.length())};
71};
72
73#endif // MEMORYACCESSOR_SRC_SEGMENTINFO_H_
A class to store the information of a memory segment.
Definition segmentinfo.h:37
std::string path_
Path or name.
Definition segmentinfo.h:64
uint8_t mode_
is 1 (private - shared)
Definition segmentinfo.h:55
size_t end_
End address (first address that does not belong to the segment)
Definition segmentinfo.h:51
size_t inode_id_
ROM)
Definition segmentinfo.h:61
size_t start_
Start address.
Definition segmentinfo.h:49
size_t offset_
(e.g., executable from ROM)
Definition segmentinfo.h:52
uint8_t DecodePermissions(const std::string &permissions) noexcept
Get permissions stored to mode_ field from std::string.
Definition segmentinfo.cc:39
uint32_t major_id_
Major ID.
Definition segmentinfo.h:58
std::string EncodePermissions() const noexcept
Get permissions stored as std::string processed from the mode_ field.
Definition segmentinfo.cc:67
uint32_t minor_id_
Minor ID.
Definition segmentinfo.h:59