Intercepting Program Calls
Novell Cool Solutions: Trench
Digg This -
Posted: 4 May 1999
Earlier I sent an e-mail to Cool Solutions requesting information/documentation about the command-line parameters for ZENworks Remote Control.
While writing a wrapper utility program, I wanted to be able to launch ZENworks Remote Control. I found that the program was WVIEWNT.EXE, but when I tried to run the program by itself, I'd receive the error message: Cannot execute because the command line is invalid. This is what prompted my e-mail.
Then I had an idea...how about if I wrote a program to "intercept" the program call and show the command line parameters being passed!
I wrote INTERCEPT.EXE that would replace itself with the selected program, show the parameters being passed, then continue on to the original executable. Running INTERCEPT.EXE while holding down the CTRL key, allows you "control" of the INTERCEPT.EXE program. You are prompted whether to INTERCEPT a specified program or RESTORE a previously intercepted program.
When you choose to intercept a program, you're prompted to browse to the program to be intercepted. Once selected, it MOVES the executable to C:\INTERCEPT, makes an entry in C:\INTERCEPT\INTERCEPT.INI (to remember the original location), and then copies the running INTERCEPT.EXE to the same location and name of the originally selected file.
For example: for my own use, it copied INTERCEPT.EXE to F:\PUBLIC\WIN32\WVIEWNT.EXE. Then, when NWADMIN32.EXE goes to access the remote control function, it calls WVIEWNT.EXE, the interceptor, shows the command line parameters, and prompts as to whether you want to continue with the passed parameters.
You'll notice the parameters are in an editable box (for modification or cut-n-pasting). INTERCEPT.EXE isn't perfect. In the case of WVIEWNT.EXE, the parameters being passed showed to be: -wBKEADLES_DP556_.Workstations.CC.VOP -nVOP_TREE -cRemote Control but I still received the "invalid command line" error message. I played around with the command line and found that '-cRemote Control' needed to be '-c"Remote Control" '. Viola!, I had the information I need to continue my utility program.
By selecting RESTORE, you're given a list of previously selected intercepted programs. Select from the list the program to restore, and it will MOVE the program from C:\INTERCEPT back to its original location, overwriting the renamed INTERCEPT.EXE. You're back in business!
Obviously, this is a kind of a crude remedy, but is a handy utility for techie-types like me that need more information about programs' use of command-line options that are sometimes unavailable or difficult to find information for.
For those of you interested in investigating WinBatch "language", also attached is the source-code.
- This is only tested (and intended) for NT workstation. Though, it should work on any 32-bit platform. 16-bit application is possible, by request.
- Though I'm not "supporting" this utility, I'm open for suggestions and recommendations if you find it useful: bkeadle@TAKETHISOUTkeadle.net
- Important Note: This program comes with the usual disclaimers about the author or Novell not being responsible for any ill effects. Proceed at your own risk.