This page contains several examples of using CrashRptProbe API described in
Using CrashRptProbe API.
The following example shows how to open an error report file:
The following example shows how to get count of rows in a table.
#include "CrashRptProbe.h"
#include <assert.h>
CrpHandle hReport;
int nRowCount = crpGetProperty(hReport, CRP_TBL_XMLDESC_MISC,
CRP_META_ROW_COUNT, 0, NULL, 0, NULL);
assert(nRowCount==1);
nRowCount = crpGetProperty(hReport, CRP_TBL_MDMP_MODULES,
CRP_META_ROW_COUNT, 0, NULL, 0, NULL);
The following example shows how to get miscellaneous information from
CRP_TBL_XMLDESC_MISC and
CRP_TBL_MDMP_MISC tables.
#include "CrashRptProbe.h"
CrpHandle hReport;
const int BUFF_SIZE = 1024;
TCHAR szBuffer[BUFF_SIZE];
int nResult = crpGetProperty(hReport, CRP_TBL_XMLDESC_MISC,
CRP_COL_CRASHRPT_VERSION, 0, szBuffer, BUFF_SIZE, NULL);
nResult = crpGetProperty(hReport, CRP_TBL_XMLDESC_MISC,
CRP_COL_APP_NAME, 0, szBuffer, BUFF_SIZE, NULL);
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_MISC,
CRP_COL_EXCEPTION_ADDRESS, 0, szBuffer, BUFF_SIZE, NULL);
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_MISC,
CRP_COL_EXCEPTION_THREAD_ROWID, 0, szBuffer, BUFF_SIZE, NULL);
int nExceptionThreadRowId = _ttoi(szBuffer);
if(nResult==0)
{
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_THREADS,
CRP_COL_THREAD_ID, nExceptionThreadRowId, szBuffer, BUFF_SIZE, NULL);
}
#include "CrashRptProbe.h"
#include <assert.h>
CrpHandle hReport;
int nThreadCount = crpGetProperty(hReport, CRP_TBL_MDMP_THREADS,
CRP_META_ROW_COUNT, 0, NULL, 0, NULL);
int i;
for(i=0; i<nThreadCount; i++)
{
const int BUFF_SIZE = 1024;
TCHAR szThreadID[BUFF_SIZE];
TCHAR szStackTableID[BUFF_SIZE];
TCHAR szBuffer[BUFF_SIZE];
int nResult = crpGetProperty(hReport, CRP_TBL_MDMP_THREADS,
CRP_COL_THREAD_ID, i, szThreadID, BUFF_SIZE, NULL);
assert(nResult==0);
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_THREADS,
CRP_COL_THREAD_STACK_TABLEID, i, szStackTableID, BUFF_SIZE, NULL);
assert(nResult==0);
int nFrameCount = crpGetProperty(hReport, szStackTableID,
CRP_META_ROW_COUNT, 0, NULL, 0, NULL);
int j;
for(j=0; j<nFrameCount; j++)
{
nResult = crpGetProperty(hReport, szStackTableID,
CRP_COL_STACK_MODULE_ROWID, j, szStackTableID, BUFF_SIZE, NULL);
if(nResult==0)
{
int nModuleRowID = _ttoi(szBuffer);
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_MODULES,
CRP_COL_MODULE_NAME, nModuleRowID, szBuffer, BUFF_SIZE, NULL);
}
nResult = crpGetProperty(hReport, szStackTableID,
CRP_COL_STACK_SYMBOL_NAME, j, szStackTableID, BUFF_SIZE, NULL);
assert(nResult==0);
if(_tcscmp(szBuffer, _T(""))!=0)
{
nResult = crpGetProperty(hReport, szStackTableID,
CRP_COL_STACK_OFFSET_IN_SYMBOL, j, szStackTableID, BUFF_SIZE, NULL);
}
else
{
nResult = crpGetProperty(hReport, szStackTableID,
CRP_COL_STACK_ADDR_PC_OFFSET, j, szStackTableID, BUFF_SIZE, NULL);
}
}
}
The following examples shows how to enumerate loaded modules.
#include "CrashRptProbe.h"
#include <assert.h>
CrpHandle hReport;
int nRowCount = crpGetProperty(hReport, CRP_TBL_MDMP_MODULES,
CRP_META_ROW_COUNT, 0, NULL, 0, NULL);
int i;
for(i=0; i<nRowCount; i++)
{
const int BUFF_SIZE = 1024;
TCHAR szBuffer[BUFF_SIZE];
int nResult = crpGetProperty(hReport, CRP_TBL_MDMP_MODULES,
CRP_COL_MODULE_NAME, i, szBuffer, BUFF_SIZE, NULL);
assert(nResult==0);
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_MODULES,
CRP_COL_MODULE_IMAGE_NAME, i, szBuffer, BUFF_SIZE, NULL);
assert(nResult==0);
nResult = crpGetProperty(hReport, CRP_TBL_MDMP_MODULES,
CRP_COL_MODULE_LOADED_PDB_NAME, i, szBuffer, BUFF_SIZE, NULL);
assert(nResult==0);
}
The following example shows how to enumerate files contained in the error report and extract them.
#include "CrashRptProbe.h"
#include <assert.h>
CrpHandle hReport;
int nRowCount = crpGetProperty(hReport, CRP_TBL_XMLDESC_FILE_ITEMS,
CRP_META_ROW_COUNT, 0, NULL, 0, NULL);
int i;
for(i=0; i<nRowCount; i++)
{
const int BUFF_SIZE = 1024;
TCHAR szBuffer[BUFF_SIZE];
int nResult = crpGetProperty(hReport, CRP_TBL_XMLDESC_FILE_ITEMS,
CRP_COL_FILE_ITEM_NAME, i, szBuffer, BUFF_SIZE, NULL);
if(nResult==0)
{
int nExtract = crpExtractFile(hReport, szBuffer, szBuffer, TRUE);
}
nResult = crpGetProperty(hReport, CRP_TBL_XMLDESC_FILE_ITEMS,
CRP_COL_FILE_ITEM_DESCRIPTION, i, szBuffer, BUFF_SIZE, NULL);
assert(nResult==0);
}