From da3caadf48fc93341a24b0f20606773566f0e2b8 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 19 Jun 2019 09:38:39 +0200 Subject: [PATCH] Accept IRP_MJ_WRITE when paused but silently drop the packets Signed-off-by: Simon Rozman --- wintun.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wintun.c b/wintun.c index 23f2906..f4ba4b4 100644 --- a/wintun.c +++ b/wintun.c @@ -643,8 +643,7 @@ static NTSTATUS TunDispatchWrite(_Inout_ TUN_CTX *ctx, _Inout_ IRP *Irp) KIRQL irql = ExAcquireSpinLockShared(&ctx->TransitionLock); LONG flags = InterlockedGet(&ctx->Flags); - if ((status = STATUS_FILE_FORCED_CLOSED, !(flags & TUN_FLAGS_PRESENT)) || - (status = STATUS_CANCELLED , !(flags & TUN_FLAGS_RUNNING))) + if (status = STATUS_FILE_FORCED_CLOSED, !(flags & TUN_FLAGS_PRESENT)) goto cleanup_ExReleaseSpinLockShared; UCHAR *buffer; @@ -734,6 +733,12 @@ static NTSTATUS TunDispatchWrite(_Inout_ TUN_CTX *ctx, _Inout_ IRP *Irp) status = STATUS_SUCCESS; goto cleanup_ExReleaseSpinLockShared; } + if (!(flags & TUN_FLAGS_RUNNING)) { + InterlockedAdd64((LONG64 *)&ctx->Statistics.ifInDiscards, nbl_count); + InterlockedAdd64((LONG64 *)&ctx->Statistics.ifInErrors, nbl_count); + status = STATUS_SUCCESS; + goto cleanup_nbl_queues; + } InterlockedAdd64(&ctx->ActiveNBLCount, nbl_count); InterlockedExchange(IRP_REFCOUNT(Irp), nbl_count);