home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / DOCJET.ZIP / data.z / HookTestDebug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-18  |  768 b   |  33 lines

  1. /* Copyright (C) 1997-1998, Tall Tree Software Co.
  2.  *
  3.  * This code is provided AS-IS, with no warranty expressed or implied.
  4.  *  in no way shall Tall Tree Software Co. be held liable for damages
  5.  *  brought about by the use of this software.
  6.  */
  7.  
  8. #ifndef HookTestDebug_h
  9.  
  10. #ifdef _DEBUG
  11. static void StopForDebug()
  12. {
  13.     static bool alreadyStopped = false;
  14.     static HMODULE main = 0;
  15.     if ( main == 0 && !alreadyStopped ) {
  16.         main = GetModuleHandle( 0 );
  17.         FARPROC f = GetProcAddress( main, "DebugModeOn" );
  18.         if ( f != 0 ) {
  19.             if ( (*(bool (*)())f)() ) {
  20.                 alreadyStopped = true;
  21.                 _asm { int 3 }
  22.                 // You can step past that statement
  23.                 //   now that you're in the debugger.
  24.             }
  25.         }
  26.     }
  27. }
  28. #else
  29. #define StopForDebug()
  30. #endif
  31.  
  32. #endif
  33.