diff --git a/Cxbx.opt b/Cxbx.opt index 240b68b72..261c288b8 100644 Binary files a/Cxbx.opt and b/Cxbx.opt differ diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 49432b687..d70a9b363 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -785,6 +785,8 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID) Sleep(1); } + + return 0; } // check if a resource has been registered yet (if not, register it) diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp index 5968ce64c..0ac565b07 100644 --- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp +++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp @@ -729,7 +729,27 @@ XBSYSAPI EXPORTNUM(165) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo } #endif - PVOID pRet = VirtualAlloc(NULL, NumberOfBytes, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + // + // NOTE: Kludgey (but necessary) solution: + // + // Since this memory must be aligned on a page boundary, we must allocate an extra page + // so that we can return a valid page aligned pointer + // + + PVOID pRet = malloc(NumberOfBytes + 0x1000); + + // align to page boundary + { + DWORD dwRet = (DWORD)pRet; + + dwRet += 0x1000 - dwRet%0x1000; + + pRet = (PVOID)dwRet; + } + + #ifdef _DEBUG_TRACE + printf("EmuKrnl (0x%X): MmAllocateContiguous returned 0x%.08X\n", GetCurrentThreadId(), pRet); + #endif EmuSwapFS(); // Xbox FS @@ -766,7 +786,23 @@ XBSYSAPI EXPORTNUM(166) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo } #endif - PVOID pRet = malloc(NumberOfBytes); + // + // NOTE: Kludgey (but necessary) solution: + // + // Since this memory must be aligned on a page boundary, we must allocate an extra page + // so that we can return a valid page aligned pointer + // + + PVOID pRet = malloc(NumberOfBytes + 0x1000); + + // align to page boundary + { + DWORD dwRet = (DWORD)pRet; + + dwRet += 0x1000 - dwRet%0x1000; + + pRet = (PVOID)dwRet; + } static int count = 0; @@ -774,7 +810,7 @@ XBSYSAPI EXPORTNUM(166) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo g_HaloHack[count-1] = (uint32)pRet; #ifdef _DEBUG_TRACE - printf("EmuKrnl (0x%X): MmAllocateContiguous returned 0x%.08X\n", GetCurrentThreadId(), pRet); + printf("EmuKrnl (0x%X): MmAllocateContiguousEx returned 0x%.08X\n", GetCurrentThreadId(), pRet); #endif EmuSwapFS(); // Xbox FS