removed exception handlers for callbacks (this is dangerous)

This commit is contained in:
Mr. eXoDia 2015-04-17 00:36:47 +02:00
parent b9dd68f5c7
commit 268c684125
2 changed files with 58 additions and 372 deletions

View File

@ -45,8 +45,6 @@ LPVOID StepOutCallBack = NULL;
// Global.Debugger.functions: // Global.Debugger.functions:
long DebugLoopInSecondThread(LPVOID InputParameter) long DebugLoopInSecondThread(LPVOID InputParameter)
{ {
__try
{
if(InputParameter == NULL) //IsFileDll if(InputParameter == NULL) //IsFileDll
{ {
InitDebugExW(expertDebug.szFileName, expertDebug.szCommandLine, expertDebug.szCurrentFolder, expertDebug.EntryCallBack); InitDebugExW(expertDebug.szFileName, expertDebug.szCommandLine, expertDebug.szCurrentFolder, expertDebug.EntryCallBack);
@ -56,12 +54,7 @@ long DebugLoopInSecondThread(LPVOID InputParameter)
InitDLLDebugW(expertDebug.szFileName, expertDebug.ReserveModuleBase, expertDebug.szCommandLine, expertDebug.szCurrentFolder, expertDebug.EntryCallBack); InitDLLDebugW(expertDebug.szFileName, expertDebug.ReserveModuleBase, expertDebug.szCommandLine, expertDebug.szCurrentFolder, expertDebug.EntryCallBack);
} }
DebugLoop(); DebugLoop();
return(NULL); return NULL;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return(-1);
}
} }
void DebuggerReset() void DebuggerReset()
@ -94,14 +87,8 @@ void StepOutStepCallBack()
else else
{ {
typedef void(TITCALL * fCustomBreakPoint)(); typedef void(TITCALL * fCustomBreakPoint)();
__try
{
((fCustomBreakPoint)StepOutCallBack)(); ((fCustomBreakPoint)StepOutCallBack)();
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
} }
else else
StepOver(StepOutStepCallBack); StepOver(StepOutStepCallBack);

View File

@ -89,15 +89,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chDebugEvent != NULL) if(DBGCustomHandler->chDebugEvent != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chDebugEvent); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chDebugEvent);
__try
{
myCustomHandler(&DBGEvent); myCustomHandler(&DBGEvent);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chDebugEvent = NULL;
}
}
//Debug event //Debug event
switch(DBGEvent.dwDebugEventCode) switch(DBGEvent.dwDebugEventCode)
@ -169,15 +162,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chCreateProcess != NULL) if(DBGCustomHandler->chCreateProcess != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chCreateProcess); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chCreateProcess);
__try
{
myCustomHandler(&DBGEvent.u.CreateProcessInfo); myCustomHandler(&DBGEvent.u.CreateProcessInfo);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chCreateProcess = NULL;
}
}
EngineCloseHandle(DBGFileHandle); //close file handle EngineCloseHandle(DBGFileHandle); //close file handle
} }
@ -194,15 +180,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chExitProcess != NULL) if(DBGCustomHandler->chExitProcess != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chExitProcess); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chExitProcess);
__try
{
myCustomHandler(&DBGEvent.u.ExitProcess); myCustomHandler(&DBGEvent.u.ExitProcess);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chExitProcess = NULL;
}
}
} }
break; break;
@ -237,15 +216,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chCreateThread != NULL) if(DBGCustomHandler->chCreateThread != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chCreateThread); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chCreateThread);
__try
{
myCustomHandler(&DBGEvent.u.CreateThread); myCustomHandler(&DBGEvent.u.CreateThread);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chCreateThread = NULL;
}
}
} }
break; break;
@ -255,26 +227,12 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chExitThread != NULL) if(DBGCustomHandler->chExitThread != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chExitThread); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chExitThread);
__try
{
myCustomHandler(&DBGEvent.u.ExitThread); myCustomHandler(&DBGEvent.u.ExitThread);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chExitThread = NULL;
}
}
if(engineExitThreadOneShootCallBack != NULL) if(engineExitThreadOneShootCallBack != NULL)
{ {
myCustomHandler = (fCustomHandler)(engineExitThreadOneShootCallBack); myCustomHandler = (fCustomHandler)(engineExitThreadOneShootCallBack);
__try
{
myCustomHandler(&DBGEvent.u.ExitThread); myCustomHandler(&DBGEvent.u.ExitThread);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
engineExitThreadOneShootCallBack = NULL; engineExitThreadOneShootCallBack = NULL;
} }
@ -355,14 +313,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(ptrLibrarianData->bpxType == UE_ON_LIB_LOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL) if(ptrLibrarianData->bpxType == UE_ON_LIB_LOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL)
{ {
myCustomHandler = (fCustomHandler)(ptrLibrarianData->bpxCallBack); myCustomHandler = (fCustomHandler)(ptrLibrarianData->bpxCallBack);
__try
{
myCustomHandler(&DBGEvent.u.LoadDll); myCustomHandler(&DBGEvent.u.LoadDll);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
LibrarianRemoveBreakPoint(ptrLibrarianData->szLibraryName, ptrLibrarianData->bpxType);
}
if(ptrLibrarianData->bpxSingleShoot) if(ptrLibrarianData->bpxSingleShoot)
{ {
LibrarianRemoveBreakPoint(ptrLibrarianData->szLibraryName, ptrLibrarianData->bpxType); LibrarianRemoveBreakPoint(ptrLibrarianData->szLibraryName, ptrLibrarianData->bpxType);
@ -381,15 +332,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chLoadDll != NULL) if(DBGCustomHandler->chLoadDll != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chLoadDll); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chLoadDll);
__try
{
myCustomHandler(&DBGEvent.u.LoadDll); myCustomHandler(&DBGEvent.u.LoadDll);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chLoadDll = NULL;
}
}
} }
break; break;
@ -399,15 +343,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chUnloadDll != NULL) if(DBGCustomHandler->chUnloadDll != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chUnloadDll); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chUnloadDll);
__try
{
myCustomHandler(&DBGEvent.u.UnloadDll); myCustomHandler(&DBGEvent.u.UnloadDll);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chUnloadDll = NULL;
}
}
//library breakpoint //library breakpoint
hLoadedLibData = (PLIBRARY_ITEM_DATAW)LibrarianGetLibraryInfoEx(DBGEvent.u.UnloadDll.lpBaseOfDll); hLoadedLibData = (PLIBRARY_ITEM_DATAW)LibrarianGetLibraryInfoEx(DBGEvent.u.UnloadDll.lpBaseOfDll);
@ -424,14 +361,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(ptrLibrarianData->bpxType == UE_ON_LIB_UNLOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL) if(ptrLibrarianData->bpxType == UE_ON_LIB_UNLOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL)
{ {
myCustomHandler = (fCustomHandler)(ptrLibrarianData->bpxCallBack); myCustomHandler = (fCustomHandler)(ptrLibrarianData->bpxCallBack);
__try
{
myCustomHandler(&DBGEvent.u.UnloadDll); myCustomHandler(&DBGEvent.u.UnloadDll);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
LibrarianRemoveBreakPoint(ptrLibrarianData->szLibraryName, ptrLibrarianData->bpxType);
}
if(ptrLibrarianData->bpxSingleShoot) if(ptrLibrarianData->bpxSingleShoot)
{ {
LibrarianRemoveBreakPoint(ptrLibrarianData->szLibraryName, ptrLibrarianData->bpxType); LibrarianRemoveBreakPoint(ptrLibrarianData->szLibraryName, ptrLibrarianData->bpxType);
@ -472,15 +402,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chOutputDebugString != NULL) if(DBGCustomHandler->chOutputDebugString != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chOutputDebugString); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chOutputDebugString);
__try
{
myCustomHandler(&DBGEvent.u.DebugString); myCustomHandler(&DBGEvent.u.DebugString);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chOutputDebugString = NULL;
}
}
} }
break; break;
@ -491,15 +414,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chEverythingElse != NULL) if(DBGCustomHandler->chEverythingElse != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chEverythingElse); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chEverythingElse);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chEverythingElse = NULL;
}
}
if(DBGEvent.u.Exception.dwFirstChance == FALSE) //second chance exception if(DBGEvent.u.Exception.dwFirstChance == FALSE) //second chance exception
{ {
//NOTE: unclear behavious of ->Pass<- all exceptions (not to debuggee, but to debugger) //NOTE: unclear behavious of ->Pass<- all exceptions (not to debuggee, but to debugger)
@ -569,14 +485,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
//execute callback //execute callback
myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack); myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack);
__try
{
myCustomBreakPoint(); myCustomBreakPoint();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
if(FoundBreakPoint.BreakPointType != UE_SINGLESHOOT) if(FoundBreakPoint.BreakPointType != UE_SINGLESHOOT)
{ {
@ -597,15 +506,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chBreakPoint != NULL) if(DBGCustomHandler->chBreakPoint != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chBreakPoint); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chBreakPoint);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chBreakPoint = NULL;
}
}
} }
else //system breakpoint else //system breakpoint
{ {
@ -614,15 +516,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DebugAttachedToProcess) if(DebugAttachedToProcess)
{ {
myCustomBreakPoint = (fCustomBreakPoint)(DebugAttachedProcessCallBack); myCustomBreakPoint = (fCustomBreakPoint)(DebugAttachedProcessCallBack);
__try
{
myCustomBreakPoint(); myCustomBreakPoint();
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
if(engineAutoHideFromDebugger) if(engineAutoHideFromDebugger)
{ {
HideDebugger(dbgProcessInformation.hProcess, UE_HIDE_PEBONLY); HideDebugger(dbgProcessInformation.hProcess, UE_HIDE_PEBONLY);
@ -644,15 +539,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chSystemBreakpoint != NULL) if(DBGCustomHandler->chSystemBreakpoint != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chSystemBreakpoint); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chSystemBreakpoint);
__try
{
myCustomHandler(&DBGEvent); myCustomHandler(&DBGEvent);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chSystemBreakpoint = NULL;
}
}
} }
} }
} }
@ -684,17 +572,10 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(engineStepCount == 0) if(engineStepCount == 0)
{ {
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack); myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
{
engineStepActive = false; engineStepActive = false;
engineStepCallBack = NULL; engineStepCallBack = NULL;
myCustomBreakPoint(); myCustomBreakPoint();
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else else
{ {
SingleStep(engineStepCount, engineStepCallBack); SingleStep(engineStepCount, engineStepCallBack);
@ -720,17 +601,10 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(engineStepCount == 0) if(engineStepCount == 0)
{ {
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack); myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
{
engineStepActive = false; engineStepActive = false;
engineStepCallBack = NULL; engineStepCallBack = NULL;
myCustomBreakPoint(); myCustomBreakPoint();
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else else
{ {
SingleStep(engineStepCount, engineStepCallBack); SingleStep(engineStepCount, engineStepCallBack);
@ -749,17 +623,10 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(engineStepCount == 0) if(engineStepCount == 0)
{ {
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack); myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
{
engineStepActive = false; engineStepActive = false;
engineStepCallBack = NULL; engineStepCallBack = NULL;
myCustomBreakPoint(); myCustomBreakPoint();
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else else
{ {
SingleStep(engineStepCount, engineStepCallBack); SingleStep(engineStepCount, engineStepCallBack);
@ -781,14 +648,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
SetThreadContext(hActiveThread, &myDBGContext); SetThreadContext(hActiveThread, &myDBGContext);
myCustomHandler = (fCustomHandler)(DebugRegister[0].DrxCallBack); myCustomHandler = (fCustomHandler)(DebugRegister[0].DrxCallBack);
__try
{
myCustomHandler((void*)myDBGContext.Dr0); myCustomHandler((void*)myDBGContext.Dr0);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
if(DebugRegister[0].DrxEnabled) if(DebugRegister[0].DrxEnabled)
{ {
memcpy(&DebugRegisterX, &DebugRegister[0], sizeof(HARDWARE_DATA)); memcpy(&DebugRegisterX, &DebugRegister[0], sizeof(HARDWARE_DATA));
@ -810,14 +670,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
SetThreadContext(hActiveThread, &myDBGContext); SetThreadContext(hActiveThread, &myDBGContext);
myCustomHandler = (fCustomHandler)(DebugRegister[1].DrxCallBack); myCustomHandler = (fCustomHandler)(DebugRegister[1].DrxCallBack);
__try
{
myCustomHandler((void*)myDBGContext.Dr1); myCustomHandler((void*)myDBGContext.Dr1);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
if(DebugRegister[1].DrxEnabled) if(DebugRegister[1].DrxEnabled)
{ {
memcpy(&DebugRegisterX, &DebugRegister[1], sizeof(HARDWARE_DATA)); memcpy(&DebugRegisterX, &DebugRegister[1], sizeof(HARDWARE_DATA));
@ -839,14 +692,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
SetThreadContext(hActiveThread, &myDBGContext); SetThreadContext(hActiveThread, &myDBGContext);
myCustomHandler = (fCustomHandler)(DebugRegister[2].DrxCallBack); myCustomHandler = (fCustomHandler)(DebugRegister[2].DrxCallBack);
__try
{
myCustomHandler((void*)myDBGContext.Dr2); myCustomHandler((void*)myDBGContext.Dr2);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
if(DebugRegister[2].DrxEnabled) if(DebugRegister[2].DrxEnabled)
{ {
memcpy(&DebugRegisterX, &DebugRegister[2], sizeof(HARDWARE_DATA)); memcpy(&DebugRegisterX, &DebugRegister[2], sizeof(HARDWARE_DATA));
@ -868,14 +714,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
SetThreadContext(hActiveThread, &myDBGContext); SetThreadContext(hActiveThread, &myDBGContext);
myCustomHandler = (fCustomHandler)(DebugRegister[3].DrxCallBack); myCustomHandler = (fCustomHandler)(DebugRegister[3].DrxCallBack);
__try
{
myCustomHandler((void*)myDBGContext.Dr3); myCustomHandler((void*)myDBGContext.Dr3);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
if(DebugRegister[3].DrxEnabled) if(DebugRegister[3].DrxEnabled)
{ {
memcpy(&DebugRegisterX, &DebugRegister[3], sizeof(HARDWARE_DATA)); memcpy(&DebugRegisterX, &DebugRegister[3], sizeof(HARDWARE_DATA));
@ -909,17 +748,10 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(engineStepCount == 0) if(engineStepCount == 0)
{ {
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack); myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
{
engineStepActive = false; engineStepActive = false;
engineStepCallBack = NULL; engineStepCallBack = NULL;
myCustomBreakPoint(); myCustomBreakPoint();
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else else
{ {
SingleStep(engineStepCount, engineStepCallBack); SingleStep(engineStepCount, engineStepCallBack);
@ -931,15 +763,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chSingleStep != NULL) if(DBGCustomHandler->chSingleStep != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chSingleStep); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chSingleStep);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chSingleStep = NULL;
}
}
} }
} }
break; break;
@ -988,15 +813,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
ResetMemBPX = true; ResetMemBPX = true;
} }
myCustomHandler = (fCustomHandler)(MemoryBpxCallBack); myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
myCustomHandler((void*)bpaddr); myCustomHandler((void*)bpaddr);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else if(FoundBreakPoint.BreakPointType == UE_MEMORY_READ) //READ else if(FoundBreakPoint.BreakPointType == UE_MEMORY_READ) //READ
{ {
if(FoundBreakPoint.MemoryBpxRestoreOnHit != 1) //do not restore the memory breakpoint if(FoundBreakPoint.MemoryBpxRestoreOnHit != 1) //do not restore the memory breakpoint
@ -1015,15 +833,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0) //read operation if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0) //read operation
{ {
myCustomHandler = (fCustomHandler)(MemoryBpxCallBack); myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
myCustomHandler((void*)bpaddr); myCustomHandler((void*)bpaddr);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else //no read operation, restore breakpoint else //no read operation, restore breakpoint
{ {
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
@ -1051,15 +862,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 1) //write operation if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 1) //write operation
{ {
myCustomHandler = (fCustomHandler)(MemoryBpxCallBack); myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
myCustomHandler((void*)bpaddr); myCustomHandler((void*)bpaddr);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else //no write operation, restore breakpoint else //no write operation, restore breakpoint
{ {
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
@ -1089,15 +893,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress == DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[1]) //exception address == read address (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress == DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[1]) //exception address == read address
{ {
myCustomHandler = (fCustomHandler)(MemoryBpxCallBack); myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
myCustomHandler((void*)bpaddr); myCustomHandler((void*)bpaddr);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else //no execute operation, restore breakpoint else //no execute operation, restore breakpoint
{ {
myDBGContext.EFlags |= UE_TRAP_FLAG; myDBGContext.EFlags |= UE_TRAP_FLAG;
@ -1130,15 +927,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chPageGuard != NULL) if(DBGCustomHandler->chPageGuard != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chPageGuard); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chPageGuard);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chPageGuard = NULL;
}
}
} }
} }
break; break;
@ -1148,15 +938,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chAccessViolation != NULL) if(DBGCustomHandler->chAccessViolation != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chAccessViolation); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chAccessViolation);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chAccessViolation = NULL;
}
}
} }
break; break;
@ -1202,14 +985,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
//execute callback //execute callback
myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack); myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack);
__try
{
myCustomBreakPoint(); myCustomBreakPoint();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
if(FoundBreakPoint.BreakPointType != UE_SINGLESHOOT) if(FoundBreakPoint.BreakPointType != UE_SINGLESHOOT)
{ {
@ -1231,15 +1007,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chIllegalInstruction != NULL) if(DBGCustomHandler->chIllegalInstruction != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chIllegalInstruction); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chIllegalInstruction);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chIllegalInstruction = NULL;
}
}
} }
} }
break; break;
@ -1249,15 +1018,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chNonContinuableException != NULL) if(DBGCustomHandler->chNonContinuableException != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chNonContinuableException); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chNonContinuableException);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chNonContinuableException = NULL;
}
}
} }
break; break;
@ -1266,15 +1028,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chArrayBoundsException != NULL) if(DBGCustomHandler->chArrayBoundsException != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chArrayBoundsException); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chArrayBoundsException);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chArrayBoundsException = NULL;
}
}
} }
break; break;
@ -1283,15 +1038,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chFloatDenormalOperand != NULL) if(DBGCustomHandler->chFloatDenormalOperand != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chFloatDenormalOperand); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chFloatDenormalOperand);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chFloatDenormalOperand = NULL;
}
}
} }
break; break;
@ -1300,15 +1048,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chFloatDevideByZero != NULL) if(DBGCustomHandler->chFloatDevideByZero != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chFloatDevideByZero); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chFloatDevideByZero);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chFloatDevideByZero = NULL;
}
}
} }
break; break;
@ -1317,15 +1058,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chIntegerDevideByZero != NULL) if(DBGCustomHandler->chIntegerDevideByZero != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chIntegerDevideByZero); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chIntegerDevideByZero);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chIntegerDevideByZero = NULL;
}
}
} }
break; break;
@ -1334,15 +1068,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chIntegerOverflow != NULL) if(DBGCustomHandler->chIntegerOverflow != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chIntegerOverflow); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chIntegerOverflow);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chIntegerOverflow = NULL;
}
}
} }
break; break;
@ -1351,15 +1078,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chPrivilegedInstruction != NULL) if(DBGCustomHandler->chPrivilegedInstruction != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chPrivilegedInstruction); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chPrivilegedInstruction);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chPrivilegedInstruction = NULL;
}
}
} }
break; break;
} }
@ -1374,30 +1094,16 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chUnhandledException != NULL) if(DBGCustomHandler->chUnhandledException != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chUnhandledException); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chUnhandledException);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chUnhandledException = NULL;
}
}
} }
//general after-exception callback (includes debugger exceptions) //general after-exception callback (includes debugger exceptions)
if(DBGCustomHandler->chAfterException != NULL) if(DBGCustomHandler->chAfterException != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chAfterException); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chAfterException);
__try
{
myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord); myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chAfterException = NULL;
}
}
} }
break; break;
@ -1412,15 +1118,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(DBGCustomHandler->chRipEvent != NULL) if(DBGCustomHandler->chRipEvent != NULL)
{ {
myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chRipEvent); myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chRipEvent);
__try
{
myCustomHandler(&DBGEvent); myCustomHandler(&DBGEvent);
} }
__except(EXCEPTION_EXECUTE_HANDLER)
{
DBGCustomHandler->chRipEvent = NULL;
}
}
} }
break; break;
} }