aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/adapter.c43
-rw-r--r--api/adapter.h15
-rw-r--r--api/driver.c4
3 files changed, 0 insertions, 62 deletions
diff --git a/api/adapter.c b/api/adapter.c
index b71032a..6aa6c21 100644
--- a/api/adapter.c
+++ b/api/adapter.c
@@ -191,8 +191,6 @@ WintunCloseAdapter(WINTUN_ADAPTER *Adapter)
if (!Adapter)
return;
Free(Adapter->InterfaceFilename);
- if (Adapter->DevInfo)
- AdapterForceCloseHandles(Adapter->DevInfo, &Adapter->DevInfoData);
if (Adapter->SwDevice)
SwDeviceClose(Adapter->SwDevice);
if (Adapter->DevInfo)
@@ -896,47 +894,6 @@ cleanup:
return RET_ERROR(Adapter, LastError);
}
-#define TUN_IOCTL_FORCE_CLOSE_HANDLES CTL_CODE(51820U, 0x971U, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
-
-_Use_decl_annotations_
-BOOL
-AdapterForceCloseHandles(HDEVINFO DevInfo, SP_DEVINFO_DATA *DevInfoData)
-{
- DWORD LastError = ERROR_SUCCESS;
- WCHAR InstanceId[MAX_INSTANCE_ID];
- DWORD RequiredChars = _countof(InstanceId);
- if (!SetupDiGetDeviceInstanceIdW(DevInfo, DevInfoData, InstanceId, RequiredChars, &RequiredChars))
- {
- LOG_LAST_ERROR(L"Failed to get adapter instance ID");
- return FALSE;
- }
- WINTUN_ADAPTER Adapter = { .InterfaceFilename = AdapterGetDeviceObjectFileName(InstanceId) };
- if (!Adapter.InterfaceFilename)
- {
- LOG_LAST_ERROR(L"Failed to get adapter file name");
- return FALSE;
- }
- HANDLE Handle = AdapterOpenDeviceObject(&Adapter);
- Free(Adapter.InterfaceFilename);
- if (Handle == INVALID_HANDLE_VALUE)
- {
- LastError = LOG(WINTUN_LOG_ERR, L"Failed to get adapter file object");
- return FALSE;
- }
- DWORD RequiredBytes;
- if (DeviceIoControl(Handle, TUN_IOCTL_FORCE_CLOSE_HANDLES, NULL, 0, NULL, 0, &RequiredBytes, NULL))
- {
- LastError = ERROR_SUCCESS;
- Sleep(200);
- }
- else if (GetLastError() == ERROR_NOTHING_TO_TERMINATE)
- LastError = ERROR_SUCCESS;
- else
- LastError = LOG_LAST_ERROR(L"Failed to perform force close ioctl");
- CloseHandle(Handle);
- return RET_ERROR(TRUE, LastError);
-}
-
_Use_decl_annotations_
BOOL
AdapterRemoveInstance(HDEVINFO DevInfo, SP_DEVINFO_DATA *DevInfoData)
diff --git a/api/adapter.h b/api/adapter.h
index ec84d70..567ee82 100644
--- a/api/adapter.h
+++ b/api/adapter.h
@@ -135,18 +135,3 @@ AdapterEnableInstance(_In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA *DevInfoData);
_Return_type_success_(return != FALSE)
BOOL
AdapterDisableInstance(_In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA *DevInfoData);
-
-/**
- * Force closes all device handles of the specified device instance.
- *
- * @param DevInfo Device info handle from SetupAPI.
- * @param DevInfoData Device info data specifying which device.
- *
- * @return If the function succeeds, the return value is TRUE. If the
- * function fails, the return value is FALSE. To get extended
- * error information, call GetLastError.
- */
-
-_Return_type_success_(return != FALSE)
-BOOL
-AdapterForceCloseHandles(_In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA *DevInfoData);
diff --git a/api/driver.c b/api/driver.c
index 3fb4909..172749f 100644
--- a/api/driver.c
+++ b/api/driver.c
@@ -69,10 +69,6 @@ DisableAllOurAdapters(_In_ HDEVINFO DevInfo, _Inout_ SP_DEVINFO_DATA_LIST **Disa
((Status & DN_HAS_PROBLEM) && ProblemCode == CM_PROB_DISABLED))
goto cleanupDeviceNode;
- LOG(WINTUN_LOG_INFO, L"Force closing adapter \"%s\" open handles", Name);
- if (!AdapterForceCloseHandles(DevInfo, &DeviceNode->Data))
- LOG(WINTUN_LOG_WARN, L"Failed to force close adapter \"%s\" open handles", Name);
-
LOG(WINTUN_LOG_INFO, L"Disabling adapter \"%s\"", Name);
if (!AdapterDisableInstance(DevInfo, &DeviceNode->Data))
{