Memory mirror support

Implemented utils::memory_release (not used)
Implemented utils::shm class (handler for shared memory)
Improved sys_mmapper syscalls
Rewritten ppu_patch function
Implemented vm::get_super_ptr (ignores memory protection)
Minimal allocation alignment increased to 0x10000
This commit is contained in:
Nekotekina 2018-05-07 21:57:06 +03:00
parent fe4c3c4d84
commit 5d15d64ec8
14 changed files with 541 additions and 232 deletions

View file

@ -30,6 +30,56 @@ namespace utils
*/
void memory_decommit(void* pointer, std::size_t size);
// Free memory after reserved by memory_reserve, should specify original size
void memory_release(void* pointer, std::size_t size);
// Set memory protection
void memory_protect(void* pointer, std::size_t size, protection prot);
// Shared memory handle
class shm
{
#ifdef _WIN32
void* m_handle;
#else
int m_file;
#endif
u32 m_size;
u8* m_ptr;
public:
explicit shm(u32 size);
shm(const shm&) = delete;
~shm();
// Map shared memory
u8* map(void* ptr, protection prot = protection::rw) const;
// Map shared memory over reserved memory region, which is unsafe (non-atomic) under Win32
u8* map_critical(void* ptr, protection prot = protection::rw);
// Unmap shared memory
void unmap(void* ptr) const;
// Unmap shared memory, undoing map_critical
void unmap_critical(void* ptr);
// Access memory with simple range check
u8* get(u32 offset, u32 size) const
{
if (offset >= m_size || m_size - offset < size)
{
return nullptr;
}
return m_ptr + offset;
}
u32 size() const
{
return m_size;
}
};
}