2020-07-29 10:10:42 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-10-17 15:11:34 +02:00
|
|
|
#include "wintun.h"
|
2020-10-31 11:55:26 +01:00
|
|
|
#include <IPExport.h>
|
2020-10-15 11:32:06 +02:00
|
|
|
#include <SetupAPI.h>
|
2020-10-31 11:55:26 +01:00
|
|
|
#include <Windows.h>
|
2020-07-29 10:10:42 +02:00
|
|
|
|
|
|
|
#define MAX_INSTANCE_ID MAX_PATH /* TODO: Is MAX_PATH always enough? */
|
2020-10-30 09:53:09 +01:00
|
|
|
#define WINTUN_HWID L"Wintun"
|
2020-07-29 10:10:42 +02:00
|
|
|
|
2020-10-15 11:32:06 +02:00
|
|
|
typedef struct _SP_DEVINFO_DATA_LIST
|
|
|
|
{
|
|
|
|
SP_DEVINFO_DATA Data;
|
|
|
|
struct _SP_DEVINFO_DATA_LIST *Next;
|
|
|
|
} SP_DEVINFO_DATA_LIST;
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
|
|
|
* Retrieves driver information detail for a device information set or a particular device information element in the
|
|
|
|
* device information set.
|
|
|
|
*
|
|
|
|
* @param DevInfo A handle to the device information set that contains a device information element that
|
|
|
|
* represents the device for which to retrieve driver information.
|
|
|
|
*
|
|
|
|
* @param DevInfoData A pointer to a structure that specifies the device information element in DevInfo.
|
|
|
|
*
|
|
|
|
* @param DrvInfoData A pointer to a structure that specifies the driver information element that represents the
|
|
|
|
* driver for which to retrieve details.
|
|
|
|
*
|
|
|
|
* @param DrvInfoDetailData A pointer to a structure that receives detailed information about the specified driver.
|
2020-10-24 22:12:47 +02:00
|
|
|
* Must be released with HeapFree(ModuleHeap, 0, *DrvInfoDetailData) after use.
|
2020-10-15 12:52:01 +02:00
|
|
|
*
|
|
|
|
* @return ERROR_SUCCESS on success; Win32 error code otherwise.
|
|
|
|
*/
|
2020-10-15 11:32:06 +02:00
|
|
|
WINTUN_STATUS
|
|
|
|
AdapterGetDrvInfoDetail(
|
|
|
|
_In_ HDEVINFO DevInfo,
|
|
|
|
_In_opt_ SP_DEVINFO_DATA *DevInfoData,
|
|
|
|
_In_ SP_DRVINFO_DATA_W *DrvInfoData,
|
|
|
|
_Out_ SP_DRVINFO_DETAIL_DATA_W **DrvInfoDetailData);
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
|
|
|
* Disables all Wintun adapters.
|
|
|
|
*
|
|
|
|
* @param DevInfo A handle to the device information set.
|
|
|
|
*
|
|
|
|
* @param DisabledAdapters Output list of disabled adapters. The adapters disabled are inserted in the list head.
|
|
|
|
*
|
|
|
|
* @return ERROR_SUCCESS on success; Win32 error code otherwise.
|
|
|
|
*/
|
2020-10-15 11:32:06 +02:00
|
|
|
WINTUN_STATUS
|
|
|
|
AdapterDisableAllOurs(_In_ HDEVINFO DevInfo, _Inout_ SP_DEVINFO_DATA_LIST **DisabledAdapters);
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
|
|
|
* Enables all adapters.
|
|
|
|
*
|
|
|
|
* @param DevInfo A handle to the device information set.
|
|
|
|
*
|
|
|
|
* @param AdaptersToEnable Input list of adapters to enable.
|
|
|
|
*
|
|
|
|
* @return ERROR_SUCCESS on success; Win32 error code otherwise.
|
|
|
|
*/
|
2020-10-15 11:32:06 +02:00
|
|
|
WINTUN_STATUS
|
|
|
|
AdapterEnableAll(_In_ HDEVINFO DevInfo, _In_ SP_DEVINFO_DATA_LIST *AdaptersToEnable);
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
|
|
|
* Removes all Wintun adapters.
|
|
|
|
*
|
|
|
|
* @return ERROR_SUCCESS on success; Win32 error code otherwise.
|
|
|
|
*/
|
2020-10-15 11:32:06 +02:00
|
|
|
WINTUN_STATUS
|
2020-10-30 06:03:21 +01:00
|
|
|
AdapterDeleteAllOurs(void);
|
2020-10-15 11:32:06 +02:00
|
|
|
|
|
|
|
void
|
2020-10-30 06:03:21 +01:00
|
|
|
AdapterInit(void);
|
2020-10-15 11:32:06 +02:00
|
|
|
|
2020-10-17 15:11:34 +02:00
|
|
|
/**
|
|
|
|
* Wintun adapter descriptor.
|
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
typedef struct _WINTUN_ADAPTER
|
|
|
|
{
|
|
|
|
GUID CfgInstanceID;
|
|
|
|
WCHAR DevInstanceID[MAX_INSTANCE_ID];
|
|
|
|
DWORD LuidIndex;
|
|
|
|
DWORD IfType;
|
2020-10-31 08:53:32 +01:00
|
|
|
WCHAR Pool[WINTUN_MAX_POOL];
|
2020-07-29 10:10:42 +02:00
|
|
|
} WINTUN_ADAPTER;
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
2020-10-17 15:11:34 +02:00
|
|
|
* @copydoc WINTUN_FREE_ADAPTER_FUNC
|
2020-10-15 12:52:01 +02:00
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
void WINAPI
|
|
|
|
WintunFreeAdapter(_In_ WINTUN_ADAPTER *Adapter);
|
|
|
|
|
2020-10-24 08:28:17 +02:00
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_GET_ADAPTER_DEVICE_OBJECT_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_STATUS WINAPI
|
|
|
|
WintunGetAdapterDeviceObject(_In_ const WINTUN_ADAPTER *Adapter, _Out_ HANDLE *Handle);
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
2020-10-17 15:11:34 +02:00
|
|
|
* @copydoc WINTUN_CREATE_ADAPTER_FUNC
|
2020-10-15 12:52:01 +02:00
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
|
|
|
WintunCreateAdapter(
|
2020-10-31 08:53:32 +01:00
|
|
|
_In_z_count_c_(WINTUN_MAX_POOL) const WCHAR *Pool,
|
2020-07-29 10:10:42 +02:00
|
|
|
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
|
|
|
_In_opt_ const GUID *RequestedGUID,
|
|
|
|
_Out_ WINTUN_ADAPTER **Adapter,
|
|
|
|
_Inout_ BOOL *RebootRequired);
|
|
|
|
|
2020-10-15 12:52:01 +02:00
|
|
|
/**
|
2020-10-17 15:11:34 +02:00
|
|
|
* @copydoc WINTUN_DELETE_ADAPTER_FUNC
|
2020-10-15 12:52:01 +02:00
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-10-30 14:34:40 +01:00
|
|
|
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _In_ BOOL ForceCloseSessions, _Inout_ BOOL *RebootRequired);
|