aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-helper-vpn-windows.c
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-15 20:22:54 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-15 20:22:54 +0000
commite1379548b2669fd3d3bf356e9764ea2e13cda1c9 (patch)
tree010284c4485ee994d83f1d9ef320cd3e003d8688 /src/vpn/gnunet-helper-vpn-windows.c
parente156f8cceb6186d03b836b14dc308e8ff0bba16e (diff)
added calls for updating the driver in a for device. seems like this is
mandatory when adding a new device node. unfortunately this is pretty slow... added new required include+library to link against: newdev.h/dll
Diffstat (limited to 'src/vpn/gnunet-helper-vpn-windows.c')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index 2fe0391070..dffe92cce4 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -35,11 +35,11 @@
#include <windows.h>
#include <setupapi.h>
#include <ddk/cfgmgr32.h>
+#include <ddk/newdev.h>
#include <Winsock2.h>
#include "platform.h"
#include "tap-windows.h"
-
/**
* Need 'struct GNUNET_MessageHeader'.
*/
@@ -165,7 +165,9 @@ struct io_facility
#define IOSTATE_QUEUED 1 /* overlapped I/O has been queued */
#define IOSTATE_WAITING 3 /* overlapped I/O has finished, but is waiting for it's write-partner */
-// ReOpenFile is only available as of XP SP2 and 2003 SP1
+/**
+ * ReOpenFile is only available as of XP SP2 and 2003 SP1
+ */
WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD);
/**
@@ -401,7 +403,7 @@ setup_interface ()
class_name,
&class_guid,
NULL,
- NULL,
+ 0,
DICD_GENERATE_ID,
&DeviceNode))
return FALSE;
@@ -411,15 +413,22 @@ setup_interface ()
&DeviceNode,
SPDRP_HARDWAREID,
(LPBYTE) hwidlist,
- (strlen (hwidlist) + 2) * sizeof (char)))
+ (lstrlenA (hwidlist) + 2) * sizeof (char)))
return FALSE;
/* Install our new class(=device) into the system */
if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
DeviceInfo,
&DeviceNode))
- return FALSE;
-
+ return FALSE;
+
+ if(!UpdateDriverForPlugAndPlayDevicesA(NULL,
+ HARDWARE_ID, // I can haz secondary HWID too?
+ inf_file_path,
+ INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE,
+ NULL)) //reboot required? NEVER!
+ return FALSE;
+
return TRUE;
}
@@ -651,7 +660,7 @@ init_tun ()
errno = ENODEV;
return INVALID_HANDLE_VALUE;
}
-
+
/* Open Windows TAP-Windows adapter */
snprintf (device_path, sizeof (device_path), "%s%s%s",
USERMODEDEVICEDIR,
@@ -673,14 +682,14 @@ init_tun ()
fprintf (stderr, "CreateFile failed on TAP device: %s\n", device_path);
return handle;
}
-
+
/* get driver version info */
if (!check_tapw32_version (handle))
{
CloseHandle (handle);
return INVALID_HANDLE_VALUE;
}
-
+
/* TODO (opt?): get MTU-Size */
return handle;