aboutsummaryrefslogtreecommitdiffstats
path: root/api/nci.c
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-07-07 15:32:06 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-10-30 16:50:58 +0100
commit3fa45fec719947f4659846e53e84381eca5236bb (patch)
tree27496fc2af62d0d7c7d338a5b3cafef73c6ef342 /api/nci.c
parentapi: port tun\wintun\namespace_windows.go from wireguard-go (diff)
downloadwintun-3fa45fec719947f4659846e53e84381eca5236bb.tar.xz
wintun-3fa45fec719947f4659846e53e84381eca5236bb.zip
api: port nci package from wireguard-go
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'api/nci.c')
-rw-r--r--api/nci.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/api/nci.c b/api/nci.c
new file mode 100644
index 0000000..c479f50
--- /dev/null
+++ b/api/nci.c
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
+ */
+
+#include "api.h"
+
+static HMODULE NciModule;
+
+_Return_type_success_(return == 0) DWORD (WINAPI *NciSetConnectionName)(_In_ LPCGUID Guid, _In_z_ LPCWSTR NewName);
+
+_Return_type_success_(return == 0) DWORD (WINAPI *NciGetConnectionName)(
+ _In_ LPCGUID Guid,
+ _Out_z_bytecap_(InDestNameBytes) LPWSTR Name,
+ _In_ DWORD InDestNameBytes,
+ _Out_opt_ DWORD *OutDestNameBytes);
+
+void
+NciInit()
+{
+ NciModule = LoadLibraryW(L"nci.dll");
+ if (!NciModule)
+ return;
+ NciSetConnectionName = (DWORD (WINAPI *)(LPCGUID, LPCWSTR))GetProcAddress(NciModule, "NciSetConnectionName");
+ NciGetConnectionName = (DWORD (WINAPI *)(LPCGUID, LPWSTR, DWORD, DWORD *))GetProcAddress(NciModule, "NciGetConnectionName");
+}
+
+void
+NciCleanup()
+{
+ if (NciModule)
+ FreeLibrary(NciModule);
+}