You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
codm/ligma/ligma-cheat/utils/utils.h

23 lines
628 B

#pragma once
#include <functional>
#include <fstream>
#include <map>
namespace ligma
{
namespace utils
{
inline void iterate_memory(const std::function<void(const std::pair<std::uintptr_t, std::uintptr_t>&, const std::string& protection)>& callback)
{
std::fstream maps("/proc/self/maps");
std::pair<std::uintptr_t, std::uintptr_t> memory_range;
std::string page_perms;
while (maps >> memory_range.first >> memory_range.second >> page_perms)
{
maps.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // skip to next line :)
callback(memory_range, page_perms);
}
maps.close();
}
}
}