Fix an assert on VMManager in Fable

This commit is contained in:
ergo720 2018-04-02 12:26:56 +02:00
parent 16f57fa35d
commit 17b90b5aa8
2 changed files with 8 additions and 9 deletions

View File

@ -1869,7 +1869,7 @@ void WndMain::OpenXbe(const char *x_filename)
if(m_Xbe->HasError())
{
// Save the error message as a separate string. This fixes a corruption in the message "Disclaimer: Cxbx-Reloaded has no
// affiliation with Microsoft" that would occour if loading an xbe and then launching the dashboard with the "Load dashboard"
// affiliation with Microsoft" that would occur if loading an xbe and then launching the dashboard with the "Open dashboard"
// option but it's not installed
std::string ErrorMessage = m_Xbe->GetError();

View File

@ -1660,16 +1660,15 @@ xboxkrnl::NTSTATUS VMManager::XbAllocateVirtualMemory(VAddr* addr, ULONG ZeroBit
AlignedCapturedBase = ROUND_DOWN(CapturedBase, X64KB);
AlignedCapturedSize = ROUND_UP_4K(CapturedSize);
// Only reserve memory if the base address is higher than XBE_IMAGE_BASE
if ((AlignedCapturedBase >= XBE_IMAGE_BASE + ROUND_UP_4K(CxbxKrnl_Xbe->m_Header.dwSizeofImage) && AlignedCapturedBase < XBE_MAX_VA) ||
(AlignedCapturedBase >= XBE_MAX_VA &&
(VAddr)VirtualAlloc((void*)AlignedCapturedBase, AlignedCapturedSize, MEM_RESERVE, PAGE_NOACCESS) != AlignedCapturedBase))
if ((VAddr)VirtualAlloc((void*)AlignedCapturedBase, AlignedCapturedSize, MEM_RESERVE, PAGE_NOACCESS) != AlignedCapturedBase)
{
// Something else is already mapped at the specified address, report an error and bail out
// VirtualAlloc failed, check to see if we are reserving the memory for the xbe sections
status = STATUS_CONFLICTING_ADDRESSES;
goto Exit;
if (AlignedCapturedBase + AlignedCapturedSize > XBE_IMAGE_BASE + ROUND_UP_4K(CxbxKrnl_Xbe->m_Header.dwSizeofImage))
{
status = STATUS_CONFLICTING_ADDRESSES;
goto Exit;
}
}
}