Solved

ISAPI Filter not getting invoked (or loaded)

Posted on 2000-04-05
3
602 Views
Last Modified: 2013-11-20
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 9

Accepted Solution

by:
ShaunWilde earned 50 total points
Comment Utility
whenevr I have loaded a filter I used the internet service manager and added the filter that way - the instructions come with the sample upcase which is avalable from the inetsdk

This sample works by monitoring requests for .htm files in a directory path that ends with /UC. It then strips the trailing /UC from the directory path and uppercases the body of the HTML text that goes by.
To install this filter, use the Internet Service Manager in the Start menu.

Start\
  Programs\
    Windows NT 4.0 Option Pack\
      Microsoft Internet Information Server\
        Internet Service Manager

Right mouse click on the Web Site you wish to install the filter on. Choose Properties. Click on the ISAPI Filters tab, and add the filter.

Like any ISAPI Filter, this DLL is loaded when the web server is started and it stays loaded until the server is stopped.

0
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
Are you sure that you have IIS installed?  If you don't have it installed, some of the W3SVC keys get created by NT, but aren't populated.

Can you get plain webpages from your machine?

Have you tried debuggging? Is your DllMain() being executed?

..B ekiM
0
 

Author Comment

by:bustany
Comment Utility
thank you.  it worked
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 58
pre4 challenge 19 87
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 111
Path of Workbook 3 44
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

10 Experts available now in Live!

Get 1:1 Help Now