Microsoft Internet Security and Acceleration Server 2000 |
You need to create a filter object that will implement the IFWXFilter interface. This interface is necessary for the creation of a filter. The filter object will monitor fwx_AcceptedConnection events.
Warning Visual C++ will not create a new ATL object if more than one .idl file is included in your project. Delete all the .idl files except SMTPFLTR.idl from the project, add the ATL object as described in step 1, and then replace the .idl files that you removed.
To create the filter object
Insert a new ATL object (Simple Object), with the following properties:
Threading Model — Free
Interface — Custom
Aggregation — No
[ uuid(20F10C85-2C5E-11D2-8C3D-006094EB63EF), helpstring("IFWXFilter Interface"), pointer_default(unique) ] interface IFWXFilter : IUnknown { };
// IFWXFilter virtual HRESULT STDMETHODCALLTYPE FilterInit( /* [in] */ IFWXFirewall __RPC_FAR *pIFWXFirewall, /* [out] */ PFwxFilterHookEvents __RPC_FAR *ppFilterHookEvents); virtual HRESULT STDMETHODCALLTYPE FilterShutdown(void); virtual HRESULT STDMETHODCALLTYPE AttachToSession( /* [in] */ IFWXSession __RPC_FAR *piSession, /* [out] */ IFWXSessionFilter __RPC_FAR *__RPC_FAR *piSessionFilter, /* [out] */ PFwxFilterHookEvents __RPC_FAR *ppFilterHookEvents);
Start with a simple implementation, for example:
return E_NOTIMPL;
The implementation code should look like this:
// CSMTPFilter HRESULT STDMETHODCALLTYPE CSMTPFilter::FilterInit( /* [in] */ IFWXFirewall __RPC_FAR *pIFWXFirewall, /* [out] */ PFwxFilterHookEvents __RPC_FAR *ppFilterHookEvents) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CSMTPFilter::FilterShutdown( void) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CSMTPFilter::AttachToSession( /* [in] */ IFWXSession __RPC_FAR *piSession, /* [out] */ IFWXSessionFilter __RPC_FAR *__RPC_FAR *piSessionFilter, /* [out] */ PFwxFilterHookEvents __RPC_FAR *ppFilterHookEvents) { return E_NOTIMPL; }
In SMTPfilter.h, add the following code:
private: CComPtr<IFWXFirewall> m_pIFWXFirewall; FwxFilterHookEvents m_FwxFilterHookEvents; FwxPortRangeEvents m_FwxPortRangeEvents;
In SMTPfilter.h, locate the default object constructor code, and remove the default implementation ({}) and add a semicolon as shown:
CSMTPFilter(); { }
and place the following object constructor code and FilterInit implementation in SMTPFilter.cpp:
CSMTPFilter::CSMTPFilter () { m_FwxPortRangeEvents.StartPort = 25; m_FwxPortRangeEvents.EndPort = 25; m_FwxPortRangeEvents.dwSocketEvents = FWX_ALL_SOURCES // Event Source is either NAT or Firewall client | fwx_Bind_Tcp;//At this level, monitor binds m_FwxFilterHookEvents.dwGlobalEvents = 0; m_FwxFilterHookEvents.dwNumPortRanges = 1; m_FwxFilterHookEvents.FwxPortRangeEvents = &m_FwxPortRangeEvents; } HRESULT STDMETHODCALLTYPE CSMTPFilter::FilterInit( /* [in] */ IFWXFirewall __RPC_FAR *pIFWXFirewall, /* [out] */ FwxFilterHookEvents __RPC_FAR *__RPC_FAR *ppFilterHookEvents) { m_pIFWXFirewall = pIFWXFirewall; return m_pIFWXFirewall->DuplicateFilterHookEvents (&m_FwxFilterHookEvents, ppFilterHookEvents); }
HRESULT STDMETHODCALLTYPE CSMTPFilter::FilterShutdown( void) { return S_OK; }