December 01, 2002
Visual C++ Exception-Handling Instrumentation
Listing 6 Usage of GetCurrentExceptionRecord() (compile with /EHa)
void gpf()
{
char * p = 0;
p[6] = 'a';
}
int main()
{
try
{
gpf();
}
catch(...)
{
const EXCEPTION_RECORD * pr = GetCurrentExceptionRecord();
if (pr && pr->ExceptionCode != CPP_EXCEPTION)
{
std::cout << "SEH Exception with code "
<< std::hex
<< pr->ExceptionCode
<< std::dec
<< " occured at "
<< pr->ExceptionAddress
<< "\n";
}
}
return 0;
}
|
|
||||||||||||||||||||||||||||
|
|
|
|