diff --git a/Driver.cpp b/Driver.cpp
index 4f5e564..e76473c 100644
--- a/Driver.cpp
+++ b/Driver.cpp
@@ -291,7 +291,9 @@ VOID OvpnEvtDeviceCleanup(WDFOBJECT obj) {
OvpnBufferQueueDelete(device->ControlRxBufferQueue);
OvpnBufferQueueDelete(device->DataRxBufferQueue);
- OvpnAdapterDestroy(device->Adapter);
+ KIRQL irql = ExAcquireSpinLockExclusive(&device->SpinLock);
+ device->Adapter = WDF_NO_HANDLE;
+ ExReleaseSpinLockExclusive(&device->SpinLock, irql);
}
EVT_WDF_DRIVER_DEVICE_ADD OvpnEvtDeviceAdd;
diff --git a/PropertySheet.props b/PropertySheet.props
index 3e80690..6fcd970 100644
--- a/PropertySheet.props
+++ b/PropertySheet.props
@@ -4,7 +4,7 @@
0
7
- 3
+ 4
diff --git a/adapter.cpp b/adapter.cpp
index 5e9f1f6..1d70240 100644
--- a/adapter.cpp
+++ b/adapter.cpp
@@ -104,27 +104,6 @@ OvpnAdapterSetLinkState(POVPN_ADAPTER adapter, NET_IF_MEDIA_CONNECT_STATE state)
NetAdapterSetLinkState(adapter->NetAdapter, &linkState);
}
-
-_Use_decl_annotations_
-VOID
-OvpnAdapterDestroy(NETADAPTER netAdapter)
-{
- if (netAdapter == WDF_NO_HANDLE)
- return;
-
- POVPN_ADAPTER adapter = OvpnGetAdapterContext(netAdapter);
- POVPN_DEVICE device = OvpnGetDeviceContext(adapter->WdfDevice);
-
- KIRQL irql = ExAcquireSpinLockExclusive(&device->SpinLock);
- device->Adapter = WDF_NO_HANDLE;
- ExReleaseSpinLockExclusive(&device->SpinLock, irql);
-
- // TODO: this breaks on Windows 10 when called from EvtCleanupCallback, is this call even needed?
- // NetAdapterStop(netAdapter);
-
- WdfObjectDelete(netAdapter);
-}
-
EVT_NET_ADAPTER_CREATE_TXQUEUE OvpnEvtAdapterCreateTxQueue;
_Use_decl_annotations_
diff --git a/adapter.h b/adapter.h
index b04b857..2eb0a3a 100644
--- a/adapter.h
+++ b/adapter.h
@@ -48,10 +48,6 @@ _IRQL_requires_same_
NTSTATUS
OvpnAdapterCreate(OVPN_DEVICE* device);
-_IRQL_requires_(PASSIVE_LEVEL)
-VOID
-OvpnAdapterDestroy(NETADAPTER netAdapter);
-
// notify NetAdapter (if it is ready) that more packets are available
NTSTATUS
OvpnAdapterNotifyRx(NETADAPTER netAdapter);