Skip to content

Instantly share code, notes, and snippets.

@agustingianni
Created May 11, 2016 19:17
Show Gist options
  • Select an option

  • Save agustingianni/07c5739439a70815cd95ff9fa9ee010d to your computer and use it in GitHub Desktop.

Select an option

Save agustingianni/07c5739439a70815cd95ff9fa9ee010d to your computer and use it in GitHub Desktop.
class AbstractMemory {
public:
AbstractMemory() = default;
~AbstractMemory() = default;
template <typename T> size_t read(uintptr_t address, T &value) {
return read(address, reinterpret_cast<void *>(&value), sizeof(T));
}
template <typename T> size_t write(uintptr_t address, T value) {
return write(address, reinterpret_cast<void *>(&value), sizeof(T));
}
virtual bool map(uintptr_t address, size_t size, unsigned prot) = 0;
virtual size_t read(uintptr_t address, void *buffer, size_t size) = 0;
virtual size_t write(uintptr_t address, const void *buffer, size_t size) = 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment