Bug fixes

This commit is contained in:
ergo720 2018-08-16 20:57:00 +02:00
parent 67b5b9b341
commit 397efc08fc
1 changed files with 8 additions and 6 deletions

View File

@ -77,12 +77,13 @@ void VMManager::Initialize(HANDLE memory_view, HANDLE pagetables_view, int BootF
ConstructMemoryRegion(CONTIGUOUS_MEMORY_BASE, CONTIGUOUS_MEMORY_XBOX_SIZE, ContiguousRegion);
ConstructMemoryRegion(SYSTEM_MEMORY_BASE, SYSTEM_MEMORY_SIZE, SystemRegion);
ConstructMemoryRegion(DEVKIT_MEMORY_BASE, DEVKIT_MEMORY_SIZE, DevkitRegion);
unsigned char PreviousLayout;
if ((BootFlags & BOOT_QUICK_REBOOT) != 0)
{
// Restore the memory layout we were emulating in the previous session
unsigned char PreviousLayout = *(unsigned char*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 9);
PreviousLayout = *(unsigned char*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 9);
m_MmLayoutChihiro = (PreviousLayout == MmChihiro);
m_MmLayoutDebug = (PreviousLayout == MmDebug);
m_MmLayoutRetail = (PreviousLayout == MmRetail);
@ -95,8 +96,8 @@ void VMManager::Initialize(HANDLE memory_view, HANDLE pagetables_view, int BootF
m_MmLayoutChihiro = (g_XbeType == xtChihiro);
m_MmLayoutDebug = (g_XbeType == xtDebug);
m_MmLayoutRetail = (g_XbeType == xtRetail);
*(unsigned char*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 9) = m_MmLayoutChihiro ? MmChihiro : (m_MmLayoutDebug ? MmDebug : MmRetail);
PreviousLayout = m_MmLayoutChihiro ? MmChihiro : (m_MmLayoutDebug ? MmDebug : MmRetail);
}
// Set up general memory variables according to the xbe type
@ -137,7 +138,8 @@ void VMManager::Initialize(HANDLE memory_view, HANDLE pagetables_view, int BootF
// The memory manager needs updating to only persist areas of memory marked with MmPersistContiguousMemory and discard the rest.
// But right now it persists the whole block". So we also clear the entire mapped memory.bin since we are not quick rebooting
xboxkrnl::RtlFillMemoryUlong((void*)CONTIGUOUS_MEMORY_BASE, g_SystemMaxMemory, 0);
xboxkrnl::RtlFillMemoryUlong((void*)PAGE_TABLES_BASE, PAGE_TABLES_SIZE, 0);
xboxkrnl::RtlFillMemoryUlong((void*)PAGE_TABLES_BASE, PAGE_TABLES_SIZE, 0);
*(unsigned char*)(CONTIGUOUS_MEMORY_BASE + PAGE_SIZE - 9) = PreviousLayout;
InitializePfnDatabase();
}
else {
@ -2134,7 +2136,7 @@ xboxkrnl::NTSTATUS VMManager::XbVirtualMemoryStatistics(VAddr addr, xboxkrnl::PM
// ergo720: hack. Always report as reserved the region after the memory placeholder and below 0x8000000 if we are emulating
// a 128 MiB system regardless of what VirtualQuery says. Once LLE CPU and MMU are implemented, this can be removed
if (g_bIsRetail != true && addr >= XBE_IMAGE_BASE + XBE_MAX_VA && addr < CHIHIRO_MEMORY_SIZE) {
if (m_MmLayoutRetail != true && addr >= XBE_IMAGE_BASE + XBE_MAX_VA && addr < CHIHIRO_MEMORY_SIZE) {
memory_statistics->AllocationBase = (void*)(XBE_IMAGE_BASE + XBE_MAX_VA);
memory_statistics->AllocationProtect = XBOX_PAGE_NOACCESS;
memory_statistics->BaseAddress = (void*)ROUND_DOWN_4K(addr);