- Towards WinDivert 1.1:

* Re-brand "DIVERT" to "WINDIVERT" throughout the code-base.
* New flags:
  > WINDIVERT_FLAG_PASSTHRU: Do not drop nor capture packets.  Useful
    for injection-only handles.
  > WINDIVERT_FLAG_NO_CHECKSUM: Do not guarantee that diverted packets
    have a correct checksum.
  NOTE: Not yet tested!
* New default values and limits for various WinDivert parameters,
  including WINDIVERT_PARAM_QUEUE_LEN, WINDIVERT_PARAM_QUEUE_TIME, and
  the maximum filter length.
* New extended WinDivert functions that support asynchronous I/O:
  > WinDivertRecvEx(..)
  > WinDivertSendEx(..)
  NOTE: Not yet tested!
* The WinDivert driver now services reads (receives) out-of-band.
  The motivation is because WFP callouts are run at DISPATCH_LEVEL, so
  we should not be doing expensive work in the ClassifyFn.  This is also
  the same reason why the filter length has been restricted.
This commit is contained in:
basil00
2013-06-30 15:58:21 +08:00
parent 7f70f9a575
commit 38f1f3a16d
30 changed files with 1954 additions and 1751 deletions
+14
View File
@@ -18,3 +18,17 @@ WinDivert 1.0.4
WinDivert 1.0.5
- Fix the DIVERT_NETWORK_FORWARD_LAYER implementation.
- Upgrade Visual Studio support to 2012.
WinDivert 1.1.0
- Re-brand "DIVERT" to "WINDIVERT" throughout the code-base.
- New flags:
* WINDIVERT_FLAG_PASSTHRU: Do not drop nor capture packets. Useful
for injection-only handles.
* WINDIVERT_FLAG_NO_CHECKSUM: Do not guarantee that diverted packets
have a correct checksum.
- New default values and limits for various WinDivert parameters,
including WINDIVERT_PARAM_QUEUE_LEN, WINDIVERT_PARAM_QUEUE_TIME, and
the maximum filter length.
- New extended WinDivert functions that support asynchronous I/O:
* WinDivertRecvEx(..)
* WinDivertSendEx(..)
- The WinDivert driver now services reads (receives) out-of-band.
+3 -3
View File
@@ -1,11 +1,11 @@
WinDivert 1.0: Windows Packet Divert
WinDivert 1.1: Windows Packet Divert
====================================
1. Introduction
---------------
Windows Packet Divert (WinDivert) is a user-mode packet capture-and-divert
package for Windows Vista, Windows 2008, and Windows 7.
package for Windows Vista, Windows 2008, Windows 7, and Windows 8.
With WinDivert developers can write user-mode programs that capture and
modify or drop network packets sent to/from the Windows network stack.
@@ -99,7 +99,7 @@ following then happens
sh mingw-build.sh
For more detailed build instructions, see doc\divert.html
For more detailed build instructions, see doc\windivert.html
5. License
----------
+1 -1
View File
@@ -1 +1 @@
1.0.5
1.1.0
-13
View File
@@ -1,13 +0,0 @@
LIBRARY WinDivert
EXPORTS
DivertDllEntry
DivertOpen
DivertRecv
DivertSend
DivertClose
DivertSetParam
DivertGetParam
DivertHelperCalcChecksums
DivertHelperParsePacket
DivertHelperParseIPv4Address
DivertHelperParseIPv6Address
+4 -4
View File
@@ -1,5 +1,5 @@
# sources
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@@ -24,9 +24,9 @@ TARGETLIBS=\
$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\ws2_32.lib
C_DEFINES=/DWIN32 /D_WINDOWS /D_USRDLL /DUSE_STDAFX /DUNICODE /D_UNICODE
DLLENTRY=DivertDllEntry
DLLDEF=divert.def
DLLENTRY=WinDivertDllEntry
DLLDEF=windivert.def
USE_MSVCRT=1
INCLUDES=$(DDK_INC_PATH);$(KMDF_INC_PATH)\$(KMDF_VER_PATH);..\include
SOURCES=divert.c
SOURCES=windivert.c
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
LIBRARY WinDivert
EXPORTS
WinDivertDllEntry
WinDivertOpen
WinDivertRecv
WinDivertRecvEx
WinDivertSend
WinDivertSendEx
WinDivertClose
WinDivertSetParam
WinDivertGetParam
WinDivertHelperCalcChecksums
WinDivertHelperParsePacket
WinDivertHelperParseIPv4Address
WinDivertHelperParseIPv6Address
+3 -3
View File
@@ -28,7 +28,7 @@
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<ModuleDefinitionFile>divert.def</ModuleDefinitionFile>
<ModuleDefinitionFile>windivert.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
@@ -52,10 +52,10 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ItemGroup>
<ClCompile Include="divert.c"/>
<ClCompile Include="windivert.c"/>
</ItemGroup>
<ItemGroup>
<None Include="divert.def"/>
<None Include="windivert.def"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
</Project>
+27 -25
View File
@@ -1,6 +1,6 @@
/*
* netdump.c
* (C) 2012, all rights reserved,
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -18,10 +18,10 @@
/*
* DESCRIPTION:
* This is a simple traffic monitor. It uses a divert handle in SNIFF mode.
* This is a simple traffic monitor. It uses a WinDivert handle in SNIFF mode.
* The SNIFF mode copies packets and does not block the original.
*
* usage: netdump.exe divert-filter [priority]
* usage: netdump.exe windivert-filter [priority]
*
*/
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include "divert.h"
#include "windivert.h"
#define MAXBUF 0xFFFF
@@ -45,13 +45,13 @@ int __cdecl main(int argc, char **argv)
INT16 priority = 0;
char packet[MAXBUF];
UINT packet_len;
DIVERT_ADDRESS addr;
PDIVERT_IPHDR ip_header;
PDIVERT_IPV6HDR ipv6_header;
PDIVERT_ICMPHDR icmp_header;
PDIVERT_ICMPV6HDR icmpv6_header;
PDIVERT_TCPHDR tcp_header;
PDIVERT_UDPHDR udp_header;
WINDIVERT_ADDRESS addr;
PWINDIVERT_IPHDR ip_header;
PWINDIVERT_IPV6HDR ipv6_header;
PWINDIVERT_ICMPHDR icmp_header;
PWINDIVERT_ICMPV6HDR icmpv6_header;
PWINDIVERT_TCPHDR tcp_header;
PWINDIVERT_UDPHDR udp_header;
// Check arguments.
switch (argc)
@@ -62,7 +62,7 @@ int __cdecl main(int argc, char **argv)
priority = (INT16)atoi(argv[2]);
break;
default:
fprintf(stderr, "usage: %s divert-filter [priority]\n",
fprintf(stderr, "usage: %s windivert-filter [priority]\n",
argv[0]);
fprintf(stderr, "examples:\n");
fprintf(stderr, "\t%s true\n", argv[0]);
@@ -76,7 +76,8 @@ int __cdecl main(int argc, char **argv)
console = GetStdHandle(STD_OUTPUT_HANDLE);
// Divert traffic matching the filter:
handle = DivertOpen(argv[1], (DIVERT_LAYER)0, priority, DIVERT_FLAG_SNIFF);
handle = WinDivertOpen(argv[1], WINDIVERT_LAYER_NETWORK, priority,
WINDIVERT_FLAG_SNIFF);
if (handle == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_INVALID_PARAMETER)
@@ -84,19 +85,19 @@ int __cdecl main(int argc, char **argv)
fprintf(stderr, "error: filter syntax error\n");
exit(EXIT_FAILURE);
}
fprintf(stderr, "error: failed to open Divert device (%d)\n",
fprintf(stderr, "error: failed to open the WinDivert device (%d)\n",
GetLastError());
exit(EXIT_FAILURE);
}
// Max-out the packet queue:
if (!DivertSetParam(handle, DIVERT_PARAM_QUEUE_LEN, 8192))
if (!WinDivertSetParam(handle, WINDIVERT_PARAM_QUEUE_LEN, 8192))
{
fprintf(stderr, "error: failed to set packet queue length (%d)\n",
GetLastError());
exit(EXIT_FAILURE);
}
if (!DivertSetParam(handle, DIVERT_PARAM_QUEUE_TIME, 1024))
if (!WinDivertSetParam(handle, WINDIVERT_PARAM_QUEUE_TIME, 2048))
{
fprintf(stderr, "error: failed to set packet queue time (%d)\n",
GetLastError());
@@ -107,7 +108,7 @@ int __cdecl main(int argc, char **argv)
while (TRUE)
{
// Read a matching packet.
if (!DivertRecv(handle, packet, sizeof(packet), &addr, &packet_len))
if (!WinDivertRecv(handle, packet, sizeof(packet), &addr, &packet_len))
{
fprintf(stderr, "warning: failed to read packet (%d)\n",
GetLastError());
@@ -115,9 +116,9 @@ int __cdecl main(int argc, char **argv)
}
// Print info about the matching packet.
DivertHelperParse(packet, packet_len, &ip_header, &ipv6_header,
&icmp_header, &icmpv6_header, &tcp_header, &udp_header, NULL,
NULL);
WinDivertHelperParsePacket(packet, packet_len, &ip_header,
&ipv6_header, &icmp_header, &icmpv6_header, &tcp_header,
&udp_header, NULL, NULL);
if (ip_header == NULL && ipv6_header == NULL)
{
fprintf(stderr, "warning: junk packet\n");
@@ -139,9 +140,10 @@ int __cdecl main(int argc, char **argv)
"Checksum=0x%.4X SrcAddr=%u.%u.%u.%u DstAddr=%u.%u.%u.%u]\n",
ip_header->Version, ip_header->HdrLength,
ntohs(ip_header->TOS), ntohs(ip_header->Length),
ntohs(ip_header->Id), DIVERT_IPHDR_GET_RESERVED(ip_header),
DIVERT_IPHDR_GET_DF(ip_header), DIVERT_IPHDR_GET_MF(ip_header),
ntohs(DIVERT_IPHDR_GET_FRAGOFF(ip_header)), ip_header->TTL,
ntohs(ip_header->Id), WINDIVERT_IPHDR_GET_RESERVED(ip_header),
WINDIVERT_IPHDR_GET_DF(ip_header),
WINDIVERT_IPHDR_GET_MF(ip_header),
ntohs(WINDIVERT_IPHDR_GET_FRAGOFF(ip_header)), ip_header->TTL,
ip_header->Protocol, ntohs(ip_header->Checksum),
src_addr[0], src_addr[1], src_addr[2], src_addr[3],
dst_addr[0], dst_addr[1], dst_addr[2], dst_addr[3]);
@@ -155,8 +157,8 @@ int __cdecl main(int argc, char **argv)
printf("IPv6 [Version=%u TrafficClass=%u FlowLabel=%u Length=%u "
"NextHdr=%u HopLimit=%u SrcAddr=",
ipv6_header->Version,
DIVERT_IPV6HDR_GET_TRAFFICCLASS(ipv6_header),
ntohl(DIVERT_IPV6HDR_GET_FLOWLABEL(ipv6_header)),
WINDIVERT_IPV6HDR_GET_TRAFFICCLASS(ipv6_header),
ntohl(WINDIVERT_IPV6HDR_GET_FLOWLABEL(ipv6_header)),
ntohs(ipv6_header->Length), ipv6_header->NextHdr,
ipv6_header->HopLimit);
for (i = 0; i < 8; i++)
+1 -1
View File
@@ -1,5 +1,5 @@
# sources
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
+54 -53
View File
@@ -1,6 +1,6 @@
/*
* netfilter.c
* (C) 2012, all rights reserved,
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -20,9 +20,9 @@
* DESCRIPTION:
* This is a simple traffic filter/firewall using WinDivert.
*
* usage: netfilter.exe divert-filter [priority]
* usage: netfilter.exe windivert-filter [priority]
*
* Any traffic that matches the divert-filter will be blocked using one of
* Any traffic that matches the windivert-filter will be blocked using one of
* the following methods:
* - TCP: send a TCP RST to the packet's source.
* - UDP: send a ICMP(v6) "destination unreachable" to the packet's source.
@@ -37,7 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include "divert.h"
#include "windivert.h"
#define MAXBUF 0xFFFF
@@ -46,37 +46,37 @@
*/
typedef struct
{
DIVERT_IPHDR ip;
DIVERT_TCPHDR tcp;
WINDIVERT_IPHDR ip;
WINDIVERT_TCPHDR tcp;
} TCPPACKET, *PTCPPACKET;
typedef struct
{
DIVERT_IPV6HDR ipv6;
DIVERT_TCPHDR tcp;
WINDIVERT_IPV6HDR ipv6;
WINDIVERT_TCPHDR tcp;
} TCPV6PACKET, *PTCPV6PACKET;
typedef struct
{
DIVERT_IPHDR ip;
DIVERT_ICMPHDR icmp;
WINDIVERT_IPHDR ip;
WINDIVERT_ICMPHDR icmp;
UINT8 data[];
} ICMPPACKET, *PICMPPACKET;
typedef struct
{
DIVERT_IPV6HDR ipv6;
DIVERT_ICMPV6HDR icmpv6;
WINDIVERT_IPV6HDR ipv6;
WINDIVERT_ICMPV6HDR icmpv6;
UINT8 data[];
} ICMPV6PACKET, *PICMPV6PACKET;
/*
* Prototypes.
*/
static void PacketIpInit(PDIVERT_IPHDR packet);
static void PacketIpInit(PWINDIVERT_IPHDR packet);
static void PacketIpTcpInit(PTCPPACKET packet);
static void PacketIpIcmpInit(PICMPPACKET packet);
static void PacketIpv6Init(PDIVERT_IPV6HDR packet);
static void PacketIpv6Init(PWINDIVERT_IPV6HDR packet);
static void PacketIpv6TcpInit(PTCPV6PACKET packet);
static void PacketIpv6Icmpv6Init(PICMPV6PACKET packet);
@@ -90,13 +90,13 @@ int __cdecl main(int argc, char **argv)
INT16 priority = 0;
char packet[MAXBUF];
UINT packet_len;
DIVERT_ADDRESS recv_addr, send_addr;
PDIVERT_IPHDR ip_header;
PDIVERT_IPV6HDR ipv6_header;
PDIVERT_ICMPHDR icmp_header;
PDIVERT_ICMPV6HDR icmpv6_header;
PDIVERT_TCPHDR tcp_header;
PDIVERT_UDPHDR udp_header;
WINDIVERT_ADDRESS recv_addr, send_addr;
PWINDIVERT_IPHDR ip_header;
PWINDIVERT_IPV6HDR ipv6_header;
PWINDIVERT_ICMPHDR icmp_header;
PWINDIVERT_ICMPV6HDR icmpv6_header;
PWINDIVERT_TCPHDR tcp_header;
PWINDIVERT_UDPHDR udp_header;
UINT payload_len;
TCPPACKET reset0;
@@ -106,8 +106,8 @@ int __cdecl main(int argc, char **argv)
TCPV6PACKET resetv6_0;
PTCPV6PACKET resetv6 = &resetv6_0;
UINT8 dnrv6_0[sizeof(ICMPV6PACKET) + sizeof(DIVERT_IPV6HDR) +
sizeof(DIVERT_TCPHDR)];
UINT8 dnrv6_0[sizeof(ICMPV6PACKET) + sizeof(WINDIVERT_IPV6HDR) +
sizeof(WINDIVERT_TCPHDR)];
PICMPV6PACKET dnrv6 = (PICMPV6PACKET)dnrv6_0;
// Check arguments.
@@ -119,7 +119,7 @@ int __cdecl main(int argc, char **argv)
priority = (INT16)atoi(argv[2]);
break;
default:
fprintf(stderr, "usage: %s divert-filter [priority]\n",
fprintf(stderr, "usage: %s windivert-filter [priority]\n",
argv[0]);
fprintf(stderr, "examples:\n");
fprintf(stderr, "\t%s true\n", argv[0]);
@@ -140,8 +140,8 @@ int __cdecl main(int argc, char **argv)
resetv6->tcp.Rst = 1;
resetv6->tcp.Ack = 1;
PacketIpv6Icmpv6Init(dnrv6);
dnrv6->ipv6.Length = htons(sizeof(DIVERT_ICMPV6HDR) + 4 +
sizeof(DIVERT_IPV6HDR) + sizeof(DIVERT_TCPHDR));
dnrv6->ipv6.Length = htons(sizeof(WINDIVERT_ICMPV6HDR) + 4 +
sizeof(WINDIVERT_IPV6HDR) + sizeof(WINDIVERT_TCPHDR));
dnrv6->icmpv6.Type = 1; // Destination not reachable.
dnrv6->icmpv6.Code = 4; // Port not reachable.
@@ -149,7 +149,7 @@ int __cdecl main(int argc, char **argv)
console = GetStdHandle(STD_OUTPUT_HANDLE);
// Divert traffic matching the filter:
handle = DivertOpen(argv[1], (DIVERT_LAYER)0, priority, 0);
handle = WinDivertOpen(argv[1], WINDIVERT_LAYER_NETWORK, priority, 0);
if (handle == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_INVALID_PARAMETER)
@@ -157,7 +157,7 @@ int __cdecl main(int argc, char **argv)
fprintf(stderr, "error: filter syntax error\n");
exit(EXIT_FAILURE);
}
fprintf(stderr, "error: failed to open Divert device (%d)\n",
fprintf(stderr, "error: failed to open the WinDivert device (%d)\n",
GetLastError());
exit(EXIT_FAILURE);
}
@@ -166,7 +166,7 @@ int __cdecl main(int argc, char **argv)
while (TRUE)
{
// Read a matching packet.
if (!DivertRecv(handle, packet, sizeof(packet), &recv_addr,
if (!WinDivertRecv(handle, packet, sizeof(packet), &recv_addr,
&packet_len))
{
fprintf(stderr, "warning: failed to read packet\n");
@@ -174,9 +174,9 @@ int __cdecl main(int argc, char **argv)
}
// Print info about the matching packet.
DivertHelperParse(packet, packet_len, &ip_header, &ipv6_header,
&icmp_header, &icmpv6_header, &tcp_header, &udp_header, NULL,
&payload_len);
WinDivertHelperParsePacket(packet, packet_len, &ip_header,
&ipv6_header, &icmp_header, &icmpv6_header, &tcp_header,
&udp_header, NULL, &payload_len);
if (ip_header == NULL && ipv6_header == NULL)
{
continue;
@@ -267,11 +267,12 @@ int __cdecl main(int argc, char **argv)
htonl(ntohl(tcp_header->SeqNum) + 1):
htonl(ntohl(tcp_header->SeqNum) + payload_len));
DivertHelperCalcChecksums((PVOID)reset, sizeof(TCPPACKET), 0);
WinDivertHelperCalcChecksums((PVOID)reset, sizeof(TCPPACKET),
0);
memcpy(&send_addr, &recv_addr, sizeof(send_addr));
send_addr.Direction = !recv_addr.Direction;
if (!DivertSend(handle, (PVOID)reset, sizeof(TCPPACKET),
if (!WinDivertSend(handle, (PVOID)reset, sizeof(TCPPACKET),
&send_addr, NULL))
{
fprintf(stderr, "warning: failed to send TCP reset (%d)\n",
@@ -294,12 +295,12 @@ int __cdecl main(int argc, char **argv)
htonl(ntohl(tcp_header->SeqNum) + 1):
htonl(ntohl(tcp_header->SeqNum) + payload_len));
DivertHelperCalcChecksums((PVOID)resetv6, sizeof(TCPV6PACKET),
0);
WinDivertHelperCalcChecksums((PVOID)resetv6,
sizeof(TCPV6PACKET), 0);
memcpy(&send_addr, &recv_addr, sizeof(send_addr));
send_addr.Direction = !recv_addr.Direction;
if (!DivertSend(handle, (PVOID)resetv6, sizeof(TCPV6PACKET),
if (!WinDivertSend(handle, (PVOID)resetv6, sizeof(TCPV6PACKET),
&send_addr, NULL))
{
fprintf(stderr, "warning: failed to send TCP (IPV6) "
@@ -324,11 +325,11 @@ int __cdecl main(int argc, char **argv)
dnr->ip.SrcAddr = ip_header->DstAddr;
dnr->ip.DstAddr = ip_header->SrcAddr;
DivertHelperCalcChecksums((PVOID)dnr, icmp_length, 0);
WinDivertHelperCalcChecksums((PVOID)dnr, icmp_length, 0);
memcpy(&send_addr, &recv_addr, sizeof(send_addr));
send_addr.Direction = DIVERT_DIRECTION_OUTBOUND;
if (!DivertSend(handle, (PVOID)dnr, icmp_length, &send_addr,
send_addr.Direction = WINDIVERT_DIRECTION_OUTBOUND;
if (!WinDivertSend(handle, (PVOID)dnr, icmp_length, &send_addr,
NULL))
{
fprintf(stderr, "warning: failed to send ICMP message "
@@ -338,8 +339,8 @@ int __cdecl main(int argc, char **argv)
if (ipv6_header != NULL)
{
UINT icmpv6_length = sizeof(DIVERT_IPV6HDR) +
sizeof(DIVERT_TCPHDR);
UINT icmpv6_length = sizeof(WINDIVERT_IPV6HDR) +
sizeof(WINDIVERT_TCPHDR);
memcpy(dnrv6->data, ipv6_header, icmpv6_length);
icmpv6_length += sizeof(ICMPV6PACKET);
memcpy(dnrv6->ipv6.SrcAddr, ipv6_header->DstAddr,
@@ -347,11 +348,11 @@ int __cdecl main(int argc, char **argv)
memcpy(dnrv6->ipv6.DstAddr, ipv6_header->SrcAddr,
sizeof(dnrv6->ipv6.DstAddr));
DivertHelperCalcChecksums((PVOID)dnrv6, icmpv6_length, 0);
WinDivertHelperCalcChecksums((PVOID)dnrv6, icmpv6_length, 0);
memcpy(&send_addr, &recv_addr, sizeof(send_addr));
send_addr.Direction = DIVERT_DIRECTION_OUTBOUND;
if (!DivertSend(handle, (PVOID)dnrv6, icmpv6_length,
send_addr.Direction = WINDIVERT_DIRECTION_OUTBOUND;
if (!WinDivertSend(handle, (PVOID)dnrv6, icmpv6_length,
&send_addr, NULL))
{
fprintf(stderr, "warning: failed to send ICMPv6 message "
@@ -366,11 +367,11 @@ int __cdecl main(int argc, char **argv)
/*
* Initialize a PACKET.
*/
static void PacketIpInit(PDIVERT_IPHDR packet)
static void PacketIpInit(PWINDIVERT_IPHDR packet)
{
memset(packet, 0, sizeof(DIVERT_IPHDR));
memset(packet, 0, sizeof(WINDIVERT_IPHDR));
packet->Version = 4;
packet->HdrLength = sizeof(DIVERT_IPHDR) / sizeof(UINT32);
packet->HdrLength = sizeof(WINDIVERT_IPHDR) / sizeof(UINT32);
packet->Id = ntohs(0xDEAD);
packet->TTL = 64;
}
@@ -384,7 +385,7 @@ static void PacketIpTcpInit(PTCPPACKET packet)
PacketIpInit(&packet->ip);
packet->ip.Length = htons(sizeof(TCPPACKET));
packet->ip.Protocol = IPPROTO_TCP;
packet->tcp.HdrLength = sizeof(DIVERT_TCPHDR) / sizeof(UINT32);
packet->tcp.HdrLength = sizeof(WINDIVERT_TCPHDR) / sizeof(UINT32);
}
/*
@@ -400,9 +401,9 @@ static void PacketIpIcmpInit(PICMPPACKET packet)
/*
* Initialize a PACKETV6.
*/
static void PacketIpv6Init(PDIVERT_IPV6HDR packet)
static void PacketIpv6Init(PWINDIVERT_IPV6HDR packet)
{
memset(packet, 0, sizeof(DIVERT_IPV6HDR));
memset(packet, 0, sizeof(WINDIVERT_IPV6HDR));
packet->Version = 6;
packet->HopLimit = 64;
}
@@ -414,9 +415,9 @@ static void PacketIpv6TcpInit(PTCPV6PACKET packet)
{
memset(packet, 0, sizeof(TCPV6PACKET));
PacketIpv6Init(&packet->ipv6);
packet->ipv6.Length = htons(sizeof(DIVERT_TCPHDR));
packet->ipv6.Length = htons(sizeof(WINDIVERT_TCPHDR));
packet->ipv6.NextHdr = IPPROTO_TCP;
packet->tcp.HdrLength = sizeof(DIVERT_TCPHDR) / sizeof(UINT32);
packet->tcp.HdrLength = sizeof(WINDIVERT_TCPHDR) / sizeof(UINT32);
}
/*
+1 -1
View File
@@ -1,5 +1,5 @@
# sources
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
+8 -8
View File
@@ -1,6 +1,6 @@
/*
* passthru.c
* (C) 2012, all rights reserved,
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -21,7 +21,7 @@
* This program does nothing except divert packets and re-inject them. This is
* useful for performance testing.
*
* usage: netdump.exe divert-filter num-threads
* usage: netdump.exe windivert-filter num-threads
*/
#include <winsock2.h>
@@ -29,7 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "divert.h"
#include "windivert.h"
#define MAXBUF 0xFFFF
@@ -56,7 +56,7 @@ int __cdecl main(int argc, char **argv)
}
// Divert traffic matching the filter:
handle = DivertOpen(argv[1], (DIVERT_LAYER)0, 0, 0);
handle = WinDivertOpen(argv[1], WINDIVERT_LAYER_NETWORK, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_INVALID_PARAMETER)
@@ -64,7 +64,7 @@ int __cdecl main(int argc, char **argv)
fprintf(stderr, "error: filter syntax error\n");
exit(EXIT_FAILURE);
}
fprintf(stderr, "error: failed to open Divert device (%d)\n",
fprintf(stderr, "error: failed to open the WinDivert device (%d)\n",
GetLastError());
exit(EXIT_FAILURE);
}
@@ -93,14 +93,14 @@ static DWORD passthru(LPVOID arg)
{
char packet[MAXBUF];
UINT packet_len;
DIVERT_ADDRESS addr;
WINDIVERT_ADDRESS addr;
HANDLE handle = (HANDLE)arg;
// Main loop:
while (TRUE)
{
// Read a matching packet.
if (!DivertRecv(handle, packet, sizeof(packet), &addr, &packet_len))
if (!WinDivertRecv(handle, packet, sizeof(packet), &addr, &packet_len))
{
fprintf(stderr, "warning: failed to read packet (%d)\n",
GetLastError());
@@ -108,7 +108,7 @@ static DWORD passthru(LPVOID arg)
}
// Re-inject the matching packet.
if (!DivertSend(handle, packet, packet_len, &addr, NULL))
if (!WinDivertSend(handle, packet, packet_len, &addr, NULL))
{
fprintf(stderr, "warning: failed to reinject packet (%d)\n",
GetLastError());
+1 -1
View File
@@ -1,5 +1,5 @@
# sources
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# sources
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
+24 -23
View File
@@ -1,6 +1,6 @@
/*
* webfilter.c
* (C) 2012, all rights reserved,
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "divert.h"
#include "windivert.h"
#define MAXBUF 0xFFFF
#define MAXURL 4096
@@ -56,8 +56,8 @@ typedef struct
*/
typedef struct
{
DIVERT_IPHDR ip;
DIVERT_TCPHDR tcp;
WINDIVERT_IPHDR ip;
WINDIVERT_TCPHDR tcp;
} PACKET, *PPACKET;
typedef struct
{
@@ -105,11 +105,11 @@ static BOOL BlackListPayloadMatch(PBLACKLIST blacklist, char *data,
int __cdecl main(int argc, char **argv)
{
HANDLE handle;
DIVERT_ADDRESS addr;
WINDIVERT_ADDRESS addr;
UINT8 packet[MAXBUF];
UINT packet_len;
PDIVERT_IPHDR ip_header;
PDIVERT_TCPHDR tcp_header;
PWINDIVERT_IPHDR ip_header;
PWINDIVERT_TCPHDR tcp_header;
PVOID payload;
UINT payload_len;
PACKET reset0;
@@ -158,37 +158,37 @@ int __cdecl main(int argc, char **argv)
finish->tcp.Ack = 1;
// Open the Divert device:
handle = DivertOpen(
handle = WinDivertOpen(
"outbound && " // Outbound traffic only
"ip && " // Only IPv4 supported
"tcp.DstPort == 80 && " // HTTP (port 80) only
"tcp.PayloadLength > 0", // TCP data packets only
(DIVERT_LAYER)0, priority, 0
WINDIVERT_LAYER_NETWORK, priority, 0
);
if (handle == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "error: failed to open Divert device (%d)\n",
fprintf(stderr, "error: failed to open the WinDivert device (%d)\n",
GetLastError());
exit(EXIT_FAILURE);
}
printf("OPENED divert\n");
printf("OPENED WinDivert\n");
// Main loop:
while (TRUE)
{
if (!DivertRecv(handle, packet, sizeof(packet), &addr, &packet_len))
if (!WinDivertRecv(handle, packet, sizeof(packet), &addr, &packet_len))
{
fprintf(stderr, "warning: failed to read packet (%d)\n",
GetLastError());
continue;
}
if (!DivertHelperParse(packet, packet_len, &ip_header, NULL, NULL,
NULL, &tcp_header, NULL, &payload, &payload_len) ||
if (!WinDivertHelperParsePacket(packet, packet_len, &ip_header, NULL,
NULL, NULL, &tcp_header, NULL, &payload, &payload_len) ||
!BlackListPayloadMatch(blacklist, payload, (UINT16)payload_len))
{
// Packet does not match the blacklist; simply reinject it.
if (!DivertSend(handle, packet, packet_len, &addr, NULL))
if (!WinDivertSend(handle, packet, packet_len, &addr, NULL))
{
fprintf(stderr, "warning: failed to reinject packet (%d)\n",
GetLastError());
@@ -207,8 +207,8 @@ int __cdecl main(int argc, char **argv)
reset->tcp.DstPort = htons(80);
reset->tcp.SeqNum = tcp_header->SeqNum;
reset->tcp.AckNum = tcp_header->AckNum;
DivertHelperCalcChecksums((PVOID)reset, sizeof(PACKET), 0);
if (!DivertSend(handle, (PVOID)reset, sizeof(PACKET), &addr, NULL))
WinDivertHelperCalcChecksums((PVOID)reset, sizeof(PACKET), 0);
if (!WinDivertSend(handle, (PVOID)reset, sizeof(PACKET), &addr, NULL))
{
fprintf(stderr, "warning: failed to send reset packet (%d)\n",
GetLastError());
@@ -221,9 +221,10 @@ int __cdecl main(int argc, char **argv)
blockpage->header.tcp.SeqNum = tcp_header->AckNum;
blockpage->header.tcp.AckNum =
htonl(ntohl(tcp_header->SeqNum) + payload_len);
DivertHelperCalcChecksums((PVOID)blockpage, blockpage_len, 0);
WinDivertHelperCalcChecksums((PVOID)blockpage, blockpage_len, 0);
addr.Direction = !addr.Direction; // Reverse direction.
if (!DivertSend(handle, (PVOID)blockpage, blockpage_len, &addr, NULL))
if (!WinDivertSend(handle, (PVOID)blockpage, blockpage_len, &addr,
NULL))
{
fprintf(stderr, "warning: failed to send block page packet (%d)\n",
GetLastError());
@@ -239,8 +240,8 @@ int __cdecl main(int argc, char **argv)
htonl(ntohl(tcp_header->AckNum) + sizeof(block_data) - 1);
finish->tcp.AckNum =
htonl(ntohl(tcp_header->SeqNum) + payload_len);
DivertHelperCalcChecksums((PVOID)finish, sizeof(PACKET), 0);
if (!DivertSend(handle, (PVOID)finish, sizeof(PACKET), &addr, NULL))
WinDivertHelperCalcChecksums((PVOID)finish, sizeof(PACKET), 0);
if (!WinDivertSend(handle, (PVOID)finish, sizeof(PACKET), &addr, NULL))
{
fprintf(stderr, "warning: failed to send finish packet (%d)\n",
GetLastError());
@@ -255,11 +256,11 @@ static void PacketInit(PPACKET packet)
{
memset(packet, 0, sizeof(PACKET));
packet->ip.Version = 4;
packet->ip.HdrLength = sizeof(DIVERT_IPHDR) / sizeof(UINT32);
packet->ip.HdrLength = sizeof(WINDIVERT_IPHDR) / sizeof(UINT32);
packet->ip.Length = htons(sizeof(PACKET));
packet->ip.TTL = 64;
packet->ip.Protocol = IPPROTO_TCP;
packet->tcp.HdrLength = sizeof(DIVERT_TCPHDR) / sizeof(UINT32);
packet->tcp.HdrLength = sizeof(WINDIVERT_TCPHDR) / sizeof(UINT32);
}
/*
-199
View File
@@ -1,199 +0,0 @@
/*
* divert_device.h
* (C) 2012, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DIVERT_DEVICE_H
#define __DIVERT_DEVICE_H
/*
* NOTE: This is the low-level interface to the divert device driver.
* This interface should not be used directly, instead use the high-level
* interface provided by the divert API.
*/
#define DIVERT_KERNEL
#include "divert.h"
#define DIVERT_VERSION 1
#define DIVERT_VERSION_MINOR 0
#define DIVERT_STR2(s) #s
#define DIVERT_STR(s) DIVERT_STR2(s)
#define DIVERT_LSTR2(s) L ## #s
#define DIVERT_LSTR(s) DIVERT_LSTR2(s)
#define DIVERT_VERSION_LSTR \
DIVERT_LSTR(DIVERT_VERSION) L"." DIVERT_LSTR(DIVERT_VERSION_MINOR)
#define DIVERT_DEVICE_NAME \
L"WinDivert" DIVERT_VERSION_LSTR
#define DIVERT_IOCTL_VERSION 2
#define DIVERT_IOCTL_MAGIC 0xE8D3
#define DIVERT_FILTER_FIELD_ZERO 0
#define DIVERT_FILTER_FIELD_INBOUND 1
#define DIVERT_FILTER_FIELD_OUTBOUND 2
#define DIVERT_FILTER_FIELD_IFIDX 3
#define DIVERT_FILTER_FIELD_SUBIFIDX 4
#define DIVERT_FILTER_FIELD_IP 5
#define DIVERT_FILTER_FIELD_IPV6 6
#define DIVERT_FILTER_FIELD_ICMP 7
#define DIVERT_FILTER_FIELD_TCP 8
#define DIVERT_FILTER_FIELD_UDP 9
#define DIVERT_FILTER_FIELD_ICMPV6 10
#define DIVERT_FILTER_FIELD_IP_HDRLENGTH 11
#define DIVERT_FILTER_FIELD_IP_TOS 12
#define DIVERT_FILTER_FIELD_IP_LENGTH 13
#define DIVERT_FILTER_FIELD_IP_ID 14
#define DIVERT_FILTER_FIELD_IP_DF 15
#define DIVERT_FILTER_FIELD_IP_MF 16
#define DIVERT_FILTER_FIELD_IP_FRAGOFF 17
#define DIVERT_FILTER_FIELD_IP_TTL 18
#define DIVERT_FILTER_FIELD_IP_PROTOCOL 19
#define DIVERT_FILTER_FIELD_IP_CHECKSUM 20
#define DIVERT_FILTER_FIELD_IP_SRCADDR 21
#define DIVERT_FILTER_FIELD_IP_DSTADDR 22
#define DIVERT_FILTER_FIELD_IPV6_TRAFFICCLASS 23
#define DIVERT_FILTER_FIELD_IPV6_FLOWLABEL 24
#define DIVERT_FILTER_FIELD_IPV6_LENGTH 25
#define DIVERT_FILTER_FIELD_IPV6_NEXTHDR 26
#define DIVERT_FILTER_FIELD_IPV6_HOPLIMIT 27
#define DIVERT_FILTER_FIELD_IPV6_SRCADDR 28
#define DIVERT_FILTER_FIELD_IPV6_DSTADDR 29
#define DIVERT_FILTER_FIELD_ICMP_TYPE 30
#define DIVERT_FILTER_FIELD_ICMP_CODE 31
#define DIVERT_FILTER_FIELD_ICMP_CHECKSUM 32
#define DIVERT_FILTER_FIELD_ICMP_BODY 33
#define DIVERT_FILTER_FIELD_ICMPV6_TYPE 34
#define DIVERT_FILTER_FIELD_ICMPV6_CODE 35
#define DIVERT_FILTER_FIELD_ICMPV6_CHECKSUM 36
#define DIVERT_FILTER_FIELD_ICMPV6_BODY 37
#define DIVERT_FILTER_FIELD_TCP_SRCPORT 38
#define DIVERT_FILTER_FIELD_TCP_DSTPORT 39
#define DIVERT_FILTER_FIELD_TCP_SEQNUM 40
#define DIVERT_FILTER_FIELD_TCP_ACKNUM 41
#define DIVERT_FILTER_FIELD_TCP_HDRLENGTH 42
#define DIVERT_FILTER_FIELD_TCP_URG 43
#define DIVERT_FILTER_FIELD_TCP_ACK 44
#define DIVERT_FILTER_FIELD_TCP_PSH 45
#define DIVERT_FILTER_FIELD_TCP_RST 46
#define DIVERT_FILTER_FIELD_TCP_SYN 47
#define DIVERT_FILTER_FIELD_TCP_FIN 48
#define DIVERT_FILTER_FIELD_TCP_WINDOW 49
#define DIVERT_FILTER_FIELD_TCP_CHECKSUM 50
#define DIVERT_FILTER_FIELD_TCP_URGPTR 51
#define DIVERT_FILTER_FIELD_TCP_PAYLOADLENGTH 52
#define DIVERT_FILTER_FIELD_UDP_SRCPORT 53
#define DIVERT_FILTER_FIELD_UDP_DSTPORT 54
#define DIVERT_FILTER_FIELD_UDP_LENGTH 55
#define DIVERT_FILTER_FIELD_UDP_CHECKSUM 56
#define DIVERT_FILTER_FIELD_UDP_PAYLOADLENGTH 57
#define DIVERT_FILTER_FIELD_MAX \
DIVERT_FILTER_FIELD_UDP_PAYLOADLENGTH
#define DIVERT_FILTER_TEST_EQ 0
#define DIVERT_FILTER_TEST_NEQ 1
#define DIVERT_FILTER_TEST_LT 2
#define DIVERT_FILTER_TEST_LEQ 3
#define DIVERT_FILTER_TEST_GT 4
#define DIVERT_FILTER_TEST_GEQ 5
#define DIVERT_FILTER_TEST_MAX DIVERT_FILTER_TEST_GEQ
#define DIVERT_FILTER_MAXLEN 512
#define DIVERT_FILTER_RESULT_ACCEPT (DIVERT_FILTER_MAXLEN+1)
#define DIVERT_FILTER_RESULT_REJECT (DIVERT_FILTER_MAXLEN+2)
/*
* Divert layers.
*/
#define DIVERT_LAYER_DEFAULT DIVERT_LAYER_NETWORK
#define DIVERT_LAYER_MAX DIVERT_LAYER_NETWORK_FORWARD
/*
* Divert flags.
*/
#define DIVERT_FLAGS_MAX \
(DIVERT_FLAG_SNIFF | DIVERT_FLAG_DROP)
/*
* Divert priorities.
*/
#define DIVERT_PRIORITY(priority16) \
((UINT32)((INT32)(priority16) + 0x7FFF + 1))
#define DIVERT_PRIORITY_DEFAULT DIVERT_PRIORITY(0)
#define DIVERT_PRIORITY_MAX DIVERT_PRIORITY(1000)
/*
* Divert parameters.
*/
#define DIVERT_PARAM_QUEUE_LEN_DEFAULT 512
#define DIVERT_PARAM_QUEUE_LEN_MIN 1
#define DIVERT_PARAM_QUEUE_LEN_MAX 8192
#define DIVERT_PARAM_QUEUE_TIME_DEFAULT 256
#define DIVERT_PARAM_QUEUE_TIME_MIN 32
#define DIVERT_PARAM_QUEUE_TIME_MAX 1024
/*
* Message definitions.
*/
#pragma pack(push, 1)
struct divert_ioctl_s
{
UINT16 magic; // DIVERT_IOCTL_MAGIC
UINT8 version; // DIVERT_IOCTL_VERSION
UINT8 arg8; // 8-bit argument
UINT64 arg; // 64-bit argument
};
typedef struct divert_ioctl_s *divert_ioctl_t;
/*
* IOCTL structures.
*/
struct divert_ioctl_filter_s
{
UINT8 field; // DIVERT_FILTER_FIELD_IP_*
UINT8 test; // DIVERT_FILTER_TEST_*
UINT16 success; // Success continuation.
UINT16 failure; // Fail continuation.
UINT32 arg[4]; // Argument.
};
typedef struct divert_ioctl_filter_s *divert_ioctl_filter_t;
#pragma pack(pop)
/*
* IOCTL codes.
*/
#define IOCTL_DIVERT_RECV \
CTL_CODE(FILE_DEVICE_NETWORK, 0x908, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_SEND \
CTL_CODE(FILE_DEVICE_NETWORK, 0x909, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_START_FILTER \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90A, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_SET_LAYER \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90B, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_SET_PRIORITY \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90C, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_SET_FLAGS \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90D, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_SET_PARAM \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90E, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_DIVERT_GET_PARAM \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90F, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#endif // __DIVERT_DEVICE_H
+103 -92
View File
@@ -1,6 +1,6 @@
/*
* divert.h
* (C) 2012, all rights reserved,
* windivert.h
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -16,16 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DIVERT_H
#define __DIVERT_H
#ifndef __WINDIVERT_H
#define __WINDIVERT_H
#ifndef DIVERT_KERNEL
#ifndef WINDIVERT_KERNEL
#include <windows.h>
#endif /* DIVERT_KERNEL */
#endif /* WINDIVERT_KERNEL */
#ifndef DIVERTEXPORT
#define DIVERTEXPORT __declspec(dllimport)
#endif /* DIVERTEXPORT */
#ifndef WINDIVERTEXPORT
#define WINDIVERTEXPORT __declspec(dllimport)
#endif /* WINDIVERTEXPORT */
#ifdef __MINGW32__
#define __in
@@ -48,7 +48,7 @@ extern "C" {
#endif
/****************************************************************************/
/* DIVERT API */
/* WINDIVERT API */
/****************************************************************************/
/*
@@ -59,101 +59,119 @@ typedef struct
UINT32 IfIdx; /* Packet's interface index. */
UINT32 SubIfIdx; /* Packet's sub-interface index. */
UINT8 Direction; /* Packet's direction. */
} DIVERT_ADDRESS, *PDIVERT_ADDRESS;
} WINDIVERT_ADDRESS, *PWINDIVERT_ADDRESS;
#define DIVERT_DIRECTION_OUTBOUND 0
#define DIVERT_DIRECTION_INBOUND 1
/*
* Old names (deprecated).
*/
#define DIVERT_PACKET_DIRECTION_OUTBOUND \
DIVERT_DIRECTION_OUTBOUND
#define DIVERT_PACKET_DIRECTION_INBOUND \
DIVERT_DIRECTION_INBOUND
#define WINDIVERT_DIRECTION_OUTBOUND 0
#define WINDIVERT_DIRECTION_INBOUND 1
/*
* Divert layers.
*/
typedef enum
{
DIVERT_LAYER_NETWORK = 0, /* Network layer. */
DIVERT_LAYER_NETWORK_FORWARD = 1 /* Network layer (forwarded packets) */
} DIVERT_LAYER, *PDIVERT_LAYER;
WINDIVERT_LAYER_NETWORK = 0, /* Network layer. */
WINDIVERT_LAYER_NETWORK_FORWARD = 1 /* Network layer (forwarded packets) */
} WINDIVERT_LAYER, *PWINDIVERT_LAYER;
/*
* Divert flags.
*/
#define DIVERT_FLAG_SNIFF 1
#define DIVERT_FLAG_DROP 2
#define WINDIVERT_FLAG_SNIFF 1
#define WINDIVERT_FLAG_DROP 2
#define WINDIVERT_FLAG_PASSTHRU 4
#define WINDIVERT_FLAG_NO_CHECKSUM 1024
/*
* Divert parameters.
*/
typedef enum
{
DIVERT_PARAM_QUEUE_LEN = 0, /* Packet queue length. */
DIVERT_PARAM_QUEUE_TIME = 1 /* Packet queue time. */
} DIVERT_PARAM, *PDIVERT_PARAM;
#define DIVERT_PARAM_MAX DIVERT_PARAM_QUEUE_TIME
WINDIVERT_PARAM_QUEUE_LEN = 0, /* Packet queue length. */
WINDIVERT_PARAM_QUEUE_TIME = 1 /* Packet queue time. */
} WINDIVERT_PARAM, *PWINDIVERT_PARAM;
#define WINDIVERT_PARAM_MAX WINDIVERT_PARAM_QUEUE_TIME
#ifndef WINDIVERT_KERNEL
/*
* Open a divert handle.
* Open a WinDivert handle.
*/
extern DIVERTEXPORT HANDLE DivertOpen(
extern WINDIVERTEXPORT HANDLE WinDivertOpen(
__in const char *filter,
__in DIVERT_LAYER layer,
__in WINDIVERT_LAYER layer,
__in INT16 priority,
__in UINT64 flags);
/*
* Receive (read) a packet from a divert handle.
* Receive (read) a packet from a WinDivert handle.
*/
extern DIVERTEXPORT BOOL DivertRecv(
extern WINDIVERTEXPORT BOOL WinDivertRecv(
__in HANDLE handle,
__out PVOID pPacket,
__in UINT packetLen,
__out_opt PDIVERT_ADDRESS pAddr,
__out_opt PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *readLen);
/*
* Send (write/inject) a packet to a divert handle.
* Receive (read) a packet from a WinDivert handle.
*/
extern DIVERTEXPORT BOOL DivertSend(
extern WINDIVERTEXPORT BOOL WinDivertRecvEx(
__in HANDLE handle,
__out PVOID pPacket,
__in UINT packetLen,
__in UINT64 flags,
__out_opt PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *readLen,
__inout_opt LPOVERLAPPED lpOverlapped);
/*
* Send (write/inject) a packet to a WinDivert handle.
*/
extern WINDIVERTEXPORT BOOL WinDivertSend(
__in HANDLE handle,
__in PVOID pPacket,
__in UINT packetLen,
__in PDIVERT_ADDRESS pAddr,
__in PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *writeLen);
/*
* Close a divert handle.
* Send (write/inject) a packet to a WinDivert handle.
*/
extern DIVERTEXPORT BOOL DivertClose(
extern WINDIVERTEXPORT BOOL WinDivertSendEx(
__in HANDLE handle,
__in PVOID pPacket,
__in UINT packetLen,
__in UINT64 flags,
__in PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *writeLen,
__inout_opt LPOVERLAPPED lpOverlapped);
/*
* Close a WinDivert handle.
*/
extern WINDIVERTEXPORT BOOL WinDivertClose(
__in HANDLE handle);
/*
* Set a divert handle parameter.
* Set a WinDivert handle parameter.
*/
extern DIVERTEXPORT BOOL DivertSetParam(
extern WINDIVERTEXPORT BOOL WinDivertSetParam(
__in HANDLE handle,
__in DIVERT_PARAM param,
__in WINDIVERT_PARAM param,
__in UINT64 value);
/*
* Get a divert handle parameter.
* Get a WinDivert handle parameter.
*/
extern DIVERTEXPORT BOOL DivertGetParam(
extern WINDIVERTEXPORT BOOL WinDivertGetParam(
__in HANDLE handle,
__in DIVERT_PARAM param,
__in WINDIVERT_PARAM param,
__out UINT64 *pValue);
/****************************************************************************/
/* DIVERT HELPER API */
/* WINDIVERT HELPER API */
/****************************************************************************/
#ifndef DIVERT_NO_HELPER_API
/*
* IPv4/IPv6/ICMP/ICMPv6/TCP/UDP header definitions.
*/
@@ -170,39 +188,39 @@ typedef struct
UINT16 Checksum;
UINT32 SrcAddr;
UINT32 DstAddr;
} DIVERT_IPHDR, *PDIVERT_IPHDR;
} WINDIVERT_IPHDR, *PWINDIVERT_IPHDR;
#define DIVERT_IPHDR_GET_FRAGOFF(hdr) \
#define WINDIVERT_IPHDR_GET_FRAGOFF(hdr) \
(((hdr)->FragOff0) & 0xFF1F)
#define DIVERT_IPHDR_GET_MF(hdr) \
#define WINDIVERT_IPHDR_GET_MF(hdr) \
((((hdr)->FragOff0) & 0x0020) != 0)
#define DIVERT_IPHDR_GET_DF(hdr) \
#define WINDIVERT_IPHDR_GET_DF(hdr) \
((((hdr)->FragOff0) & 0x0040) != 0)
#define DIVERT_IPHDR_GET_RESERVED(hdr) \
#define WINDIVERT_IPHDR_GET_RESERVED(hdr) \
((((hdr)->FragOff0) & 0x0080) != 0)
#define DIVERT_IPHDR_SET_FRAGOFF(hdr, val) \
#define WINDIVERT_IPHDR_SET_FRAGOFF(hdr, val) \
do \
{ \
(hdr)->FragOff0 = (((hdr)->FragOff0) & 0x00E0) | \
((val) & 0xFF1F); \
} \
while (FALSE)
#define DIVERT_IPHDR_SET_MF(hdr, val) \
#define WINDIVERT_IPHDR_SET_MF(hdr, val) \
do \
{ \
(hdr)->FragOff0 = (((hdr)->FragOff0) & 0xFFDF) | \
(((val) & 0x0001) << 5); \
} \
while (FALSE)
#define DIVERT_IPHDR_SET_DF(hdr, val) \
#define WINDIVERT_IPHDR_SET_DF(hdr, val) \
do \
{ \
(hdr)->FragOff0 = (((hdr)->FragOff0) & 0xFFBF) | \
(((val) & 0x0001) << 6); \
} \
while (FALSE)
#define DIVERT_IPHDR_SET_RESERVED(hdr, val) \
#define WINDIVERT_IPHDR_SET_RESERVED(hdr, val) \
do \
{ \
(hdr)->FragOff0 = (((hdr)->FragOff0) & 0xFF7F) | \
@@ -222,21 +240,21 @@ typedef struct
UINT8 HopLimit;
UINT32 SrcAddr[4];
UINT32 DstAddr[4];
} DIVERT_IPV6HDR, *PDIVERT_IPV6HDR;
} WINDIVERT_IPV6HDR, *PWINDIVERT_IPV6HDR;
#define DIVERT_IPV6HDR_GET_TRAFFICCLASS(hdr) \
#define WINDIVERT_IPV6HDR_GET_TRAFFICCLASS(hdr) \
((((hdr)->TrafficClass0) << 4) | ((hdr)->TrafficClass1))
#define DIVERT_IPV6HDR_GET_FLOWLABEL(hdr) \
#define WINDIVERT_IPV6HDR_GET_FLOWLABEL(hdr) \
((((UINT32)(hdr)->FlowLabel0) << 16) | ((UINT32)(hdr)->FlowLabel1))
#define DIVERT_IPV6HDR_SET_TRAFFICCLASS(hdr, val) \
#define WINDIVERT_IPV6HDR_SET_TRAFFICCLASS(hdr, val) \
do \
{ \
(hdr)->TrafficClass0 = ((UINT8)(val) >> 4); \
(hdr)->TrafficClass1 = (UINT8)(val); \
} \
while (FALSE)
#define DIVERT_IPV6HDR_SET_FLOWLABEL(hdr, val) \
#define WINDIVERT_IPV6HDR_SET_FLOWLABEL(hdr, val) \
do \
{ \
(hdr)->FlowLabel0 = (UINT8)((val) >> 16); \
@@ -250,7 +268,7 @@ typedef struct
UINT8 Code;
UINT16 Checksum;
UINT32 Body;
} DIVERT_ICMPHDR, *PDIVERT_ICMPHDR;
} WINDIVERT_ICMPHDR, *PWINDIVERT_ICMPHDR;
typedef struct
{
@@ -258,7 +276,7 @@ typedef struct
UINT8 Code;
UINT16 Checksum;
UINT32 Body;
} DIVERT_ICMPV6HDR, *PDIVERT_ICMPV6HDR;
} WINDIVERT_ICMPV6HDR, *PWINDIVERT_ICMPV6HDR;
typedef struct
{
@@ -278,7 +296,7 @@ typedef struct
UINT16 Window;
UINT16 Checksum;
UINT16 UrgPtr;
} DIVERT_TCPHDR, *PDIVERT_TCPHDR;
} WINDIVERT_TCPHDR, *PWINDIVERT_TCPHDR;
typedef struct
{
@@ -286,65 +304,58 @@ typedef struct
UINT16 DstPort;
UINT16 Length;
UINT16 Checksum;
} DIVERT_UDPHDR, *PDIVERT_UDPHDR;
} WINDIVERT_UDPHDR, *PWINDIVERT_UDPHDR;
/*
* Flags for DivertHelperCalcChecksums()
*/
#define DIVERT_HELPER_NO_IP_CHECKSUM 1
#define DIVERT_HELPER_NO_ICMP_CHECKSUM 2
#define DIVERT_HELPER_NO_ICMPV6_CHECKSUM 4
#define DIVERT_HELPER_NO_TCP_CHECKSUM 8
#define DIVERT_HELPER_NO_UDP_CHECKSUM 16
#define WINDIVERT_HELPER_NO_IP_CHECKSUM 1
#define WINDIVERT_HELPER_NO_ICMP_CHECKSUM 2
#define WINDIVERT_HELPER_NO_ICMPV6_CHECKSUM 4
#define WINDIVERT_HELPER_NO_TCP_CHECKSUM 8
#define WINDIVERT_HELPER_NO_UDP_CHECKSUM 16
/*
* Parse IPv4/IPv6/ICMP/ICMPv6/TCP/UDP headers from a raw packet.
*/
extern DIVERTEXPORT BOOL DivertHelperParsePacket(
extern WINDIVERTEXPORT BOOL WinDivertHelperParsePacket(
__in PVOID pPacket,
__in UINT packetLen,
__out_opt PDIVERT_IPHDR *ppIpHdr,
__out_opt PDIVERT_IPV6HDR *ppIpv6Hdr,
__out_opt PDIVERT_ICMPHDR *ppIcmpHdr,
__out_opt PDIVERT_ICMPV6HDR *ppIcmpv6Hdr,
__out_opt PDIVERT_TCPHDR *ppTcpHdr,
__out_opt PDIVERT_UDPHDR *ppUdpHdr,
__out_opt PWINDIVERT_IPHDR *ppIpHdr,
__out_opt PWINDIVERT_IPV6HDR *ppIpv6Hdr,
__out_opt PWINDIVERT_ICMPHDR *ppIcmpHdr,
__out_opt PWINDIVERT_ICMPV6HDR *ppIcmpv6Hdr,
__out_opt PWINDIVERT_TCPHDR *ppTcpHdr,
__out_opt PWINDIVERT_UDPHDR *ppUdpHdr,
__out_opt PVOID *ppData,
__out_opt UINT *pDataLen);
/*
* Old name (deprecated).
*/
#define DivertHelperParse(p, pl, ip, ip6, icmp, icmp6, tcp, udp, d, dl) \
DivertHelperParsePacket((p), (pl), (ip), (ip6), (icmp), (icmp6), (tcp), \
(udp), (d), (dl))
/*
* Parse an IPv4 address.
*/
extern DIVERTEXPORT BOOL DivertHelperParseIPv4Address(
extern WINDIVERTEXPORT BOOL WinDivertHelperParseIPv4Address(
__in const char *addrStr,
__out_opt UINT32 *pAddr);
/*
* Parse an IPv6 address.
*/
extern DIVERTEXPORT BOOL DivertHelperParseIPv6Address(
extern WINDIVERTEXPORT BOOL WinDivertHelperParseIPv6Address(
__in const char *addrStr,
__out_opt UINT32 *pAddr);
/*
* Calculate IPv4/IPv6/ICMP/ICMPv6/TCP/UDP checksums.
*/
extern DIVERTEXPORT UINT DivertHelperCalcChecksums(
extern WINDIVERTEXPORT UINT WinDivertHelperCalcChecksums(
__inout PVOID pPacket,
__in UINT packetLen,
__in UINT64 flags);
#endif /* DIVERT_NO_HELPER_API */
#endif /* WINDIVERT_KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* __DIVERT_H */
#endif /* __WINDIVERT_H */
+211
View File
@@ -0,0 +1,211 @@
/*
* windivert_device.h
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WINDIVERT_DEVICE_H
#define __WINDIVERT_DEVICE_H
/*
* NOTE: This is the low-level interface to the divert device driver.
* This interface should not be used directly, instead use the high-level
* interface provided by the divert API.
*/
#define WINDIVERT_KERNEL
#include "windivert.h"
#define WINDIVERT_VERSION 1
#define WINDIVERT_VERSION_MINOR 1
#define WINDIVERT_STR2(s) #s
#define WINDIVERT_STR(s) WINDIVERT_STR2(s)
#define WINDIVERT_LSTR2(s) L ## #s
#define WINDIVERT_LSTR(s) WINDIVERT_LSTR2(s)
#define WINDIVERT_VERSION_LSTR \
WINDIVERT_LSTR(WINDIVERT_VERSION) L"." \
WINDIVERT_LSTR(WINDIVERT_VERSION_MINOR)
#define WINDIVERT_DEVICE_NAME \
L"WinDivert" WINDIVERT_VERSION_LSTR
#define WINDIVERT_IOCTL_VERSION 3
#define WINDIVERT_IOCTL_MAGIC 0xE8D3
#define WINDIVERT_FILTER_FIELD_ZERO 0
#define WINDIVERT_FILTER_FIELD_INBOUND 1
#define WINDIVERT_FILTER_FIELD_OUTBOUND 2
#define WINDIVERT_FILTER_FIELD_IFIDX 3
#define WINDIVERT_FILTER_FIELD_SUBIFIDX 4
#define WINDIVERT_FILTER_FIELD_IP 5
#define WINDIVERT_FILTER_FIELD_IPV6 6
#define WINDIVERT_FILTER_FIELD_ICMP 7
#define WINDIVERT_FILTER_FIELD_TCP 8
#define WINDIVERT_FILTER_FIELD_UDP 9
#define WINDIVERT_FILTER_FIELD_ICMPV6 10
#define WINDIVERT_FILTER_FIELD_IP_HDRLENGTH 11
#define WINDIVERT_FILTER_FIELD_IP_TOS 12
#define WINDIVERT_FILTER_FIELD_IP_LENGTH 13
#define WINDIVERT_FILTER_FIELD_IP_ID 14
#define WINDIVERT_FILTER_FIELD_IP_DF 15
#define WINDIVERT_FILTER_FIELD_IP_MF 16
#define WINDIVERT_FILTER_FIELD_IP_FRAGOFF 17
#define WINDIVERT_FILTER_FIELD_IP_TTL 18
#define WINDIVERT_FILTER_FIELD_IP_PROTOCOL 19
#define WINDIVERT_FILTER_FIELD_IP_CHECKSUM 20
#define WINDIVERT_FILTER_FIELD_IP_SRCADDR 21
#define WINDIVERT_FILTER_FIELD_IP_DSTADDR 22
#define WINDIVERT_FILTER_FIELD_IPV6_TRAFFICCLASS 23
#define WINDIVERT_FILTER_FIELD_IPV6_FLOWLABEL 24
#define WINDIVERT_FILTER_FIELD_IPV6_LENGTH 25
#define WINDIVERT_FILTER_FIELD_IPV6_NEXTHDR 26
#define WINDIVERT_FILTER_FIELD_IPV6_HOPLIMIT 27
#define WINDIVERT_FILTER_FIELD_IPV6_SRCADDR 28
#define WINDIVERT_FILTER_FIELD_IPV6_DSTADDR 29
#define WINDIVERT_FILTER_FIELD_ICMP_TYPE 30
#define WINDIVERT_FILTER_FIELD_ICMP_CODE 31
#define WINDIVERT_FILTER_FIELD_ICMP_CHECKSUM 32
#define WINDIVERT_FILTER_FIELD_ICMP_BODY 33
#define WINDIVERT_FILTER_FIELD_ICMPV6_TYPE 34
#define WINDIVERT_FILTER_FIELD_ICMPV6_CODE 35
#define WINDIVERT_FILTER_FIELD_ICMPV6_CHECKSUM 36
#define WINDIVERT_FILTER_FIELD_ICMPV6_BODY 37
#define WINDIVERT_FILTER_FIELD_TCP_SRCPORT 38
#define WINDIVERT_FILTER_FIELD_TCP_DSTPORT 39
#define WINDIVERT_FILTER_FIELD_TCP_SEQNUM 40
#define WINDIVERT_FILTER_FIELD_TCP_ACKNUM 41
#define WINDIVERT_FILTER_FIELD_TCP_HDRLENGTH 42
#define WINDIVERT_FILTER_FIELD_TCP_URG 43
#define WINDIVERT_FILTER_FIELD_TCP_ACK 44
#define WINDIVERT_FILTER_FIELD_TCP_PSH 45
#define WINDIVERT_FILTER_FIELD_TCP_RST 46
#define WINDIVERT_FILTER_FIELD_TCP_SYN 47
#define WINDIVERT_FILTER_FIELD_TCP_FIN 48
#define WINDIVERT_FILTER_FIELD_TCP_WINDOW 49
#define WINDIVERT_FILTER_FIELD_TCP_CHECKSUM 50
#define WINDIVERT_FILTER_FIELD_TCP_URGPTR 51
#define WINDIVERT_FILTER_FIELD_TCP_PAYLOADLENGTH 52
#define WINDIVERT_FILTER_FIELD_UDP_SRCPORT 53
#define WINDIVERT_FILTER_FIELD_UDP_DSTPORT 54
#define WINDIVERT_FILTER_FIELD_UDP_LENGTH 55
#define WINDIVERT_FILTER_FIELD_UDP_CHECKSUM 56
#define WINDIVERT_FILTER_FIELD_UDP_PAYLOADLENGTH 57
#define WINDIVERT_FILTER_FIELD_MAX \
WINDIVERT_FILTER_FIELD_UDP_PAYLOADLENGTH
#define WINDIVERT_FILTER_TEST_EQ 0
#define WINDIVERT_FILTER_TEST_NEQ 1
#define WINDIVERT_FILTER_TEST_LT 2
#define WINDIVERT_FILTER_TEST_LEQ 3
#define WINDIVERT_FILTER_TEST_GT 4
#define WINDIVERT_FILTER_TEST_GEQ 5
#define WINDIVERT_FILTER_TEST_MAX WINDIVERT_FILTER_TEST_GEQ
#define WINDIVERT_FILTER_MAXLEN 32
#define WINDIVERT_FILTER_RESULT_ACCEPT (WINDIVERT_FILTER_MAXLEN+1)
#define WINDIVERT_FILTER_RESULT_REJECT (WINDIVERT_FILTER_MAXLEN+2)
/*
* WinDivert layers.
*/
#define WINDIVERT_LAYER_DEFAULT WINDIVERT_LAYER_NETWORK
#define WINDIVERT_LAYER_MAX \
WINDIVERT_LAYER_NETWORK_FORWARD
/*
* WinDivert flags.
*/
#define WINDIVERT_FLAGS_ALL \
(WINDIVERT_FLAG_SNIFF | WINDIVERT_FLAG_DROP | WINDIVERT_FLAG_PASSTHRU | \
WINDIVERT_FLAG_NO_CHECKSUM)
#define WINDIVERT_FLAGS_EXCLUDE(flags, flag1, flag2) \
(((flags) & ((flag1) | (flag2))) != ((flag1) | (flag2)))
#define WINDIVERT_FLAGS_VALID(flags) \
((((flags) & ~WINDIVERT_FLAGS_ALL) == 0) && \
WINDIVERT_FLAGS_EXCLUDE(flags, WINDIVERT_FLAG_SNIFF, \
WINDIVERT_FLAG_DROP) && \
WINDIVERT_FLAGS_EXCLUDE(flags, WINDIVERT_FLAG_SNIFF, \
WINDIVERT_FLAG_PASSTHRU) && \
WINDIVERT_FLAGS_EXCLUDE(flags, WINDIVERT_FLAG_DROP, \
WINDIVERT_FLAG_PASSTHRU))
/*
* WinDivert priorities.
*/
#define WINDIVERT_PRIORITY(priority16) \
((UINT32)((INT32)(priority16) + 0x7FFF + 1))
#define WINDIVERT_PRIORITY_DEFAULT WINDIVERT_PRIORITY(0)
#define WINDIVERT_PRIORITY_MAX WINDIVERT_PRIORITY(1000)
/*
* WinDivert parameters.
*/
#define WINDIVERT_PARAM_QUEUE_LEN_DEFAULT 1024
#define WINDIVERT_PARAM_QUEUE_LEN_MIN 1
#define WINDIVERT_PARAM_QUEUE_LEN_MAX 8192
#define WINDIVERT_PARAM_QUEUE_TIME_DEFAULT 512
#define WINDIVERT_PARAM_QUEUE_TIME_MIN 128
#define WINDIVERT_PARAM_QUEUE_TIME_MAX 2048
/*
* WinDivert message definitions.
*/
#pragma pack(push, 1)
struct windivert_ioctl_s
{
UINT16 magic; // WINDIVERT_IOCTL_MAGIC
UINT8 version; // WINDIVERT_IOCTL_VERSION
UINT8 arg8; // 8-bit argument
UINT64 arg; // 64-bit argument
};
typedef struct windivert_ioctl_s *windivert_ioctl_t;
/*
* WinDivert IOCTL structures.
*/
struct windivert_ioctl_filter_s
{
UINT8 field; // WINDIVERT_FILTER_FIELD_IP_*
UINT8 test; // WINDIVERT_FILTER_TEST_*
UINT16 success; // Success continuation.
UINT16 failure; // Fail continuation.
UINT32 arg[4]; // Argument.
};
typedef struct windivert_ioctl_filter_s *windivert_ioctl_filter_t;
#pragma pack(pop)
/*
* IOCTL codes.
*/
#define IOCTL_WINDIVERT_RECV \
CTL_CODE(FILE_DEVICE_NETWORK, 0x908, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_SEND \
CTL_CODE(FILE_DEVICE_NETWORK, 0x909, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_START_FILTER \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90A, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_SET_LAYER \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90B, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_SET_PRIORITY \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90C, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_SET_FLAGS \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90D, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_SET_PARAM \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90E, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_WINDIVERT_GET_PARAM \
CTL_CODE(FILE_DEVICE_NETWORK, 0x90F, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#endif /* __WINDIVERT_DEVICE_H */
+3 -3
View File
@@ -1,7 +1,7 @@
#!/bin/bash
#
# mingw-build.sh
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@@ -45,8 +45,8 @@ do
echo "\tmake install/MINGW/$CPU..."
mkdir -p "install/MINGW/$CPU"
echo "\tbuild install/MINGW/$CPU/WinDivert.dll..."
$CC -Wall -O2 -Iinclude/ -c dll/divert.c -o dll/divert.o
$CC -Wall -shared -o "install/MINGW/$CPU/WinDivert.dll" dll/divert.o
$CC -Wall -O2 -Iinclude/ -c dll/windivert.c -o dll/windivert.o
$CC -Wall -shared -o "install/MINGW/$CPU/WinDivert.dll" dll/windivert.o
$STRIP --strip-debug "install/MINGW/$CPU/WinDivert.dll"
echo "\tbuild install/MINGW/$CPU/netdump.exe..."
$CC -s -O2 -Iinclude/ examples/netdump/netdump.c \
+1 -1
View File
@@ -1,5 +1,5 @@
:: msvc-build.bat
:: (C) 2012, all rights reserved,
:: (C) 2013, all rights reserved,
::
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU Lesser General Public License as published by
+6 -6
View File
@@ -1,6 +1,6 @@
#!/bin/bash
#
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@@ -44,16 +44,16 @@ do
cp VERSION $INSTALL
echo "\tmake $INSTALL/include..."
mkdir -p $INSTALL/include
echo "\tcopy $INSTALL/include/divert.h..."
cp include/divert.h $INSTALL/include
echo "\tcopy $INSTALL/include/windivert.h..."
cp include/windivert.h $INSTALL/include
echo "\tmake $INSTALL/doc..."
mkdir -p $INSTALL/doc
echo "\tcopy $INSTALL/doc/WinDivert.html..."
cp doc/divert.html $INSTALL/doc/WinDivert.html
cp doc/windivert.html $INSTALL/doc/WinDivert.html
echo "\tmake $INSTALL/x86..."
mkdir -p $INSTALL/x86
echo "\tcopy $INSTALL/x86/WinDivert.inf..."
cp sys/divert.inf $INSTALL/x86/WinDivert.inf
cp sys/windivert.inf $INSTALL/x86/WinDivert.inf
echo "\tcopy $INSTALL/x86/WinDivert.sys..."
cp install/$TARGET/i386/WinDivert.sys $INSTALL/x86
if ! grep "DigiCert High Assurance EV Root" $INSTALL/x86/WinDivert.sys \
@@ -88,7 +88,7 @@ do
echo "\tmake $INSTALL/amd64..."
mkdir -p $INSTALL/amd64
echo "\tcopy $INSTALL/amd64/WinDivert.inf..."
cp sys/divert.inf $INSTALL/amd64/WinDivert.inf
cp sys/windivert.inf $INSTALL/amd64/WinDivert.inf
echo "\tcopy $INSTALL/amd64/WinDivert.sys..."
cp install/$TARGET/amd64/WinDivert.sys $INSTALL/amd64
if ! grep "DigiCert High Assurance EV Root" \
+2 -2
View File
@@ -4,7 +4,7 @@ CPU=i386
CPU=$(_BUILDARCH)
!ENDIF
$(TARGETPATH)\$(CPU)\WinDivert.inf: divert.inf
copy /y divert.inf $@
$(TARGETPATH)\$(CPU)\WinDivert.inf: windivert.inf
copy /y windivert.inf $@
$(TARGETPATH)\$(CPU)\WdfCoInstaller01009.dll:
copy /y $(BASEDIR)\redist\wdf\$(_BUILDARCH)\WdfCoInstaller01009.dll $@
-9
View File
@@ -1,9 +0,0 @@
[Version]
Signature="$WINDOWS NT$"
[divert.NT.Wdf]
KmdfService = divert, divert_WdfSection
[divert_WdfSection]
KmdfLibraryVersion = 1.9
+2 -2
View File
@@ -1,5 +1,5 @@
# sources
# (C) 2012, all rights reserved,
# (C) 2013, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
@@ -35,5 +35,5 @@ KMDF_VERSION_MAJOR=1
C_DEFINES=$(C_DEFINES) -DBINARY_COMPATIBLE=0 -DNT -DUNICODE -D_UNICODE \
-DNDIS60 -DNDIS_SUPPORT_NDIS60
INCLUDES=$(DDK_INC_PATH);..\include
SOURCES=divert.rc divert.c
SOURCES=windivert.rc windivert.c
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
[Version]
Signature="$WINDOWS NT$"
[windivert.NT.Wdf]
KmdfService = windivert, windivert_WdfSection
[windivert_WdfSection]
KmdfLibraryVersion = 1.9
+4 -4
View File
@@ -1,5 +1,5 @@
/*
* divert.rc
* windivert.rc
* (C) 2013, all rights reserved,
*
* This program is free software: you can redistribute it and/or modify
@@ -25,9 +25,9 @@
"WinDivert network packet capture and (re)injection driver"
#define VER_INTERNALNAME_STR "WinDivert.sys"
#define VER_ORIGINALFILENAME_STR "WinDivert.sys"
#define VER_PRODUCTVERSION 1.0
#define VER_PRODUCTVERSION_STR "1.0"
#define VER_COMPANYNAME_STR "basil"
#define VER_PRODUCTVERSION 1.1
#define VER_PRODUCTVERSION_STR "1.1"
#define VER_COMPANYNAME_STR "Basil Projects"
#define VER_LEGALCOPYRIGHT_YEARS "2011-2013"
#define VER_LEGALCOPYRIGHT_STR \
"Copyright \251 " VER_COMPANYNAME_STR " " VER_LEGALCOPYRIGHT_YEARS
+1 -1
View File
@@ -1,5 +1,5 @@
:: wddk-build.bat
:: (C) 2012, all rights reserved,
:: (C) 2013, all rights reserved,
::
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU Lesser General Public License as published by