From 17e9e17826ef6f89129cb3515f3dac88be268935 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 31 May 2019 08:42:36 +0200 Subject: [PATCH] Upgrade to VS2019 and update CSQ locking for analysis Signed-off-by: Simon Rozman --- README.md | 4 ++-- wintun.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9da3f1d..ae56e62 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is a layer 3 TUN driver for Windows 7, 8, 8.1, and 10. Originally created f ## Build Requirements -- [Visual Studio 2017](https://visualstudio.microsoft.com/downloads/) +- [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) - [Windows Driver Kit for Windows 10](https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) - [WiX Toolset 3.11.1](http://wixtoolset.org/releases/) @@ -35,7 +35,7 @@ If you already have `wintun.vcxproj.user` file, just add the `` s ## Building from Command Line -Open _Developer Command Prompt for VS 2017_ and use the `msbuild` command: +Open _Developer Command Prompt for VS 2019_ and use the `msbuild` command: ``` msbuild wintun.proj [/t:] diff --git a/wintun.c b/wintun.c index 0217596..9718e7b 100644 --- a/wintun.c +++ b/wintun.c @@ -217,19 +217,19 @@ static IRP *TunCsqPeekNextIrp(IO_CSQ *Csq, IRP *Irp, _In_ PVOID PeekContext) _IRQL_raises_(DISPATCH_LEVEL) _IRQL_requires_max_(DISPATCH_LEVEL) +_Requires_lock_not_held_(CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq)->Device.ReadQueue.Lock) _Acquires_lock_(CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq)->Device.ReadQueue.Lock) static VOID TunCsqAcquireLock(_In_ IO_CSQ *Csq, _Out_ _At_(*Irql, _Post_ _IRQL_saves_) KIRQL *Irql) { - TUN_CTX *ctx = CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq); - KeAcquireSpinLock(&ctx->Device.ReadQueue.Lock, Irql); + KeAcquireSpinLock(&CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq)->Device.ReadQueue.Lock, Irql); } _IRQL_requires_(DISPATCH_LEVEL) +_Requires_lock_held_(CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq)->Device.ReadQueue.Lock) _Releases_lock_(CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq)->Device.ReadQueue.Lock) static VOID TunCsqReleaseLock(_In_ IO_CSQ *Csq, _In_ _IRQL_restores_ KIRQL Irql) { - TUN_CTX *ctx = CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq); - KeReleaseSpinLock(&ctx->Device.ReadQueue.Lock, Irql); + KeReleaseSpinLock(&CONTAINING_RECORD(Csq, TUN_CTX, Device.ReadQueue.Csq)->Device.ReadQueue.Lock, Irql); } static IO_CSQ_COMPLETE_CANCELED_IRP TunCsqCompleteCanceledIrp;