Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ISAPI Filter not getting invoked (or loaded)

Posted on 2000-04-05
3
Medium Priority
?
749 Views
Last Modified: 2008-03-17
Platform:  Win NT Server 4.0 + SP6 with IIS4.0

I copied two sample ISAPI filter, one from the Visual C++ ISAPI programming book and the other from MSDN.  They are both created in VC++ projects.  They compiled successfully.

Based on the instructions, I am supposed to list the full path for each DLL in the registry at:
"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\FilterDLLs"

1. First, there was no such key, so I had to create FilterDLLs key.

2. I listed both DLLs as such:
D:\Books\Pro VC++ ISAPI\SimpleFilter\Debug\SimpleFilter.dll, D:\Program Files\Microsoft Visual Studio\MyProjects\Filter\Debug\Filter.dll
However, neither one gets invoked when I http to the server.  Both filters have OnUrlMap() and all the other methods so any http request should load and invoke the filter.  however, nothing is happening.

Here is SimpleFilter.dll

/////////////////////////////////////////////////
//  SimpleFilter.cpp


#include <windows.h>
#include <httpfilt.h>


//  DebugMsg() is used for debugging
#define DEST buff
#define DebugMsg(x)            \
   {                           \
      char buff[256];          \
      wsprintf x;              \
      OutputDebugString(buff); \
   }


BOOL WINAPI GetFilterVersion(HTTP_FILTER_VERSION* pVer)
{
   // The version of the web server this is running on
   DebugMsg(( DEST, "Web Server is version is %d.%d\n",
              HIWORD( pVer->dwServerFilterVersion ),
              LOWORD( pVer->dwServerFilterVersion ) ));

   // Our filter version nuumber.
   pVer->dwFilterVersion = MAKELONG( 1, 0 );   // Version 0.1

   // The description
   strcpy( pVer->lpszFilterDesc, "Simple Filter, 0.1" );

   // Requests Everything
   pVer->dwFlags = ( SF_NOTIFY_SECURE_PORT         |
                     SF_NOTIFY_NONSECURE_PORT      |
                     SF_NOTIFY_READ_RAW_DATA       |
                     SF_NOTIFY_PREPROC_HEADERS     |
                     SF_NOTIFY_URL_MAP             |
                     SF_NOTIFY_AUTHENTICATION      |
                     SF_NOTIFY_SEND_RAW_DATA       |
                     SF_NOTIFY_LOG                 |
                     SF_NOTIFY_END_OF_NET_SESSION  |
                     SF_NOTIFY_ORDER_DEFAULT );

   return TRUE;
}


DWORD OnReadRawData(HTTP_FILTER_CONTEXT *pfc,
                    HTTP_FILTER_RAW_DATA *pRawDataInfo)
{
   DebugMsg((DEST,"OnReadRawData\r\n"));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD OnPreprocHeaders(HTTP_FILTER_CONTEXT* pFC,
                       HTTP_FILTER_PREPROC_HEADERS* pHeaderInfo)
{
   DebugMsg((DEST,"OnPreprocHeaders\r\n"));

   CHAR achUrl[512];
   DWORD cbURL=512;

   pHeaderInfo->GetHeader(pFC, "url",achUrl,&cbURL);

   DebugMsg((DEST,"Requested URL is:%s.\r\n",achUrl));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD OnUrlMap(HTTP_FILTER_CONTEXT* pFC, HTTP_FILTER_URL_MAP* pUrlMapInfo)
{
   DebugMsg((DEST,"OnUrlMap\r\n"));
   DebugMsg((DEST,"PhysicalPath: %s\r\n",pUrlMapInfo->pszPhysicalPath));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD  OnAuthentication(HTTP_FILTER_CONTEXT* pFC,
                        HTTP_FILTER_AUTHENT* pAuthInfo)
{
   DebugMsg((DEST,"OnAuthentication\r\n"));
   DebugMsg((DEST,"UserName: %s\r\n",pAuthInfo->pszUser));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD OnSendRawData(HTTP_FILTER_CONTEXT* pFC,
                    HTTP_FILTER_RAW_DATA* pRawDataInfo)
{
   DebugMsg((DEST,"OnSendRawData\r\n"));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD OnLog(HTTP_FILTER_CONTEXT* pFC, HTTP_FILTER_LOG* pLogInfo)
{
   DebugMsg((DEST,"OnLog\r\n"));
   DebugMsg((DEST,"Target:%s\r\n",pLogInfo->pszTarget));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD OnEndOfNetSession(HTTP_FILTER_CONTEXT* pFC)
{
   DebugMsg((DEST,"OnEndOfNetSession\r\n"));
   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}


DWORD WINAPI HttpFilterProc(HTTP_FILTER_CONTEXT* pFC,
                            DWORD NotificationType, VOID* pvData)
{
   DWORD dwRet;

   // Send this notification to the right function
   switch ( NotificationType )
   {
   case SF_NOTIFY_READ_RAW_DATA:
      dwRet = OnReadRawData( pFC, (PHTTP_FILTER_RAW_DATA) pvData );
      break;
   case SF_NOTIFY_PREPROC_HEADERS:
      dwRet = OnPreprocHeaders( pFC,
                                (PHTTP_FILTER_PREPROC_HEADERS) pvData );
      break;
   case SF_NOTIFY_URL_MAP:
      dwRet = OnUrlMap( pFC, (PHTTP_FILTER_URL_MAP) pvData );
      break;
   case SF_NOTIFY_AUTHENTICATION:
      dwRet = OnAuthentication( pFC, (PHTTP_FILTER_AUTHENT) pvData );
      break;
   case SF_NOTIFY_SEND_RAW_DATA:
      dwRet = OnSendRawData( pFC, (PHTTP_FILTER_RAW_DATA) pvData );
      break;
   case SF_NOTIFY_LOG:
      dwRet = OnLog( pFC, (PHTTP_FILTER_LOG) pvData );
      break;
   case SF_NOTIFY_END_OF_NET_SESSION:
      dwRet = OnEndOfNetSession(pFC);
      break;
   default:
      DebugMsg(( DEST,
                 "[HttpFilterProc] Unknown notification type, %d\r\n",
                 NotificationType ));
      dwRet = SF_STATUS_REQ_NEXT_NOTIFICATION;
      break;
   }
   return dwRet;
}


Thank you





0
Comment
Question by:bustany
3 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 200 total points
ID: 2688312
You've probably got some old documentation (maybe IIS 3) for how to install an ISAPI filter.  Under IIS 4, start up the MMC, right-click your website, select properties, click the ISAPI filter tab, and add the DLL.
0
 
LVL 4

Expert Comment

by:jkunal
ID: 2688596
First you delete the key from the registry.

Then follow what clockwatcher says,stop and start your website,open the filter tab again,if your filter is loaded you will get a green arrow,otherwise a red one.
If the arrow is green your filter will run with the http request.
0
 

Author Comment

by:bustany
ID: 2753286
Thank you both.  It worked.

I had a hard time choosing which answer to accept since both of you are correct.  I assume I should select the first one, so I chose clockwatcher (even though the other answer was more complete!!!)  Again, thank you both.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question