diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2023-10-07 16:16:30 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2023-10-07 16:16:30 +0200 |
commit | 9128c38e0fcb4d46504f72b33f1eb0574247f681 (patch) | |
tree | 04e978bf001041876e82e43a986454d3864f9ef0 /stringify.hpp |
initial commit
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'stringify.hpp')
-rw-r--r-- | stringify.hpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/stringify.hpp b/stringify.hpp new file mode 100644 index 0000000..c61c757 --- /dev/null +++ b/stringify.hpp @@ -0,0 +1,73 @@ +#ifndef STRINGIFY_H +#define STRINGIFY_H 1 + +#include <eastl_compat.hpp> + +#define MEM_IMAGE 0x1000000 +#define MEM_MAPPED 0x40000 +#define MEM_PRIVATE 0x20000 + +static inline eastl::string toString(uint64_t addr, size_t size, uint32_t type, + uint32_t state, uint32_t protect) { + eastl::string result = "0x"; + + result += ::to_string_hex(addr, 16); + result += " "; + result += ::to_string(size); + result += " "; + + switch (type) { + case MEM_IMAGE: + result += "MEM_IMAGE"; + break; + case MEM_MAPPED: + result += "MEM_MAPPED"; + break; + case MEM_PRIVATE: + result += "MEM_PRIVATE"; + break; + default: + result += "-"; + break; + } + result += " "; + + switch (state) { + case MEM_COMMIT: + result += "MEM_COMMIT"; + break; + case MEM_FREE: + result += "MEM_FREE"; + break; + case MEM_RESERVE: + result += "MEM_RESERVE"; + break; + default: + result += "-"; + break; + } + result += " "; + + if (protect & PAGE_READONLY) { + result += "R"; + } + if (protect & PAGE_READWRITE) { + result += "RW"; + } + if (protect & PAGE_EXECUTE_READWRITE) { + result += "RWX"; + } + if (protect & PAGE_EXECUTE) { + result += "X"; + } + if (protect & PAGE_WRITECOPY) { + result += "C"; + } + if (protect & PAGE_NOACCESS) { + result += "NO_ACCESS"; + } + + return result; +} + +#endif |