Microsoft Internet Security and Acceleration Server 2004 SDK

IFWXFilter::AttachToSession

The AttachToSession method creates a session filter object when the Microsoft Firewall service detects an event for which the filter is registered. The AttachToSession method also indicates the set of events that the session filter will handle. This set of events includes the events requested in the IFWXFilter::FilterInit method. The events for which the filter is registered are received in a FwxFilterHookEvents structure.

The Firewall service calls this method when it detects an event for which the filter is registered.

HRESULT AttachToSession(
  IFWXSession* piSession,
  IFWXSessionFilter** piSessionFilter,
  PFwxFilterHookEvents pFilterHookEvents
);

Parameters

piSession
[in] Pointer to the IFWXSession interface associated with the session to be monitored.
piSessionFilter
[out] Address of a variable that receives a pointer to the IFWXSessionFilter interface on the session filter object created. The session filter object receives event notifications for the session.
pFilterHookEvents
[in, out] Pointer to a FwxFilterHookEvents structure containing the initial set of events that the filter monitors. Use the CoTaskMemAlloc function to allocate the structure.

Return Values

Implementations of this method should return the following:
S_OK
The method succeeded.
E_OUTOFMEMORY
Insufficient memory or resources to process the event. This will cause the request that generated the event to fail.

Example Code

The following is an example implementation of the AttachToSession method.

HRESULT STDMETHODCALLTYPE AttachToSession(IFWXSession *piSession,
										IFWXSessionFilter ** piSessionFilter,
										PFwxFilterHookEvents  *ppFilterHookEvents)
{
	UNREFERENCED_PARAMETER(piSession);

	HRESULT hr = S_OK;
 
	// Create an instance of the session filter.
	CComObject<CMyFWXSessionFilter> *pSessionFilter;
	hr = CComObject<CMyFWXSessionFilter>::CreateInstance(&pSessionFilter);
	if (SUCCEEDED(hr)) 
	{
		pSessionFilter->AddRef();
		pSessionFilter->Initialize(this);

		// Give back the required events and the session filter object
		*pFilterHookEvents = m_FwxFilterHookEvents;
		*piSessionFilter = pSessionFilter;
	
		return S_OK;
}
	if (FAILED(hr))
	{
		return E_OUTOFMEMORY;
}
}

Requirements

Server: Requires Windows Server 2003 or Windows 2000.
Version: Requires Internet Security and Acceleration Server 2004.
Header: Declared in Wspfwext.idl.

See Also

IFWXFilter