Revert "Remove __try/__catch blocks: Vectored Exceptions made this

unnecessary"

This reverts commit 1ff481ac0a.
This commit is contained in:
Luke Usher 2018-08-16 22:05:11 +01:00
parent 1e53620385
commit 6d15ab07d3
4 changed files with 72 additions and 31 deletions

View File

@ -195,7 +195,14 @@ void SetupPerTitleKeys()
void CxbxLaunchXbe(void(*Entry)())
{
Entry();
__try
{
Entry();
}
__except (EmuException(GetExceptionInformation()))
{
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter");
}
}
// Entry point address XOR keys per Xbe type (Retail, Debug or Chihiro) :
@ -686,8 +693,8 @@ bool IsRdtscInstruction(xbaddr addr)
// Note : Check second opcode first, as that's most likely to fail fast
return (opAddr[1] == 0x90) // NOP
&& (opAddr[0] == 0xEF) // OUT DX, EAX
// Note : It's not needed to check for g_SkipRdtscPatching,
// as when that's set, the g_RdtscPatches vector will be empty
// Note : It's not needed to check for g_SkipRdtscPatching,
// as when that's set, the g_RdtscPatches vector will be empty
// anyway, failing this lookup :
&& (std::find(g_RdtscPatches.begin(), g_RdtscPatches.end(), addr) != g_RdtscPatches.end());
}

View File

@ -161,12 +161,18 @@ DWORD ExecuteDpcQueue()
// Set DpcRoutineActive to support KeIsExecutingDpc:
KeGetCurrentPrcb()->DpcRoutineActive = TRUE; // Experimental
DbgPrintf(LOG_PREFIX, "Global DpcQueue, calling DPC at 0x%.8X\n", pkdpc->DeferredRoutine);
// Call the Deferred Procedure :
pkdpc->DeferredRoutine(
pkdpc,
pkdpc->DeferredContext,
pkdpc->SystemArgument1,
pkdpc->SystemArgument2);
__try {
// Call the Deferred Procedure :
pkdpc->DeferredRoutine(
pkdpc,
pkdpc->DeferredContext,
pkdpc->SystemArgument1,
pkdpc->SystemArgument2);
} __except (EmuException(GetExceptionInformation()))
{
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
}
KeGetCurrentPrcb()->DpcRoutineActive = FALSE; // Experimental
}
@ -200,11 +206,16 @@ DWORD ExecuteDpcQueue()
DbgPrintf(LOG_PREFIX, "Global TimerQueue, calling DPC at 0x%.8X\n", pkdpc->DeferredRoutine);
pkdpc->DeferredRoutine(
pkdpc,
pkdpc->DeferredContext,
pkdpc->SystemArgument1,
pkdpc->SystemArgument2);
__try {
pkdpc->DeferredRoutine(
pkdpc,
pkdpc->DeferredContext,
pkdpc->SystemArgument1,
pkdpc->SystemArgument2);
} __except (EmuException(GetExceptionInformation()))
{
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
}
}
}

View File

@ -167,21 +167,28 @@ static unsigned int WINAPI PCSTProxy
}
// use the special calling convention
// Given the non-standard calling convention (requiring
// the first argument in ebp+4) we need the below __asm.
//
// Otherwise, this call would have looked something like this :
// ((xboxkrnl::PKSYSTEM_ROUTINE)SystemRoutine)(
// (xboxkrnl::PKSTART_ROUTINE)StartRoutine,
// StartContext);
__asm
__try
{
mov esi, SystemRoutine
push StartContext
push StartRoutine
push offset callComplete
lea ebp, [esp - 4]
jmp near esi
// Given the non-standard calling convention (requiring
// the first argument in ebp+4) we need the below __asm.
//
// Otherwise, this call would have looked something like this :
// ((xboxkrnl::PKSYSTEM_ROUTINE)SystemRoutine)(
// (xboxkrnl::PKSTART_ROUTINE)StartRoutine,
// StartContext);
__asm
{
mov esi, SystemRoutine
push StartContext
push StartRoutine
push offset callComplete
lea ebp, [esp - 4]
jmp near esi
}
}
__except (EmuException(GetExceptionInformation()))
{
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!");
}
callComplete:
@ -200,7 +207,16 @@ void PspSystemThreadStartup
IN PVOID StartContext
)
{
(StartRoutine)(StartContext);
__try
{
(StartRoutine)(StartContext);
}
__except (EmuException(GetExceptionInformation()))
// TODO : Call PspUnhandledExceptionInSystemThread(GetExceptionInformation())
{
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter!"); // TODO : Disable?
}
xboxkrnl::PsTerminateSystemThread(STATUS_SUCCESS);
}

View File

@ -1424,8 +1424,15 @@ typedef struct {
void WINAPI EmuFiberStartup(fiber_context_t* context)
{
LPFIBER_START_ROUTINE pfStartRoutine = (LPFIBER_START_ROUTINE)context->lpStartRoutine;
pfStartRoutine(context->lpParameter);
__try
{
LPFIBER_START_ROUTINE pfStartRoutine = (LPFIBER_START_ROUTINE)context->lpStartRoutine;
pfStartRoutine(context->lpParameter);
}
__except (EmuException(GetExceptionInformation()))
{
EmuLog(LOG_PREFIX, LOG_LEVEL::WARNING, "Problem with ExceptionFilter");
}
}
// ******************************************************************