From 3345d6e50380e9e3d018644728c083514914bac4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Sep 2015 13:45:30 -0400 Subject: [PATCH] MemoryFilter starts to compile (now with 32-bit support!). --- .../N64 System/Mips/Memory Virtual Mem.cpp | 34 ++++++++++++------- .../N64 System/Mips/Memory Virtual Mem.h | 20 +++++++++++ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index c21d5abca..5bb1992f3 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -1987,7 +1987,16 @@ void CMipsMemoryVM::ResetMemoryStack() int CMipsMemoryVM::MemoryFilter( DWORD dwExptCode, void * lpExceptionPointer ) { -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(_WIN32) +// to do: Remove the _M_IX86 criteria. This can compile on 64-bit Windows. +#ifndef _WIN64 + DWORD * Reg; +// We need this to fix 32-bit Windows builds, +// because Project64 currently uses DWORD all the time instead of int32_t. +#else + size_t * Reg; +#endif + if (dwExptCode != EXCEPTION_ACCESS_VIOLATION) { if (bHaveDebugger()) @@ -2009,12 +2018,11 @@ int CMipsMemoryVM::MemoryFilter( DWORD dwExptCode, void * lpExceptionPointer ) // } return EXCEPTION_EXECUTE_HANDLER; } - - DWORD * Reg = NULL; BYTE * TypePos = (unsigned char *)lpEP->ContextRecord->Eip; EXCEPTION_RECORD exRec = *lpEP->ExceptionRecord; - + + Reg = NULL; if (*TypePos == 0xF3 && (*(TypePos + 1) == 0xA4 || *(TypePos + 1) == 0xA5)) { DWORD Start = (lpEP->ContextRecord->Edi - (DWORD)m_RDRAM); @@ -2088,16 +2096,16 @@ int CMipsMemoryVM::MemoryFilter( DWORD dwExptCode, void * lpExceptionPointer ) ReadPos = TypePos + 1; } - switch ((*ReadPos & 0x38)) + switch (*ReadPos & 0x38) { - case 0x00: Reg = &lpEP->ContextRecord->Eax; break; - case 0x08: Reg = &lpEP->ContextRecord->Ecx; break; - case 0x10: Reg = &lpEP->ContextRecord->Edx; break; - case 0x18: Reg = &lpEP->ContextRecord->Ebx; break; - case 0x20: Reg = &lpEP->ContextRecord->Esp; break; - case 0x28: Reg = &lpEP->ContextRecord->Ebp; break; - case 0x30: Reg = &lpEP->ContextRecord->Esi; break; - case 0x38: Reg = &lpEP->ContextRecord->Edi; break; + case 0x00: Reg = &(lpEP->ContextRecord->Eax); break; + case 0x08: Reg = &(lpEP->ContextRecord->Ecx); break; + case 0x10: Reg = &(lpEP->ContextRecord->Edx); break; + case 0x18: Reg = &(lpEP->ContextRecord->Ebx); break; + case 0x20: Reg = &(lpEP->ContextRecord->Esp); break; + case 0x28: Reg = &(lpEP->ContextRecord->Ebp); break; + case 0x30: Reg = &(lpEP->ContextRecord->Esi); break; + case 0x38: Reg = &(lpEP->ContextRecord->Edi); break; } switch ((*ReadPos & 0xC7)) diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index 128983cb2..34a459ca6 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -10,6 +10,26 @@ ****************************************************************************/ #pragma once +/* + * 64-bit Windows exception recovery facilities will expect to interact with + * the 64-bit registers of the Intel architecture (e.g., rax instead of eax). + * + * Attempting to read the 32-bit subsets seems to be erroneous and forbidden. + * Refer to "MemoryFilter" in `Memory Virtual Mem.cpp`. + */ +#ifdef _WIN64 +#define Eax Rax +#define Ebx Rbx +#define Ecx Rcx +#define Edx Rdx +#define Esp Rsp +#define Ebp Rbp +#define Esi Rsi +#define Edi Rdi + +#define Eip Rip +#endif + extern unsigned long swap32by8(unsigned long word); class CMipsMemoryVM :