windows-nt/Source/XPSP1/NT/printscan/print/spooler/inetsrv/mynotes.txt
2020-09-26 16:20:57 +08:00

86 lines
5.4 KiB
Plaintext

.\scripts is an IIS Exec dir. An Exec dir is one that is added as a Virtual dir.
================
The application will be called at HttpExtensionProc and will receive a pointer to the ECB structure.
The application will then determine what needs to be done by reading the client input (calling the
functions GetServerVariable and, if necessary, ReadClient.) This is similar to setting up environment
variables and reading stdin.
So:
GetServerVariable <==> setting up environment variables in CGI
ReadClient <==> reading stdin in CGI
Use Try/Except in ISAPI code you won't kill the IIS process!
ISAPI calls:
GetServerVariable(); ISAPI app makes the call to get info on connection... predefined vars are extracted,
HttpExtensionProc, takes only one input parameter: a pointer to structure of type
EXTENSION_CONTROL_BLOCK (ECB). Application developers are not expected to change the following fields
in the ECB structure: cbSize, dwVersion, and connID.
For every client request, the HttpExtensionProc entry point is called.
The extension receives the commonly needed information such as the query string, path information, method name, and the translated path. Subsequent sections of this document explain in detail how to retrieve the data sent by the client browser. The way the server communicates with the extension .DLL is through a data structure called the EXTENSION_CONTROL_BLOCK.
typedef struct _EXTENSION_CONTROL_BLOCK {
DWORD cbSize; // Size of this struct.
DWORD dwVersion; // Version info of this spec
HCONN ConnID; // Context number not to be modified!
DWORD dwHttpStatusCode; // HTTP Status code
CHAR lpszLogData[HSE_LOG_BUFFER_LEN];// null terminated log info specific to this Extension DLL
LPSTR lpszMethod; // REQUEST_METHOD
LPSTR lpszQueryString; // QUERY_STRING
LPSTR lpszPathInfo; // PATH_INFO
LPSTR lpszPathTranslated; // PATH_TRANSLATED
DWORD cbTotalBytes; // Total bytes indicated from client
DWORD cbAvailable; // Available number of bytes
LPBYTE lpbData; // Pointer to cbAvailable bytes
LPSTR lpszContentType; // Content type of client data
BOOL (WINAPI * GetServerVariable) ( HCONN hConn,
LPSTR lpszVariableName,
LPVOID lpvBuffer,
LPDWORD lpdwSizeofBuffer );
BOOL (WINAPI * WriteClient) ( HCONN ConnID,
LPVOID Buffer,
LPDWORD lpdwBytes,
DWORD dwReserved );
BOOL (WINAPI * ReadClient) ( HCONN ConnID,
LPVOID lpvBuffer,
LPDWORD lpdwSize );
BOOL (WINAPI * ServerSupportFunction)( HCONN hConn,
DWORD dwHSERRequest,
LPVOID lpvBuffer,
LPDWORD lpdwSize,
LPDWORD lpdwDataType );
}
This control block contains the following fields:
Field Remarks
cbSize (IN) The size of this structure.
dwVersion (IN) The version information of this specification. The HIWORD has the major version number and the LOWORD has the minor version number.
connID (IN) A unique number assigned by the HTTP server and which should not to be modified.
dwHttpStatusCode (OUT) The status of the current transaction when the request is completed.
lpszLogData (OUT) Buffer of size HSE_LOG_BUFFER_LEN. Contains a null-terminated log information string, specific to the ISAPI Applications, of the current transaction. This log information will be entered in the HTTP server log. Maintaining a single log file with both HTTP server and ISAPI Applications transactions is very useful for administration purposes.
lpszMethod (IN) The method with which the request was made. This is equivalent to the CGI variable REQUEST_METHOD.
lpszQueryString (IN) A null-terminated string containing the query information. This is equivalent to the CGI variable QUERY_STRING.
lpszPathInfo (IN) A null-terminated string containing extra path information given by the client. This is equivalent to the CGI variable PATH_INFO.
lpszPathTranslated (IN) A null-terminated string containing the translated path. This is equivalent to the CGI variable PATH_TRANSLATED.
cbTotalBytes (IN) The total number of bytes to be received from the client. This is equivalent to the CGI variable CONTENT_LENGTH. If this value is 0xffffffff, then there are 4 gigabytes or more of available data. In this case, ReadClient should be called until no more data is returned.
cbAvailable (IN) The available number of bytes (out of a total of cbTotalBytes) in the buffer pointed to by lpbData. If cbTotalBytes is the same as cbAvailable, the lpbData variable will point to a buffer that contains all the data as sent by the client. Otherwise, cbTotalBytes will contain the total number of bytes of data received. The ISAPI Applications will then need to use the callback function ReadClient to read the rest of the data (beginning from an offset of cbAvailable).
lpbData (IN) This points to a buffer of size cbAvailable that has the data sent by the client. You will get the first 48k of data.