Commit Graph

34 Commits

Author SHA1 Message Date
Jason A. Donenfeld
470bdf3e26 api: use proper instance id bounds
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-14 06:51:22 +00:00
Jason A. Donenfeld
544fdaaf8f api: rewrite based on SwDevice
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-12 18:54:20 +00:00
Jason A. Donenfeld
42030404e0 api: rundll32: make empty string if no instance id
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-08-08 16:42:37 +02:00
Simon Rozman
d675646ab8 api: upgrade
Signed-off-by: Simon Rozman <simon@rozman.si>
2021-07-28 20:25:27 +02:00
Simon Rozman
7dffa4be72 vs: move shared configuration to wintun.props and upgrade
Remember to rename wintun.vcxproj.user file in your local working folder
to wintun.props.user manually.

Signed-off-by: Simon Rozman <simon@rozman.si>
2021-07-28 20:22:18 +02:00
Jason A. Donenfeld
899e085a91 api: build with WDK
Makes builds more reproducable, as we can do our next release using the
EWDK, an all-in-one ISO of build tools from Microsoft.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-07-23 20:20:43 +02:00
Jason A. Donenfeld
2628412d71 global: bump copyright
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-30 16:45:26 +01:00
Jason A. Donenfeld
e73613ee24 api: remove return value from logger function
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-10 22:06:25 +01:00
Simon Rozman
f657e6fd27 api: use GetLastError() to report failures like standard Win32
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-04 13:21:42 +01:00
Jason A. Donenfeld
7dede73406 api: add pool/driver removal for uninstaller semantics
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:27:42 +01:00
Simon Rozman
63b99bc2b4 api: bulk-disable unreferenced param warning where it nags the most
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-03 10:58:58 +01:00
Jason A. Donenfeld
1201c9f346 api: ensure more code compiles by using dead code elimination
It'd be nicer to do this via

if (is_defined(HAVE_WHATEVER))

But MSVC won't work with the linux kernel macros for this. Ongoing
research.

Nevertheless, this makes most of the program always pass through the
compiler's type checker, only to have dead code removed later.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 02:25:57 +01:00
Jason A. Donenfeld
9a937c7a49 example: rewrite and replace api's debug rundll32 functionality
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 23:42:43 +01:00
Simon Rozman
283f6c8e63 api: install driver on demand
...and add API for uninstalling it.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-02 23:33:20 +01:00
Jason A. Donenfeld
c20e1683c2 api: separate read-wait handle into other function
Makes the API a bit more clear.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 16:38:56 +01:00
Jason A. Donenfeld
dfa53185d0 api: check for duplicate adapter status
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 09:17:47 +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
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
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
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
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
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
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
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
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
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
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
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
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