2020-07-29 10:10:42 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
2021-01-30 16:45:26 +01:00
|
|
|
* Copyright (C) 2018-2021 WireGuard LLC. All Rights Reserved.
|
2020-07-29 10:10:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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-17 15:11:34 +02:00
|
|
|
/**
|
|
|
|
* Wintun adapter descriptor.
|
|
|
|
*/
|
2020-07-29 10:10:42 +02:00
|
|
|
typedef struct _WINTUN_ADAPTER
|
|
|
|
{
|
2021-07-28 20:20:09 +02:00
|
|
|
HDEVINFO DevInfo;
|
|
|
|
SP_DEVINFO_DATA DevInfoData;
|
2020-07-29 10:10:42 +02:00
|
|
|
GUID CfgInstanceID;
|
|
|
|
WCHAR DevInstanceID[MAX_INSTANCE_ID];
|
|
|
|
DWORD LuidIndex;
|
|
|
|
DWORD IfType;
|
2021-07-28 20:20:09 +02:00
|
|
|
DWORD IfIndex;
|
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
|
|
|
*/
|
2021-07-28 20:20:09 +02:00
|
|
|
WINTUN_FREE_ADAPTER_FUNC_IMPL WintunFreeAdapter;
|
2020-07-29 10:10:42 +02:00
|
|
|
|
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
|
|
|
*/
|
2021-07-28 20:20:09 +02:00
|
|
|
WINTUN_CREATE_ADAPTER_FUNC_IMPL WintunCreateAdapter;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_OPEN_ADAPTER_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_OPEN_ADAPTER_FUNC_IMPL WintunOpenAdapter;
|
2020-07-29 10:10:42 +02:00
|
|
|
|
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
|
|
|
*/
|
2021-07-28 20:20:09 +02:00
|
|
|
WINTUN_DELETE_ADAPTER_FUNC_IMPL WintunDeleteAdapter;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_ENUM_ADAPTERS_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_ENUM_ADAPTERS_FUNC_IMPL WintunEnumAdapters;
|
2020-11-02 16:28:51 +01:00
|
|
|
|
|
|
|
/**
|
2020-11-03 12:27:42 +01:00
|
|
|
* @copydoc WINTUN_DELETE_POOL_DRIVER_FUNC
|
2020-11-02 16:28:51 +01:00
|
|
|
*/
|
2021-07-28 20:20:09 +02:00
|
|
|
WINTUN_DELETE_POOL_DRIVER_FUNC_IMPL WintunDeletePoolDriver;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_GET_ADAPTER_LUID_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_GET_ADAPTER_LUID_FUNC_IMPL WintunGetAdapterLUID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_GET_ADAPTER_NAME_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_GET_ADAPTER_NAME_FUNC_IMPL WintunGetAdapterName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_SET_ADAPTER_NAME_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_SET_ADAPTER_NAME_FUNC_IMPL WintunSetAdapterName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_GET_RUNNING_DRIVER_VERSION_FUNC
|
|
|
|
*/
|
|
|
|
WINTUN_GET_RUNNING_DRIVER_VERSION_FUNC_IMPL WintunGetRunningDriverVersion;
|
2020-11-05 15:25:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a handle to the adapter device object.
|
|
|
|
*
|
|
|
|
* @param Adapter Adapter handle obtained with WintunOpenAdapter or WintunCreateAdapter.
|
|
|
|
*
|
2021-07-28 20:20:09 +02:00
|
|
|
* @return If the function succeeds, the return value is adapter device object handle.
|
|
|
|
* 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);
|
|
|
|
/**
|
|
|
|
* Returns an adapter object based on a devnode instance ID.
|
|
|
|
*
|
|
|
|
* @param Pool Pool name of adapter object to be opened.
|
|
|
|
*
|
|
|
|
* @param DevInstanceID Instance ID of devnode for opening adapter.
|
|
|
|
*
|
|
|
|
* @return If the function succeeds, the return value is adapter object..
|
|
|
|
* If the function fails, the return value is NULL. To get extended error
|
2020-11-05 15:25:52 +01:00
|
|
|
* information, call GetLastError.
|
|
|
|
*/
|
2021-07-28 20:20:09 +02:00
|
|
|
_Must_inspect_result_
|
|
|
|
_Return_type_success_(return != NULL)
|
|
|
|
_Post_maybenull_
|
|
|
|
WINTUN_ADAPTER *
|
|
|
|
AdapterOpenFromDevInstanceId(_In_z_ LPCWSTR Pool, _In_z_ LPCWSTR DevInstanceID);
|