From 048d28b28dcaba3b0773c129d8dd63084420b01e Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Thu, 13 Feb 2025 17:29:05 +1100 Subject: initial commit --- src/memory/maps.hh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/memory/maps.hh (limited to 'src/memory/maps.hh') 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 +#include +#include +#include +#include +#include + +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; + +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 -- cgit v1.2.3