home *** CD-ROM | disk | FTP | other *** search
- '************************** TRAPRIP.MST *********************************
- 'Demonstrates: Trapping a Windows RIP from a MSTest script
- '
- 'Required Files: RIPTRAP.DLL, TESTDRVR.EXE, TOOLHELP.DLL
- '
- 'Uses: CAUSERIP.MST
- '
- 'Complexity Level: ADVANCED
- '
- 'Notes: This script uses the RIPTRAP.DLL to trap a Windows FatalExit
- ' call. RIPTRAP.DLL must be in the current directory, in the
- ' same directory as TESTDRVR.EXE, or on the PATH to be found.
- '
- ' NOTE!: You must be running Windows 3.1 with the debug kernel
- ' installed for this script to run. You must have the Windows
- ' 3.1 SDK to install the debug kernel.
- '
- ' FatalExit is a Windows function which should only be called by an
- ' application when it wants to inform a debugger (such as CodeView)
- ' that an fatal event has occurred. However, Windows itself will
- ' call FatalExit if you have the Windows debug kernel installed and
- ' certain problems occur with your application. An example is if an
- ' invalid handle is passed to one of the Windows API.
- '
- ' If you are not in a debugger, this causes the RIP information to
- ' be displayed to a debug terminal, and prompts the user for a
- ' response. The result is that the test suite is stopped.
- ' Therefore, you may wish to trap FatalExit so that a test suite can
- ' continue.
- '
- '*************************************************************************
-
- '$define W_MENU
- '$define W_BUTTON
- '$define TESTEVNT
- '$Include 'MSTEST.INC'
-
- Type RIPInfo
- Size AS Long
- IP AS Integer
- CS AS Integer
- SS AS Integer
- BP AS Integer
- EXITCODE AS Integer
- End Type
-
- Declare Sub GetRIPInfo Lib "RIPTrap.DLL" (lpRipInfo AS RIPINFO)
- GLOBAL RIPoccurred AS Integer
-
- '******************** CODE THAT RUNS WHEN RIP OCCURS *********************
-
- TRAP RIPTrap From "RIPTRAP.DLL"
- DIM RI AS RIPINFO
-
- 'Tell demo user that RIP has occurred.
- DT$ = Mid$(DateTime$,9)
- Print "RIP occurred @ " + DT$
- Pause "Entered Trap..." + CRLF + "RIP occurred @ " + DT$ + CRLF + "I'll now log the info on the RIP."+ CRLF + " (hit ok)"
-
- 'Log FatalExit code and register information.
- GetRIPInfo RI
- Print "Fatal Exit code: ", RI.EXITCODE
- Print "Register values."
- PRINT " IP: ", HEX$(RI.IP)
- PRINT " CS: ", HEX$(RI.CS)
- PRINT " SS: ", HEX$(RI.SS)
- PRINT " BP: ", HEX$(RI.BP)
- PRINT
-
- RIPoccurred = TRUE
-
- 'RETURN from the trap and allow the other script to continue.
- Print "The other script will now continue @ " + Mid$(DateTime$,9)
-
- End Trap
-
-
- '******************** MAIN CODE ******************************************
-
- ' Turn on and Initialize Viewport
- ViewPort On
- Viewport Clear
-
-
- ' RUN Another copy of TESTDRVR with a script that RIPs.
- ' NOTE!: TESTDRVR.EXE and RIPTRAP.DLL are assumed to be on the
- ' PATH and CAUSERIP.MST must be in the current directory.
- '
- Print "Starting Another copy of TESTDrvr that RIPs @ " + Mid$(DateTime$,9)
- Run "TESTDRVR.EXE CAUSERIP.MST /RUN"
-
- 'Trap code will execute now
- 'Execution starts here after return from TRAP.
-
- 'Check if RIP occurred
- If RIPoccurred = TRUE Then
- Print "A rip occurred and was trapped."
- Pause "The other script has ended, but the test suite " + CRLF + "was not stopped by the RIP."
- Else
- Pause "RIP did not occur." + CRLF + "You may not be running debug Windows." + CRLF + " (hit ok)"
- End If
-
- End
-
-