home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d009_2 / 1.ddi / SAMPLES / TRAPS / TRAPRIP.MS$ / TRAPRIP.bin
Encoding:
Text File  |  1992-02-04  |  3.6 KB  |  105 lines

  1. '************************** TRAPRIP.MST *********************************
  2. 'Demonstrates:  Trapping a Windows RIP from a MSTest script
  3. '
  4. 'Required Files: RIPTRAP.DLL, TESTDRVR.EXE, TOOLHELP.DLL
  5. '
  6. 'Uses: CAUSERIP.MST
  7. '
  8. 'Complexity Level: ADVANCED
  9. '
  10. 'Notes: This script uses the RIPTRAP.DLL to trap a Windows FatalExit
  11. '       call.  RIPTRAP.DLL must be in the current directory, in the
  12. '       same directory as TESTDRVR.EXE, or on the PATH to be found.
  13. '
  14. '       NOTE!: You must be running Windows 3.1 with the debug kernel
  15. '       installed for this script to run.  You must have the Windows
  16. '       3.1 SDK to install the debug kernel.
  17. '
  18. '       FatalExit is a Windows function which should only be called by an
  19. '       application when it wants to inform a debugger (such as CodeView)
  20. '       that an fatal event has occurred.  However, Windows itself will
  21. '       call FatalExit if you have the Windows debug kernel installed and
  22. '       certain problems occur with your application.  An example is if an
  23. '       invalid handle is passed to one of the Windows API.
  24. '
  25. '       If you are not in a debugger, this causes the RIP information to
  26. '       be displayed to a debug terminal, and prompts the user for a
  27. '       response. The result is that the test suite is stopped.
  28. '       Therefore, you may wish to trap FatalExit so that a test suite can
  29. '       continue.
  30. '
  31. '*************************************************************************
  32.  
  33. '$define W_MENU
  34. '$define W_BUTTON
  35. '$define TESTEVNT
  36. '$Include 'MSTEST.INC'
  37.  
  38. Type RIPInfo
  39.    Size     AS Long
  40.    IP       AS Integer
  41.    CS       AS Integer
  42.    SS       AS Integer
  43.    BP       AS Integer
  44.    EXITCODE AS Integer
  45. End Type
  46.  
  47. Declare Sub GetRIPInfo Lib "RIPTrap.DLL" (lpRipInfo AS RIPINFO)
  48. GLOBAL RIPoccurred AS Integer
  49.  
  50. '******************** CODE THAT RUNS WHEN RIP OCCURS *********************
  51.  
  52. TRAP RIPTrap From "RIPTRAP.DLL"
  53.     DIM RI AS RIPINFO
  54.  
  55.     'Tell demo user that RIP has occurred.
  56.     DT$ = Mid$(DateTime$,9)
  57.     Print "RIP occurred                                    @ " + DT$
  58.     Pause "Entered Trap..." + CRLF + "RIP occurred @ " + DT$ + CRLF + "I'll now log the info on the RIP."+ CRLF + "       (hit ok)"
  59.  
  60.     'Log FatalExit code and register information.
  61.     GetRIPInfo RI
  62.     Print "Fatal Exit code: ", RI.EXITCODE
  63.     Print "Register values."
  64.     PRINT "  IP: ", HEX$(RI.IP)
  65.     PRINT "  CS: ", HEX$(RI.CS)
  66.     PRINT "  SS: ", HEX$(RI.SS)
  67.     PRINT "  BP: ", HEX$(RI.BP)
  68.     PRINT
  69.  
  70.     RIPoccurred = TRUE
  71.  
  72.     'RETURN from the trap and allow the other script to continue.
  73.     Print "The other script will now continue              @ " + Mid$(DateTime$,9)
  74.  
  75. End Trap
  76.  
  77.  
  78. '******************** MAIN CODE ******************************************
  79.  
  80.     ' Turn on and Initialize Viewport
  81.     ViewPort On
  82.     Viewport Clear
  83.  
  84.  
  85.     ' RUN Another copy of TESTDRVR with a script that RIPs.
  86.     ' NOTE!: TESTDRVR.EXE and RIPTRAP.DLL are assumed to be on the
  87.     '        PATH and CAUSERIP.MST must be in the current directory.
  88.     '
  89.     Print "Starting Another copy of TESTDrvr that RIPs     @ " + Mid$(DateTime$,9)
  90.     Run "TESTDRVR.EXE CAUSERIP.MST /RUN"
  91.  
  92.     'Trap code will execute now
  93.     'Execution starts here after return from TRAP.
  94.  
  95.     'Check if RIP occurred
  96.     If RIPoccurred = TRUE Then
  97.         Print "A rip occurred and was trapped."
  98.         Pause "The other script has ended, but the test suite " + CRLF + "was not stopped by the RIP."
  99.     Else
  100.         Pause "RIP did not occur." + CRLF + "You may not be running debug Windows." + CRLF + "    (hit ok)"
  101.     End If
  102.  
  103. End
  104.  
  105.