VirtualProtect platform abstraction.

This commit is contained in:
Ben Vanik
2015-07-15 18:20:05 -07:00
parent 99104a25a8
commit 58c3a1ba79
11 changed files with 155 additions and 56 deletions

View File

@@ -18,6 +18,21 @@
#include "xenia/base/byte_order.h"
namespace xe {
namespace memory {
// Returns the native page size of the system, in bytes.
size_t page_size();
enum class PageAccess {
kNoAccess = 0,
kReadOnly,
kReadWrite,
};
// Sets the access rights for the given block of memory and returns the previous
// access rights. Both base_address and length will be adjusted to page_size().
bool Protect(void* base_address, size_t length, PageAccess access,
PageAccess* out_old_access);
inline size_t hash_combine(size_t seed) { return seed; }
@@ -28,6 +43,10 @@ size_t hash_combine(size_t seed, const T& v, const Ts&... vs) {
return hash_combine(seed, vs...);
}
} // namespace memory
// TODO(benvanik): move into xe::memory::
constexpr void* low_address(void* address) {
return (void*)(uint64_t(address) & 0xFFFFFFFF);
}