2020-07-07 15:32:06 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
2020-10-31 11:55:26 +01:00
|
|
|
#include "nci.h"
|
|
|
|
#include <Windows.h>
|
2020-07-07 15:32:06 +02:00
|
|
|
|
|
|
|
static HMODULE NciModule;
|
|
|
|
|
2020-07-21 18:19:15 +02:00
|
|
|
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
|
|
|
DWORD(WINAPI *NciGetConnectionName)
|
2020-07-21 18:19:15 +02:00
|
|
|
(_In_ const GUID *Guid,
|
|
|
|
_Out_z_bytecap_(InDestNameBytes) WCHAR *Name,
|
2020-07-21 11:11:14 +02:00
|
|
|
_In_ DWORD InDestNameBytes,
|
|
|
|
_Out_opt_ DWORD *OutDestNameBytes);
|
2020-07-07 15:32:06 +02:00
|
|
|
|
2020-10-31 08:15:52 +01:00
|
|
|
WINTUN_STATUS
|
2020-10-30 06:03:21 +01:00
|
|
|
NciInit(void)
|
2020-07-07 15:32:06 +02:00
|
|
|
{
|
2020-10-30 11:43:47 +01:00
|
|
|
NciModule = LoadLibraryExW(L"nci.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
2020-07-07 15:32:06 +02:00
|
|
|
if (!NciModule)
|
2020-10-31 08:15:52 +01:00
|
|
|
return GetLastError();
|
2020-07-21 18:19:15 +02:00
|
|
|
NciSetConnectionName =
|
|
|
|
(DWORD(WINAPI *)(const GUID *, const WCHAR *))GetProcAddress(NciModule, "NciSetConnectionName");
|
2020-10-31 08:15:52 +01:00
|
|
|
if (!NciSetConnectionName)
|
|
|
|
return GetLastError();
|
2020-07-21 11:11:14 +02:00
|
|
|
NciGetConnectionName =
|
2020-07-21 18:19:15 +02:00
|
|
|
(DWORD(WINAPI *)(const GUID *, WCHAR *, DWORD, DWORD *))GetProcAddress(NciModule, "NciGetConnectionName");
|
2020-10-31 08:15:52 +01:00
|
|
|
if (!NciGetConnectionName)
|
|
|
|
return GetLastError();
|
|
|
|
return ERROR_SUCCESS;
|
2020-07-07 15:32:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-10-30 06:03:21 +01:00
|
|
|
NciCleanup(void)
|
2020-07-07 15:32:06 +02:00
|
|
|
{
|
|
|
|
if (NciModule)
|
|
|
|
FreeLibrary(NciModule);
|
|
|
|
}
|