Commit Graph

199 Commits

Author SHA1 Message Date
Jason A. Donenfeld
b65e35569b api: account for nt path to module
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-01 00:00:14 +01:00
Simon Rozman
60ad907b99 api: check buffer overflows in runtime
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:57 +01:00
Jason A. Donenfeld
8edd627f4d api: fix up console writing for debug
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:57 +01:00
Jason A. Donenfeld
378e8eec27 api: clear up argument evaluation order
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:56 +01:00
Jason A. Donenfeld
17bd620a36 api: do not require RebootRequired
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:56 +01:00
Jason A. Donenfeld
ffab1eabe3 api: RebootRequire is an _Out_
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:56 +01:00
Jason A. Donenfeld
6c40f24498 api: add debugging rundll32 entry point
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:56 +01:00
Jason A. Donenfeld
f6d8b694eb api: add missing header for rundll32 mode
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:52 +01:00
Jason A. Donenfeld
26c5478042 api: opencode bin2hex in same manner as random directory creation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:51 +01:00
Jason A. Donenfeld
62f21f2fdd 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>
2020-10-31 19:11:51 +01:00
Jason A. Donenfeld
937eb44727 api: get rid of pch and make headers sane
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:51 +01:00
Jason A. Donenfeld
c5b05150c6 api: simplify build settings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:51 +01:00
Jason A. Donenfeld
0faba6c3e8 api: use NT api directly for enumerating kernel modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:51 +01:00
Simon Rozman
efbc70635b api expose Send.TailMoved event to clients
This allows clients to use it in WaitForMultipleObjects().

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:50 +01:00
Simon Rozman
c8004933c1 api: rename MAX_POOL to WINTUN_MAX_POOL
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:50 +01:00
Simon Rozman
9957396dc7 api: upgrade source analysis annotations
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:50 +01:00
Simon Rozman
08440580c3 api: refuse to load DLL on init failure
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:50 +01:00
Jason A. Donenfeld
e7a85b7b28 api: attempt to upgrade currently running adapters
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:50 +01:00
Jason A. Donenfeld
f947205cee api: use proper iso atomic semantics
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:50 +01:00
Jason A. Donenfeld
b4a1494fb2 api: rework pool hashing
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:49 +01:00
Jason A. Donenfeld
0a8bf9d1ff api: only force close handles if requested
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:49 +01:00
Jason A. Donenfeld
a332f54a1b api: only sleep after force closing handles if required
Also force close handles when deleting the adapter, in case the function
is called from another process, for example an uninstaller.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 19:11:49 +01:00
Simon Rozman
1b3af95be3 api: selectively use temporary variable to prepare output
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 19:11:49 +01:00
Jason A. Donenfeld
8c935ce151 api: remove security attributes debug trap door
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 10:41:49 +01:00
Jason A. Donenfeld
7964694e1e api: elevate only when needed for system operations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 10:41:49 +01:00
Simon Rozman
779d0e0c38 api: simplify driver selection by always including EV driver
When Windows 7-8.1 support is sunset, there will be no more EV driver
deployment at all.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:49 +01:00
Jason A. Donenfeld
c928ad4de7 api: fix dll hijacking vulns
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-10-31 10:41:48 +01:00
Simon Rozman
abf6962144 api: simplify driver removal
When we install the Wintun driver to the store, we get exact oem<nn>.inf
filename of the driver in the store we just installed. Since the
installation should be only temporarily, we should uninstall only the
driver we installed.

This also eliminates the need for iterating driver store speeding up
things.

The code we removed was inherited from the installer.dll, where it made
perfect sense to remove all installed Wintun drivers in the update
process.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:48 +01:00
Simon Rozman
eeb42a5f12 api: make #ifdef-s more descriptive
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:48 +01:00
Simon Rozman
4b0470210d api: cleanup driver selection logic
With all the platforms (including ARM) having at least one driver now,
the dead-code removal #ifdef-s are no longer required.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:48 +01:00
Simon Rozman
77459a130a Add ARM driver compilation
This adds the ARM driver to the list of Wintun drivers we compile for
future deployment. Since we're not in position to test it in the real
world, any feedback is greatly appreciated.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:48 +01:00
Simon Rozman
44cfac5d63 api: add a cleanup note when Windows 7 support is discontinued
DriverMajorVersion and DriverMinorVersion registry values were
introduced in Windows 8.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:48 +01:00
Simon Rozman
5a3a217b0b api: split adapter creation/deletion to delegator and worker functions
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:48 +01:00
Simon Rozman
3dacd1c6ce api: make pipe handles non-inheritable by default
...and change to inheritable only the ones really needed, eliminating a
window where we'd have inheritable handles that are not supposed to be
inheritable.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
fb6d5b62f1 api: check the stdout reader thread exit status for failures
...and refactor the ExecuteRunDll32().

Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
44568f81cb api: make architecture-dependent wintun.dll selection an explicit select
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
8b0409ce2a api: fix adapter name numbering termination
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
254a900a76 api: bail out on _TRUNCATE truncation
Silently ignoring truncation of the strings(like adapter and pool names,
registry paths etc.) leads to strange failures later down the road (like
registry key not found) masking the true reason of the failure. This
makes troubleshooting difficult.

Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
13e90b52cc api: simplify RemoveNumberedSuffix()
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
f389fd5629 api: use C locale for adapter and pool name case-insensitive comparing
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:47 +01:00
Simon Rozman
e630c3bec1 api: fix zero-parameter C function prototypes
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:46 +01:00
Simon Rozman
4a575d210a api: fallback to hard-coded version
Windows 7 doesn't have DriverMajorVersion and DriverMinorVersion
registry values yet.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:46 +01:00
Simon Rozman
e11897e343 api: depretiate WintunIsPacketAvailable()
Spinning on the WintunReceivePacket() while it returns
ERROR_NO_MORE_ITEMS achieves the same.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:41:46 +01:00
Simon Rozman
660a61b865 api: use catalog file for signing certificate extraction
The .sys file of the driver does not need to be digitally signed. It is
the .cat file that Windows is checking for complete driver .inf+.sys+
.cat bundle.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:15:15 +01:00
Simon Rozman
2439b05212 api: upgrade ring management
- Return pointer to ring buffer with packet data allowing clients to
  read/write directly. This eliminates one memcpy().

- Make sending/receiving packets thread-safe.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-31 10:15:15 +01:00
Simon Rozman
fbb9098393 api: allow wintun.h use in C++
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
bf4eabb4ca api: switch to private heap
We must not use the process heap, as it is changeable. Client may change
it causing our HeapFree() to use wrong heap.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
4b8f879fd6 api: add ring management
Rather than every client reinvent the art of using the Wintun and its
ring buffers, we offer helper structs and functions to unify and
simplify Wintun usage.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
84c066fa79 api: revise logging
RegistryQueryString() may produce one or more "File not found" errors
when called from RegistryQueryStringWait() - which is expected while
waiting. Those errors were annoying and awkward to read in the log.

Furthermore, should RegistryQueryString() fail, it already displays
detailed Windows error message and the parent's logging was simplified
to prevent repetitions in the log.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
faf7d3771c api: connect rundll32 child with parent using stdout and stderr
The WintunCreateAdapter()+CreateAdapter() and WintunDeleteAdapter()+
DeleteAdapter() communicate using Unicode anonymous pipes now. This
allows the WintunCreateAdapter() to exactly determine the adapter
CreateAdapter() just created by its GUID rather than its name - avoiding
the possible ambiguity caused by same-adapter-name ordinal suffixes.
This also allows exact retrieval of the result code and pending reboot
flag from the rundll32 child process.

Furthermore, CreateAdapter() and DeleteAdapter() are now available in
_DEBUG for all platforms to allow testing. It took a #pragma comment(
linker, "/EXPORT") trick to stop compiler from decorating function names
and exporting as _CreateAdapter@16() and _DeleteAdapter@16() in x86.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
0fdd9fbb85 api: use standard C void
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
449876fdfd api: introduce wintun.h
The SDK header for deployment containing datatype and function
declarations for use by C/C++ clients.

As we shall not distribute MSVC wintun.lib files, making clients need to
use GetProcAddress(), this file contains function type declarations
rather then __declspec(dllimport) function declarations.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
4ac9a6dcc6 api: fix grammar
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
ef66541200 api: fix dead code warning for arm platform
arm platform has no driver leading to a lot of dead code.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
c049a8f853 api: make logger callback return a dummy value
Go supports only callbacks that return "something" of a size up to
uintptr. It panics on void-returning callbacks.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:01 +01:00
Simon Rozman
9a16d4e3cc api: build the bridge from WoW64 to native in
SetupAPI fails to create a device in WoW64 processes. x86 (and arm)
wintun.dll pack the amd64 and arm64 wintun.dll now, and use rundll32 to
create a native process to do the job where required.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
2d20564f0a api: redirect log to stderr in rundll32 invocations
The WoW64 client will provide stdio handles to read the log messages.
Furthermore, the rundll32 calls could return results using stdout.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
b79703bba8 vcxproj: swap configuration and platform subfolder hierarchy
This should allow wintun.dll to simplify referencing same configuration
but different platform wintun.dll for WoW64 support.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
d04721dee6 api: test the temporary driver idea
1. Add driver to the store: SetupCopyOEMInfW()
2. Create the adapter using explicit path to .inf file: DI_ENUMSINGLEINF
3. Delete all Wintun drivers from the store.

This is a subject of further research:

- It appears those adapters survive a reboot. So, Windows must store the
  driver somewhere on the disk and the driver removal is not completed.
  If the driver removal is not completed until there are existing
  adapters, this is excellent, as it will provide a self-cleanup.

- Test multiple adapters with different driver versions. Which driver
  wins?

- Are other Wintun adapters interrupted when adding a new one?

- Test Windows 7 behaviour.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
8272da638e api: unify security descriptors and disable for _DEBUG
When debugger is attached, CreateDirectory() with SYSTEM-only SID fails
with "This security ID may not be assigned as the owner of this object.
(Code 0x0000051B)".

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
8bfe692c97 api: arrange rundll32 a console logger
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
70461121f7 api: remove temporary folder in case of intermediate failure
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
369801cdfa api: elevate rundll32 calls to SYSTEM
I need this for debugging. In production environment, WoW64 clients will
already call rundll32 elevated to SYSTEM.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
ac6db7788a api: move documentation to .h and discontinue on static functions
While Doxygen correctly locates the function documentation when it is
written directly preceding the function body, Microsoft Visual Studio
IDE does not. The former requires the documentation to precede the
function declaration.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
1f87c307f6 api: log out-of-memory errors too
It's not likely the write to log will succeed in low memory condition
thou.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
2a77f20277 api: remove dead code
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
3058f1e57e api: added missing allocation-failure check
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
0ad302c11d api: stop double error status reporting
When an internal function logs an error and its cause, it bloats the log
when the caller logs the cause again.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
16a9737578 api: internal reorganization
Gather adapter management in adapter.h/.c (formerly devmgmt.h/.c) and
unify HwID tests.

Use "Namespace" namespace in all functions from namespace.h/.c.

Fix char strings in LOG_...

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
78b7a01eb3 api: simplify logger macros names
WINTUN_LOGGER_... => LOGGER_... => LOG_...

Those macros are internal, so they don/t need to start with WINTUN_...

Replacing the noun LOGGER_... with the verb LOG_... makes the code more
natural to read now.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
e157d421ec api: implement driver version extraction from .inf file
With installer.dll the installer did the decision whether to install or
upgrade the driver according to installer.dll version and hash stored in
registry by MSM.

With wintun.dll we need to know, which version of Wintun driver we are
packing in the resources to decide about driver upgrade. The most
accurate source of the driver version is the DriverVer directive in
[Version] section of the driver's .inf file.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
85c32a5566 api: disable driver management for wintun.dll that don't have a driver
Namely the 32-bit ARM platform, which we will ship wintun.dll for ARM on
ARM64 clients exclusively.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
84113bd294 api: unify and document resource loading
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:51:00 +01:00
Simon Rozman
a3d9431e70 api: unify hardware ID string
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
2727d14438 api: unify callback function type names
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
c324d07ffb api: add driver management
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
f316c13b3e api: introduce logging
And other unifications with installer before merging.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
abd20337e2 api: split api.h
As the project grew, api.h got bloated.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
295591046f api: revise str/memcpy
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
af937e52eb api: make adapter name searching more efficient
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
4c131caa7d api: honor locale when comparing case-insensitive
Quote from MSDN:
> You will need to call setlocale for _wcsicmp to work with Latin 1
> characters. The C locale is in effect by default, so, for example, ä
> will not compare equal to Ä.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
c8711464bb api: fix trailing number detection in RemoveNumberedSuffix()
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
5925f914e4 api: add support for WoW64
Some functions of SetupAPI only work when invoked from a native process.
Registry and filesystem reflection makes them fail on WoW64. For WoW64
processes, a minimum set of rundll32 functions are provided.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
b592e071d2 api: tighten source code annotation
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
640605a8d9 api: update documentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
355ce73841 api: simplify workflow
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
c213663a90 api: revise and unify error codes
GetDevInfoData: Some functions returned ERROR_OBJECT_NOT_FOUND, others
ERROR_FILE_NOT_FOUND when the needle was not found in the haystack.

GetTcpipInterfaceRegPath: When IpConfig is an empty REG_MULTI_SZ, it is
actually ERROR_INVALID_DATA - like other unexpected registry values -
rather than a misleading ERROR_NETWORK_NOT_AVAILABLE.

Failure in TakeNameMutex result in ERROR_INVALID_HANDLE rather than the
ERROR_GEN_FAILURE with a misleading message: "A device attached to the
system is not functioning."

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
28c135b8e1 api: tighten maximum registry key path length
Maximum registry key path length is not 260 (MAX_PATH), but 255 (256
incl. zero terminator).

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
43a1751b21 api: fix SPDRP_DEVICEDESC zero-termination
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
0adf0fab8d api: do the set-quiet-install later
Rather than setting the "quiet" flag to each and every device in the
process of iterating, set it when actually creating/deleting it.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
08e2993d23 api: cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:59 +01:00
Simon Rozman
0a986ce9fc api: add pre-compiled header support
...for super-fast compilation.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
a283add85b api: rename WINSTATUS to WINTUN_STATUS
...to reduce name collision probability.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
7e3740018d api: finish porting from wireguard-go
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
c8bf62ac19 api: unify Win32 error type
This makes the code more readable and works around the clang-format.exe
issues with _Return_type_success_ source annotation.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
d3a63116ba api: port GetInterface member from wireguard-go
Mind that this also fixes the order of adapter detection checks. A fast
test to eliminate non-Wintun adapters from iteration to speed things up
rendered the method incapable of detecting a non-Wintun adapter with the
name we are looking for.

ERROR_OBJECT_NOT_FOUND was replaced with ERROR_FILE_NOT_FOUND.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
3fa45fec71 api: port nci package from wireguard-go
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
6f55786c65 api: port tun\wintun\namespace_windows.go from wireguard-go
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00
Simon Rozman
0ef8578c81 api: add skeleton for wintun.dll
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-10-30 16:50:58 +01:00