vendredi 27 février 2015

Windows VEH - catch and discard a SINGLE_STEP exception

In a 3rd party application I'm modifying by means of DLL injection, there's a chunk of code that pointlessly throws an EXCEPTION_SINGLE_STEP exception. I wish to catch that exception and discard it completely. However, Windows keeps rethrowing it and therefore my exception handler is stuck in an endless loop.


My code currently:



LONG WINAPI VEH_Handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
printf("Got an exception %X at address %X\n", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);

if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_SINGLE_STEP)
{
return EXCEPTION_CONTINUE_EXECUTION;
}

return EXCEPTION_CONTINUE_SEARCH;
}

//...

//in DllMain
AddVectoredExceptionHandler(1, VEH_Handler);


Is there a way for me to force Windows to forget about the exception and continue execution?


Aucun commentaire:

Enregistrer un commentaire