api: remove WintunOpenAdapterDeviceObject
Discourage use of kernel interface, which gives us more flexibility if we ever want to change it. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
1e00f310ec
commit
9f3d466791
14
README.md
14
README.md
@ -243,20 +243,6 @@ Deletes all Wintun adapters in a pool and if there are no more adapters in any o
|
|||||||
|
|
||||||
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||||
|
|
||||||
#### WintunOpenAdapterDeviceObject()
|
|
||||||
|
|
||||||
`HANDLE WintunOpenAdapterDeviceObject (WINTUN_ADAPTER_HANDLE Adapter)`
|
|
||||||
|
|
||||||
Returns a handle to the adapter device object.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
|
|
||||||
|
|
||||||
**Returns**
|
|
||||||
|
|
||||||
If the function succeeds, the return value is adapter device object handle. Must be released with CloseHandle. If the function fails, the return value is INVALID\_HANDLE\_VALUE. To get extended error information, call GetLastError.
|
|
||||||
|
|
||||||
#### WintunGetAdapterLuid()
|
#### WintunGetAdapterLuid()
|
||||||
|
|
||||||
`void WintunGetAdapterLuid (WINTUN_ADAPTER_HANDLE Adapter, NET_LUID * Luid)`
|
`void WintunGetAdapterLuid (WINTUN_ADAPTER_HANDLE Adapter, NET_LUID * Luid)`
|
||||||
|
@ -824,7 +824,7 @@ WintunGetAdapterLUID(_In_ const WINTUN_ADAPTER *Adapter, _Out_ NET_LUID *Luid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Return_type_success_(return != INVALID_HANDLE_VALUE) HANDLE WINAPI
|
_Return_type_success_(return != INVALID_HANDLE_VALUE) HANDLE WINAPI
|
||||||
WintunOpenAdapterDeviceObject(_In_ const WINTUN_ADAPTER *Adapter)
|
AdapterOpenDeviceObject(_In_ const WINTUN_ADAPTER *Adapter)
|
||||||
{
|
{
|
||||||
return OpenDeviceObject(Adapter->DevInstanceID);
|
return OpenDeviceObject(Adapter->DevInstanceID);
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,6 @@ typedef struct _WINTUN_ADAPTER
|
|||||||
void WINAPI
|
void WINAPI
|
||||||
WintunFreeAdapter(_In_ WINTUN_ADAPTER *Adapter);
|
WintunFreeAdapter(_In_ WINTUN_ADAPTER *Adapter);
|
||||||
|
|
||||||
/**
|
|
||||||
* @copydoc WINTUN_OPEN_ADAPTER_DEVICE_OBJECT_FUNC
|
|
||||||
*/
|
|
||||||
_Return_type_success_(return != INVALID_HANDLE_VALUE) HANDLE WINAPI
|
|
||||||
WintunOpenAdapterDeviceObject(_In_ const WINTUN_ADAPTER *Adapter);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc WINTUN_CREATE_ADAPTER_FUNC
|
* @copydoc WINTUN_CREATE_ADAPTER_FUNC
|
||||||
*/
|
*/
|
||||||
@ -62,3 +56,15 @@ _Return_type_success_(return != FALSE) BOOL WINAPI WintunDeleteAdapter(
|
|||||||
*/
|
*/
|
||||||
_Return_type_success_(return != FALSE) BOOL WINAPI
|
_Return_type_success_(return != FALSE) BOOL WINAPI
|
||||||
WintunDeletePoolDriver(_In_z_ const WCHAR *Pool, _Out_opt_ BOOL *RebootRequired);
|
WintunDeletePoolDriver(_In_z_ const WCHAR *Pool, _Out_opt_ BOOL *RebootRequired);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a handle to the adapter device object.
|
||||||
|
*
|
||||||
|
* @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
|
||||||
|
*
|
||||||
|
* @return If the function succeeds, the return value is adapter device object handle. Must be released with
|
||||||
|
* CloseHandle. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error
|
||||||
|
* information, call GetLastError.
|
||||||
|
*/
|
||||||
|
_Return_type_success_(return != INVALID_HANDLE_VALUE) HANDLE WINAPI
|
||||||
|
AdapterOpenDeviceObject(_In_ const WINTUN_ADAPTER *Adapter);
|
@ -8,7 +8,6 @@ EXPORTS
|
|||||||
WintunEnumAdapters
|
WintunEnumAdapters
|
||||||
WintunFreeAdapter
|
WintunFreeAdapter
|
||||||
WintunOpenAdapter
|
WintunOpenAdapter
|
||||||
WintunOpenAdapterDeviceObject
|
|
||||||
WintunGetAdapterLUID
|
WintunGetAdapterLUID
|
||||||
WintunGetAdapterName
|
WintunGetAdapterName
|
||||||
WintunGetReadWaitEvent
|
WintunGetReadWaitEvent
|
||||||
|
@ -109,7 +109,7 @@ _Return_type_success_(return != NULL) TUN_SESSION *WINAPI
|
|||||||
goto cleanupSendTailMoved;
|
goto cleanupSendTailMoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session->Handle = WintunOpenAdapterDeviceObject(Adapter);
|
Session->Handle = AdapterOpenDeviceObject(Adapter);
|
||||||
if (Session->Handle == INVALID_HANDLE_VALUE)
|
if (Session->Handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
LastError = LOG(WINTUN_LOG_ERR, L"Failed to open adapter device object");
|
LastError = LOG(WINTUN_LOG_ERR, L"Failed to open adapter device object");
|
||||||
|
12
api/wintun.h
12
api/wintun.h
@ -131,18 +131,6 @@ typedef void(WINAPI *WINTUN_FREE_ADAPTER_FUNC)(_In_ WINTUN_ADAPTER_HANDLE Adapte
|
|||||||
typedef _Return_type_success_(return != FALSE)
|
typedef _Return_type_success_(return != FALSE)
|
||||||
BOOL(WINAPI *WINTUN_DELETE_POOL_DRIVER_FUNC)(_In_z_ const WCHAR *Pool, _Out_opt_ BOOL *RebootRequired);
|
BOOL(WINAPI *WINTUN_DELETE_POOL_DRIVER_FUNC)(_In_z_ const WCHAR *Pool, _Out_opt_ BOOL *RebootRequired);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a handle to the adapter device object.
|
|
||||||
*
|
|
||||||
* @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
|
|
||||||
*
|
|
||||||
* @return If the function succeeds, the return value is adapter device object handle. Must be released with
|
|
||||||
* CloseHandle. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error
|
|
||||||
* information, call GetLastError.
|
|
||||||
*/
|
|
||||||
typedef _Return_type_success_(return != INVALID_HANDLE_VALUE)
|
|
||||||
HANDLE(WINAPI *WINTUN_OPEN_ADAPTER_DEVICE_OBJECT_FUNC)(_In_ WINTUN_ADAPTER_HANDLE Adapter);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the LUID of the adapter.
|
* Returns the LUID of the adapter.
|
||||||
*
|
*
|
||||||
|
@ -18,7 +18,6 @@ static WINTUN_DELETE_POOL_DRIVER_FUNC WintunDeletePoolDriver;
|
|||||||
static WINTUN_ENUM_ADAPTERS_FUNC WintunEnumAdapters;
|
static WINTUN_ENUM_ADAPTERS_FUNC WintunEnumAdapters;
|
||||||
static WINTUN_FREE_ADAPTER_FUNC WintunFreeAdapter;
|
static WINTUN_FREE_ADAPTER_FUNC WintunFreeAdapter;
|
||||||
static WINTUN_OPEN_ADAPTER_FUNC WintunOpenAdapter;
|
static WINTUN_OPEN_ADAPTER_FUNC WintunOpenAdapter;
|
||||||
static WINTUN_OPEN_ADAPTER_DEVICE_OBJECT_FUNC WintunOpenAdapterDeviceObject;
|
|
||||||
static WINTUN_GET_ADAPTER_LUID_FUNC WintunGetAdapterLUID;
|
static WINTUN_GET_ADAPTER_LUID_FUNC WintunGetAdapterLUID;
|
||||||
static WINTUN_GET_ADAPTER_NAME_FUNC WintunGetAdapterName;
|
static WINTUN_GET_ADAPTER_NAME_FUNC WintunGetAdapterName;
|
||||||
static WINTUN_SET_ADAPTER_NAME_FUNC WintunSetAdapterName;
|
static WINTUN_SET_ADAPTER_NAME_FUNC WintunSetAdapterName;
|
||||||
@ -43,7 +42,6 @@ InitializeWintun(void)
|
|||||||
if (X(WintunCreateAdapter, WINTUN_CREATE_ADAPTER_FUNC) || X(WintunDeleteAdapter, WINTUN_DELETE_ADAPTER_FUNC) ||
|
if (X(WintunCreateAdapter, WINTUN_CREATE_ADAPTER_FUNC) || X(WintunDeleteAdapter, WINTUN_DELETE_ADAPTER_FUNC) ||
|
||||||
X(WintunDeletePoolDriver, WINTUN_DELETE_POOL_DRIVER_FUNC) || X(WintunEnumAdapters, WINTUN_ENUM_ADAPTERS_FUNC) ||
|
X(WintunDeletePoolDriver, WINTUN_DELETE_POOL_DRIVER_FUNC) || X(WintunEnumAdapters, WINTUN_ENUM_ADAPTERS_FUNC) ||
|
||||||
X(WintunFreeAdapter, WINTUN_FREE_ADAPTER_FUNC) || X(WintunOpenAdapter, WINTUN_OPEN_ADAPTER_FUNC) ||
|
X(WintunFreeAdapter, WINTUN_FREE_ADAPTER_FUNC) || X(WintunOpenAdapter, WINTUN_OPEN_ADAPTER_FUNC) ||
|
||||||
X(WintunOpenAdapterDeviceObject, WINTUN_OPEN_ADAPTER_DEVICE_OBJECT_FUNC) ||
|
|
||||||
X(WintunGetAdapterLUID, WINTUN_GET_ADAPTER_LUID_FUNC) ||
|
X(WintunGetAdapterLUID, WINTUN_GET_ADAPTER_LUID_FUNC) ||
|
||||||
X(WintunGetAdapterName, WINTUN_GET_ADAPTER_NAME_FUNC) ||
|
X(WintunGetAdapterName, WINTUN_GET_ADAPTER_NAME_FUNC) ||
|
||||||
X(WintunSetAdapterName, WINTUN_SET_ADAPTER_NAME_FUNC) ||
|
X(WintunSetAdapterName, WINTUN_SET_ADAPTER_NAME_FUNC) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user