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
Jason A. Donenfeld
64f39cd95d
api: only return top two version nibbles
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 11:01:20 +01:00
Simon Rozman
aa6e540811
api: prevent double SetupDiDestroyDriverInfoList calls on error
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-03 10:40:09 +01:00
Jason A. Donenfeld
19d6227c1d
api: rundll32: repair token spawning semantics
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 10:34:25 +01:00
Simon Rozman
a73927ea6c
api: refactor .inf parsing and check SystemTimeToFileTime for errors
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-03 10:34:23 +01:00
Simon Rozman
77ff03f621
api: simplify IsOurDrvInfoDetail()
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-03 10:34:23 +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
353cfa562e
api: begin to separate rundll32 jumps
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 02:25:20 +01:00
Jason A. Donenfeld
0d7b9c7319
api: free beginning of heap object
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 23:42:43 +01:00
Jason A. Donenfeld
ddacb5491a
api: pass around NET_LUID instead of LUID
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 23:33:20 +01:00
Jason A. Donenfeld
351349b4c4
api: return correct error when there's a duplicate
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 23:33:20 +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
78bad1436e
api: statically compile devpkey constants
...
I don't like this solution, but I don't see much other choice. It's not
in uuid.lib or anywhere like that.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 13:52:47 +01:00
Jason A. Donenfeld
007db8bd94
api: serialize driver installation
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 12:07:05 +01:00
Jason A. Donenfeld
7f35f0dbab
api: map cr errors to win32 errors
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 12:38:37 +01:00
Simon Rozman
47a241e5d8
api: simplify and unify error messages
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-02 12:19:36 +01:00
Jason A. Donenfeld
13494e979e
api: pnf param is none
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 12:19:36 +01:00
Jason A. Donenfeld
b5836e9fb9
api: make version function uniform
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 09:17:47 +01:00
Jason A. Donenfeld
99097022fe
api: avoid call to CM_Get_DevNode_Status
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 09:17:47 +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
9adb49e13d
api: separate out driver installation
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-02 09:17:47 +01:00
Jason A. Donenfeld
334a5e619f
api: cleanup names
...
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-01 00:00:14 +01:00
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
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
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
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
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
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
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
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
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
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