Solved

ISAPI Filter not getting invoked (or loaded)

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error viewing ASP page 12 176
Issues with Insert statement 12 29
Select only the top record in a left join 13 48
MS SQL and column defined as time 7 25
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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