How To Debug CGI Using Visual C++ Just-In-Time Debugger (239535)



The information in this article applies to:

  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Server 4.0 SP4
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Windows NT Workstation 4.0 SP4

This article was previously published under Q239535

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)

  1. 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.
  2. Invoke the CGI application from a browser.
  3. 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")

  1. Build a helper application and run it before start debugging CGI.
  2. Invoke the CGI application from a browser.
  3. 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:

238788 How To Debug CGI applications running under IIS


Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbhowto KB239535