Reverse order of WinDivert handle priorities.
Higher values now correspond to higher priorities.
This commit is contained in:
@@ -276,3 +276,7 @@ WinDivert 2.0.0-rc
|
||||
ip.TTL/ipv6.HopLimit field of a packet.
|
||||
- Add new WinDivertHelperNto*()/WinDivertHelperHton*() helper functions
|
||||
for swapping from network to host byte ordering, and vice versa.
|
||||
- WinDivertOpen() priorities now are ascending, meaning that higher
|
||||
values correspond to higher priorities.
|
||||
- The last two arguments for WinDivertRecv() and WinDivertSend() have been
|
||||
swapped.
|
||||
|
||||
+2
-2
@@ -300,8 +300,8 @@ extern WINDIVERTEXPORT BOOL WinDivertGetParam(
|
||||
/*
|
||||
* WinDivert constants.
|
||||
*/
|
||||
#define WINDIVERT_PRIORITY_LOWEST 30000
|
||||
#define WINDIVERT_PRIORITY_HIGHEST (-WINDIVERT_PRIORITY_LOWEST)
|
||||
#define WINDIVERT_PRIORITY_HIGHEST 30000
|
||||
#define WINDIVERT_PRIORITY_LOWEST (-WINDIVERT_PRIORITY_HIGHEST)
|
||||
#define WINDIVERT_PARAM_QUEUE_LENGTH_DEFAULT 4096
|
||||
#define WINDIVERT_PARAM_QUEUE_LENGTH_MIN 32
|
||||
#define WINDIVERT_PARAM_QUEUE_LENGTH_MAX 16384
|
||||
|
||||
@@ -219,8 +219,8 @@
|
||||
/*
|
||||
* WinDivert priorities.
|
||||
*/
|
||||
#define WINDIVERT_PRIORITY_MAX WINDIVERT_PRIORITY_LOWEST
|
||||
#define WINDIVERT_PRIORITY_MIN WINDIVERT_PRIORITY_HIGHEST
|
||||
#define WINDIVERT_PRIORITY_MAX WINDIVERT_PRIORITY_HIGHEST
|
||||
#define WINDIVERT_PRIORITY_MIN WINDIVERT_PRIORITY_LOWEST
|
||||
|
||||
/*
|
||||
* WinDivert message definitions.
|
||||
|
||||
+3
-8
@@ -317,7 +317,7 @@ static MM_PAGE_PRIORITY no_write_flag = 0;
|
||||
static MM_PAGE_PRIORITY no_exec_flag = 0;
|
||||
|
||||
/*
|
||||
* Priorities & weights.
|
||||
* Priorities.
|
||||
*/
|
||||
static UINT32 windivert_context_priority(UINT32 priority)
|
||||
{
|
||||
@@ -328,9 +328,6 @@ static UINT32 windivert_context_priority(UINT32 priority)
|
||||
return priority;
|
||||
}
|
||||
|
||||
#define WINDIVERT_FILTER_WEIGHT(priority) \
|
||||
((UINT64)((UINT64)UINT32_MAX - (priority)))
|
||||
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
@@ -1674,7 +1671,7 @@ static NTSTATUS windivert_install_callout(context_t context, UINT idx,
|
||||
engine_handle = context->engine_handle;
|
||||
KeReleaseInStackQueuedSpinLock(&lock_handle);
|
||||
|
||||
weight = WINDIVERT_FILTER_WEIGHT(priority);
|
||||
weight = (UINT64)priority;
|
||||
|
||||
RtlZeroMemory(&scallout, sizeof(scallout));
|
||||
scallout.calloutKey = callout_guid;
|
||||
@@ -1876,7 +1873,6 @@ extern VOID windivert_cleanup(IN WDFFILEOBJECT object)
|
||||
WDFWORKITEM worker;
|
||||
LONGLONG timestamp;
|
||||
BOOL sniff_mode, timeout, forward;
|
||||
UINT priority;
|
||||
NTSTATUS status;
|
||||
|
||||
DEBUG("CLEANUP: cleaning up WinDivert context (context=%p)", context);
|
||||
@@ -1897,7 +1893,6 @@ windivert_cleanup_error:
|
||||
context->state = WINDIVERT_CONTEXT_STATE_CLOSING;
|
||||
sniff_mode = ((context->flags & WINDIVERT_FLAG_SNIFF) != 0);
|
||||
forward = (context->layer == WINDIVERT_LAYER_NETWORK_FORWARD);
|
||||
priority = context->priority;
|
||||
while (!IsListEmpty(&context->flow_set))
|
||||
{
|
||||
entry = RemoveHeadList(&context->flow_set);
|
||||
@@ -3664,7 +3659,7 @@ static void windivert_network_classify(context_t context,
|
||||
packet_state == FWPS_PACKET_PREVIOUSLY_INJECTED_BY_SELF)
|
||||
{
|
||||
packet_priority = (UINT32)packet_context;
|
||||
if (packet_priority >= priority)
|
||||
if (packet_priority <= priority)
|
||||
{
|
||||
WdfObjectDereference(object);
|
||||
return;
|
||||
|
||||
+5
-5
@@ -855,9 +855,9 @@ int main(void)
|
||||
// Open handles to:
|
||||
// (1) stop normal traffic from interacting with the tests; and
|
||||
// (2) stop test packets escaping to the Internet or TCP/IP stack.
|
||||
upper_handle = WinDivertOpen("true", WINDIVERT_LAYER_NETWORK, -999,
|
||||
upper_handle = WinDivertOpen("true", WINDIVERT_LAYER_NETWORK, 9999,
|
||||
WINDIVERT_FLAG_DROP);
|
||||
lower_handle = WinDivertOpen("true", WINDIVERT_LAYER_NETWORK, 999,
|
||||
lower_handle = WinDivertOpen("true", WINDIVERT_LAYER_NETWORK, -9999,
|
||||
WINDIVERT_FLAG_DROP);
|
||||
if (upper_handle == INVALID_HANDLE_VALUE ||
|
||||
lower_handle == INVALID_HANDLE_VALUE)
|
||||
@@ -1018,14 +1018,14 @@ static BOOL run_test(HANDLE inject_handle, const char *filter,
|
||||
}
|
||||
|
||||
// (1) Open WinDivert handles:
|
||||
handle[0] = WinDivertOpen(object, WINDIVERT_LAYER_NETWORK, 777, 0);
|
||||
handle[0] = WinDivertOpen(object, WINDIVERT_LAYER_NETWORK, 8888, 0);
|
||||
if (handle[0] == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fprintf(stderr, "error: failed to open WinDivert handle for filter "
|
||||
"\"%s\" (err = %d)\n", filter, GetLastError());
|
||||
goto failed;
|
||||
}
|
||||
handle[1] = WinDivertOpen("true", WINDIVERT_LAYER_NETWORK, 888, 0);
|
||||
handle[1] = WinDivertOpen("true", WINDIVERT_LAYER_NETWORK, 7777, 0);
|
||||
if (handle[1] == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fprintf(stderr, "error: failed to open WinDivert handle "
|
||||
@@ -1244,7 +1244,7 @@ static DWORD monitor_worker(LPVOID arg)
|
||||
PWINDIVERT_IPHDR iphdr;
|
||||
UINT i;
|
||||
|
||||
snprintf(filter, sizeof(filter), "processId=%d and priority=777 and "
|
||||
snprintf(filter, sizeof(filter), "processId=%d and priority=8888 and "
|
||||
"event=OPEN", GetCurrentProcessId());
|
||||
HANDLE handle = WinDivertOpen(filter, WINDIVERT_LAYER_REFLECT, 0,
|
||||
WINDIVERT_FLAG_SNIFF | WINDIVERT_FLAG_RECV_ONLY);
|
||||
|
||||
Reference in New Issue
Block a user