mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-19 22:42:25 +00:00
* Check if the 4 GB memory allocation failed. * Update UnleashedRecomp/locale/locale.cpp Co-authored-by: Hyper <34012267+hyperbx@users.noreply.github.com> * Update locale.cpp * Add localizations. * Fix installer not booting with the changes. * Fix stale reference crash. --------- Co-authored-by: Hyper <34012267+hyperbx@users.noreply.github.com>
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#include <stdafx.h>
|
|
#include "memory.h"
|
|
|
|
Memory::Memory()
|
|
{
|
|
#ifdef _WIN32
|
|
base = (uint8_t*)VirtualAlloc((void*)0x100000000ull, PPC_MEMORY_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
|
|
|
if (base == nullptr)
|
|
base = (uint8_t*)VirtualAlloc(nullptr, PPC_MEMORY_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
|
|
|
if (base == nullptr)
|
|
return;
|
|
|
|
DWORD oldProtect;
|
|
VirtualProtect(base, 4096, PAGE_NOACCESS, &oldProtect);
|
|
#else
|
|
base = (uint8_t*)mmap((void*)0x100000000ull, PPC_MEMORY_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
|
|
|
if (base == (uint8_t*)MAP_FAILED)
|
|
base = (uint8_t*)mmap(NULL, PPC_MEMORY_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
|
|
|
if (base == nullptr)
|
|
return;
|
|
|
|
mprotect(base, 4096, PROT_NONE);
|
|
#endif
|
|
|
|
for (size_t i = 0; PPCFuncMappings[i].guest != 0; i++)
|
|
{
|
|
if (PPCFuncMappings[i].host != nullptr)
|
|
InsertFunction(PPCFuncMappings[i].guest, PPCFuncMappings[i].host);
|
|
}
|
|
}
|
|
|
|
void* MmGetHostAddress(uint32_t ptr)
|
|
{
|
|
return g_memory.Translate(ptr);
|
|
}
|