aboutsummaryrefslogtreecommitdiff
path: root/src/memory/maps.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory/maps.hh')
-rw-r--r--src/memory/maps.hh62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/memory/maps.hh b/src/memory/maps.hh
new file mode 100644
index 0000000..67914b6
--- /dev/null
+++ b/src/memory/maps.hh
@@ -0,0 +1,62 @@
+#ifndef MEMORY_HH_
+#define MEMORY_HH_
+
+#include <filesystem>
+#include <fstream>
+#include <sstream>
+#include <stdexcept>
+#include <string>
+#include <vector>
+
+namespace memory {
+
+class maps {
+public:
+ struct region {
+ public:
+ void* start;
+ void* end;
+ char perms[5];
+ std::string offset; // TODO who cares
+ std::string dev;
+ int inode;
+ std::string pathname;
+
+ public:
+ region() noexcept = default;
+ region(const region&) = default;
+ region(region&&) = default;
+
+ public:
+ bool is_read() const noexcept { return this->perms[0] == 'r'; }
+ bool is_write() const noexcept { return this->perms[1] == 'w'; }
+ bool is_execute() const noexcept { return this->perms[2] == 'x'; }
+ bool is_protected() const noexcept { return this->perms[3] == 'p'; }
+ };
+ using regions_t = std::vector<region>;
+
+private:
+ std::string pid;
+ regions_t regions;
+
+public:
+ auto begin() const noexcept {
+ return std::begin(this->regions);
+ }
+ auto end() const noexcept {
+ return std::end(this->regions);
+ }
+
+public:
+ maps(const char* const name);
+ maps(const maps& m) = default;
+ maps(maps&&) = default;
+
+public:
+ const std::string& get_pid() const noexcept { return this->pid; }
+ const regions_t& get_regions() const noexcept { return this->regions; }
+};
+
+} // namespace memory
+
+#endif