4 * A test program involving an exception handler that fixes the exception
\r
7 * In this code we install an exception handler my_handler and then a piece
\r
8 * of inline assembly attempts to write at the address marked in eax, after
\r
9 * setting eax to 10. This should produce an exception. The handler then
\r
10 * changes the eax register of the exception context to be the address of
\r
11 * a static variable and restarts the code. This should allow everything
\r
15 #include <windows.h>
\r
22 EXCEPTION_DISPOSITION
\r
24 struct _EXCEPTION_RECORD* pExceptionRec,
\r
25 void* pEstablisherFrame,
\r
26 struct _CONTEXT* pContextRecord,
\r
27 void* pDispatcherContext
\r
30 printf ("In my exception handler!\n");
\r
31 DumpExceptionRecord (pExceptionRec);
\r
32 pContextRecord->Eax = (DWORD) &x;
\r
33 return ExceptionContinueExecution;
\r
40 printf ("x = %d\n", x);
\r
42 WalkExceptionHandlers();
\r
46 WalkExceptionHandlers();
\r
48 /* This assembly code should produce an exception. */
\r
49 __asm__("movl $10,%%eax;movl $1,(%%eax);" : : : "%eax");
\r
53 WalkExceptionHandlers();
\r
55 printf ("x = %d\n", x);
\r
57 printf ("Finished!\n");
\r