2015-08-26 17:18:01 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-03-13 10:40:54 +01:00
|
|
|
namespace utils
|
2015-08-26 17:18:01 +02:00
|
|
|
{
|
|
|
|
/**
|
2016-06-27 18:34:08 +02:00
|
|
|
* Reserve `size` bytes of virtual memory and returns it.
|
2015-08-26 17:18:01 +02:00
|
|
|
* The memory should be commited before usage.
|
|
|
|
*/
|
2017-03-13 10:40:54 +01:00
|
|
|
void* memory_reserve(std::size_t size);
|
2015-08-26 17:18:01 +02:00
|
|
|
|
|
|
|
/**
|
2016-06-27 18:34:08 +02:00
|
|
|
* Commit `size` bytes of virtual memory starting at pointer.
|
2015-08-26 17:18:01 +02:00
|
|
|
* That is, bake reserved memory with physical memory.
|
|
|
|
* pointer should belong to a range of reserved memory.
|
|
|
|
*/
|
2017-03-13 10:40:54 +01:00
|
|
|
void memory_commit(void* pointer, std::size_t size);
|
2015-08-26 17:18:01 +02:00
|
|
|
|
|
|
|
/**
|
2016-06-27 18:34:08 +02:00
|
|
|
* Decommit all memory committed via commit_page_memory.
|
2015-08-26 17:18:01 +02:00
|
|
|
*/
|
2017-03-13 10:40:54 +01:00
|
|
|
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);
|
2016-06-27 18:34:08 +02:00
|
|
|
}
|