Fix QueryAllocationSize & other small tweaks

This commit is contained in:
Luke Usher 2017-03-24 13:31:05 +00:00
parent 45ade469cf
commit 022b2ee77c
3 changed files with 11 additions and 10 deletions

View File

@ -569,14 +569,6 @@ void CxbxKrnlInit
{
// Create a fake kernel header for XapiRestrictCodeSelectorLimit
// Thanks advancingdragon / DirtBox
typedef struct DUMMY_KERNEL
{
IMAGE_DOS_HEADER DosHeader;
DWORD Signature;
IMAGE_FILE_HEADER FileHeader;
IMAGE_SECTION_HEADER SectionHeader;
} *PDUMMY_KERNEL;
PDUMMY_KERNEL DummyKernel = (PDUMMY_KERNEL)XBOX_KERNEL_BASE;
memset(DummyKernel, 0, sizeof(DUMMY_KERNEL));

View File

@ -99,4 +99,12 @@ extern HANDLE g_hInputHandle[XINPUT_HANDLE_SLOTS];
extern void InitializeSectionStructures(void);
typedef struct DUMMY_KERNEL
{
IMAGE_DOS_HEADER DosHeader;
DWORD Signature;
IMAGE_FILE_HEADER FileHeader;
IMAGE_SECTION_HEADER SectionHeader;
} *PDUMMY_KERNEL;
#endif

View File

@ -116,7 +116,8 @@ void* MemoryManager::AllocateContiguous(size_t size, size_t alignment)
// If the allocation table is empty, we can allocate wherever we please
if (m_ContiguousMemoryRegions.size() == 0) {
addr = MM_SYSTEM_PHYSICAL_MAP;
// Start allocating Contiguous Memory after the Kernel image header to prevent overwriting our dummy Kernel
addr = XBOX_KERNEL_BASE + sizeof(DUMMY_KERNEL);
} else {
// Locate the first available Memory Region with enough space for the requested buffer
// This could be improved later on by always locating the smallest block with enough space
@ -219,7 +220,7 @@ size_t MemoryManager::QueryAllocationSize(void* block)
size_t ret = 0;
if (IsAllocated(block)) {
MemoryBlockInfo info = m_MemoryBlockInfo[info.offset];
MemoryBlockInfo info = m_MemoryBlockInfo[(uint32_t)block];
ret = info.size;
}
else {