What is WinpkFilter Home

Introduction
What is WinpkFilter?
Programming Languages Support
Installation
Helper drivers IOCTLs
IOCTL_NDISRD_ADAPTER_QUEUE_SIZE
IOCTL_NDISRD_FLUSH_ADAPTER_QUEUE
IOCTL_NDISRD_GET_ADAPTER_MODE
IOCTL_NDISRD_GET_PACKET_FILTERS_RESET_STATS
IOCTL_NDISRD_GET_PACKET_FILTERS
IOCTL_NDISRD_GET_PACKET_FILTERS_TABLESIZE
IOCTL_NDISRD_GET_RAS_LINKS
IOCTL_NDISRD_GET_TCPIP_INTERFACES
IOCTL_NDISRD_GET_VERSION
IOCTL_NDISRD_READ_PACKET
IOCTL_NDISRD_READ_PACKETS
IOCTL_NDISRD_RESET_PACKET_FILTERS
IOCTL_NDISRD_SEND_PACKET_TO_ADAPTER
IOCTL_NDISRD_SEND_PACKET_TO_MSTCP
IOCTL_NDISRD_SEND_PACKETS_TO_ADAPTER
IOCTL_NDISRD_SEND_PACKETS_TO_MSTCP
IOCTL_NDISRD_SET_ADAPTER_EVENT
IOCTL_NDISRD_SET_ADAPTER_MODE
IOCTL_NDISRD_SET_EVENT
IOCTL_NDISRD_SET_PACKET_FILTERS
IOCTL_NDISRD_SET_WAN_EVENT
User-mode API
C++ Interface
CNdisApi::CNdisApi
CNdisApi::~CNdisApi
CNdisApi::ConvertWindows2000AdapterName
CNdisApi::ConvertWindows9xAdapterName
CNdisApi::ConvertWindowsNTAdapterName
CNdisApi::DeviceIoControl
CNdisApi::FlushAdapterPacketQueue
CNdisApi::GetAdapterMode
CNdisApi::GetAdapterPacketQueueSize
CNdisApi::GetAdaptersStartupMode
CNdisApi::GetBytesReturned
CNdisApi::GetHwPacketFilter
CNdisApi::GetMTUDecrement
CNdisApi::GetPacketFilterTable
CNdisApi::GetPacketFilterTableResetStats
CNdisApi::GetPacketFilterTableSize
CNdisApi::GetRasLinks
CNdisApi::GetTcpipBoundAdaptersInfo
CNdisApi::GetVersion
CNdisApi::IsDriverLoaded
CNdisApi::NdisrdRequest
CNdisApi::ReadPacket
CNdisApi::ReadPackets
CNdisApi::ResetPacketFilterTable
CNdisApi::SendPacketsToAdapter
CNdisApi::SendPacketsToMstcp
CNdisApi::SendPacketToMstcp
CNdisApi::SendPacketToAdapter
CNdisApi::SetAdapterMode
CNdisApi::SetAdapterListChangeEvent
CNdisApi::SetAdaptersStartupMode
CNdisApi::SetHwPacketFilter
CNdisApi::SetMTUDecrement
CNdisApi::SetPacketFilterTable
CNdisApi::SetPacketEvent
CNdisApi::SetWANEvent
C Interface
CloseFilterDriver
FlushAdapterPacketQueue
GetAdapterMode
GetAdapterPacketQueueSize
GetAdaptersStartupMode
GetBytesReturned
GetDriverVersion
GetMTUDecrement
GetHwPacketFilter
GetPacketFilterTableResetStats
GetPacketFilterTable
GetPacketFilterTableSize
GetRasLinks
GetTcpipBoundAdaptersInfo
IsDriverLoaded
NdisrdRequest
OpenFilterDriver
ReadPacket
ReadPackets
ResetPacketFilterTable
SendPacketsToAdapter
SendPacketsToMstcp
SendPacketToAdapter
SendPacketToMstcp
SetAdapterListChangeEvent
SetAdapterMode
SetAdaptersStartupMode
SetHwPacketFilter
SetMTUDecrement
SetPacketFilterTable
SetPacketEvent
SetWANEvent
WinpkFilter Structures
_ADAPTER_EVENT
_ADAPTER_MODE
_DATA_LINK_LAYER_FILTER
_ETH_802_3_FILTER
_ETH_M_REQUEST
_ETH_REQUEST
_INTERMEDIATE_BUFFER
_IP_ADDRESS_V4
_IP_RANGE_V4
_IP_SUBNET_V4
_IP_V4_FILTER
_NETWORK_LAYER_FILTER
_NDISRD_ETH_Packet
_PACKET_OID_DATA
_PORT_RANGE
_RAS_LINK_INFO
_RAS_LINKS
_STATIC_FILTER
_STATIC_FILTER_TABLE
_TCP_AdapterList
_TCPUDP_FILTER
_TRANSPORT_LAYER_FILTER
WinpkFilter Samples
Filter
FilterStats
GRETunnel
ListAdapters
NdisRequest
PacketSniffer
PassThru
WWWCensor

 
Windows Packet Filter Kit: Introduction

What is WinpkFilter©?

WinpkFilter is a high performance packet filtering framework for Windows 9x/ME/NT/2000/XP/2003/Vista/2008 that allows developers to transparently filter (view and modify) raw network packets with minimal impact on network activity without having to write low level TDI or NDIS driver code.

WinpkFilter is more than just a firewall development kit for Windows. Wide range of solutions can be implemented using WinpkFilter: custom firewalls, internet connection sharing (NAT), IP shaper, VPN and many other low-level network solutions completely in user-mode using your favorite development environment: Visual C++, Delphi, C++ Builder etc.

Using WinpkFilter requires no experience in kernel mode programming on your behalf since WinpkFilter provides you with powerful user level API. However, if you need to implement your solution (to achieve better performance) in kernel mode you can use well-documented raw IOCTL interface as well.

Product features:

  • The easiest way to develop and debug packet filtering/modifying communication applications such as firewalls, sniffers, internet connection sharing, VPN, etc.
  • Full portability to all Windows platforms due to the common API.
  • Operates on RAS/PPP adapters
  • Complete source code for sample applications and wrapper API DLL (registered version only) is available. Source code for helper drivers supplied when you purchase Source Code License ONLY.
  • Passive network listening and active filtering (with possible packet modification) modes
  • Interface for sending RAW Ethernet packets to network interface (originated by MSTCP) or to MSTCP
  • Supports MTU decrement (allows you to set system-wide MTU decrement). This option is required if you plan to add additional headers to IP packets (implement IP in IP packet tunneling, IPSEC based VPN and so on).
  • Helper routines in ndisapi.dll for converting internal (NDIS level) network interface names to the user friendly ones (the names you see in Network connections properties)
  • 32 bit helper drivers are based on NDIS-hooking and NDIS intermediate driver technology.
  • 64 bit helper drivers are based on NDIS intermediate driver technology.

 

Windows Packet Filter Kit can be used for the wide range of applications. Here are few of them:

  • User-mode firewall solutions. That’s right! WinpkFilter allows implementing a firewall completely in user-mode. This is not recommended for high speed connections (over 100Mbit) since filtering network packets in user-mode decreases network performance up to 30-40%, but it is quite useful for dial-up, DSL or even 100MBit Ethernet connections.
  • Kernel-mode firewall solutions. You can use RAW IOCTLs for calling helper driver from your kernel mode driver. This requires kernel-mode programming skills while eliminating performance degradation caused by redirecting packets from kernel mode to user mode and back.
  • Internet Connection Sharing (Network Address Translation) that can be implemented both in user and kernel modes.
  • VPN solution (IPSEC an example) that can also be implemented both in user and kernel modes.
  • Packets tunneling. Example: packets captured from the network (or from MSTCP) delivered into the user mode and tunneled to the remote system inside SSL stream. Remote system can indicate them to MSTCP (or send over network) after extracting packets from the SSL stream. Classic approaches like ‘IP in IP’ can also be implemented.
  • Packet sniffer. You can inspect all packets sent to (received from) MSTCP.
  • IP shaping solutions (when you need to limit bandwidth for Internet users).
  • Network traffic count solutions.
  • Wireless Firewall Gateways.

"The core" of WinpkFilter is composed by following files:

ndisrd.vxd The virtual device driver supported by Windows 95/98/ME. Must be located under \<windows>\system;
ndisrd.sys The kernel-mode driver supported by Windows NT/2000/XP/2003/Vista. Must be located under \<winnt>\system32\drivers; This driver exists in two forms: NDIS-hooking (can be used on WIndows NT 4.0, Windows 2000, Windows XP, Windows 2003) variant and NDIS IM one (can be used on Windows XP x64, Windows 2003 x64, Windows Vista x86/x64).
ndisapi.dll The library providing driver function call for almost all programming languages. Must be located under \<windows>\system or any other directory available for the running application. Note, that ndisapi.dll is available in two variants for Microsoft Visual C++ and for Borland C++ Builder due to the difference in the *.lib file format and exporting C++ classes.
ndisapi.h header file providing a C/C++ interface to ndisapi.dll
modDecl_Ndisapi.bas provides a MSVB6 interface to ndisapi.dll
ndisapi.pas provides a Delphi interface to ndisapi.dll
ndisapi.cs provides a C# interface to ndisapi.dll