Solved

ISAPI Filter not getting invoked (or loaded)

Posted on 2000-04-05
3
694 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 50 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now