I have an application implemented as an ISAPI filter whose behavior needs to change depending on whether it is being loaded by ISA or IIS. During GetFilterVersion it needs to register for SF_NOTIFY_SEND_RAW_DATA if being loaded by ISA or SF_NOTIFY_SEND_RESPONSE if being loaded by IIS.
There doesn't seem to be any information about the server passed to GetFilterVersion. Are there some tricks that might identify and distinguish between IIS and ISA?
[edit]
The application needs to know what server is loading it at initialization time, during the GetFilterVersion call. There is no current request, so attempting to get SERVER_VARIABLE from header variables will not work; there are no header variables at this point.
To elaborate, my application sets response headers, such as cookies and cache control headers. When running in the context of an ISA server, it must use the SF_NOTIFY_SEND_RAW_DATA event to complete this operation, modifying the raw data being sent by the ISA proxy. In IIS, however, using this notification comes with a severe performance penalty, so the application should use SF_NOTIFY_SEND_RESPONSE. SF_NOTIFY_SEND_RESPONSE will not work with ISA because this event does not get fired for proxied responses, only for responses which originate from the ISA itself, such as error pages. Finally, registering for events happens once during GetFilterVersion() and cannot be modified once the filter is loaded.
So the app needs to know, during initialization, when it decides to register for SF_NOTIFY_SEND_RESPONSE or SF_NOTIFY_SEND_RAW_DATA, whether it is being loaded by IIS or ISA.
Recent versions of IIS and ISA should both operate with worker processes. The name "w3proxy.exe" belongs to ISA and "w3wp.exe" belongs to IIS. Acquire the current process name and test it, voila.
HANDLE winapi GetCurrentProcess()
and this:
DWORD WINAPI GetModuleFileNameEx(
__in HANDLE hProcess,
__in_opt HMODULE hModule,
__out LPTSTR lpFilename,
__in DWORD nSize
);
Should do the trick