diff --git a/Source/Project64-core/MemoryExceptionFilter.cpp b/Source/Project64-core/MemoryExceptionFilter.cpp new file mode 100644 index 000000000..f6e635b30 --- /dev/null +++ b/Source/Project64-core/MemoryExceptionFilter.cpp @@ -0,0 +1,402 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "stdafx.h" +#include +#include +#include + +#ifdef _WIN32 +int32_t CMipsMemoryVM::MemoryFilter(uint32_t dwExptCode, void * lpExceptionPointer) +{ +#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 uint32_t all the time instead of int32_t. +#else + size_t * Reg; +#endif + + if (dwExptCode != EXCEPTION_ACCESS_VIOLATION) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + + //convert the pointer since we are not having win32 structures in headers + LPEXCEPTION_POINTERS lpEP = (LPEXCEPTION_POINTERS)lpExceptionPointer; + + uint32_t MemAddress = (char *)lpEP->ExceptionRecord->ExceptionInformation[1] - (char *)g_MMU->Rdram(); + if ((int32_t)(MemAddress) < 0 || MemAddress > 0x1FFFFFFF) + { + // if (bHaveDebugger()) + // { + // g_Notify->BreakPoint(__FILE__, __LINE__); + // } + return EXCEPTION_EXECUTE_HANDLER; + } + + uint8_t * TypePos = (uint8_t *)lpEP->ContextRecord->Eip; + EXCEPTION_RECORD exRec = *lpEP->ExceptionRecord; + + Reg = NULL; + if (*TypePos == 0xF3 && (*(TypePos + 1) == 0xA4 || *(TypePos + 1) == 0xA5)) + { + uint32_t Start = (lpEP->ContextRecord->Edi - (uint32_t)m_RDRAM); + uint32_t End = Start + lpEP->ContextRecord->Ecx; + if ((int32_t)Start < 0) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } +#ifdef CFB_READ + uint32_t count, OldProtect; + if (Start >= CFBStart && End < CFBEnd) + { + for (count = Start; count < End; count += 0x1000) + { + VirtualProtect(m_RDRAM + count, 4, PAGE_READONLY, &OldProtect); + if (FrameBufferRead) + { + FrameBufferRead(count & ~0xFFF); + } + } + return EXCEPTION_CONTINUE_EXECUTION; + } +#endif + if (End < RdramSize()) + { + for (uint32_t count = (Start & ~0xFFF); count < End; count += 0x1000) + { + g_Recompiler->ClearRecompCode_Phys(count, 0x1000, CRecompiler::Remove_ProtectedMem); + } + return EXCEPTION_CONTINUE_EXECUTION; + } + if (Start >= 0x04000000 && End < 0x04002000) + { + g_Recompiler->ClearRecompCode_Phys(Start & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); + return EXCEPTION_CONTINUE_EXECUTION; + } + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + + uint8_t * ReadPos; + if (*TypePos == 0x0F && *(TypePos + 1) == 0xB6) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x0F && *(TypePos + 1) == 0xB7) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBE) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBF) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x66) + { + ReadPos = TypePos + 2; + } + else + { + ReadPos = TypePos + 1; + } + + 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; + } + + switch ((*ReadPos & 0xC7)) + { + case 0: ReadPos += 1; break; + case 1: ReadPos += 1; break; + case 2: ReadPos += 1; break; + case 3: ReadPos += 1; break; + case 4: + ReadPos += 1; + switch ((*ReadPos & 0xC7)) + { + case 0: ReadPos += 1; break; + case 1: ReadPos += 1; break; + case 2: ReadPos += 1; break; + case 3: ReadPos += 1; break; + case 6: ReadPos += 1; break; + case 7: ReadPos += 1; break; + case 0x80: ReadPos += 1; break; + default: + g_Notify->BreakPoint(__FILE__, __LINE__); + } + break; + case 5: ReadPos += 5; break; + case 6: ReadPos += 1; break; + case 7: ReadPos += 1; break; + case 0x40: ReadPos += 2; break; + case 0x41: ReadPos += 2; break; + case 0x42: ReadPos += 2; break; + case 0x43: ReadPos += 2; break; + case 0x44: ReadPos += 3; break; + case 0x46: ReadPos += 2; break; + case 0x47: ReadPos += 2; break; + case 0x80: ReadPos += 5; break; + case 0x81: ReadPos += 5; break; + case 0x82: ReadPos += 5; break; + case 0x83: ReadPos += 5; break; + case 0x86: ReadPos += 5; break; + case 0x87: ReadPos += 5; break; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + + if (Reg == NULL) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + + switch (*TypePos) + { + case 0x0F: + switch (*(TypePos + 1)) + { + case 0xB6: + if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xB7: + if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xBE: + if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, true)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xBF: + if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, true)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + break; + case 0x66: + switch (*(TypePos + 1)) + { + case 0x8B: + if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to half word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x89: + if (!SH_NonMemory(MemAddress, *(uint16_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xC7: + if (Reg != &lpEP->ContextRecord->Eax) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + if (!SH_NonMemory(MemAddress, *(uint16_t *)ReadPos)) { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 2); + return EXCEPTION_CONTINUE_EXECUTION; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + break; + case 0x88: + if (!SB_NonMemory(MemAddress, *(uint8_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x8A: + if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x8B: + if (!LW_NonMemory(MemAddress, (uint32_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x89: + if (!SW_NonMemory(MemAddress, *(uint32_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xC6: + if (Reg != &lpEP->ContextRecord->Eax) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + if (!SB_NonMemory(MemAddress, *(uint8_t *)ReadPos)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 1); + return EXCEPTION_CONTINUE_EXECUTION; + case 0xC7: + if (Reg != &lpEP->ContextRecord->Eax) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + if (!SW_NonMemory(MemAddress, *(uint32_t *)ReadPos)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 4); + return EXCEPTION_CONTINUE_EXECUTION; + } + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } +#else + g_Notify->BreakPoint(__FILE__, __LINE__); +#endif + return EXCEPTION_EXECUTE_HANDLER; +} +#endif \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp index d0aa7d664..5761cf678 100644 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include uint32_t RegModValue; @@ -26,8 +26,9 @@ uint32_t CMipsMemoryVM::m_MemLookupAddress = 0; MIPS_DWORD CMipsMemoryVM::m_MemLookupValue; bool CMipsMemoryVM::m_MemLookupValid = true; -CMipsMemoryVM::CMipsMemoryVM(bool SavesReadOnly) : +#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list +CMipsMemoryVM::CMipsMemoryVM(bool SavesReadOnly) : CPifRam(SavesReadOnly), CFlashram(SavesReadOnly), CSram(SavesReadOnly), @@ -104,10 +105,10 @@ void CMipsMemoryVM::Reset(bool /*EraseMemory*/) void CMipsMemoryVM::ReserveMemory() { - m_Reserve1 = (uint8_t *)VirtualAlloc(NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE); + m_Reserve1 = (uint8_t *)AllocateAddressSpace(0x20000000); if (g_Settings->LoadBool(Debugger_Enabled)) { - m_Reserve2 = (uint8_t *)VirtualAlloc(NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE); + m_Reserve2 = (uint8_t *)AllocateAddressSpace(0x20000000); } } @@ -115,12 +116,12 @@ void CMipsMemoryVM::FreeReservedMemory() { if (m_Reserve1) { - VirtualFree(m_Reserve1, 0, MEM_RELEASE); + FreeAddressSpace(m_Reserve1, 0x20000000); m_Reserve1 = NULL; } if (m_Reserve2) { - VirtualFree(m_Reserve2, 0, MEM_RELEASE); + FreeAddressSpace(m_Reserve2, 0x20000000); m_Reserve2 = NULL; } } @@ -142,7 +143,7 @@ bool CMipsMemoryVM::Initialize() } if (m_RDRAM == NULL) { - m_RDRAM = (uint8_t *)VirtualAlloc(NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE); + m_RDRAM = (uint8_t *)AllocateAddressSpace(0x20000000); } if (m_RDRAM == NULL) { @@ -152,14 +153,14 @@ bool CMipsMemoryVM::Initialize() } m_AllocatedRdramSize = g_Settings->LoadDword(Game_RDRamSize); - if (VirtualAlloc(m_RDRAM, m_AllocatedRdramSize, MEM_COMMIT, PAGE_READWRITE) == NULL) + if (CommitMemory(m_RDRAM, m_AllocatedRdramSize, MEM_READWRITE) == NULL) { WriteTrace(TraceN64System, TraceError, "Failed to Allocate RDRAM (Size: 0x%X)", m_AllocatedRdramSize); FreeMemory(); return false; } - if (VirtualAlloc(m_RDRAM + 0x04000000, 0x2000, MEM_COMMIT, PAGE_READWRITE) == NULL) + if (CommitMemory(m_RDRAM + 0x04000000, 0x2000, MEM_READWRITE) == NULL) { WriteTrace(TraceN64System, TraceError, "Failed to Allocate DMEM/IMEM (Size: 0x%X)", 0x2000); FreeMemory(); @@ -174,7 +175,7 @@ bool CMipsMemoryVM::Initialize() m_RomMapped = true; m_Rom = m_RDRAM + 0x10000000; m_RomSize = g_Rom->GetRomSize(); - if (VirtualAlloc(m_Rom, g_Rom->GetRomSize(), MEM_COMMIT, PAGE_READWRITE) == NULL) + if (CommitMemory(m_Rom, g_Rom->GetRomSize(), MEM_READWRITE) == NULL) { WriteTrace(TraceN64System, TraceError, "Failed to Allocate Rom (Size: 0x%X)", g_Rom->GetRomSize()); FreeMemory(); @@ -182,8 +183,7 @@ bool CMipsMemoryVM::Initialize() } memcpy(m_Rom, g_Rom->GetRomAddress(), g_Rom->GetRomSize()); - DWORD OldProtect; - VirtualProtect(m_Rom, g_Rom->GetRomSize(), PAGE_READONLY, &OldProtect); + ::ProtectMemory(m_Rom, g_Rom->GetRomSize(), MEM_READONLY); } else { @@ -193,25 +193,15 @@ bool CMipsMemoryVM::Initialize() } CPifRam::Reset(); - m_TLB_ReadMap = (size_t *)VirtualAlloc( - NULL, - 0xFFFFF * sizeof(size_t), - MEM_RESERVE | MEM_COMMIT, - PAGE_READWRITE - ); + m_TLB_ReadMap = new size_t[0x100000]; if (m_TLB_ReadMap == NULL) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate m_TLB_ReadMap (Size: 0x%X)", 0xFFFFF * sizeof(size_t)); + WriteTrace(TraceN64System, TraceError, "Failed to Allocate m_TLB_ReadMap (Size: 0x%X)", 0x100000 * sizeof(size_t)); FreeMemory(); return false; } - m_TLB_WriteMap = (size_t *)VirtualAlloc( - NULL, - 0xFFFFF * sizeof(size_t), - MEM_RESERVE | MEM_COMMIT, - PAGE_READWRITE - ); + m_TLB_WriteMap = new size_t[0x100000]; if (m_TLB_WriteMap == NULL) { WriteTrace(TraceN64System, TraceError, "Failed to Allocate m_TLB_WriteMap (Size: 0x%X)", 0xFFFFF * sizeof(size_t)); @@ -226,7 +216,7 @@ void CMipsMemoryVM::FreeMemory() { if (m_RDRAM) { - if (VirtualFree(m_RDRAM, 0x20000000, MEM_DECOMMIT) != 0) + if (DecommitMemory(m_RDRAM, 0x20000000)) { if (m_Reserve1 == NULL) { @@ -238,12 +228,12 @@ void CMipsMemoryVM::FreeMemory() } else { - VirtualFree(m_RDRAM, 0, MEM_RELEASE); + FreeAddressSpace(m_RDRAM, 0x20000000); } } else { - VirtualFree(m_RDRAM, 0, MEM_RELEASE); + FreeAddressSpace(m_RDRAM, 0x20000000); } m_RDRAM = NULL; m_IMEM = NULL; @@ -251,12 +241,12 @@ void CMipsMemoryVM::FreeMemory() } if (m_TLB_ReadMap) { - VirtualFree(m_TLB_ReadMap, 0, MEM_RELEASE); + delete[] m_TLB_ReadMap; m_TLB_ReadMap = NULL; } if (m_TLB_WriteMap) { - VirtualFree(m_TLB_WriteMap, 0, MEM_RELEASE); + delete[] m_TLB_WriteMap; m_TLB_WriteMap = NULL; } CPifRam::Reset(); @@ -607,7 +597,7 @@ void CMipsMemoryVM::Compile_LB(x86Reg Reg, uint32_t VAddr, bool SignExtend) CPU_Message("Compile_LB\nFailed to translate address %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -637,7 +627,7 @@ void CMipsMemoryVM::Compile_LB(x86Reg Reg, uint32_t VAddr, bool SignExtend) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to compile address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to compile address: %08X", __FUNCTION__, VAddr).c_str()); } } } @@ -678,7 +668,7 @@ void CMipsMemoryVM::Compile_LH(x86Reg Reg, uint32_t VAddr, bool SignExtend) CPU_Message("Compile_LH\nFailed to translate address %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -708,7 +698,7 @@ void CMipsMemoryVM::Compile_LH(x86Reg Reg, uint32_t VAddr, bool SignExtend) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to compile address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to compile address: %08X", __FUNCTION__, VAddr).c_str()); } } } @@ -775,7 +765,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; @@ -785,7 +775,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) BeforeCallDirect(m_RegWorkingSet); PushImm32("TempValue", (uint32_t)&TempValue); PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CMipsMemoryVM *)this), x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::LW_NonMemory), "CMipsMemoryVM::LW_NonMemory"); AfterCallDirect(m_RegWorkingSet); MoveVariableToX86reg(&TempValue, "TempValue", Reg); @@ -800,7 +790,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) case 0x0430000C: MoveVariableToX86reg(&g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG", Reg); break; default: MoveConstToX86reg(0, Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); } + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; case 0x04400000: @@ -820,7 +810,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; @@ -875,7 +865,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; @@ -895,7 +885,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; @@ -908,7 +898,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; @@ -920,7 +910,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(0, Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } break; @@ -940,8 +930,8 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) MoveConstToX86reg(((PAddr & 0xFFFF) << 16) | (PAddr & 0xFFFF), Reg); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - CPU_Message(__FUNCTION__ "\nFailed to translate address: %08X", VAddr); - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } } } @@ -969,7 +959,7 @@ void CMipsMemoryVM::Compile_SB_Const(uint8_t Value, uint32_t VAddr) if (!TranslateVaddr(VAddr, PAddr)) { CPU_Message("Compile_SB\nFailed to translate address: %08X", VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); } + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f("%s, \nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -989,7 +979,7 @@ void CMipsMemoryVM::Compile_SB_Const(uint8_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %02X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %02X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } } @@ -1019,7 +1009,7 @@ void CMipsMemoryVM::Compile_SB_Register(x86Reg Reg, uint32_t VAddr) CPU_Message("Compile_SB\nFailed to translate address: %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -1040,7 +1030,7 @@ void CMipsMemoryVM::Compile_SB_Register(x86Reg Reg, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } } @@ -1067,7 +1057,7 @@ void CMipsMemoryVM::Compile_SH_Const(uint16_t Value, uint32_t VAddr) CPU_Message("Compile_SH\nFailed to translate address: %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -1088,7 +1078,7 @@ void CMipsMemoryVM::Compile_SH_Const(uint16_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %04X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %04X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } } @@ -1117,7 +1107,7 @@ void CMipsMemoryVM::Compile_SH_Register(x86Reg Reg, uint32_t VAddr) CPU_Message("Compile_SH\nFailed to translate address: %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -1138,7 +1128,7 @@ void CMipsMemoryVM::Compile_SH_Register(x86Reg Reg, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", PAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, PAddr).c_str()); } } } @@ -1167,7 +1157,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) CPU_Message("Compile_SW\nFailed to translate address: %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -1207,7 +1197,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1225,7 +1215,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) case 0x04040008: MoveConstToVariable(Value, &g_Reg->SP_RD_LEN_REG, "SP_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::SP_DMA_READ), "CDMA::SP_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; @@ -1238,7 +1228,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) BeforeCallDirect(m_RegWorkingSet); PushImm32(Value); PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CMipsMemoryVM *)this), x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); AfterCallDirect(m_RegWorkingSet); } @@ -1248,7 +1238,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1259,14 +1249,14 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) BeforeCallDirect(m_RegWorkingSet); PushImm32(Value); PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CMipsMemoryVM *)this), x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); AfterCallDirect(m_RegWorkingSet); break; default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1384,7 +1374,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1442,7 +1432,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1485,7 +1475,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) MoveConstToVariable(Value, PAddr + m_RDRAM, VarName); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1497,14 +1487,14 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) case 0x04600008: MoveConstToVariable(Value, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::PI_DMA_READ), "CDMA::PI_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x0460000C: MoveConstToVariable(Value, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::PI_DMA_WRITE), "CDMA::PI_DMA_WRITE"); AfterCallDirect(m_RegWorkingSet); break; @@ -1525,7 +1515,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1539,7 +1529,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1578,7 +1568,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -1591,7 +1581,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) BeforeCallDirect(m_RegWorkingSet); PushImm32(Value); PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CMipsMemoryVM *)this), x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); AfterCallDirect(m_RegWorkingSet); } @@ -1599,7 +1589,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); @@ -1608,7 +1598,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) BeforeCallDirect(m_RegWorkingSet); PushImm32(Value); PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CMipsMemoryVM *)this), x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); AfterCallDirect(m_RegWorkingSet); } @@ -1640,7 +1630,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) CPU_Message("Compile_SW_Register\nFailed to translate address: %08X", VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } return; } @@ -1666,14 +1656,14 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) case 0x04040008: MoveX86regToVariable(Reg, &g_Reg->SP_RD_LEN_REG, "SP_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::SP_DMA_READ), "CDMA::SP_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x0404000C: MoveX86regToVariable(Reg, &g_Reg->SP_WR_LEN_REG, "SP_WR_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::SP_DMA_WRITE), "CDMA::SP_DMA_WRITE"); AfterCallDirect(m_RegWorkingSet); break; @@ -1683,7 +1673,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); MoveX86regToVariable(Reg, &RegModValue, "RegModValue"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeSpStatus, "ChangeSpStatus"); + Call_Direct((void *)ChangeSpStatus, "ChangeSpStatus"); AfterCallDirect(m_RegWorkingSet); break; case 0x0404001C: MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; @@ -1702,7 +1692,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } } @@ -1717,7 +1707,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) BeforeCallDirect(m_RegWorkingSet); Push(Reg); PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CMipsMemoryVM *)this), x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); AfterCallDirect(m_RegWorkingSet); break; @@ -1727,20 +1717,20 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) case 0x04300000: MoveX86regToVariable(Reg, &RegModValue, "RegModValue"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeMiIntrMask, "ChangeMiModeReg"); + Call_Direct((void *)ChangeMiIntrMask, "ChangeMiModeReg"); AfterCallDirect(m_RegWorkingSet); break; case 0x0430000C: MoveX86regToVariable(Reg, &RegModValue, "RegModValue"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeMiIntrMask, "ChangeMiIntrMask"); + Call_Direct((void *)ChangeMiIntrMask, "ChangeMiIntrMask"); AfterCallDirect(m_RegWorkingSet); break; default: CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -1801,7 +1791,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -1847,7 +1837,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) MoveX86regToVariable(Reg, PAddr + m_RDRAM, VarName); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -1859,21 +1849,21 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) case 0x04600008: MoveX86regToVariable(Reg, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::PI_DMA_READ), "CDMA::PI_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x0460000C: MoveX86regToVariable(Reg, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + MoveConstToX86reg((uint32_t)((CDMA *)this), x86_ECX); Call_Direct(AddressOf(&CDMA::PI_DMA_WRITE), "CDMA::PI_DMA_WRITE"); AfterCallDirect(m_RegWorkingSet); break; case 0x04600010: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } AndConstToVariable((uint32_t)~MI_INTR_PI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); BeforeCallDirect(m_RegWorkingSet); @@ -1901,7 +1891,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -1912,7 +1902,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -1945,7 +1935,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) default: if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -1957,7 +1947,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } } @@ -2005,392 +1995,6 @@ void CMipsMemoryVM::ResetMemoryStack() MoveX86regToVariable(Reg, &(g_Recompiler->MemoryStackPos()), "MemoryStack"); } -int32_t CMipsMemoryVM::MemoryFilter(uint32_t dwExptCode, void * lpExceptionPointer) -{ -#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 uint32_t all the time instead of int32_t. -#else - size_t * Reg; -#endif - - if (dwExptCode != EXCEPTION_ACCESS_VIOLATION) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - - //convert the pointer since we are not having win32 structures in headers - LPEXCEPTION_POINTERS lpEP = (LPEXCEPTION_POINTERS)lpExceptionPointer; - - uint32_t MemAddress = (char *)lpEP->ExceptionRecord->ExceptionInformation[1] - (char *)g_MMU->Rdram(); - if ((int32_t)(MemAddress) < 0 || MemAddress > 0x1FFFFFFF) - { - // if (bHaveDebugger()) - // { - // g_Notify->BreakPoint(__FILE__, __LINE__); - // } - return EXCEPTION_EXECUTE_HANDLER; - } - - uint8_t * TypePos = (uint8_t *)lpEP->ContextRecord->Eip; - EXCEPTION_RECORD exRec = *lpEP->ExceptionRecord; - - Reg = NULL; - if (*TypePos == 0xF3 && (*(TypePos + 1) == 0xA4 || *(TypePos + 1) == 0xA5)) - { - uint32_t Start = (lpEP->ContextRecord->Edi - (uint32_t)m_RDRAM); - uint32_t End = Start + lpEP->ContextRecord->Ecx; - if ((int32_t)Start < 0) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } -#ifdef CFB_READ - uint32_t count, OldProtect; - if (Start >= CFBStart && End < CFBEnd) - { - for ( count = Start; count < End; count += 0x1000 ) - { - VirtualProtect(m_RDRAM+count,4,PAGE_READONLY, &OldProtect); - if (FrameBufferRead) - { - FrameBufferRead(count & ~0xFFF); - } - } - return EXCEPTION_CONTINUE_EXECUTION; - } -#endif - if (End < RdramSize()) - { - for (uint32_t count = (Start & ~0xFFF); count < End; count += 0x1000) - { - g_Recompiler->ClearRecompCode_Phys(count, 0x1000, CRecompiler::Remove_ProtectedMem); - } - return EXCEPTION_CONTINUE_EXECUTION; - } - if (Start >= 0x04000000 && End < 0x04002000) - { - g_Recompiler->ClearRecompCode_Phys(Start & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); - return EXCEPTION_CONTINUE_EXECUTION; - } - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - - uint8_t * ReadPos; - if (*TypePos == 0x0F && *(TypePos + 1) == 0xB6) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x0F && *(TypePos + 1) == 0xB7) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBE) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBF) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x66) - { - ReadPos = TypePos + 2; - } - else - { - ReadPos = TypePos + 1; - } - - 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; - } - - switch ((*ReadPos & 0xC7)) - { - case 0: ReadPos += 1; break; - case 1: ReadPos += 1; break; - case 2: ReadPos += 1; break; - case 3: ReadPos += 1; break; - case 4: - ReadPos += 1; - switch ((*ReadPos & 0xC7)) - { - case 0: ReadPos += 1; break; - case 1: ReadPos += 1; break; - case 2: ReadPos += 1; break; - case 3: ReadPos += 1; break; - case 6: ReadPos += 1; break; - case 7: ReadPos += 1; break; - case 0x80: ReadPos += 1; break; - default: - g_Notify->BreakPoint(__FILE__, __LINE__); - } - break; - case 5: ReadPos += 5; break; - case 6: ReadPos += 1; break; - case 7: ReadPos += 1; break; - case 0x40: ReadPos += 2; break; - case 0x41: ReadPos += 2; break; - case 0x42: ReadPos += 2; break; - case 0x43: ReadPos += 2; break; - case 0x44: ReadPos += 3; break; - case 0x46: ReadPos += 2; break; - case 0x47: ReadPos += 2; break; - case 0x80: ReadPos += 5; break; - case 0x81: ReadPos += 5; break; - case 0x82: ReadPos += 5; break; - case 0x83: ReadPos += 5; break; - case 0x86: ReadPos += 5; break; - case 0x87: ReadPos += 5; break; - default: - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - - if (Reg == NULL) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - - switch (*TypePos) - { - case 0x0F: - switch (*(TypePos + 1)) - { - case 0xB6: - if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xB7: - if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xBE: - if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, true)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xBF: - if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, true)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - default: - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - break; - case 0x66: - switch (*(TypePos + 1)) - { - case 0x8B: - if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to half word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x89: - if (!SH_NonMemory(MemAddress, *(uint16_t *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xC7: - if (Reg != &lpEP->ContextRecord->Eax) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - if (!SH_NonMemory(MemAddress, *(uint16_t *)ReadPos)) { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 2); - return EXCEPTION_CONTINUE_EXECUTION; - default: - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - break; - case 0x88: - if (!SB_NonMemory(MemAddress, *(uint8_t *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x8A: - if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x8B: - if (!LW_NonMemory(MemAddress, (uint32_t *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x89: - if (!SW_NonMemory(MemAddress, *(uint32_t *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xC6: - if (Reg != &lpEP->ContextRecord->Eax) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - if (!SB_NonMemory(MemAddress, *(uint8_t *)ReadPos)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 1); - return EXCEPTION_CONTINUE_EXECUTION; - case 0xC7: - if (Reg != &lpEP->ContextRecord->Eax) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - if (!SW_NonMemory(MemAddress, *(uint32_t *)ReadPos)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (uint8_t *)lpEP->ContextRecord->Eip).c_str()); - } - } - lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 4); - return EXCEPTION_CONTINUE_EXECUTION; - } - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } -#else - g_Notify->BreakPoint(__FILE__, __LINE__); -#endif - return EXCEPTION_EXECUTE_HANDLER; -} - bool CMipsMemoryVM::LB_NonMemory(uint32_t PAddr, uint32_t* Value, bool /*SignExtend*/) { if (PAddr < 0x800000) @@ -2540,9 +2144,8 @@ bool CMipsMemoryVM::SB_NonMemory(uint32_t PAddr, uint8_t Value) #endif if (PAddr < RdramSize()) { - DWORD OldProtect; g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0xFFC, CRecompiler::Remove_ProtectedMem); - VirtualProtect(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, PAGE_READWRITE, &OldProtect); + ::ProtectMemory(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, MEM_READWRITE); *(uint8_t *)(m_RDRAM + PAddr) = Value; } break; @@ -2580,9 +2183,8 @@ bool CMipsMemoryVM::SH_NonMemory(uint32_t PAddr, uint16_t Value) #endif if (PAddr < RdramSize()) { - DWORD OldProtect; g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); - VirtualProtect(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, PAGE_READWRITE, &OldProtect); + ::ProtectMemory(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, MEM_READWRITE); *(uint16_t *)(m_RDRAM + PAddr) = Value; } break; @@ -2642,9 +2244,8 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t PAddr, uint32_t Value) #endif if (PAddr < RdramSize()) { - DWORD OldProtect; g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); - VirtualProtect(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, PAGE_READWRITE, &OldProtect); + ::ProtectMemory(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, MEM_READWRITE); *(uint32_t *)(m_RDRAM + PAddr) = Value; } break; @@ -2738,11 +2339,10 @@ void CMipsMemoryVM::ProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) } //Protect that memory address space - DWORD OldProtect; uint8_t * MemLoc = Rdram() + StartPAddr; WriteTrace(TraceProtectedMem, TraceDebug, "Paddr: %08X Length: %X", StartPAddr, Length); - VirtualProtect(MemLoc, Length, PAGE_READONLY, &OldProtect); + ::ProtectMemory(MemLoc, Length, MEM_READONLY); } void CMipsMemoryVM::UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) @@ -2769,10 +2369,8 @@ void CMipsMemoryVM::UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) } //Protect that memory address space - DWORD OldProtect; uint8_t * MemLoc = Rdram() + StartPAddr; - - VirtualProtect(MemLoc, Length, PAGE_READWRITE, &OldProtect); + ::ProtectMemory(MemLoc, Length, MEM_READWRITE); } void CMipsMemoryVM::Compile_LB() @@ -3632,7 +3230,7 @@ void CMipsMemoryVM::Compile_LDL() BeforeCallDirect(m_RegWorkingSet); MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::LDL, "R4300iOp::LDL"); + Call_Direct((void *)R4300iOp::LDL, "R4300iOp::LDL"); AfterCallDirect(m_RegWorkingSet); } @@ -3654,7 +3252,7 @@ void CMipsMemoryVM::Compile_LDR() BeforeCallDirect(m_RegWorkingSet); MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::LDR, "R4300iOp::LDR"); + Call_Direct((void *)R4300iOp::LDR, "R4300iOp::LDR"); AfterCallDirect(m_RegWorkingSet); } @@ -4316,7 +3914,7 @@ void CMipsMemoryVM::Compile_StoreInstructClean(x86Reg AddressReg, int32_t Length MoveX86RegToX86Reg(AddressReg, StoreTemp1); ShiftRightUnsignImmed(StoreTemp1,12); - LeaRegReg(StoreTemp1,StoreTemp1,(ULONG)&(g_Recompiler->FunctionTable()[0]),Multip_x4); + LeaRegReg(StoreTemp1,StoreTemp1,(uint32_t)&(g_Recompiler->FunctionTable()[0]),Multip_x4); CompConstToX86regPointer(StoreTemp1,0); JeLabel8("MemCheckDone",0); uint8_t * MemCheckDone2 = m_RecompPos - 1; @@ -4594,7 +4192,7 @@ void CMipsMemoryVM::Compile_SDL() BeforeCallDirect(m_RegWorkingSet); MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SDL, "R4300iOp::SDL"); + Call_Direct((void *)R4300iOp::SDL, "R4300iOp::SDL"); AfterCallDirect(m_RegWorkingSet); } @@ -4616,11 +4214,11 @@ void CMipsMemoryVM::Compile_SDR() BeforeCallDirect(m_RegWorkingSet); MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SDR, "R4300iOp::SDR"); + Call_Direct((void *)R4300iOp::SDR, "R4300iOp::SDR"); AfterCallDirect(m_RegWorkingSet); } -LPCTSTR CMipsMemoryVM::LabelName(uint32_t Address) const +const char * CMipsMemoryVM::LabelName(uint32_t Address) const { //StringMap::iterator theIterator = m_LabelList.find(Address); //if (theIterator != m_LabelList.end()) @@ -4672,22 +4270,11 @@ void CMipsMemoryVM::RdramChanged(CMipsMemoryVM * _this) } if (old_size > new_size) { - VirtualFree( - _this->m_RDRAM + new_size, - old_size - new_size, - MEM_DECOMMIT - ); + DecommitMemory(_this->m_RDRAM + new_size, old_size - new_size); } else { - void * result; - - result = VirtualAlloc( - _this->m_RDRAM + old_size, - new_size - old_size, - MEM_COMMIT, - PAGE_READWRITE - ); + void * result = CommitMemory(_this->m_RDRAM + old_size, new_size - old_size, MEM_READWRITE); if (result == NULL) { WriteTrace(TraceN64System, TraceError, "failed to allocate extended memory"); diff --git a/Source/Project64-core/Project64-core.vcproj b/Source/Project64-core/Project64-core.vcproj index 12897ce1e..ad1589c97 100644 --- a/Source/Project64-core/Project64-core.vcproj +++ b/Source/Project64-core/Project64-core.vcproj @@ -317,6 +317,10 @@ RelativePath=".\N64System\FramePerSecondClass.cpp" > + + diff --git a/Source/Project64-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index ecc6b0454..9b063fe59 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -37,6 +37,7 @@ + diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index 57887154d..c07dc23bd 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -291,6 +291,9 @@ Source Files\Multilanguage + + Source Files\N64 System +