CGI Wrapper

Overview

This sample demonstrates how you can create a wrapper for an ISAPI DLL, so that the DLL can be executed on servers that support only CGI applications. This sample is not itself an ISAPI extension, but rather extends the environment in which ISAPI applications can be used.

To use this sample, you must first compile it into an EXE file. It then must be renamed, so that the filename before the .exe extension matches the filename of the DLL that you wish to wrap. For instance, if the target DLL is MyExtension.DLL, you would rename this sample's executable to MyExtension.EXE. To change target DLLs, recompilation is unnecessary, as only the filename must be changed.

Code Tour

When this application is executed by the server, in response to a client browser's request, the application first parses its own filename to arrive at the name of its companion DLL. This DLL is then loaded, and the address of the ISAPI extension entry-point functions (GetExtensionVersion and HttpExtensionVersion) are discovered using the GetProcAddress function.

The application then creates and fills a new ECB, and calls HttpExtensionProc in the ISAPI DLL. Most of the functionality that IIS usually provides, in the form of call-back functions such as GetServerVariable, ReadClient, WriteClient, and ServerSupportFunction, are implemented within this application.

Note   This sample can be useful for debugging simple ISAPI extensions, but the execution environment and function implementation are substantially different than the environment and implementation of the actual server. Therefore, it is probably better used as a resource for understanding more about the IIS-ISAPI interaction.

Location

This project is available in the ...\isapi\extensions\cgiwrap subdirectory of the Internet services directory.