aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-02 11:36:13 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-02 11:38:02 +0100
commit724508d61f41d5b443149a5ad88d2badb290ad3a (patch)
tree0600eb45212ed4e4c9018c89ea23d29f25e66af4 /api
parentapi: map cr errors to win32 errors (diff)
downloadwintun-724508d61f41d5b443149a5ad88d2badb290ad3a.tar.xz
wintun-724508d61f41d5b443149a5ad88d2badb290ad3a.zip
api: make nci.lib work on x86
This is an appalling hack. We need the lib tool to generate a coff lib with the "undecorate" parameter. And apparently the only way to do this with the MSVC tools is by making a stub object, and then rewriting the symbols using the def file. See Q131313 for Microsoft-sanctioned details. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'api')
-rw-r--r--api/api.vcxproj5
-rw-r--r--api/exports.def1
-rw-r--r--api/nci.def1
-rw-r--r--api/nci.h17
4 files changed, 19 insertions, 5 deletions
diff --git a/api/api.vcxproj b/api/api.vcxproj
index da3e78a..327ee44 100644
--- a/api/api.vcxproj
+++ b/api/api.vcxproj
@@ -121,7 +121,8 @@
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM64'">_M_ARM64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<PreLinkEvent>
- <Command>lib.exe /def:nci.def /out:"$(IntDir)nci.lib" /machine:$(PlatformTarget) /nologo</Command>
+ <Command>cl.exe /nologo /DGENERATE_LIB /Ob0 /c /Fo"$(IntDir)nci.obj" /Tc nci.h
+lib.exe /def:nci.def /out:"$(IntDir)nci.lib" /machine:$(PlatformTarget) /nologo "$(IntDir)nci.obj"</Command>
</PreLinkEvent>
<Link>
<DelayLoadDLLs>bcrypt.dll;iphlpapi.dll;nci.dll;newdev.dll;version.dll</DelayLoadDLLs>
@@ -201,4 +202,4 @@
<Target Name="CleanSignTarget">
<Delete Files="$(IntermediateOutputPath)$(TargetName).sign" />
</Target>
-</Project>
+</Project> \ No newline at end of file
diff --git a/api/exports.def b/api/exports.def
index 58add40..fc31c6f 100644
--- a/api/exports.def
+++ b/api/exports.def
@@ -1,3 +1,4 @@
+LIBRARY wintun.dll
EXPORTS
WintunAllocateSendPacket
WintunCreateAdapter
diff --git a/api/nci.def b/api/nci.def
index de1b6ea..db484b7 100644
--- a/api/nci.def
+++ b/api/nci.def
@@ -1,3 +1,4 @@
+LIBRARY nci.dll
EXPORTS
NciGetConnectionName
NciSetConnectionName
diff --git a/api/nci.h b/api/nci.h
index 1346d7a..0d13b19 100644
--- a/api/nci.h
+++ b/api/nci.h
@@ -7,10 +7,21 @@
#include <Windows.h>
-extern DWORD WINAPI NciSetConnectionName(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName);
+#ifdef GENERATE_LIB
+# define DECLSPEC __declspec(dllexport)
+# define STUB { return 0; }
+#else
+# define DECLSPEC __declspec(dllimport)
+# define STUB ;
+#endif
-extern DWORD WINAPI NciGetConnectionName(
+
+EXTERN_C DECLSPEC DWORD WINAPI
+NciSetConnectionName(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName) STUB
+
+EXTERN_C DECLSPEC DWORD WINAPI
+NciGetConnectionName(
_In_ const GUID *Guid,
_Out_z_bytecap_(InDestNameBytes) WCHAR *Name,
_In_ DWORD InDestNameBytes,
- _Out_opt_ DWORD *OutDestNameBytes); \ No newline at end of file
+ _Out_opt_ DWORD *OutDestNameBytes) STUB \ No newline at end of file