### ### Patches authored by William A. Rowe, Jr, Covalent Technologies. ### Copyright released, and permission granted for use with any purpose ### whatsoever provided such use is in compliance with Microsoft's own ### Platform SDK License Terms. ### ### The following patches apply cleanly in the Samples\web\iis\ directory ### of Microsoft's Platform SDK revision February, 2003, in order to either ### compile cleanly, correct scope, and comply with the ISAPI specification. ### ### ### formdump.cpp yells loudly about double declaration ### --- ../../web/iis-backup/extensions/Formdump/formdump.cpp Wed Feb 26 16:09:22 2003 +++ ./extensions/Formdump/formdump.cpp Sun Dec 31 16:53:45 2006 @@ -246,7 +246,7 @@ // Add spaces for short lines - for (DWORD i = strlen(szLine); i < 16; i++) + for (i = strlen(szLine); i < 16; i++) lstrcat(szLine, " "); // Add ASCII chars ### ### IsapiThread.cpp yells loudly about goto's skipping declarations ### --- ../../web/iis-backup/extensions/InvokObjThreads/IsapiThread.cpp Wed Feb 26 16:09:22 2003 +++ ./extensions/InvokObjThreads/IsapiThread.cpp Mon Jan 01 22:12:03 2007 @@ -28,6 +28,7 @@ BOOL ISAPITHREAD::InitThreadPool(LPTHREAD_START_ROUTINE pThreadProc, DWORD dwNumThreads, DWORD dwQueueSize) { DWORD dwThreadId; + DWORD x; // Initialize the member variables @@ -61,7 +62,7 @@ // Start the worker threads - for (DWORD x = 0; x < dwNumThreads; x++) + for (x = 0; x < dwNumThreads; x++) { m_arrWorkerThreads[x] = CreateThread( NULL, // security attributes @@ -119,6 +120,8 @@ BOOL ISAPITHREAD::QueueWorkItem(EXTENSION_CONTROL_BLOCK *pecb, BOOL fReleaseThread) { + DWORD dwInsertionPoint; + EnterCriticalSection(&m_csQueue); // Check to see if the queue is full @@ -128,7 +131,7 @@ // Add the work item to the queue - DWORD dwInsertionPoint = m_dwCurrentItem + m_dwItemsInQueue; + dwInsertionPoint = m_dwCurrentItem + m_dwItemsInQueue; if (dwInsertionPoint > m_dwWorkItemQueueSize - 1) dwInsertionPoint -= m_dwWorkItemQueueSize; @@ -170,6 +173,8 @@ EXTENSION_CONTROL_BLOCK * ISAPITHREAD::GetWorkItem(void) { + EXTENSION_CONTROL_BLOCK *pRet; + EnterCriticalSection(&m_csQueue); // Check to see if the queue is empty @@ -179,7 +184,7 @@ // Get the next item from the queue - EXTENSION_CONTROL_BLOCK *pRet = m_WorkItemQueue[m_dwCurrentItem]; + pRet = m_WorkItemQueue[m_dwCurrentItem]; m_dwCurrentItem++; ### ### KeepAlive.c uses invalid ServerSupportFunction() invocations, and ### was difficult to use due to absolute and invalid \scripts\ URI path. ### --- ../../web/iis-backup/extensions/Keep-Alive/KeepAlive.c Wed Feb 26 16:09:22 2003 +++ ./extensions/Keep-Alive/KeepAlive.c Tue Jan 02 10:56:09 2007 @@ -66,7 +66,7 @@ "Content-type: text/html\r\n\r\n"; char szContent[] = - "
"; @@ -84,13 +84,13 @@ HeaderExInfo.cchStatus = strlen(HeaderExInfo.pszStatus); HeaderExInfo.fKeepConn = TRUE; - pECB->ServerSupportFunction(pECB, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL); + pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL); /* Send content */ dwSize = strlen(szContent); - pECB->WriteClient(pECB, szContent, &dwSize, HSE_IO_SYNC); + pECB->WriteClient(pECB->ConnID, szContent, &dwSize, HSE_IO_SYNC); /* This return code tells IIS not to close the socket connection. */ ### ### aredcli STILL crashes due to a stack overflow, these fixes make addressing ### the issue in httpd more approachable. See notes in HSE_REQ_ASYNC_READ_CLIENT ### implementation in mod_isapi.c. ### ### This patch resolves various attempts to inspect the ecb after the handler ### finished processing the request, by setting aside the allocation method ### within this worker's PIOWI new hheap member. ### --- ../../web/iis-backup/extensions/io/ASyncRead/areadcli.c Wed Feb 26 16:09:22 2003 +++ ./extensions/io/ASyncRead/areadcli.c Wed Jan 03 14:56:19 2007 @@ -27,6 +27,7 @@ PBYTE pbDATAFromClient; /* Grand read data holder */ DWORD cbReadSoFar; /* Number of bytes read so far */ /* and is used as index for pbDATAFromClient */ + HANDLE hheap; /* Heap of GlobalAlloc (NULL for VirtualAlloc) */ EXTENSION_CONTROL_BLOCK *pecb; } IO_WORK_ITEM, * PIOWI; @@ -55,9 +56,9 @@ VOID DoCleanUp(IN PIOWI piowi); DWORD DoAsyncReadClient(IN PIOWI piowi); VOID WINAPI AsyncReadClientIoCompletion(IN LPEXTENSION_CONTROL_BLOCK pecb, IN PVOID pContext, IN DWORD cbIO, IN DWORD dwError); -DWORD SendMSGToClient(IN LPEXTENSION_CONTROL_BLOCK pecb, IN LPCSTR pszErrorMsg); -LPVOID AR_Allocate(IN LPEXTENSION_CONTROL_BLOCK pecb, IN DWORD dwSize); -BOOL AR_Free(IN LPEXTENSION_CONTROL_BLOCK pecb, IN LPVOID pvData); +DWORD SendMSGToClient(IN PIOWI piowi, IN LPCSTR pszErrorMsg); +LPVOID AR_Allocate(IN PIOWI piowi, IN DWORD dwSize); +BOOL AR_Free(IN PIOWI piowi, IN LPVOID pvData); /* Description: @@ -77,7 +78,7 @@ fReturns TRUE if successful; otherwise FALSE is fReturned. */ -DllMain(IN HINSTANCE hinstDll, IN DWORD fdwReason, IN LPVOID lpvContext OPTIONAL) +DWORD __stdcall DllMain(IN HINSTANCE hinstDll, IN DWORD fdwReason, IN LPVOID lpvContext OPTIONAL) { BOOL fReturn = TRUE; @@ -157,6 +158,17 @@ PIOWI piowi; DWORD hseStatus = HSE_STATUS_SUCCESS; + piowi = (PIOWI)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, sizeof(IO_WORK_ITEM)); + + if (NULL == piowi) { + + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + + return HSE_STATUS_ERROR; + } + + piowi->pecb = pecb; + /* The string length of textarea name "Data=" is 5. Available bytes <= 5 indicates that no user- @@ -166,20 +178,11 @@ if (pecb->cbAvailable <= 5) { - hseStatus = SendMSGToClient(pecb, g_szPostForm); - - } else { - - piowi = (PIOWI)LocalAlloc(LMEM_FIXED, sizeof(IO_WORK_ITEM)); - - if (NULL == piowi) { + hseStatus = SendMSGToClient(piowi, g_szPostForm); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - - return HSE_STATUS_ERROR; - } + LocalFree((HANDLE)piowi); - piowi->pecb = pecb; + } else { /* Init Grand data holder, assign the first chunk(read-ahead chunk) @@ -242,8 +245,10 @@ HSE_STATUS_ERROR */ -DWORD SendMSGToClient(IN LPEXTENSION_CONTROL_BLOCK pecb, IN LPCSTR pszMsg) +DWORD SendMSGToClient(IN PIOWI piowi, IN LPCSTR pszMsg) { + IN LPEXTENSION_CONTROL_BLOCK pecb = piowi->pecb; + HSE_SEND_HEADER_EX_INFO SHEI; BOOL fReturn; @@ -271,7 +276,7 @@ cbText = strlen("