HOWTO: Debug CGI Using Visual C++ Just-In-Time Debugger
ID: Q239535
|
The information in this article applies to:
-
Microsoft Windows NT, versions 4.0, 4.0 SP4
SUMMARY
Debugging a Common Gateway Interface (CGI) application is different from debugging it as a console application. This article illustrates the correct way to debug a CGI application under Windows Windows NT Service Pack 4 (SP4) using the Microsoft Visual C++ Just-In-Time (JIT) debugger.
MORE INFORMATION
Specify Microsoft Visual C++ as your JIT debugger (check the JIT debugging box on the VC Tools menu and then Options). Then add a DebugBreak() statement to the CGI source code.
Method 1 (Launching CGI as LocalSystem)
- Set the CreateProcessAsUser Metabase property to FALSE using either the ADSUTIL or the Metabase Editor (MetaEdit) to force IIS to use the CreateProcess API to start a CGI application. After changing the property all CGIs will be running under the Local System account. For example:
C:\>adsutil SET W3SVC/1/Root/Scripts/MYCGI.exe/CreateProcessAsUser 0
ADSUTIL could be found in the following directory (if Windows Scripting Host optional component of the Windows NT Option Pack is installed).:
WINNT\Sytem32\Inetsrv\Adminsamples
MetaEdit is available in IIS Resource Kit.
- Invoke the CGI application from a browser.
- An error dialog box will display on the server after a breakpoint has been reached. Click Cancel to start debugging.
Note that configuring either the Basic or NTLM authentication for the CGI application won't help JIT debugging. The following error message will be generated when you click Cancel:
Runtime error!
Program: <MSDevDir\bin>\MSDEV.exe
abnormal program termination
This error does not occur on Windows NT 3.51. It occurs on Windows NT 4.0 because the CGI application does not have the proper security access to the interactive window station and desktop. Therefore, the Visual C debugger cannot initialize properly.
Method 2 (Applying NULL DACL to the interactive window station and desktop, "winsta0\\default")
- Build a helper application and run it before start debugging CGI.
The following KB article provides a sample:
Q98890 HOWTO: Debugging a service
- Invoke the CGI application from a browser.
- Once the application error dialog box displays on the server click Cancel to start debugging.
You can debug a CGI application running under any account with this approach. The DACLs for the interactive window station and desktop objects can be reset by logging off and then logging on again.
REFERENCES
For additional information, please click the article number(s) below
to view the article(s) in the Microsoft Knowledge Base:
Q98890 HOWTO: Debugging a service
Q238788 HOWTO: Debug CGI applications running under IIS
Additional query words:
Keywords : kbNTOS400 kbNTOS400sp4 kbGrpInetServer kbDSupport kbhowto
Version : winnt:4.0,4.0 SP4
Platform : winnt
Issue type : kbhowto