1
0
Fork 0

DBG: added the exinfo command (extended information on the last exception)

This commit is contained in:
mrexodia 2016-07-09 08:03:16 +02:00
parent 069f524500
commit 9ee48b630b
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
5 changed files with 27 additions and 0 deletions

View File

@ -70,6 +70,7 @@ static HANDLE hTimeWastedCounterThread = 0;
static bool bStopTimeWastedCounterThread = false;
static String lastDebugText;
static duint timeWastedDebugging = 0;
static EXCEPTION_DEBUG_INFO lastExceptionInfo = { 0 };
char szFileName[MAX_PATH] = "";
char szSymbolCachePath[MAX_PATH] = "";
char sqlitedb[deflen] = "";
@ -854,6 +855,11 @@ bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
return true;
}
EXCEPTION_DEBUG_INFO getLastExceptionInfo()
{
return lastExceptionInfo;
}
static bool cbRemoveModuleBreakpoints(const BREAKPOINT* bp)
{
if(!bp->enabled)
@ -1533,6 +1539,8 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
callbackInfo.Exception = ExceptionData;
unsigned int ExceptionCode = ExceptionData->ExceptionRecord.ExceptionCode;
GuiSetLastException(ExceptionCode);
if(ExceptionData)
lastExceptionInfo = *ExceptionData;
duint addr = (duint)ExceptionData->ExceptionRecord.ExceptionAddress;
if(ExceptionData->ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT)

View File

@ -121,6 +121,7 @@ void cbRunToUserCodeBreakpoint(void* ExceptionAddress);
DWORD WINAPI threadAttachLoop(void* lpParameter);
void cbDetach();
bool cbSetModuleBreakpoints(const BREAKPOINT* bp);
EXCEPTION_DEBUG_INFO getLastExceptionInfo();
//variables
extern PROCESS_INFORMATION* fdProcessInfo;

View File

@ -2754,3 +2754,19 @@ CMDRESULT cbInstrInstrUndo(int argc, char* argv[])
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
CMDRESULT cbInstrExinfo(int argc, char* argv[])
{
auto info = getLastExceptionInfo();
const auto & record = info.ExceptionRecord;
dputs("EXCEPTION_DEBUG_INFO:");
dprintf(" dwFirstChance: %X\n", info.dwFirstChance);
dprintf(" ExceptionCode: %08X\n", record.ExceptionCode);
dprintf(" ExceptionFlags: %08X\n", record.ExceptionFlags);
dprintf(" ExceptionAddress: " fhex "\n", record.ExceptionAddress);
dprintf(" NumberParameters: %d\n", record.NumberParameters);
if(record.NumberParameters)
for(DWORD i = 0; i < record.NumberParameters; i++)
dprintf("ExceptionInformation[%02d]: " fhex "\n", i, record.ExceptionInformation[i]);
return STATUS_CONTINUE;
}

View File

@ -99,5 +99,6 @@ CMDRESULT cbInstrDisableGuiUpdate(int argc, char* argv[]);
CMDRESULT cbInstrEnableGuiUpdate(int argc, char* argv[]);
CMDRESULT cbInstrExhandlers(int argc, char* argv[]);
CMDRESULT cbInstrInstrUndo(int argc, char* argv[]);
CMDRESULT cbInstrExinfo(int argc, char* argv[]);
#endif // _INSTRUCTION_H

View File

@ -301,6 +301,7 @@ static void registercommands()
dbgcmdnew("guiupdatedisable", cbInstrDisableGuiUpdate, true); //disable gui message
dbgcmdnew("guiupdateenable", cbInstrEnableGuiUpdate, true); //enable gui message
dbgcmdnew("exhandlers", cbInstrExhandlers, true); //enumerate exception handlers
dbgcmdnew("exinfo", cbInstrExinfo, true); //dump last exception information
}
static bool cbCommandProvider(char* cmd, int maxlen)