utils::memory_protect

This commit is contained in:
Nekotekina 2017-03-13 12:40:54 +03:00
parent ed711c0e59
commit d09dd29054
4 changed files with 58 additions and 16 deletions

View file

@ -1,22 +1,34 @@
#pragma once
namespace memory_helper
namespace utils
{
/**
* Reserve `size` bytes of virtual memory and returns it.
* The memory should be commited before usage.
*/
void* reserve_memory(std::size_t size);
void* memory_reserve(std::size_t size);
/**
* Commit `size` bytes of virtual memory starting at pointer.
* That is, bake reserved memory with physical memory.
* pointer should belong to a range of reserved memory.
*/
void commit_page_memory(void* pointer, std::size_t size);
void memory_commit(void* pointer, std::size_t size);
/**
* Decommit all memory committed via commit_page_memory.
*/
void free_reserved_memory(void* pointer, std::size_t size);
void memory_decommit(void* pointer, std::size_t size);
// Memory protection type
enum class protection
{
rw, // Read + write (default)
ro, // Read only
no, // No access
wx, // Read + write + execute
rx, // Read + execute
};
void memory_protect(void* pointer, std::size_t size, protection prot);
}