aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-07-22 11:13:20 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-07-31 13:59:54 +0000
commit999a6744db6e33ddabb5de0d260b121e69d09d1e (patch)
treeaafbb5d060178c6ee4b1ba0e8cf7067e7b61639b
parentCleanup TUN_FLAGS_PRESENT (diff)
downloadwintun-999a6744db6e33ddabb5de0d260b121e69d09d1e.tar.xz
wintun-999a6744db6e33ddabb5de0d260b121e69d09d1e.zip
Assert that adapter is always running when client is registering rings
By attaching to NDIS device instead of creating our own device for I/O, the adapter is always running before client is able to connect and register rings. NDIS also won't allow adapter to pause with connected clients. Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r--wintun.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/wintun.c b/wintun.c
index 62b2485..0e19ee9 100644
--- a/wintun.c
+++ b/wintun.c
@@ -606,6 +606,8 @@ TunRegisterBuffers(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
if (InterlockedCompareExchangePointer(&Ctx->Device.Owner, Stack->FileObject, NULL) != NULL)
return STATUS_ALREADY_INITIALIZED;
+ ASSERT(InterlockedGet(&Ctx->Flags) & TUN_FLAGS_RUNNING);
+
TUN_REGISTER_RINGS *Rrb = Irp->AssociatedIrp.SystemBuffer;
if (Status = STATUS_INVALID_PARAMETER, Stack->Parameters.DeviceIoControl.InputBufferLength != sizeof(*Rrb))
goto cleanupResetOwner;