aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* api: selectively use temporary variable to prepare outputSimon Rozman2020-10-313-55/+66
| | | | | Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: remove security attributes debug trap doorJason A. Donenfeld2020-10-316-20/+14
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* api: elevate only when needed for system operationsJason A. Donenfeld2020-10-318-115/+179
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* api: simplify driver selection by always including EV driverSimon Rozman2020-10-313-7/+1
| | | | | | | | 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>
* api: fix dll hijacking vulnsJason A. Donenfeld2020-10-314-3/+20
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* api: simplify driver removalSimon Rozman2020-10-317-123/+31
| | | | | | | | | | | | | | | | | 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>
* api: make #ifdef-s more descriptiveSimon Rozman2020-10-313-6/+13
| | | | | Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: cleanup driver selection logicSimon Rozman2020-10-312-21/+5
| | | | | | | | 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>
* Add ARM driver compilationSimon Rozman2020-10-314-5/+45
| | | | | | | | | 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>
* api: add a cleanup note when Windows 7 support is discontinuedSimon Rozman2020-10-311-0/+1
| | | | | | | | 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>
* api: split adapter creation/deletion to delegator and worker functionsSimon Rozman2020-10-311-75/+92
| | | | | Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: make pipe handles non-inheritable by defaultSimon Rozman2020-10-311-7/+4
| | | | | | | | | ...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>
* api: check the stdout reader thread exit status for failuresSimon Rozman2020-10-311-34/+38
| | | | | | | ...and refactor the ExecuteRunDll32(). Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: make architecture-dependent wintun.dll selection an explicit selectSimon Rozman2020-10-311-3/+15
| | | | | Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: fix adapter name numbering terminationSimon Rozman2020-10-311-1/+1
| | | | | Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: bail out on _TRUNCATE truncationSimon Rozman2020-10-311-48/+91
| | | | | | | | | | 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>
* api: simplify RemoveNumberedSuffix()Simon Rozman2020-10-311-20/+7
| | | | | Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: use C locale for adapter and pool name case-insensitive comparingSimon Rozman2020-10-313-17/+4
| | | | | Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: fix zero-parameter C function prototypesSimon Rozman2020-10-316-16/+16
| | | | | Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: fallback to hard-coded versionSimon Rozman2020-10-314-18/+20
| | | | | | | Windows 7 doesn't have DriverMajorVersion and DriverMinorVersion registry values yet. Signed-off-by: Simon Rozman <simon@rozman.si>
* api: depretiate WintunIsPacketAvailable()Simon Rozman2020-10-314-27/+11
| | | | | | | Spinning on the WintunReceivePacket() while it returns ERROR_NO_MORE_ITEMS achieves the same. Signed-off-by: Simon Rozman <simon@rozman.si>
* api: move files from root to wintun folder within ZipSimon Rozman2020-10-311-7/+7
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: use catalog file for signing certificate extractionSimon Rozman2020-10-311-1/+1
| | | | | | | | 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>
* api: upgrade ring managementSimon Rozman2020-10-314-117/+204
| | | | | | | | | - 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>
* api: update README.mdSimon Rozman2020-10-314-279/+80
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: allow wintun.h use in C++Simon Rozman2020-10-301-0/+8
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: switch to private heapSimon Rozman2020-10-309-84/+68
| | | | | | | 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>
* api: add ring managementSimon Rozman2020-10-308-1/+383
| | | | | | | | 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>
* api: allow Debug build packagingSimon Rozman2020-10-301-30/+33
| | | | | | | | | | | The ARM64 platform has no WHQL/Attestation driver available yet and the Release build of the wintun.dll was explicitly designed to include WHQL/ Attn signed ARM64 driver only: There are no Windows on ARM64 before Windows 10. This prevented alpha testing of the wintun.dll on ARM64. Debug build includes EV signed ARM64 driver. Signed-off-by: Simon Rozman <simon@rozman.si>
* api: upgrade Zip building to output SHA256Simon Rozman2020-10-301-0/+4
| | | | | | | This allows following the Zip file integrity from immediately after it is built. Signed-off-by: Simon Rozman <simon@rozman.si>
* api: revise loggingSimon Rozman2020-10-303-12/+17
| | | | | | | | | | | | 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>
* api: connect rundll32 child with parent using stdout and stderrSimon Rozman2020-10-303-24/+249
| | | | | | | | | | | | | | | | | 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>
* api: installer: switch from MSM to ZIP distributionSimon Rozman2020-10-3011-1582/+42
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: use standard C voidSimon Rozman2020-10-307-12/+13
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: introduce wintun.hSimon Rozman2020-10-3010-159/+231
| | | | | | | | | | | 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>
* api: fix grammarSimon Rozman2020-10-301-11/+11
| | | | | Reported-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
* api: fix dead code warning for arm platformSimon Rozman2020-10-301-65/+72
| | | | | | arm platform has no driver leading to a lot of dead code. Signed-off-by: Simon Rozman <simon@rozman.si>
* api: make logger callback return a dummy valueSimon Rozman2020-10-303-4/+6
| | | | | | | 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>
* api: build the bridge from WoW64 to native inSimon Rozman2020-10-303-11/+166
| | | | | | | | 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>
* api: redirect log to stderr in rundll32 invocationsSimon Rozman2020-10-301-44/+24
| | | | | | | 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>
* vcxproj: swap configuration and platform subfolder hierarchySimon Rozman2020-10-305-31/+31
| | | | | | | 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>
* api: test the temporary driver ideaSimon Rozman2020-10-303-406/+191
| | | | | | | | | | | | | | | | | | | | | | 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>
* api: unify security descriptors and disable for _DEBUGSimon Rozman2020-10-306-45/+25
| | | | | | | | 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>
* api: arrange rundll32 a console loggerSimon Rozman2020-10-301-6/+57
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: remove temporary folder in case of intermediate failureSimon Rozman2020-10-301-1/+2
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: elevate rundll32 calls to SYSTEMSimon Rozman2020-10-302-0/+99
| | | | | | | 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>
* api: move documentation to .h and discontinue on static functionsSimon Rozman2020-10-3010-523/+315
| | | | | | | | | 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>
* api: log out-of-memory errors tooSimon Rozman2020-10-303-36/+24
| | | | | | | It's not likely the write to log will succeed in low memory condition thou. Signed-off-by: Simon Rozman <simon@rozman.si>
* api: remove dead codeSimon Rozman2020-10-302-14/+0
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* api: added missing allocation-failure checkSimon Rozman2020-10-301-0/+2
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>