Skip to content

Commit e306d00

Browse files
committed
WinDivert filter language improvements.
- Add "length" for total packet length. - Add "timestamp" for timestamp filtering. - All filter language numbers are now signed. - Add new macros: TRUE, FALSE, TCP, UDP, ICMP & ICMPV6. - Future-proof the WINDIVERT_FILTER struct.
1 parent d29688e commit e306d00

File tree

11 files changed

+402
-119
lines changed

11 files changed

+402
-119
lines changed

CHANGELOG

+11-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ WinDivert 2.0.0-rc
186186
operation occurred.
187187
- The WinDivert filter language has been expanded with new fields:
188188
* event: The event value.
189-
* processId: (FLOW/SOCKET/REFLECT layers) the process Id.
189+
* timestamp: The event timestamp.
190+
* endpointId: (FLOW/SOCKET layers) the endpoint ID.
191+
* parentEndpointId: (FLOW/SOCKET layers) the parent endpoint ID.
192+
* processId: (FLOW/SOCKET/REFLECT layers) the process ID.
190193
* localAddr: (NETWORK/NETWORK_FORWARD/FLOW/SOCKET layers) the local
191194
address.
192195
* localPort: (NETWORK/NETWORK_FORWARD/FLOW/SOCKET layers) the local
@@ -204,6 +207,7 @@ WinDivert 2.0.0-rc
204207
number.
205208
* random32: (NETWORK/NETWORK_FORWARD layers) a 32-bit pseudo random
206209
number.
210+
* length: (NETWORK/NETWORK_FORWARD layers) the packet length.
207211
* zero: The value "0".
208212
- The WinDivert filter language can now address packet/payload data for
209213
the NETWORK/NETWORK_FORWARD layers:
@@ -241,6 +245,12 @@ WinDivert 2.0.0-rc
241245
* FLOW: (REFLECT layer) equal to WINDIVERT_LAYER_FLOW.
242246
* SOCKET: (REFLECT layer) equal to WINDIVERT_LAYER_SOCKET.
243247
* REFLECT: (REFLECT layer) equal to WINDIVERT_LAYER_REFLECT.
248+
* TRUE: equal to 1.
249+
* FALSE: equal to 0.
250+
* TCP: equal to IPPROTO_TCP (6).
251+
* UDP: equal to IPPROTO_UDP (17).
252+
* ICMP: equal to IPPROTO_ICMP (1).
253+
* ICMPV6: equal to IPPROTO_ICMPV6 (58).
244254
- WinDivertOpen() now supports several new flags:
245255
* WINDIVERT_FLAG_RECV_ONLY/WINDIVERT_FLAG_READ_ONLY: The handle cannot
246256
be used for send operations.

dll/windivert.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,20 @@ extern HANDLE WinDivertOpen(const char *filter, WINDIVERT_LAYER layer,
386386
WINDIVERT_IOCTL ioctl;
387387
WINDIVERT_VERSION version;
388388

389-
// Parameter checking.
389+
// Static checks (should be compiled away if TRUE):
390+
if (sizeof(WINDIVERT_ADDRESS) != 80 ||
391+
sizeof(WINDIVERT_DATA_NETWORK) != 8 ||
392+
offsetof(WINDIVERT_DATA_FLOW, Protocol) != 56 ||
393+
offsetof(WINDIVERT_DATA_SOCKET, Protocol) != 56 ||
394+
offsetof(WINDIVERT_DATA_REFLECT, Priority) != 24 ||
395+
sizeof(WINDIVERT_FILTER) != 24 ||
396+
offsetof(WINDIVERT_ADDRESS, Reserved2) != 16)
397+
{
398+
SetLastError(ERROR_INVALID_PARAMETER);
399+
return INVALID_HANDLE_VALUE;
400+
}
401+
402+
// Parameter checking:
390403
switch (layer)
391404
{
392405
case WINDIVERT_LAYER_NETWORK:

0 commit comments

Comments
 (0)