api: link to nci.dll at compile time
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
42062fe554
commit
62f21f2fdd
@ -114,9 +114,12 @@
|
|||||||
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM'">_M_ARM=7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM'">_M_ARM=7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM64'">_M_ARM64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM64'">_M_ARM64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
|
<PreLinkEvent>
|
||||||
|
<Command>lib.exe /def:nci.def /out:"$(IntDir)nci.lib" /machine:$(PlatformTarget) /nologo</Command>
|
||||||
|
</PreLinkEvent>
|
||||||
<Link>
|
<Link>
|
||||||
<DelayLoadDLLs>bcrypt.dll;iphlpapi.dll;newdev.dll;version.dll</DelayLoadDLLs>
|
<DelayLoadDLLs>bcrypt.dll;iphlpapi.dll;nci.dll;newdev.dll;version.dll</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>Bcrypt.lib;Crypt32.lib;Cfgmgr32.lib;Iphlpapi.lib;newdev.lib;ntdll.lib;Setupapi.lib;shlwapi.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Bcrypt.lib;Crypt32.lib;Cfgmgr32.lib;Iphlpapi.lib;$(IntDir)nci.lib;newdev.lib;ntdll.lib;Setupapi.lib;shlwapi.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
@ -149,6 +152,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="exports.def" />
|
<None Include="exports.def" />
|
||||||
|
<None Include="nci.def" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="entry.h" />
|
<ClInclude Include="entry.h" />
|
||||||
@ -168,7 +172,6 @@
|
|||||||
<ClCompile Include="elevate.c" />
|
<ClCompile Include="elevate.c" />
|
||||||
<ClCompile Include="logger.c" />
|
<ClCompile Include="logger.c" />
|
||||||
<ClCompile Include="namespace.c" />
|
<ClCompile Include="namespace.c" />
|
||||||
<ClCompile Include="nci.c" />
|
|
||||||
<ClCompile Include="registry.c" />
|
<ClCompile Include="registry.c" />
|
||||||
<ClCompile Include="resource.c" />
|
<ClCompile Include="resource.c" />
|
||||||
<ClCompile Include="session.c" />
|
<ClCompile Include="session.c" />
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
<None Include="exports.def">
|
<None Include="exports.def">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="nci.def">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="nci.h">
|
<ClInclude Include="nci.h">
|
||||||
@ -60,9 +63,6 @@
|
|||||||
<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>
|
|
||||||
<ClCompile Include="rundll32.c">
|
<ClCompile Include="rundll32.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
#include "nci.h"
|
|
||||||
#include "wintun.h"
|
#include "wintun.h"
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -84,12 +83,9 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
|||||||
L"O:SYD:P(A;;GA;;;SY)", SDDL_REVISION_1, &SecurityAttributes.lpSecurityDescriptor, NULL);
|
L"O:SYD:P(A;;GA;;;SY)", SDDL_REVISION_1, &SecurityAttributes.lpSecurityDescriptor, NULL);
|
||||||
AdapterInit();
|
AdapterInit();
|
||||||
NamespaceInit();
|
NamespaceInit();
|
||||||
if (NciInit() != ERROR_SUCCESS)
|
|
||||||
return FALSE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
NciCleanup();
|
|
||||||
NamespaceCleanup();
|
NamespaceCleanup();
|
||||||
LocalFree(SecurityAttributes.lpSecurityDescriptor);
|
LocalFree(SecurityAttributes.lpSecurityDescriptor);
|
||||||
HeapDestroy(ModuleHeap);
|
HeapDestroy(ModuleHeap);
|
||||||
|
41
api/nci.c
41
api/nci.c
@ -1,41 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0
|
|
||||||
*
|
|
||||||
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "nci.h"
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
static HMODULE NciModule;
|
|
||||||
|
|
||||||
DWORD(WINAPI *NciSetConnectionName)(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName);
|
|
||||||
|
|
||||||
DWORD(WINAPI *NciGetConnectionName)
|
|
||||||
(_In_ const GUID *Guid,
|
|
||||||
_Out_z_bytecap_(InDestNameBytes) WCHAR *Name,
|
|
||||||
_In_ DWORD InDestNameBytes,
|
|
||||||
_Out_opt_ DWORD *OutDestNameBytes);
|
|
||||||
|
|
||||||
WINTUN_STATUS
|
|
||||||
NciInit(void)
|
|
||||||
{
|
|
||||||
NciModule = LoadLibraryExW(L"nci.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
|
||||||
if (!NciModule)
|
|
||||||
return GetLastError();
|
|
||||||
NciSetConnectionName =
|
|
||||||
(DWORD(WINAPI *)(const GUID *, const WCHAR *))GetProcAddress(NciModule, "NciSetConnectionName");
|
|
||||||
if (!NciSetConnectionName)
|
|
||||||
return GetLastError();
|
|
||||||
NciGetConnectionName =
|
|
||||||
(DWORD(WINAPI *)(const GUID *, WCHAR *, DWORD, DWORD *))GetProcAddress(NciModule, "NciGetConnectionName");
|
|
||||||
if (!NciGetConnectionName)
|
|
||||||
return GetLastError();
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NciCleanup(void)
|
|
||||||
{
|
|
||||||
if (NciModule)
|
|
||||||
FreeLibrary(NciModule);
|
|
||||||
}
|
|
3
api/nci.def
Normal file
3
api/nci.def
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
EXPORTS
|
||||||
|
NciGetConnectionName
|
||||||
|
NciSetConnectionName
|
13
api/nci.h
13
api/nci.h
@ -5,19 +5,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "wintun.h"
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
extern DWORD(WINAPI *NciSetConnectionName)(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName);
|
extern DWORD WINAPI NciSetConnectionName(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName);
|
||||||
|
|
||||||
extern DWORD(WINAPI *NciGetConnectionName)(
|
extern DWORD WINAPI NciGetConnectionName(
|
||||||
_In_ const GUID *Guid,
|
_In_ const GUID *Guid,
|
||||||
_Out_z_bytecap_(InDestNameBytes) WCHAR *Name,
|
_Out_z_bytecap_(InDestNameBytes) WCHAR *Name,
|
||||||
_In_ DWORD InDestNameBytes,
|
_In_ DWORD InDestNameBytes,
|
||||||
_Out_opt_ DWORD *OutDestNameBytes);
|
_Out_opt_ DWORD *OutDestNameBytes);
|
||||||
|
|
||||||
WINTUN_STATUS
|
|
||||||
NciInit(void);
|
|
||||||
|
|
||||||
void
|
|
||||||
NciCleanup(void);
|
|
Loading…
Reference in New Issue
Block a user