2020-07-03 12:26:06 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Windows.h>
|
2020-07-21 16:38:00 +02:00
|
|
|
#include <IPExport.h>
|
2020-07-03 12:26:06 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
typedef _Return_type_success_(return == ERROR_SUCCESS) DWORD WINTUN_STATUS;
|
2020-07-03 12:26:06 +02:00
|
|
|
extern HINSTANCE ResourceModule;
|
2020-07-03 16:49:47 +02:00
|
|
|
|
|
|
|
_Check_return_
|
|
|
|
HANDLE
|
2020-07-21 18:19:15 +02:00
|
|
|
TakeNameMutex(_In_z_ const WCHAR *Pool);
|
2020-07-03 16:49:47 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
ReleaseNameMutex(_In_ HANDLE Mutex);
|
|
|
|
|
|
|
|
void
|
|
|
|
NamespaceInit();
|
|
|
|
|
|
|
|
void
|
|
|
|
NamespaceCleanup();
|
2020-07-07 15:32:06 +02:00
|
|
|
|
2020-07-21 18:19:15 +02:00
|
|
|
extern DWORD(WINAPI *NciSetConnectionName)(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName);
|
2020-07-07 15:32:06 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
extern DWORD(WINAPI *NciGetConnectionName)(
|
2020-07-21 18:19:15 +02:00
|
|
|
_In_ const GUID *Guid,
|
|
|
|
_Out_z_bytecap_(InDestNameBytes) WCHAR *Name,
|
2020-07-07 15:32:06 +02:00
|
|
|
_In_ DWORD InDestNameBytes,
|
|
|
|
_Out_opt_ DWORD *OutDestNameBytes);
|
|
|
|
|
|
|
|
void
|
|
|
|
NciInit();
|
|
|
|
|
|
|
|
void
|
|
|
|
NciCleanup();
|
2020-07-07 15:42:39 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 16:38:00 +02:00
|
|
|
RegistryOpenKeyWait(
|
|
|
|
_In_ HKEY Key,
|
2020-07-21 18:19:15 +02:00
|
|
|
_In_z_count_c_(MAX_PATH) const WCHAR *Path,
|
2020-07-21 16:38:00 +02:00
|
|
|
_In_ DWORD Access,
|
|
|
|
_In_ DWORD Timeout,
|
|
|
|
_Out_ HKEY *KeyOut);
|
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryWaitForKey(_In_ HKEY Key, _In_z_count_c_(MAX_PATH) const WCHAR *Path, _In_ DWORD Timeout);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryGetString(_Inout_ WCHAR **Buf, _In_ DWORD Len, _In_ DWORD ValueType);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryGetMultiString(_Inout_ WCHAR **Buf, _In_ DWORD Len, _In_ DWORD ValueType);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryQueryString(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _Out_ WCHAR **Value);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryQueryStringWait(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _In_ DWORD Timeout, _Out_ WCHAR **Value);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryQueryDWORD(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _Out_ DWORD *Value);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS
|
2020-07-21 18:19:15 +02:00
|
|
|
RegistryQueryDWORDWait(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _In_ DWORD Timeout, _Out_ DWORD *Value);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 16:38:00 +02:00
|
|
|
WintunGetVersion(
|
|
|
|
_Out_ DWORD *DriverVersionMaj,
|
|
|
|
_Out_ DWORD *DriverVersionMin,
|
|
|
|
_Out_ DWORD *NdisVersionMaj,
|
|
|
|
_Out_ DWORD *NdisVersionMin);
|
|
|
|
|
2020-07-07 15:42:39 +02:00
|
|
|
#define MAX_POOL 256
|
|
|
|
#define MAX_INSTANCE_ID MAX_PATH /* TODO: Is MAX_PATH always enough? */
|
|
|
|
|
|
|
|
typedef struct _WINTUN_ADAPTER
|
|
|
|
{
|
|
|
|
GUID CfgInstanceID;
|
|
|
|
WCHAR DevInstanceID[MAX_INSTANCE_ID];
|
|
|
|
DWORD LuidIndex;
|
|
|
|
DWORD IfType;
|
|
|
|
WCHAR Pool[MAX_POOL];
|
|
|
|
} WINTUN_ADAPTER;
|
|
|
|
|
2020-07-21 18:19:15 +02:00
|
|
|
void WINAPI
|
2020-07-07 15:42:39 +02:00
|
|
|
WintunFreeAdapter(_In_ WINTUN_ADAPTER *Adapter);
|
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 18:19:15 +02:00
|
|
|
WintunGetAdapter(_In_z_count_c_(MAX_POOL) const WCHAR *Pool, _In_z_ const WCHAR *Name, _Out_ WINTUN_ADAPTER **Adapter);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 18:19:15 +02:00
|
|
|
WintunGetAdapterName(_In_ const WINTUN_ADAPTER *Adapter, _Out_cap_c_(MAX_ADAPTER_NAME) WCHAR *Name);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 18:19:15 +02:00
|
|
|
WintunSetAdapterName(_In_ const WINTUN_ADAPTER *Adapter, _In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name);
|
2020-07-21 16:38:00 +02:00
|
|
|
|
|
|
|
void WINAPI
|
|
|
|
WintunGetAdapterGUID(_In_ const WINTUN_ADAPTER *Adapter, _Out_ GUID *Guid);
|
|
|
|
|
|
|
|
void WINAPI
|
|
|
|
WintunGetAdapterLUID(_In_ const WINTUN_ADAPTER *Adapter, _Out_ LUID *Luid);
|
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 16:38:00 +02:00
|
|
|
WintunGetAdapterDeviceObject(_In_ const WINTUN_ADAPTER *Adapter, _Out_ HANDLE *Handle);
|
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 16:38:00 +02:00
|
|
|
WintunCreateAdapter(
|
2020-07-21 18:19:15 +02:00
|
|
|
_In_z_count_c_(MAX_POOL) const WCHAR *Pool,
|
|
|
|
_In_z_ const WCHAR *Name,
|
2020-07-21 16:38:00 +02:00
|
|
|
_In_opt_ const GUID *RequestedGUID,
|
|
|
|
_Out_ WINTUN_ADAPTER **Adapter,
|
|
|
|
_Inout_ BOOL *RebootRequired);
|
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 16:38:00 +02:00
|
|
|
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequired);
|
|
|
|
|
|
|
|
typedef BOOL(CALLBACK *WINTUN_ENUMPROC)(_In_ const WINTUN_ADAPTER *Adapter, _In_ LPARAM Param);
|
|
|
|
|
2020-07-21 16:43:34 +02:00
|
|
|
WINTUN_STATUS WINAPI
|
2020-07-21 18:19:15 +02:00
|
|
|
WintunEnumAdapters(_In_z_count_c_(MAX_POOL) const WCHAR *Pool, _In_ WINTUN_ENUMPROC Func, _In_ LPARAM Param);
|