api: port nci package from wireguard-go
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
6f55786c65
commit
3fa45fec71
@ -17,9 +17,11 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
|||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
ResourceModule = hinstDLL;
|
ResourceModule = hinstDLL;
|
||||||
NamespaceInit();
|
NamespaceInit();
|
||||||
|
NciInit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
NciCleanup();
|
||||||
NamespaceCleanup();
|
NamespaceCleanup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
15
api/api.h
15
api/api.h
@ -21,3 +21,18 @@ NamespaceInit();
|
|||||||
|
|
||||||
void
|
void
|
||||||
NamespaceCleanup();
|
NamespaceCleanup();
|
||||||
|
|
||||||
|
_Return_type_success_(return ==
|
||||||
|
0) extern DWORD(WINAPI *NciSetConnectionName)(_In_ LPCGUID Guid, _In_z_ LPCWSTR NewName);
|
||||||
|
|
||||||
|
_Return_type_success_(return == 0) extern DWORD(WINAPI *NciGetConnectionName)(
|
||||||
|
_In_ LPCGUID Guid,
|
||||||
|
_Out_z_bytecap_(InDestNameBytes) LPWSTR Name,
|
||||||
|
_In_ DWORD InDestNameBytes,
|
||||||
|
_Out_opt_ DWORD *OutDestNameBytes);
|
||||||
|
|
||||||
|
void
|
||||||
|
NciInit();
|
||||||
|
|
||||||
|
void
|
||||||
|
NciCleanup();
|
||||||
|
@ -160,6 +160,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="api.c" />
|
<ClCompile Include="api.c" />
|
||||||
<ClCompile Include="namespace.c" />
|
<ClCompile Include="namespace.c" />
|
||||||
|
<ClCompile Include="nci.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@ -36,5 +36,8 @@
|
|||||||
<ClCompile Include="namespace.c">
|
<ClCompile Include="namespace.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="nci.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
33
api/nci.c
Normal file
33
api/nci.c
Normal file
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user