api: rename WintunGetAdapter to WintunOpenAdapter

"Create" and "Open" natural names for these.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-11-05 13:39:13 +01:00
parent e9e790605a
commit 1285b8f528
5 changed files with 22 additions and 22 deletions

View File

@ -179,7 +179,7 @@ Deletes a Wintun adapter.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter. - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
- *ForceCloseSessions*: Force close adapter handles that may be in use by other processes. Only set this to TRUE with extreme care, as this is resource intensive and may put processes into an undefined or unpredictable state. Most users should set this to FALSE. - *ForceCloseSessions*: Force close adapter handles that may be in use by other processes. Only set this to TRUE with extreme care, as this is resource intensive and may put processes into an undefined or unpredictable state. Most users should set this to FALSE.
- *RebootRequired*: Optional pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot. - *RebootRequired*: Optional pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot.
@ -226,11 +226,11 @@ Releases Wintun adapter resources.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter. - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
#### WintunGetAdapter() #### WintunOpenAdapter()
`WINTUN_ADAPTER_HANDLE WintunGetAdapter (const WCHAR * Pool, const WCHAR * Name)` `WINTUN_ADAPTER_HANDLE WintunOpenAdapter (const WCHAR * Pool, const WCHAR * Name)`
Finds a Wintun adapter by its name. Finds a Wintun adapter by its name.
@ -251,7 +251,7 @@ Returns a handle to the adapter device object.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter. - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
**Returns** **Returns**
@ -265,7 +265,7 @@ Returns the LUID of the adapter.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
- *Luid*: Pointer to LUID to receive adapter LUID. - *Luid*: Pointer to LUID to receive adapter LUID.
#### WintunGetAdapterName() #### WintunGetAdapterName()
@ -276,7 +276,7 @@ Returns the name of the Wintun adapter.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
- *Name*: Pointer to a string to receive adapter name - *Name*: Pointer to a string to receive adapter name
**Returns** **Returns**
@ -291,7 +291,7 @@ Sets name of the Wintun adapter.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
- *Name*: Adapter name. Zero-terminated string of up to MAX\_ADAPTER\_NAME-1 characters. - *Name*: Adapter name. Zero-terminated string of up to MAX\_ADAPTER\_NAME-1 characters.
**Returns** **Returns**
@ -326,7 +326,7 @@ Starts Wintun session.
**Parameters** **Parameters**
- *Adapter*: Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter - *Adapter*: Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
- *Capacity*: Rings capacity. Must be between WINTUN\_MIN\_RING\_CAPACITY and WINTUN\_MAX\_RING\_CAPACITY (incl.) Must be a power of two. - *Capacity*: Rings capacity. Must be between WINTUN\_MIN\_RING\_CAPACITY and WINTUN\_MAX\_RING\_CAPACITY (incl.) Must be a power of two.
**Returns** **Returns**

View File

@ -607,7 +607,7 @@ WintunFreeAdapter(_In_ WINTUN_ADAPTER *Adapter)
} }
_Return_type_success_(return != NULL) WINTUN_ADAPTER *WINAPI _Return_type_success_(return != NULL) WINTUN_ADAPTER *WINAPI
WintunGetAdapter(_In_z_ const WCHAR *Pool, _In_z_ const WCHAR *Name) WintunOpenAdapter(_In_z_ const WCHAR *Pool, _In_z_ const WCHAR *Name)
{ {
if (!ElevateToSystem()) if (!ElevateToSystem())
{ {

View File

@ -7,7 +7,7 @@ EXPORTS
WintunEndSession WintunEndSession
WintunEnumAdapters WintunEnumAdapters
WintunFreeAdapter WintunFreeAdapter
WintunGetAdapter WintunOpenAdapter
WintunOpenAdapterDeviceObject WintunOpenAdapterDeviceObject
WintunGetAdapterLUID WintunGetAdapterLUID
WintunGetAdapterName WintunGetAdapterName

View File

@ -50,7 +50,7 @@ typedef _Return_type_success_(return != NULL) WINTUN_ADAPTER_HANDLE(WINAPI *WINT
/** /**
* Deletes a Wintun adapter. * Deletes a Wintun adapter.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter. * @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
* *
* @param ForceCloseSessions Force close adapter handles that may be in use by other processes. Only set this to TRUE * @param ForceCloseSessions Force close adapter handles that may be in use by other processes. Only set this to TRUE
* with extreme care, as this is resource intensive and may put processes into an undefined * with extreme care, as this is resource intensive and may put processes into an undefined
@ -110,7 +110,7 @@ typedef _Return_type_success_(return != FALSE) BOOL(
/** /**
* Releases Wintun adapter resources. * Releases Wintun adapter resources.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter. * @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
*/ */
typedef void(WINAPI *WINTUN_FREE_ADAPTER_FUNC)(_In_ WINTUN_ADAPTER_HANDLE Adapter); typedef void(WINAPI *WINTUN_FREE_ADAPTER_FUNC)(_In_ WINTUN_ADAPTER_HANDLE Adapter);
@ -128,12 +128,12 @@ typedef void(WINAPI *WINTUN_FREE_ADAPTER_FUNC)(_In_ WINTUN_ADAPTER_HANDLE Adapte
* ERROR_ALREADY_EXISTS if adapter is found but not a Wintun-class or not a member of the pool * ERROR_ALREADY_EXISTS if adapter is found but not a Wintun-class or not a member of the pool
*/ */
typedef _Return_type_success_(return != NULL) typedef _Return_type_success_(return != NULL)
WINTUN_ADAPTER_HANDLE(WINAPI *WINTUN_GET_ADAPTER_FUNC)(_In_z_ const WCHAR *Pool, _In_z_ const WCHAR *Name); WINTUN_ADAPTER_HANDLE(WINAPI *WINTUN_OPEN_ADAPTER_FUNC)(_In_z_ const WCHAR *Pool, _In_z_ const WCHAR *Name);
/** /**
* Returns a handle to the adapter device object. * Returns a handle to the adapter device object.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter. * @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 * @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 * CloseHandle. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error
@ -145,7 +145,7 @@ typedef _Return_type_success_(return != INVALID_HANDLE_VALUE)
/** /**
* Returns the LUID of the adapter. * Returns the LUID of the adapter.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter * @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
* *
* @param Luid Pointer to LUID to receive adapter LUID. * @param Luid Pointer to LUID to receive adapter LUID.
*/ */
@ -154,7 +154,7 @@ typedef void(WINAPI *WINTUN_GET_ADAPTER_LUID_FUNC)(_In_ WINTUN_ADAPTER_HANDLE Ad
/** /**
* Returns the name of the Wintun adapter. * Returns the name of the Wintun adapter.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter * @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
* *
* @param Name Pointer to a string to receive adapter name * @param Name Pointer to a string to receive adapter name
* *
@ -168,7 +168,7 @@ typedef _Return_type_success_(return != FALSE) BOOL(WINAPI *WINTUN_GET_ADAPTER_N
/** /**
* Sets name of the Wintun adapter. * Sets name of the Wintun adapter.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter * @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
* *
* @param Name Adapter name. Zero-terminated string of up to MAX_ADAPTER_NAME-1 characters. * @param Name Adapter name. Zero-terminated string of up to MAX_ADAPTER_NAME-1 characters.
* *
@ -235,7 +235,7 @@ typedef void *WINTUN_SESSION_HANDLE;
/** /**
* Starts Wintun session. * Starts Wintun session.
* *
* @param Adapter Adapter handle obtained with WintunGetAdapter or WintunCreateAdapter * @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter
* *
* @param Capacity Rings capacity. Must be between WINTUN_MIN_RING_CAPACITY and WINTUN_MAX_RING_CAPACITY (incl.) * @param Capacity Rings capacity. Must be between WINTUN_MIN_RING_CAPACITY and WINTUN_MAX_RING_CAPACITY (incl.)
* Must be a power of two. * Must be a power of two.

View File

@ -17,7 +17,7 @@ static WINTUN_DELETE_ADAPTER_FUNC WintunDeleteAdapter;
static WINTUN_DELETE_POOL_DRIVER_FUNC WintunDeletePoolDriver; 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_GET_ADAPTER_FUNC WintunGetAdapter; static WINTUN_OPEN_ADAPTER_FUNC WintunOpenAdapter;
static WINTUN_OPEN_ADAPTER_DEVICE_OBJECT_FUNC WintunOpenAdapterDeviceObject; 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;
@ -42,7 +42,7 @@ InitializeWintun(void)
#define X(Name, Type) ((Name = (Type)GetProcAddress(Wintun, #Name)) == NULL) #define X(Name, Type) ((Name = (Type)GetProcAddress(Wintun, #Name)) == NULL)
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(WintunGetAdapter, WINTUN_GET_ADAPTER_FUNC) || X(WintunFreeAdapter, WINTUN_FREE_ADAPTER_FUNC) || X(WintunOpenAdapter, WINTUN_OPEN_ADAPTER_FUNC) ||
X(WintunOpenAdapterDeviceObject, WINTUN_OPEN_ADAPTER_DEVICE_OBJECT_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) ||
@ -320,7 +320,7 @@ main(void)
} }
GUID ExampleGuid = { 0xdeadbabe, 0xcafe, 0xbeef, { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef } }; GUID ExampleGuid = { 0xdeadbabe, 0xcafe, 0xbeef, { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef } };
WINTUN_ADAPTER_HANDLE Adapter = WintunGetAdapter(L"Example", L"Demo"); WINTUN_ADAPTER_HANDLE Adapter = WintunOpenAdapter(L"Example", L"Demo");
if (!Adapter) if (!Adapter)
{ {
Adapter = WintunCreateAdapter(L"Example", L"Demo", &ExampleGuid, NULL); Adapter = WintunCreateAdapter(L"Example", L"Demo", &ExampleGuid, NULL);