DIF_INSTALLDEVICE returns almost immediately, while the device
installation continues in the background. It might take a while, before
all registry keys and values are populated.
Previously, wireguard-go waited for HKLM\SYSTEM\CurrentControlSet\
Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\<id> registry key
only.
Followed by a SetInterfaceName() method of Wintun struct which tried to
access HKLM\SYSTEM\CurrentControlSet\Control\Network\
{4D36E972-E325-11CE-BFC1-08002BE10318}\<id>\Connection registry key
might not be available yet.
This commit loops until both registry keys are available before
returning from CreateInterface() function.
Signed-off-by: Simon Rozman <[email protected]>
As querying non-existing registry value and reading non-existing
registry string value both return ERROR_FILE_NOT_FOUND, we can
use later only.
Signed-off-by: Simon Rozman <[email protected]>
In case reading from TUN device detected TUN device was closed, it
closed the file handle and set tunFile to nil. The tunFile is
automatically reopened on retry, but... If another packet comes in the
WireGuard calls Write() method. With tunFile set to nil, this will
cause access violation.
Therefore, locking was introduced.
Signed-off-by: Simon Rozman <[email protected]>
This allows buffer alignment and keeps it together with its meta-data.
Furthermore, the write buffer has been reduced - as long as we flush
after _every_ write, we don't need a 1MiB write buffer.
Signed-off-by: Simon Rozman <[email protected]>
Do the WaitForSingleObject() always to provide high-load responsiveness.
Reorder events so TUN_SIGNAL_CLOSE has priority over
TUN_SIGNAL_DATA_AVAIL, to provide high-load responsiveness at all.
Signed-off-by: Simon Rozman <[email protected]>
Adding functions with non-consistent order made setupapi package a mess.
While we could reorder data-types and functions by alphabet - it would
make searching easier - it would put ...Get... and ...Set... functions
quite apart.
Therefore, the SetupAPI.h order was adopted.
Signed-off-by: Simon Rozman <[email protected]>
The data returned by SetupDiGetDeviceInfoListDetail() is nil on error
which will cause the test to crash should the function fail.
Signed-off-by: Simon Rozman <[email protected]>
The SetupDiEnumDeviceInfo() now returns a SP_DEVINFO_DATA rather than
taking it on input to fill it on return.
Signed-off-by: Simon Rozman <[email protected]>
The former is only a subset of the later. To minimize future
maintenance, we'll provide support for extended version only.
Signed-off-by: Simon Rozman <[email protected]>
User should not have called or deferred the Close() method should
SetupDiGetClassDevsEx() return an error (and invalid handle). And even
if user does that, a SetupDiDestroyDeviceInfoList(INVALID_HANDLE_VALUE)
is harmless. It just returns ERROR_INVALID_HANDLE - we have a unit test
for this in TestSetupDiDestroyDeviceInfoList().
Signed-off-by: Simon Rozman <[email protected]>
Furthermore setupapi.DevInfoData has been obsoleted.
SetupDiEnumDeviceInfo() fills existing SP_DEVINFO_DATA structure now.
As other functions of SetupAPI use SP_DEVINFO_DATA, converting it to
DevInfoData and back would hurt performance.
Signed-off-by: Simon Rozman <[email protected]>