Fix a crash on invalid memory accesses

This commit is contained in:
Luke Usher 2018-09-15 16:19:50 +01:00
parent 1102133475
commit b8889b6857
1 changed files with 42 additions and 27 deletions

View File

@ -119,6 +119,8 @@ void EmuX86_IOWrite(xbaddr addr, uint32_t value, int size)
uint32_t EmuX86_Mem_Read(xbaddr addr, int size)
{
__try {
switch (size) {
case sizeof(uint32_t) :
return *(uint32_t*)addr;
@ -131,9 +133,14 @@ uint32_t EmuX86_Mem_Read(xbaddr addr, int size)
return 0;
}
}
__except (true) {
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Mem_Read Failed (0x%08X, %d)", addr, size);
}
}
void EmuX86_Mem_Write(xbaddr addr, uint32_t value, int size)
{
__try {
switch (size) {
case sizeof(uint32_t) :
*(uint32_t*)addr = (uint32_t)value;
@ -149,6 +156,10 @@ void EmuX86_Mem_Write(xbaddr addr, uint32_t value, int size)
return;
}
}
__except (true) {
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "EmuX86_Mem_Write Failed (0x%08X, 0x%08X, %d)", addr, value, size);
}
}
uint32_t EmuFlash_Read32(xbaddr addr) // TODO : Move to EmuFlash.cpp
{
@ -1179,8 +1190,12 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
continue;
}
break;
case I_RET:
// RET always signifies the end of a code block
case I_CALL: case I_RET:
// RET and CALL always signify the end of a code block
return true;
case I_PUSH: case I_POP:
// TODO: Implement these instructions
// currently stubbed to prevent firing the unimplemented instruction handler
return true;
case I_ADD:
if (EmuX86_Opcode_ADD(e, info)) break;