Commit Graph

495 Commits

Author SHA1 Message Date
Simon Rozman
c581a9f6cd api: fix Function and Prefix logging order
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-07 15:04:33 +01:00
Simon Rozman
b0ebb6d0ad api: fix LastError override
The LastError was overridden by the stdout reader thread exit code
masking the true reason why ExecuteRunDll32() failed and even worse: as
the thread exited gracefully, the true reason was overridden by
ERROR_SUCCESS and returning TRUE (success).

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-07 15:04:33 +01:00
Jason A. Donenfeld
3f843c9aab proj: use less scary caps for zip license file
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-06 10:44:32 +01:00
Jason A. Donenfeld
ed0465b8a7 api: avoid loading version.dll if not used
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-06 10:25:15 +01:00
Simon Rozman
a00c8ca685 driver: move to subfolder
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-06 07:29:47 +01:00
Jason A. Donenfeld
c891e84259 api: include arm64 in amd64
ARM64 will still run AMD64 apps.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
9f3d466791 api: remove WintunOpenAdapterDeviceObject
Discourage use of kernel interface, which gives us more flexibility if
we ever want to change it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
1e00f310ec example: raise to 4MiB
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
82c41bdb4b api: rearrange wintun.h to have better grouping and improve docs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
1285b8f528 api: rename WintunGetAdapter to WintunOpenAdapter
"Create" and "Open" natural names for these.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
e9e790605a api: rename ReceiveRelease to ReleaseReceivePacket
This makes the API parallel:
Wintun*Allocate*SendPacket -> WintunSendPacket
WintunReceivePacket -> Wintun*Release*ReceivePacket

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
6afbb300b9 README: improve code example
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
b7f5ee9a4e api: move InititalizeWintun to top to be easier to find
It's the primary function we want people copy and pasting.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
8861fdc316 api: add cfgmgr32.dll to delayed load list
It's in the registry but not in the NT object key.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
e458b4a8a4 wintun: simplify vcxproj
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 16:58:43 +01:00
Jason A. Donenfeld
f2b4363f1c vs: cause example to be default selected run project
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 11:09:44 +01:00
Jason A. Donenfeld
f342cc6903 .gitignore: simplify build dir match
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-05 11:06:53 +01:00
Simon Rozman
abbf658211 api: fix typo in ring-management function prototype declarations
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-05 08:36:28 +01:00
Jason A. Donenfeld
317a91bcbe README: add reference and describe info
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 21:37:33 +01:00
Jason A. Donenfeld
3158b553c4 api: document enum argument properly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 21:22:47 +01:00
Jason A. Donenfeld
fc27d8ccd2 api: document log enum
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 21:22:47 +01:00
Jason A. Donenfeld
65dee05229 api: remove enum name for logger level
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 21:22:47 +01:00
Jason A. Donenfeld
2b4e164d69 api: document adapter handle return value properly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 16:19:53 +01:00
Jason A. Donenfeld
c26b16e06f api: CALLBACK_FUNC -> CALLBACK
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 16:46:24 +01:00
Simon Rozman
b8401ad25b api: upgrade nci.lib and wintun-inf.h building
The additional build steps performed are now attached to the build
process using BeforeTargets/AfterTargets.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-04 16:44:01 +01:00
Jason A. Donenfeld
dc99f96da7 api: rename GetVersion to GetRunningDriverVersion
This makes our intentions a lot more clear, and in case we ever add
other version functions, makes the forward path simpler.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 14:53:39 +01:00
Jason A. Donenfeld
e2ffd0b3b3 example: account for buffer being drained too slowly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 14:50:03 +01:00
Jason A. Donenfeld
5d1efa847f api: use a logging alloc function
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 13:21:43 +01:00
Jason A. Donenfeld
9c349273f5 api: concatenate function name at runtime
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-04 13:21:43 +01:00
Simon Rozman
0a51e26730 api: include the rundll32 helpers the MSVC-typical way
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-04 13:21:42 +01:00
Simon Rozman
552821f59a api: translate NTSTATUS to Win32 error codes
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-04 13:21:42 +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
5ad7d10589 example: account for adapter reuse
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 18:42:43 +01:00
Jason A. Donenfeld
ed78f86783 wintun: upset everybody by doing multiplication via string concatenation
Because we can.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 18:37:40 +01:00
Jason A. Donenfeld
677ba8680f wintun: extract inf driverver at compile time into C header
This requires us to make some insane conversions between INF date,
JavaScript time, and finally Windows file time. The point is to mimic
SystemTimeToFileTime, which is what SpInf.dll's pSetupStringToDriverDate
does on the YYYY-MM-DD from the INF.

The result is that we no longer have to parse an ancient text format in
C at runtime.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 18:29:52 +01:00
Jason A. Donenfeld
55345ae386 api: move nci.lib generation to custom step
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 16:10:16 +01:00
Jason A. Donenfeld
90a33d9cc6 api: move undocumented ntdll symbols to ntdll.h
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 15:28:17 +01:00
Jason A. Donenfeld
d5dc79255d wintun: use proper import type for undocumented functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 14:42:18 +01:00
Jason A. Donenfeld
080b6896e0 api: constify pool argument
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:47:26 +01:00
Jason A. Donenfeld
8963f7258e api: remove guid getter
The iphlpapi takes both LUIDs and GUIDs but prefers LUIDs, so exposing
the NET_LUID makes sense. However, we were previously exposing the
configuration GUID, rather than the net GUID, which is confusing, so
just make it all go away.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:34:19 +01:00
Jason A. Donenfeld
2af7fbd64a api: use 'open' name since caller must close handle
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 12:31:49 +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
Jason A. Donenfeld
0c85a2ebf1 api: move _L macro where it belongs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 11:42:48 +01:00
Jason A. Donenfeld
04437fd668 api: conditionalize quasi expensive prelinkevent
It would be better to do this only if either nci.def or nci.h are newer
than nci.lib, but who knows if msbuild is expressive enough for this.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 11:17:50 +01:00
Jason A. Donenfeld
bf0f0d27df example: add sal markings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 11:08:35 +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
Jason A. Donenfeld
dfd71bb954 example: remove extra argument from print
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-03 11:01:20 +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
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