FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Dobbs M-Dev
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
December 01, 2002

Visual C++ Exception-Handling Instrumentation

(Page 5 of 8)
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
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK