mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-06 23:11:18 +12:00
MemMapper: don't change address on non-reserved mappings
This commit is contained in:
parent
6b6a538b3a
commit
d73c5895f2
1 changed files with 5 additions and 6 deletions
|
@ -42,16 +42,15 @@ namespace MemMapper
|
|||
|
||||
void* AllocateMemory(void* baseAddr, size_t size, PAGE_PERMISSION permissionFlags, bool fromReservation)
|
||||
{
|
||||
uint64 page_size = sysconf(_SC_PAGESIZE);
|
||||
if ((uint64) baseAddr % page_size != 0)
|
||||
{
|
||||
baseAddr = (void*) ((uint64)baseAddr & ~(page_size - 1));
|
||||
}
|
||||
|
||||
void* r;
|
||||
if(fromReservation)
|
||||
{
|
||||
if( mprotect(baseAddr, size, GetProt(permissionFlags)) == 0 )
|
||||
uint64 page_size = sysconf(_SC_PAGESIZE);
|
||||
void* page = baseAddr;
|
||||
if ( (uint64) baseAddr % page_size != 0 )
|
||||
page = (void*) ((uint64)baseAddr & ~(page_size - 1));
|
||||
if( mprotect(page, size, GetProt(permissionFlags)) == 0 )
|
||||
r = baseAddr;
|
||||
else
|
||||
r = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue