home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 January / PCWorld_2000-01_cd.bin / Software / Servis / Devc / _SETUP.5 / Group18 / exutil.c < prev    next >
C/C++ Source or Header  |  1997-10-21  |  1KB  |  69 lines

  1.  
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <excpt.h>
  5. #include <windows.h>
  6.  
  7. #include "exutil.h"
  8.  
  9. void
  10. WalkExceptionHandlers ()
  11. {
  12.     PEXCEPTION_REGISTRATION_RECORD    p;
  13.     int                i;
  14.  
  15.     __asm__("movl %%fs:0,%%eax;movl %%eax,%0" : "=g" (p) : : "%eax");
  16.  
  17.     i = 0;
  18.     while (p != (PEXCEPTION_REGISTRATION_RECORD) -1 && p)
  19.     {
  20.         printf ("Registration %d at %08x : ", i, p);
  21.         printf ("Handler = %08x ", p->handler);
  22.         printf ("Next Registration = %08x\n", p->prev);
  23.         p = p->prev;
  24.         i++;
  25.     }
  26.     printf ("End of exception handler list.\n");
  27.     fflush (stdout);
  28. }
  29.  
  30. void
  31. DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec)
  32. {
  33.     printf ("Exception: Code = %08x Flags %08x", pExRec->ExceptionCode,
  34.         pExRec->ExceptionFlags);
  35.  
  36.     if (pExRec->ExceptionFlags)
  37.     {
  38.         printf (" ( ");
  39.         if (pExRec->ExceptionFlags & EH_NONCONTINUABLE)
  40.         {
  41.             printf ("EH_NONCONTINUABLE ");
  42.         }
  43.         if (pExRec->ExceptionFlags & EH_UNWINDING)
  44.         {
  45.             printf ("EH_UNWINDING ");
  46.         }
  47.         if (pExRec->ExceptionFlags & EH_EXIT_UNWIND)
  48.         {
  49.             printf ("EH_EXIT_UNWIND ");
  50.         }
  51.         if (pExRec->ExceptionFlags & EH_STACK_INVALID)
  52.         {
  53.             printf ("EH_STACK_INVALID ");
  54.         }
  55.         if (pExRec->ExceptionFlags & EH_NESTED_CALL)
  56.         {
  57.             printf ("EH_NESTED_CALL ");
  58.         }
  59.         printf (")\n");
  60.     }
  61.     else
  62.     {
  63.         printf ("\n");
  64.     }
  65.  
  66.     fflush(stdout);
  67. }
  68.  
  69.