Skip to content

Commit

Permalink
Use a more robust way to get dco-win version
Browse files Browse the repository at this point in the history
The current way doesn't work if the device is already in use.

Starting from 1.3.0, dco-win creates a non-exclusive
control device \\.\ovpn-dco-ver which can be opened by
multiple apps and supports a single IOCTL to get
a version number.

OpenVPN/ovpn-dco-win#76

This will be expecially handy later when checking which
features driver supports.

Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf
Signed-off-by: Lev Stipakov <[email protected]>
Acked-by: Gert Doering <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg29009.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
lstipakov authored and mrbff committed Sep 9, 2024
1 parent fca22e6 commit 3e03c09
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/openvpn/dco_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,16 @@ dco_version_string(struct gc_arena *gc)
OVPN_VERSION version;
ZeroMemory(&version, sizeof(OVPN_VERSION));

/* try to open device by symbolic name */
HANDLE h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, NULL);
/* first, try a non-exclusive control device, available from 1.3.0 */
HANDLE h = CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ,
0, NULL, OPEN_EXISTING, 0, NULL);

if (h == INVALID_HANDLE_VALUE)
{
/* fallback to a "normal" device, this will fail if device is already in use */
h = CreateFile("\\\\.\\ovpn-dco", GENERIC_READ,
0, NULL, OPEN_EXISTING, 0, NULL);
}

if (h == INVALID_HANDLE_VALUE)
{
Expand Down

0 comments on commit 3e03c09

Please sign in to comment.