December 01, 2002
Visual C++ Exception-Handling Instrumentation
December 2002/Visual C++ Exception-Handling Instrumentation
Listing 4 Globally replacing an exception
#include <windows.h>
#include <vector>
#include <iostream>
const DWORD CPP_EXCEPTION = 0xE06D7363;
const DWORD MS_MAGIC = 0x19930520;
extern "C"
void __stdcall _CxxThrowException(void * pObject,
_s__ThrowInfo const * pObjectInfo)
{
try
{
const ULONG_PTR args[] ={ MS_MAGIC,
(ULONG_PTR)pObject,
(ULONG_PTR)pObjectInfo };
RaiseException(CPP_EXCEPTION,
EXCEPTION_NONCONTINUABLE,
sizeof(args)/sizeof(args[0]),
args);
}
catch(std::exception & )
{
throw int(1);
}
}
int main()
{
try
{
std::vector<char> x;
x.at(100) = 'a';
}
catch(int i)
{
std::cout << i;
}
return 0;
}
Previous Page |
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
Next Page